diff --git a/RELEASES.md b/RELEASES.md index 4787c59e16..65a6196edb 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -9,8 +9,8 @@ Breaking changes - The `Num` builtin type has been renamed to `Number` - The `Str` builtin type has been renamed to `String` - The `num` stdlib module has been remaned to `number` -- The `builtin.typeof` function now returns `` `Number ``, `` `String ``, - `` `Function `` instead of respectively `` `Num ``, `` `Str ``, and `` `Fun `` +- The `builtin.typeof` function now returns `'Number`, `'String`, `'Function` + instead of respectively `'Num`, `'Str`, and `'Fun` - The `builtin.is_num`, `builtin.is_str` and `builtin.to_str` functions hav been renamed to `is_number`, `is_string` and `to_string` - The `string.to_num` and `string.from_num` functions have been renamed to diff --git a/benches/mantis.rs b/benches/mantis.rs index 7dac54df6c..04ab2328c5 100644 --- a/benches/mantis.rs +++ b/benches/mantis.rs @@ -8,13 +8,13 @@ ncl_bench_group! { { name = "mantis", path = "mantis/run", - args = (r#"{namespace = "mantis-staging", job="miner", role=`miner}"#), + args = (r#"{namespace = "mantis-staging", job="miner", role='miner}"#), eval_mode = EvalMode::DeepSeq, }, { name = "mantis serialize", path = "mantis/run", subtest = "serialize", - args = (r#"{namespace = "mantis-staging", job="miner", role=`miner}"#), + args = (r#"{namespace = "mantis-staging", job="miner", role='miner}"#), } } criterion_main!(benches); diff --git a/doc/manual/contracts.md b/doc/manual/contracts.md index c7b1e5c8a1..e90e9d1625 100644 --- a/doc/manual/contracts.md +++ b/doc/manual/contracts.md @@ -364,7 +364,7 @@ let Schema = { bar | Number, } nickel> let config | Schema = {bar = 2} -nickel> std.serialize `Json config +nickel> std.serialize 'Json config "{ "bar": 2, "foo": "foo" @@ -410,7 +410,7 @@ let Secure = { must_be_very_secure | Bool = true, data | String, } -nickel> std.serialize `Json ({data = ""} | Secure) +nickel> std.serialize 'Json ({data = ""} | Secure) "{ "data": "", "must_be_very_secure": true diff --git a/doc/manual/merging.md b/doc/manual/merging.md index 3c24c7f2fb..5f9cf05db6 100644 --- a/doc/manual/merging.md +++ b/doc/manual/merging.md @@ -284,7 +284,7 @@ A field can be marked as optional using the `optional` annotation: command | String, arg_type - | [| `String, `Number |], + | [| 'String, 'Number |], alias | String | optional, @@ -301,7 +301,7 @@ field: ```nickel { command = "exit", - arg_type = `String, + arg_type = 'String, alias = "e", } | Command ``` diff --git a/doc/manual/syntax.md b/doc/manual/syntax.md index ea88b72128..1db0e04b27 100644 --- a/doc/manual/syntax.md +++ b/doc/manual/syntax.md @@ -283,47 +283,46 @@ The following examples show how symbolic strings are desugared: ```text > mytag-s%"I'm %{"symbolic"} with %{"fragments"}"% { - tag = `SymbolicString, - prefix = `mytag + tag = 'SymbolicString, + prefix = 'mytag fragments = [ "I'm ", "symbolic", " with ", "fragments" ], } > let terraform_computed_field = { - tag = `TfComputed, + tag = 'TfComputed, resource = "foo", field = "id", } > tf-s%"id: %{terraform_computed_field}, port: %{5}"% { - tag = `SymbolicString - prefix = `tf, - fragments = [ "id: ", { resource = "foo", field = "id", tag = `TfComputed }, ", port: ", 5 ], + tag = 'SymbolicString + prefix = 'tf, + fragments = [ "id: ", { resource = "foo", field = "id", tag = 'TfComputed }, ", port: ", 5 ], } ``` #### Enum tags Enumeration tags are used to express a choice among finitely many alternatives. -They are formed by writing a backtick `` ` `` followed by any valid identifier +They are formed by writing a single quote `'` followed by any valid identifier or by a quoted string. For example, `std.serialize` takes an export format as a -first argument, which is an enum tag among `` `Json ``, `` `Toml `` or `` `Yaml -``: +first argument, which is an enum tag among `'Json`, `'Toml` or `'Yaml`: ```nickel -> std.serialize `Json {foo = 1} +> std.serialize 'Json {foo = 1} "{ \"foo\": 1 }" -> std.serialize `Toml {foo = 1} +> std.serialize 'Toml {foo = 1} "foo = 1 " ``` -An enum tag `` `foo `` is serialized as the string `"foo"`: +An enum tag `'foo` is serialized as the string `"foo"`: ```nickel -> std.serialize `Json {foo = `bar} +> std.serialize 'Json {foo = 'bar} "{ \"foo\": \"bar\" }" @@ -674,11 +673,11 @@ Nickel features the following builtin types and type constructors: represents any value) - Arrays: `Array ` is an array whose elements are of type ``. - Dictionaries: `{_ : }` is a record whose fields are of type ``. -- Enums: ``[| `tag1, .., `tagn |]`` is an enumeration comprised of the alternatives - `` `tag1 ``, .., `` `tagn``. Tags have the same syntax as identifiers and must - be prefixed with a backtick `` ` ``. Like record fields, they can however be +- Enums: `[| 'tag1, .., 'tagn |]` is an enumeration comprised of the alternatives + `'tag1`, .., `'tagn`. Tags have the same syntax as identifiers and must + be prefixed with a single quote `'`. Like record fields, they can however be enclosed in double quotes if they contain special characters: - `` `"tag with space" ``. + `'"tag with space"`. - Arrows: ` -> ` is a function taking an argument of type `` and returns values of type ``. - Foralls: `forall var1 .. varn. ` is a polymorphic type quantifying over type @@ -711,14 +710,14 @@ Here are some examples of more complicated types in Nickel: { foo = [ [ 1 ] ] } > let select - : forall a. {left: a, right: a} -> [| `left, `right |] -> a + : forall a. {left: a, right: a} -> [| 'left, 'right |] -> a = fun {left, right} => match { - `left => left, - `right => right, + 'left => left, + 'right => right, } in - (select {left = true, right = false} `left) : Bool + (select {left = true, right = false} 'left) : Bool true > let add_foo : forall a. {_: a} -> a -> {_: a} = fun dict value => @@ -905,7 +904,7 @@ record is serialized. This includes the output of the `nickel export` command: > value { foo = 1, bar = 2 } -> std.serialize `Json value +> std.serialize 'Json value "{ "foo": 1 }" diff --git a/doc/manual/typing.md b/doc/manual/typing.md index a09045cfcd..445ef8c62a 100644 --- a/doc/manual/typing.md +++ b/doc/manual/typing.md @@ -219,7 +219,7 @@ The following type constructors are available: std.record.map (fun char count => count + 1) occurrences : {_ : Number} ``` -- **Enum**: ``[| `tag1, .., `tagn |]``: an enumeration comprised of alternatives +- **Enum**: ``[| 'tag1, .., 'tagn |]``: an enumeration comprised of alternatives `tag1`, .., `tagn`. An enumeration literal is prefixed with a backtick and serialized as a string. It is useful to encode finite alternatives. The advantage over strings is that the typechecker handles them more finely: it is @@ -228,11 +228,11 @@ The following type constructors are available: Example: ```nickel - let protocol : [| `http, `ftp, `sftp |] = `http in + let protocol : [| 'http, 'ftp, 'sftp |] = 'http in (protocol |> match { - `http => 1, - `ftp => 2, - `sftp => 3 + 'http => 1, + 'ftp => 2, + 'sftp => 3 }) : Number ``` @@ -430,9 +430,9 @@ tail that can be substituted for something else. For example: ```nickel { - port_of : forall a. [| `http, `ftp; a |] -> Number = match { - `http => 80, - `ftp => 21, + port_of : forall a. [| 'http, 'ftp; a |] -> Number = match { + 'http => 80, + 'ftp => 21, _ => 8000, } } diff --git a/examples/README.md b/examples/README.md index eaa6f06f6e..38e899a58d 100644 --- a/examples/README.md +++ b/examples/README.md @@ -36,7 +36,7 @@ data! ```console $ nickel -f record-contract.ncl query kind - • contract: [|`ReplicationController, `ReplicaSet, `Pod|] + • contract: [|'ReplicationController, 'ReplicaSet, 'Pod|] • documentation: The kind of the element being configured. ``` @@ -76,7 +76,7 @@ nickel> ```text nickel>let config = import "record-contract.ncl" nickel>:query config.kind - • contract: [| `ReplicationController, `ReplicaSet, `Pod |] + • contract: [| 'ReplicationController, 'ReplicaSet, 'Pod |] • documentation: The kind of the element being configured. nickel> diff --git a/src/parser/uniterm.rs b/src/parser/uniterm.rs index bae8fc0943..1c099769ae 100644 --- a/src/parser/uniterm.rs +++ b/src/parser/uniterm.rs @@ -649,7 +649,7 @@ pub(super) trait FixTypeVars { /// forall a. Num -> {foo: Str ; a} -> {bar: Str ; a} /// # occurs both in record rows and enum rows position /// # this is inconsistent and will raise a parse error - /// forall a. [| `foo, `bar; a |] -> {foo : Str, bar: Str; a} + /// forall a. [| 'foo, 'bar; a |] -> {foo : Str, bar: Str; a} /// ``` fn fix_type_vars(&mut self, span: RawSpan) -> Result<(), ParseError> { self.fix_type_vars_env(BoundVarEnv::new(), span) diff --git a/src/term/mod.rs b/src/term/mod.rs index 2886517dba..b4f1caf616 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -1830,7 +1830,7 @@ pub mod make { /// Switch for types implementing `Into` (for patterns) and `Into` for the /// body of each case. Cases are specified as tuple, and the default case (optional) is separated by a `;`: /// `mk_switch!(format, ("Json", json_case), ("Yaml", yaml_case) ; def)` corresponds to - /// ``switch { `Json => json_case, `Yaml => yaml_case, _ => def} format``. + /// ``match { 'Json => json_case, 'Yaml => yaml_case, _ => def} format``. #[macro_export] macro_rules! mk_match { ( $( ($id:expr, $body:expr) ),* ; $default:expr ) => { diff --git a/src/typecheck/operation.rs b/src/typecheck/operation.rs index 5773748903..4d0d4d7a58 100644 --- a/src/typecheck/operation.rs +++ b/src/typecheck/operation.rs @@ -23,7 +23,7 @@ pub fn get_uop_type( mk_uty_arrow!(branches.clone(), branches.clone(), branches), ) } - // Dyn -> [| `Number, `Bool, `String, `Enum, `Function, `Array, `Record, `Label, `Other |] + // Dyn -> [| 'Number, 'Bool, 'String, 'Enum, 'Function, 'Array, 'Record, 'Label, 'Other |] UnaryOp::Typeof() => ( mk_uniftype::dynamic(), mk_uty_enum!( diff --git a/src/types.rs b/src/types.rs index 3c2d1d1f33..bb422d418d 100644 --- a/src/types.rs +++ b/src/types.rs @@ -423,8 +423,8 @@ impl EnumRowsF { /// If we put aside the state and the error (see [EnumRowsF::map), this function makes /// `EnumRowsF` a functor. As hinted by the type signature, this function just maps on /// "one-level" of recursion, so to speak. Take the instantiated version `EnumRows`, and - /// enum rows of the form ``[| `foo, `bar, `baz |]``. Then, calling `try_map_state(f_erows, - /// state)` on these rows will map `f_erows` onto ``[| `bar, `baz |]``. + /// enum rows of the form ``[| 'foo, 'bar, 'baz |]``. Then, calling `try_map_state(f_erows, + /// state)` on these rows will map `f_erows` onto ``[| 'bar, 'baz |]``. /// /// Note that `f_erows` is just mapped once. Map isn't a recursive operation. It's however a /// building block to express recursive operations: as an example, see [RecordRows::traverse]. @@ -768,15 +768,15 @@ impl EnumRows { // Otherwise, we build a match with all the tags as cases, which just returns the // original argument, and a default case that blames. // - // For example, for an enum type [| `foo, `bar, `baz |], the `case` function looks + // For example, for an enum type [| 'foo, 'bar, 'baz |], the `case` function looks // like: // // ``` // fun l x => // match { - // `foo => x, - // `bar => x, - // `baz => x, + // 'foo => x, + // 'bar => x, + // 'baz => x, // _ => $enum_fail l // } x // ```