diff --git a/compiler/can/src/effect_module.rs b/compiler/can/src/effect_module.rs index 484f0fc223..d2f6e61c5d 100644 --- a/compiler/can/src/effect_module.rs +++ b/compiler/can/src/effect_module.rs @@ -110,7 +110,7 @@ fn build_effect_always( effect_symbol: Symbol, var_store: &mut VarStore, ) -> (Symbol, Def) { - // Effect.always = \value -> $Effect \{} -> value + // Effect.always = \value -> @Effect \{} -> value let value_symbol = { scope @@ -167,9 +167,9 @@ fn build_effect_always( }) }; - // \value -> $Effect \{} -> value + // \value -> @Effect \{} -> value let (function_var, always_closure) = { - // `$Effect \{} -> value` + // `@Effect \{} -> value` let (specialized_def_type, type_arguments, lambda_set_variables) = build_fresh_opaque_variables(var_store); let body = Expr::OpaqueRef { @@ -255,7 +255,7 @@ fn build_effect_map( effect_symbol: Symbol, var_store: &mut VarStore, ) -> (Symbol, Def) { - // Effect.map = \$Effect thunk, mapper -> $Effect \{} -> mapper (thunk {}) + // Effect.map = \@Effect thunk, mapper -> @Effect \{} -> mapper (thunk {}) let thunk_symbol = { scope @@ -350,7 +350,7 @@ fn build_effect_map( }) }; - // \$Effect thunk, mapper + // \@Effect thunk, mapper let (specialized_def_type, type_arguments, lambda_set_variables) = build_fresh_opaque_variables(var_store); let arguments = vec![ @@ -374,7 +374,7 @@ fn build_effect_map( ), ]; - // `$Effect \{} -> (mapper (thunk {}))` + // `@Effect \{} -> (mapper (thunk {}))` let (specialized_def_type, type_arguments, lambda_set_variables) = build_fresh_opaque_variables(var_store); let body = Expr::OpaqueRef { @@ -473,7 +473,7 @@ fn build_effect_after( effect_symbol: Symbol, var_store: &mut VarStore, ) -> (Symbol, Def) { - // Effect.after = \$Effect effect, toEffect -> toEffect (effect {}) + // Effect.after = \@Effect effect, toEffect -> toEffect (effect {}) let thunk_symbol = { scope @@ -636,7 +636,7 @@ fn build_effect_after( (after_symbol, def) } -/// turn `value` into `$Effect \{} -> value` +/// turn `value` into `@Effect \{} -> value` fn wrap_in_effect_thunk( body: Expr, effect_symbol: Symbol, @@ -670,7 +670,7 @@ fn wrap_in_effect_thunk( }) }; - // `$Effect \{} -> value` + // `@Effect \{} -> value` let (specialized_def_type, type_arguments, lambda_set_variables) = build_fresh_opaque_variables(var_store); Expr::OpaqueRef { @@ -749,14 +749,14 @@ fn build_effect_forever( // // Effect.forever : Effect a -> Effect b // Effect.forever = \effect -> - // $Effect \{} -> - // $Effect thunk1 = effect + // @Effect \{} -> + // @Effect thunk1 = effect // _ = thunk1 {} - // $Effect thunk2 = Effect.forever effect + // @Effect thunk2 = Effect.forever effect // thunk2 {} // // We then rely on our defunctionalization to turn this into a tail-recursive loop. - // First the `$Effect` wrapper melts away + // First the `@Effect` wrapper melts away // // Effect.forever : ({} -> a) -> ({} -> b) // Effect.forever = \effect -> @@ -955,7 +955,7 @@ fn build_effect_forever_inner_body( .unwrap() }; - // $Effect thunk1 = effect + // @Effect thunk1 = effect let thunk_from_effect = { let whole_var = var_store.fresh(); @@ -1022,7 +1022,7 @@ fn build_effect_forever_inner_body( }; // ``` - // $Effect thunk2 = forever effect + // @Effect thunk2 = forever effect // thunk2 {} // ``` let force_thunk2 = Loc::at_zero(force_effect( @@ -1330,7 +1330,7 @@ fn build_effect_loop_inner_body( }; // ``` - // $Effect thunk2 = loop effect + // @Effect thunk2 = loop effect // thunk2 {} // ``` let force_thunk2 = force_effect(loop_new_state_step, effect_symbol, thunk2_symbol, var_store); diff --git a/compiler/can/src/expr.rs b/compiler/can/src/expr.rs index 31d476d2b8..15301c832a 100644 --- a/compiler/can/src/expr.rs +++ b/compiler/can/src/expr.rs @@ -163,8 +163,7 @@ pub enum Expr { name: TagName, }, - /// A wrapping of an opaque type, like `$Age 21` - // TODO(opaques): $->@ above when opaques land + /// A wrapping of an opaque type, like `@Age 21` OpaqueRef { opaque_var: Variable, name: Symbol, diff --git a/compiler/can/src/scope.rs b/compiler/can/src/scope.rs index e2bdd50d20..b45b7eea6c 100644 --- a/compiler/can/src/scope.rs +++ b/compiler/can/src/scope.rs @@ -134,15 +134,14 @@ impl Scope { } /// Check if there is an opaque type alias referenced by `opaque_ref` referenced in the - /// current scope. E.g. `$Age` must reference an opaque `Age` declared in this module, not any + /// current scope. E.g. `@Age` must reference an opaque `Age` declared in this module, not any /// other! - // TODO(opaques): $->@ in the above comment pub fn lookup_opaque_ref( &self, opaque_ref: &str, lookup_region: Region, ) -> Result<(Symbol, &Alias), RuntimeError> { - debug_assert!(opaque_ref.starts_with('$')); + debug_assert!(opaque_ref.starts_with('@')); let opaque = opaque_ref[1..].into(); match self.idents.get(&opaque) { diff --git a/compiler/load_internal/tests/test_load.rs b/compiler/load_internal/tests/test_load.rs index 6f1bfffee3..769eafc8af 100644 --- a/compiler/load_internal/tests/test_load.rs +++ b/compiler/load_internal/tests/test_load.rs @@ -757,9 +757,9 @@ mod test_load { r#" interface Main exposes [ twenty, readAge ] imports [ Age.{ Age } ] - twenty = $Age 20 + twenty = @Age 20 - readAge = \$Age n -> n + readAge = \@Age n -> n "# ), ), @@ -775,7 +775,7 @@ mod test_load { The unwrapped opaque type Age referenced here: - 3│ twenty = $Age 20 + 3│ twenty = @Age 20 ^^^^ is imported from another module: @@ -789,7 +789,7 @@ mod test_load { The unwrapped opaque type Age referenced here: - 5│ readAge = \$Age n -> n + 5│ readAge = \@Age n -> n ^^^^ is imported from another module: diff --git a/compiler/parse/src/ast.rs b/compiler/parse/src/ast.rs index 6880e42086..1b985756c8 100644 --- a/compiler/parse/src/ast.rs +++ b/compiler/parse/src/ast.rs @@ -190,8 +190,7 @@ pub enum Expr<'a> { // Tags GlobalTag(&'a str), - // Reference to an opaque type, e.g. $Opaq - // TODO(opaques): $->@ in the above comment + // Reference to an opaque type, e.g. @Opaq OpaqueRef(&'a str), // Pattern Matching diff --git a/compiler/parse/src/ident.rs b/compiler/parse/src/ident.rs index e871563d9e..82854e2acb 100644 --- a/compiler/parse/src/ident.rs +++ b/compiler/parse/src/ident.rs @@ -36,8 +36,7 @@ impl<'a> From<&'a UppercaseIdent<'a>> for &'a str { pub enum Ident<'a> { /// Foo or Bar GlobalTag(&'a str), - /// $Foo or $Bar - // TODO(opaques): $->@ in the above comment + /// @Foo or @Bar OpaqueRef(&'a str), /// foo or foo.bar or Foo.Bar.baz.qux Access { @@ -291,10 +290,10 @@ fn chomp_accessor(buffer: &[u8], pos: Position) -> Result<&str, BadIdent> { } } -/// a `$Token` opaque +/// a `@Token` opaque fn chomp_opaque_ref(buffer: &[u8], pos: Position) -> Result<&str, BadIdent> { - // assumes the leading `$` has NOT been chomped already - debug_assert_eq!(buffer.get(0), Some(&b'$')); + // assumes the leading `@` has NOT been chomped already + debug_assert_eq!(buffer.get(0), Some(&b'@')); use encode_unicode::CharExt; let bad_ident = BadIdent::BadOpaqueRef; @@ -334,7 +333,7 @@ fn chomp_identifier_chain<'a>( } Err(fail) => return Err((1, fail)), }, - '$' => match chomp_opaque_ref(buffer, pos) { + '@' => match chomp_opaque_ref(buffer, pos) { Ok(tagname) => { let bytes_parsed = tagname.len(); diff --git a/compiler/solve/tests/solve_expr.rs b/compiler/solve/tests/solve_expr.rs index a8ee55ee26..1f42973aaf 100644 --- a/compiler/solve/tests/solve_expr.rs +++ b/compiler/solve/tests/solve_expr.rs @@ -5462,7 +5462,7 @@ mod solve_expr { r#" Age := U32 - $Age 21 + @Age 21 "# ), r#"Age"#, @@ -5477,7 +5477,7 @@ mod solve_expr { Age := U32 a : Age - a = $Age 21 + a = @Age 21 a "# @@ -5493,7 +5493,7 @@ mod solve_expr { r#" Id n := [ Id U32 n ] - $Id (Id 21 "sasha") + @Id (Id 21 "sasha") "# ), r#"Id Str"#, @@ -5508,7 +5508,7 @@ mod solve_expr { Id n := [ Id U32 n ] a : Id Str - a = $Id (Id 21 "sasha") + a = @Id (Id 21 "sasha") a "# @@ -5526,8 +5526,8 @@ mod solve_expr { condition : Bool if condition - then $Id (Id 21 (Y "sasha")) - else $Id (Id 21 (Z "felix")) + then @Id (Id 21 (Y "sasha")) + else @Id (Id 21 (Z "felix")) "# ), r#"Id [ Y Str, Z Str ]*"#, @@ -5545,8 +5545,8 @@ mod solve_expr { v : Id [ Y Str, Z Str ] v = if condition - then $Id (Id 21 (Y "sasha")) - else $Id (Id 21 (Z "felix")) + then @Id (Id 21 (Y "sasha")) + else @Id (Id 21 (Z "felix")) v "# @@ -5562,7 +5562,7 @@ mod solve_expr { r#" Age := U32 - \$Age n -> n + \@Age n -> n "# ), r#"Age -> U32"#, @@ -5577,7 +5577,7 @@ mod solve_expr { Age := U32 v : Age -> U32 - v = \$Age n -> n + v = \@Age n -> n v "# ), @@ -5592,7 +5592,7 @@ mod solve_expr { r#" Id n := [ Id U32 n ] - \$Id (Id _ n) -> n + \@Id (Id _ n) -> n "# ), r#"Id a -> a"#, @@ -5607,7 +5607,7 @@ mod solve_expr { Id n := [ Id U32 n ] v : Id a -> a - v = \$Id (Id _ n) -> n + v = \@Id (Id _ n) -> n v "# @@ -5625,7 +5625,7 @@ mod solve_expr { strToBool : Str -> Bool - \$Id (Id _ n) -> strToBool n + \@Id (Id _ n) -> strToBool n "# ), r#"Id Str -> Bool"#, @@ -5642,7 +5642,7 @@ mod solve_expr { strToBool : Str -> Bool v : Id Str -> Bool - v = \$Id (Id _ n) -> strToBool n + v = \@Id (Id _ n) -> strToBool n v "# @@ -5660,9 +5660,9 @@ mod solve_expr { \id -> when id is - $Id (Id _ A) -> "" - $Id (Id _ B) -> "" - $Id (Id _ (C { a: "" })) -> "" + @Id (Id _ A) -> "" + @Id (Id _ B) -> "" + @Id (Id _ (C { a: "" })) -> "" "# ), r#"Id [ A, B, C { a : Str }* ] -> Str"#, @@ -5679,9 +5679,9 @@ mod solve_expr { f : Id [ A, B, C { a : Str }e ] -> Str f = \id -> when id is - $Id (Id _ A) -> "" - $Id (Id _ B) -> "" - $Id (Id _ (C { a: "" })) -> "" + @Id (Id _ A) -> "" + @Id (Id _ B) -> "" + @Id (Id _ (C { a: "" })) -> "" f "# @@ -5703,7 +5703,7 @@ mod solve_expr { effectAlways = \x -> inner = \{} -> x - $Effect inner + @Effect inner "# ), r#"a -> Effect a"#, @@ -5765,8 +5765,8 @@ mod solve_expr { insert : Outer k, k -> Outer k insert = \m, var -> when m is - $Outer Empty -> $Outer (Wrapped var) - $Outer (Wrapped _) -> $Outer (Wrapped var) + @Outer Empty -> @Outer (Wrapped var) + @Outer (Wrapped _) -> @Outer (Wrapped var) insert "# @@ -5782,9 +5782,9 @@ mod solve_expr { r#" Outer k := [ Empty, Wrapped k ] - when ($Outer Empty) is - $Outer Empty -> $Outer (Wrapped "") - $Outer (Wrapped k) -> $Outer (Wrapped k) + when (@Outer Empty) is + @Outer Empty -> @Outer (Wrapped "") + @Outer (Wrapped k) -> @Outer (Wrapped k) "# ), r#"Outer Str"#, @@ -5798,9 +5798,9 @@ mod solve_expr { r#" Outer := [ A, B ] - when ($Outer A) is - $Outer A -> $Outer A - $Outer B -> $Outer B + when (@Outer A) is + @Outer A -> @Outer A + @Outer B -> @Outer B "# ), r#"Outer"#, @@ -5857,7 +5857,7 @@ mod solve_expr { Id := U64 - hash = \$Id n -> n + hash = \@Id n -> n "# ), [("Hash:hash", "Id")], @@ -5877,8 +5877,8 @@ mod solve_expr { Id := U64 - hash = \$Id n -> n - hash32 = \$Id n -> Num.toU32 n + hash = \@Id n -> n + hash32 = \@Id n -> Num.toU32 n "# ), [("Hash:hash", "Id"), ("Hash:hash32", "Id")], @@ -5902,11 +5902,11 @@ mod solve_expr { Id := U64 - hash = \$Id n -> n - hash32 = \$Id n -> Num.toU32 n + hash = \@Id n -> n + hash32 = \@Id n -> Num.toU32 n - eq = \$Id m, $Id n -> m == n - le = \$Id m, $Id n -> m < n + eq = \@Id m, @Id n -> m == n + le = \@Id m, @Id n -> m < n "# ), [ @@ -5931,7 +5931,7 @@ mod solve_expr { Id := U64 hash : Id -> U64 - hash = \$Id n -> n + hash = \@Id n -> n "# ), [("Hash:hash", "Id")], @@ -5969,9 +5969,9 @@ mod solve_expr { Id := U64 - hash = \$Id n -> n + hash = \@Id n -> n - zero = hash ($Id 0) + zero = hash (@Id 0) "# ), "U64", @@ -6062,9 +6062,9 @@ mod solve_expr { hashEq = \x, y -> hash x == hash y Id := U64 - hash = \$Id n -> n + hash = \@Id n -> n - result = hashEq ($Id 100) ($Id 101) + result = hashEq (@Id 100) (@Id 101) "# ), "Bool", @@ -6084,12 +6084,12 @@ mod solve_expr { mulHashes = \x, y -> hash x * hash y Id := U64 - hash = \$Id n -> n + hash = \@Id n -> n Three := {} - hash = \$Three _ -> 3 + hash = \@Three _ -> 3 - result = mulHashes ($Id 100) ($Three {}) + result = mulHashes (@Id 100) (@Three {}) "# ), "U64", @@ -6162,7 +6162,7 @@ mod solve_expr { Task a err : Effect (Result a err) always : a -> Task a * - always = \x -> $Effect (\{} -> Ok x) + always = \x -> @Effect (\{} -> Ok x) "# ), "a -> Task a *", diff --git a/compiler/test_gen/src/gen_abilities.rs b/compiler/test_gen/src/gen_abilities.rs index f268f0ae2b..4da1464de1 100644 --- a/compiler/test_gen/src/gen_abilities.rs +++ b/compiler/test_gen/src/gen_abilities.rs @@ -23,9 +23,9 @@ fn hash_specialization() { Id := U64 - hash = \$Id n -> n + hash = \@Id n -> n - main = hash ($Id 1234) + main = hash (@Id 1234) "# ), 1234, @@ -46,13 +46,13 @@ fn hash_specialization_multiple_add() { Id := U64 - hash = \$Id n -> n + hash = \@Id n -> n One := {} - hash = \$One _ -> 1 + hash = \@One _ -> 1 - main = hash ($Id 1234) + hash ($One {}) + main = hash (@Id 1234) + hash (@One {}) "# ), 1235, @@ -73,11 +73,11 @@ fn alias_member_specialization() { Id := U64 - hash = \$Id n -> n + hash = \@Id n -> n main = aliasedHash = hash - aliasedHash ($Id 1234) + aliasedHash (@Id 1234) "# ), 1234, @@ -100,9 +100,9 @@ fn ability_constrained_in_non_member_usage() { mulHashes = \x, y -> hash x * hash y Id := U64 - hash = \$Id n -> n + hash = \@Id n -> n - result = mulHashes ($Id 5) ($Id 7) + result = mulHashes (@Id 5) (@Id 7) "# ), 35, @@ -124,9 +124,9 @@ fn ability_constrained_in_non_member_usage_inferred() { mulHashes = \x, y -> hash x * hash y Id := U64 - hash = \$Id n -> n + hash = \@Id n -> n - result = mulHashes ($Id 5) ($Id 7) + result = mulHashes (@Id 5) (@Id 7) "# ), 35, @@ -149,12 +149,12 @@ fn ability_constrained_in_non_member_multiple_specializations() { mulHashes = \x, y -> hash x * hash y Id := U64 - hash = \$Id n -> n + hash = \@Id n -> n Three := {} - hash = \$Three _ -> 3 + hash = \@Three _ -> 3 - result = mulHashes ($Id 100) ($Three {}) + result = mulHashes (@Id 100) (@Three {}) "# ), 300, @@ -176,12 +176,12 @@ fn ability_constrained_in_non_member_multiple_specializations_inferred() { mulHashes = \x, y -> hash x * hash y Id := U64 - hash = \$Id n -> n + hash = \@Id n -> n Three := {} - hash = \$Three _ -> 3 + hash = \@Three _ -> 3 - result = mulHashes ($Id 100) ($Three {}) + result = mulHashes (@Id 100) (@Three {}) "# ), 300, @@ -204,12 +204,12 @@ fn ability_used_as_type_still_compiles() { mulHashes = \x, y -> hash x * hash y Id := U64 - hash = \$Id n -> n + hash = \@Id n -> n Three := {} - hash = \$Three _ -> 3 + hash = \@Three _ -> 3 - result = mulHashes ($Id 100) ($Three {}) + result = mulHashes (@Id 100) (@Three {}) "# ), 300, diff --git a/compiler/test_gen/src/gen_primitives.rs b/compiler/test_gen/src/gen_primitives.rs index 0657eb4715..3ef5d89e8f 100644 --- a/compiler/test_gen/src/gen_primitives.rs +++ b/compiler/test_gen/src/gen_primitives.rs @@ -1137,10 +1137,10 @@ fn io_poc_effect() { Effect a := {} -> a succeed : a -> Effect a - succeed = \x -> $Effect \{} -> x + succeed = \x -> @Effect \{} -> x runEffect : Effect a -> a - runEffect = \$Effect thunk -> thunk {} + runEffect = \@Effect thunk -> thunk {} foo : Effect F64 foo = @@ -1196,7 +1196,7 @@ fn return_wrapped_function_pointer() { Effect a := {} -> a foo : Effect {} - foo = $Effect \{} -> {} + foo = @Effect \{} -> {} main : Effect {} main = foo @@ -1244,7 +1244,7 @@ fn return_wrapped_closure() { foo = x = 5 - $Effect (\{} -> if x > 3 then {} else {}) + @Effect (\{} -> if x > 3 then {} else {}) main : Effect {} main = foo @@ -1870,10 +1870,10 @@ fn task_always_twice() { effectAlways = \x -> inner = \{} -> x - $Effect inner + @Effect inner effectAfter : Effect a, (a -> Effect b) -> Effect b - effectAfter = \($Effect thunk), transform -> transform (thunk {}) + effectAfter = \(@Effect thunk), transform -> transform (thunk {}) Task a err : Effect (Result a err) @@ -1918,7 +1918,7 @@ fn wildcard_rigid() { always = \x -> inner = \{} -> (Ok x) - $Effect inner + @Effect inner main : Task {} (Float *) @@ -1947,7 +1947,7 @@ fn alias_of_alias_with_type_arguments() { always = \x -> inner = (Ok x) - $Effect inner + @Effect inner main : Task {} (Float *) @@ -1975,10 +1975,10 @@ fn todo_bad_error_message() { effectAlways = \x -> inner = \{} -> x - $Effect inner + @Effect inner effectAfter : Effect a, (a -> Effect b) -> Effect b - effectAfter = \($Effect thunk), transform -> transform (thunk {}) + effectAfter = \(@Effect thunk), transform -> transform (thunk {}) Task a err : Effect (Result a err) @@ -3111,7 +3111,7 @@ fn nested_rigid_alias() { p2 main = - when foo ($Identity "foo") is + when foo (@Identity "foo") is _ -> "hello world" "# ), @@ -3225,13 +3225,13 @@ fn recursively_build_effect() { XEffect a := {} -> a always : a -> XEffect a - always = \x -> $XEffect (\{} -> x) + always = \x -> @XEffect (\{} -> x) after : XEffect a, (a -> XEffect b) -> XEffect b - after = \($XEffect e), toB -> - $XEffect \{} -> + after = \(@XEffect e), toB -> + @XEffect \{} -> when toB (e {}) is - $XEffect e2 -> + @XEffect e2 -> e2 {} "# ), diff --git a/compiler/test_gen/src/gen_tags.rs b/compiler/test_gen/src/gen_tags.rs index 20c2d2b8d6..43bcdb05c8 100644 --- a/compiler/test_gen/src/gen_tags.rs +++ b/compiler/test_gen/src/gen_tags.rs @@ -1058,7 +1058,7 @@ fn phantom_polymorphic() { World := {} zero : Point World - zero = Point ($World {}) 0 0 + zero = Point (@World {}) 0 0 add : Point a -> Point a add = \(Point c x y) -> (Point c x y) @@ -1593,11 +1593,11 @@ fn opaque_assign_to_symbol() { fromUtf8 : U8 -> Result Variable [ InvalidVariableUtf8 ] fromUtf8 = \char -> - Ok ($Variable char) + Ok (@Variable char) out = when fromUtf8 98 is - Ok ($Variable n) -> n + Ok (@Variable n) -> n _ -> 1 "# ), diff --git a/compiler/test_mono/src/tests.rs b/compiler/test_mono/src/tests.rs index fbb2612793..f0c2c51f01 100644 --- a/compiler/test_mono/src/tests.rs +++ b/compiler/test_mono/src/tests.rs @@ -1323,9 +1323,9 @@ fn specialize_ability_call() { Id := U64 hash : Id -> U64 - hash = \$Id n -> n + hash = \@Id n -> n - main = hash ($Id 1234) + main = hash (@Id 1234) "# ) } @@ -1340,7 +1340,7 @@ fn opaque_assign_to_symbol() { fromUtf8 : U8 -> Result Variable [ InvalidVariableUtf8 ] fromUtf8 = \char -> - Ok ($Variable char) + Ok (@Variable char) out = fromUtf8 98 "# diff --git a/examples/benchmarks/Bytes/Decode.roc b/examples/benchmarks/Bytes/Decode.roc index f5b9605e4b..6a5df2c8f3 100644 --- a/examples/benchmarks/Bytes/Decode.roc +++ b/examples/benchmarks/Bytes/Decode.roc @@ -7,7 +7,7 @@ DecodeProblem : [ OutOfBytes ] Decoder a := State -> [ Good State a, Bad DecodeProblem ] decode : List U8, Decoder a -> Result a DecodeProblem -decode = \bytes, $Decoder decoder -> +decode = \bytes, @Decoder decoder -> when decoder { bytes, cursor: 0 } is Good _ value -> Ok value @@ -16,11 +16,11 @@ decode = \bytes, $Decoder decoder -> Err e succeed : a -> Decoder a -succeed = \value -> $Decoder \state -> Good state value +succeed = \value -> @Decoder \state -> Good state value map : Decoder a, (a -> b) -> Decoder b -map = \$Decoder decoder, transform -> - $Decoder +map = \@Decoder decoder, transform -> + @Decoder \state -> when decoder state is Good state1 value -> @@ -30,8 +30,8 @@ map = \$Decoder decoder, transform -> Bad e map2 : Decoder a, Decoder b, (a, b -> c) -> Decoder c -map2 = \$Decoder decoder1, $Decoder decoder2, transform -> - $Decoder +map2 = \@Decoder decoder1, @Decoder decoder2, transform -> + @Decoder \state1 -> when decoder1 state1 is Good state2 a -> @@ -46,8 +46,8 @@ map2 = \$Decoder decoder1, $Decoder decoder2, transform -> Bad e map3 : Decoder a, Decoder b, Decoder c, (a, b, c -> d) -> Decoder d -map3 = \$Decoder decoder1, $Decoder decoder2, $Decoder decoder3, transform -> - $Decoder +map3 = \@Decoder decoder1, @Decoder decoder2, @Decoder decoder3, transform -> + @Decoder \state1 -> when decoder1 state1 is Good state2 a -> @@ -67,12 +67,12 @@ map3 = \$Decoder decoder1, $Decoder decoder2, $Decoder decoder3, transform -> Bad e after : Decoder a, (a -> Decoder b) -> Decoder b -after = \$Decoder decoder, transform -> - $Decoder +after = \@Decoder decoder, transform -> + @Decoder \state -> when decoder state is Good state1 value -> - ($Decoder decoder1) = transform value + (@Decoder decoder1) = transform value decoder1 state1 @@ -80,7 +80,7 @@ after = \$Decoder decoder, transform -> Bad e u8 : Decoder U8 -u8 = $Decoder +u8 = @Decoder \state -> when List.get state.bytes state.cursor is Ok b -> @@ -93,12 +93,12 @@ Step state b : [ Loop state, Done b ] loop : (state -> Decoder (Step state a)), state -> Decoder a loop = \stepper, initial -> - $Decoder + @Decoder \state -> loopHelp stepper initial state loopHelp = \stepper, accum, state -> - ($Decoder stepper1) = stepper accum + (@Decoder stepper1) = stepper accum when stepper1 state is Good newState (Done value) -> diff --git a/examples/false-interpreter/Variable.roc b/examples/false-interpreter/Variable.roc index f6cacbdce5..866ec789b1 100644 --- a/examples/false-interpreter/Variable.roc +++ b/examples/false-interpreter/Variable.roc @@ -15,7 +15,7 @@ totalCount = + 1 toStr : Variable -> Str -toStr = \$Variable char -> +toStr = \@Variable char -> when Str.fromUtf8 [ char ] is Ok str -> str @@ -33,11 +33,11 @@ fromUtf8 = \char -> <= 0x7A # "z" then - Ok ($Variable char) + Ok (@Variable char) else Err InvalidVariableUtf8 toIndex : Variable -> Nat -toIndex = \$Variable char -> +toIndex = \@Variable char -> Num.intCast (char - 0x61)# "a" # List.first (Str.toUtf8 "a") diff --git a/examples/false-interpreter/platform/File.roc b/examples/false-interpreter/platform/File.roc index c92cf4e63c..e64efe749a 100644 --- a/examples/false-interpreter/platform/File.roc +++ b/examples/false-interpreter/platform/File.roc @@ -5,19 +5,19 @@ interface File Handle := U64 line : Handle -> Task.Task Str * -line = \$Handle handle -> Effect.after (Effect.getFileLine handle) Task.succeed +line = \@Handle handle -> Effect.after (Effect.getFileLine handle) Task.succeed chunk : Handle -> Task.Task (List U8) * -chunk = \$Handle handle -> Effect.after (Effect.getFileBytes handle) Task.succeed +chunk = \@Handle handle -> Effect.after (Effect.getFileBytes handle) Task.succeed open : Str -> Task.Task Handle * open = \path -> Effect.openFile path - |> Effect.map (\id -> $Handle id) + |> Effect.map (\id -> @Handle id) |> Effect.after Task.succeed close : Handle -> Task.Task {} * -close = \$Handle handle -> Effect.after (Effect.closeFile handle) Task.succeed +close = \@Handle handle -> Effect.after (Effect.closeFile handle) Task.succeed withOpen : Str, (Handle -> Task {} a) -> Task {} a withOpen = \path, callback -> diff --git a/packages/parser/src/Str/Parser.roc b/packages/parser/src/Str/Parser.roc index 1e7af10c75..7dc755f4c0 100644 --- a/packages/parser/src/Str/Parser.roc +++ b/packages/parser/src/Str/Parser.roc @@ -48,16 +48,16 @@ keep : Parser a, (a -> Parser b) -> Parser b skip : Parser *, ({} -> Parser b) -> Parser b symbol : Str -> Parser {} -symbol = \symbol -> $Parser Str.chompStr symbol +symbol = \symbol -> @Parser Str.chompStr symbol u8 : Parser U8 -u8 = $Parser Str.parseU8 +u8 = @Parser Str.parseU8 i8 : Parser I8 -i8 = $Parser Str.parseI8 +i8 = @Parser Str.parseI8 end : Parser {} -end = $Parser \str -> +end = @Parser \str -> if Str.isEmpty str then Ok {} else @@ -65,7 +65,7 @@ end = $Parser \str -> lazy : ({} -> Parser a) -> Parser a lazy = \thunk -> - $Parser \str -> - $Parser parse = thunk {} + @Parser \str -> + @Parser parse = thunk {} parse str diff --git a/packages/unicode/src/Unicode/CodePoint/Internal.roc b/packages/unicode/src/Unicode/CodePoint/Internal.roc index 27d754e8ca..5ff40f9513 100644 --- a/packages/unicode/src/Unicode/CodePoint/Internal.roc +++ b/packages/unicode/src/Unicode/CodePoint/Internal.roc @@ -13,9 +13,9 @@ interface Unicode.CodePoint.Internal CodePoint := U32 fromU32Unchecked : U32 -> CodePoint -fromU32Unchecked = \u32 -> $CodePoint u32 +fromU32Unchecked = \u32 -> @CodePoint u32 toU32 : CodePoint -> U32 -toU32 = \$CodePoint u32 -> u32 +toU32 = \@CodePoint u32 -> u32 fromU32 : U32 -> Result CodePoint [ BadCodePoint ]* diff --git a/packages/unicode/src/Unicode/Scalar.roc b/packages/unicode/src/Unicode/Scalar.roc index 6979d01d04..b6a06d3e38 100644 --- a/packages/unicode/src/Unicode/Scalar.roc +++ b/packages/unicode/src/Unicode/Scalar.roc @@ -21,7 +21,7 @@ interface Unicode.Scalar Scalar := U32 toStr : Scalar -> Str -toStr = \$Scalar u32 +toStr = \@Scalar u32 when Str.fromScalar u32 is Ok str -> str Err _ -> @@ -29,10 +29,10 @@ toStr = \$Scalar u32 # this Err branch will never run. That's because it only runs # if Str.fromScalar receives an invalid scalar value, and we've # already validated this! - toStr ($Scalar (scalar * 256)) + toStr (@Scalar (scalar * 256)) toCodePt : Scalar -> CodePt -toCodePt = \$Scalar u32 -> Internal.fromU32Unchecked u32 +toCodePt = \@Scalar u32 -> Internal.fromU32Unchecked u32 fromCodePt : CodePt -> Result Scalar [ PointWasSurrogate ]* diff --git a/repl_test/src/tests.rs b/repl_test/src/tests.rs index eb3b1bf6f9..29c43a10a3 100644 --- a/repl_test/src/tests.rs +++ b/repl_test/src/tests.rs @@ -1026,7 +1026,7 @@ fn opaque_apply() { r#" Age := U32 - $Age 23 + @Age 23 "# ), "23 : Age", @@ -1040,7 +1040,7 @@ fn opaque_apply_polymorphic() { r#" F t u := [ Package t u ] - $F (Package "" { a: "" }) + @F (Package "" { a: "" }) "# ), r#"Package "" { a: "" } : F Str { a : Str }"#, @@ -1054,9 +1054,9 @@ fn opaque_pattern_and_call() { r#" F t u := [ Package t u ] - f = \$F (Package A {}) -> $F (Package {} A) + f = \@F (Package A {}) -> @F (Package {} A) - f ($F (Package A {})) + f (@F (Package A {})) "# ), r#"Package {} A : F {} [ A ]*"#, diff --git a/reporting/src/report.rs b/reporting/src/report.rs index 840054cacc..1fa222c813 100644 --- a/reporting/src/report.rs +++ b/reporting/src/report.rs @@ -440,8 +440,7 @@ impl<'a> RocDocAllocator<'a> { pub fn wrapped_opaque_name(&'a self, opaque: Symbol) -> DocBuilder<'a, Self, Annotation> { debug_assert_eq!(opaque.module_id(), self.home, "Opaque wrappings can only be defined in the same module they're defined in, but this one is defined elsewhere: {:?}", opaque); - // TODO(opaques): $->@ - self.text(format!("${}", opaque.ident_str(self.interns))) + self.text(format!("@{}", opaque.ident_str(self.interns))) .annotate(Annotation::Opaque) } diff --git a/reporting/tests/test_reporting.rs b/reporting/tests/test_reporting.rs index 9606694ccc..e4f2ddf47c 100644 --- a/reporting/tests/test_reporting.rs +++ b/reporting/tests/test_reporting.rs @@ -5978,7 +5978,7 @@ I need all branches in an `if` to have the same type! report_problem_as( indoc!( r#" - $UUID.bar + @UUID.bar "# ), indoc!( @@ -5987,7 +5987,7 @@ I need all branches in an `if` to have the same type! I am very confused by this field access: - 1│ $UUID.bar + 1│ @UUID.bar ^^^^ It looks like a record field access on an opaque reference. @@ -8237,7 +8237,7 @@ I need all branches in an `if` to have the same type! report_problem_as( indoc!( r#" - $Age 21 + @Age 21 "# ), indoc!( @@ -8246,7 +8246,7 @@ I need all branches in an `if` to have the same type! The opaque type Age referenced here is not defined: - 1│ $Age 21 + 1│ @Age 21 ^^^^ Note: It looks like there are no opaque types declared in this scope yet! @@ -8262,7 +8262,7 @@ I need all branches in an `if` to have the same type! r#" Age : Num.U8 - $Age 21 + @Age 21 "# ), indoc!( @@ -8271,7 +8271,7 @@ I need all branches in an `if` to have the same type! The opaque type Age referenced here is not defined: - 3│ $Age 21 + 3│ @Age 21 ^^^^ Note: There is an alias of the same name: @@ -8300,19 +8300,19 @@ I need all branches in an `if` to have the same type! report_problem_as( indoc!( r#" - OtherModule.$Age 21 + OtherModule.@Age 21 "# ), - // TODO: get rid of the first error. Consider parsing OtherModule.$Age to completion + // TODO: get rid of the first error. Consider parsing OtherModule.@Age to completion // and checking it during can. The reason the error appears is because it is parsed as - // Apply(Error(OtherModule), [ $Age, 21 ]) + // Apply(Error(OtherModule), [ @Age, 21 ]) indoc!( r#" ── OPAQUE TYPE NOT APPLIED ─────────────────────────────── /code/proj/Main.roc ─ This opaque type is not applied to an argument: - 1│ OtherModule.$Age 21 + 1│ OtherModule.@Age 21 ^^^^ Note: Opaque types always wrap exactly one argument! @@ -8321,7 +8321,7 @@ I need all branches in an `if` to have the same type! I am trying to parse a qualified name here: - 1│ OtherModule.$Age 21 + 1│ OtherModule.@Age 21 ^ I was expecting to see an identifier next, like height. A complete @@ -8340,11 +8340,11 @@ I need all branches in an `if` to have the same type! Age := Num.U8 21u8 - $Age age + @Age age "# ), // TODO(opaques): there is a potential for a better error message here, if the usage of - // `$Age` can be linked to the declaration of `Age` inside `age`, and a suggestion to + // `@Age` can be linked to the declaration of `Age` inside `age`, and a suggestion to // raise that declaration to the outer scope. indoc!( r#" @@ -8362,7 +8362,7 @@ I need all branches in an `if` to have the same type! The opaque type Age referenced here is not defined: - 5│ $Age age + 5│ @Age age ^^^^ Note: It looks like there are no opaque types declared in this scope yet! @@ -8410,7 +8410,7 @@ I need all branches in an `if` to have the same type! Age := Num.U8 n : Age - n = $Age "" + n = @Age "" n "# @@ -8423,7 +8423,7 @@ I need all branches in an `if` to have the same type! This expression is used in an unexpected way: - 4│ n = $Age "" + 4│ n = @Age "" ^^ This argument to an opaque type has type: @@ -8446,8 +8446,8 @@ I need all branches in an `if` to have the same type! F n := n if True - then $F "" - else $F {} + then @F "" + else @F {} "# ), indoc!( @@ -8456,7 +8456,7 @@ I need all branches in an `if` to have the same type! This expression is used in an unexpected way: - 5│ else $F {} + 5│ else @F {} ^^ This argument to an opaque type has type: @@ -8561,8 +8561,8 @@ I need all branches in an `if` to have the same type! \x -> when x is - $F A -> "" - $F {} -> "" + @F A -> "" + @F {} -> "" "# ), indoc!( @@ -8571,7 +8571,7 @@ I need all branches in an `if` to have the same type! The 2nd pattern in this `when` does not match the previous ones: - 6│ $F {} -> "" + 6│ @F {} -> "" ^^^^^ The 2nd pattern is trying to matchF unwrappings of type: @@ -8596,8 +8596,8 @@ I need all branches in an `if` to have the same type! v : F [ A, B, C ] when v is - $F A -> "" - $F B -> "" + @F A -> "" + @F B -> "" "# ), indoc!( @@ -8607,8 +8607,8 @@ I need all branches in an `if` to have the same type! The branches of this `when` expression don't match the condition: 5│> when v is - 6│ $F A -> "" - 7│ $F B -> "" + 6│ @F A -> "" + 7│ @F B -> "" This `v` value is a: @@ -8638,8 +8638,8 @@ I need all branches in an `if` to have the same type! v : F Num.U8 when v is - $F 1 -> "" - $F 2 -> "" + @F 1 -> "" + @F 2 -> "" "# ), indoc!( @@ -8649,12 +8649,12 @@ I need all branches in an `if` to have the same type! This `when` does not cover all the possibilities: 5│> when v is - 6│> $F 1 -> "" - 7│> $F 2 -> "" + 6│> @F 1 -> "" + 7│> @F 2 -> "" Other possibilities include: - $F _ + @F _ I would have to crash if I saw one of those! Add branches for them! "# @@ -9490,7 +9490,7 @@ I need all branches in an `if` to have the same type! Id := U32 - hash = \$Id n -> n + hash = \@Id n -> n "# ), indoc!( @@ -9499,7 +9499,7 @@ I need all branches in an `if` to have the same type! Something is off with this specialization of `hash`: - 7│ hash = \$Id n -> n + 7│ hash = \@Id n -> n ^^^^ This value is a declared specialization of type: @@ -9528,7 +9528,7 @@ I need all branches in an `if` to have the same type! Id := U64 - eq = \$Id m, $Id n -> m == n + eq = \@Id m, @Id n -> m == n "# ), indoc!( @@ -9547,7 +9547,7 @@ I need all branches in an `if` to have the same type! `eq`, specialized here: - 9│ eq = \$Id m, $Id n -> m == n + 9│ eq = \@Id m, @Id n -> m == n ^^ "# ), @@ -9610,7 +9610,7 @@ I need all branches in an `if` to have the same type! You := {} AndI := {} - eq = \$You {}, $AndI {} -> False + eq = \@You {}, @AndI {} -> False "# ), indoc!( @@ -9619,7 +9619,7 @@ I need all branches in an `if` to have the same type! Something is off with this specialization of `eq`: - 9│ eq = \$You {}, $AndI {} -> False + 9│ eq = \@You {}, @AndI {} -> False ^^ This value is a declared specialization of type: @@ -9653,7 +9653,7 @@ I need all branches in an `if` to have the same type! Id := U64 hash : Id -> U32 - hash = \$Id n -> n + hash = \@Id n -> n "# ), indoc!( @@ -9663,7 +9663,7 @@ I need all branches in an `if` to have the same type! Something is off with the body of this definition: 8│ hash : Id -> U32 - 9│ hash = \$Id n -> n + 9│ hash = \@Id n -> n ^ This `n` value is a: @@ -9678,7 +9678,7 @@ I need all branches in an `if` to have the same type! Something is off with this specialization of `hash`: - 9│ hash = \$Id n -> n + 9│ hash = \@Id n -> n ^^^^ This value is a declared specialization of type: @@ -9706,13 +9706,13 @@ I need all branches in an `if` to have the same type! Id := U64 - hash = \$Id n -> n + hash = \@Id n -> n User := {} noGoodVeryBadTerrible = { - nope: hash ($User {}), + nope: hash (@User {}), notYet: hash (A 1), } "# @@ -9738,7 +9738,7 @@ I need all branches in an `if` to have the same type! This expression has a type that does not implement the abilities it's expected to: - 14│ nope: hash ($User {}), + 14│ nope: hash (@User {}), ^^^^^^^^ This User opaque wrapping has the type: @@ -9804,10 +9804,10 @@ I need all branches in an `if` to have the same type! hash : a -> U64 | a has Hash Id := U64 - hash = \$Id n -> n + hash = \@Id n -> n hashable : a | a has Hash - hashable = $Id 15 + hashable = @Id 15 "# ), indoc!( @@ -9817,7 +9817,7 @@ I need all branches in an `if` to have the same type! Something is off with the body of the `hashable` definition: 9│ hashable : a | a has Hash - 10│ hashable = $Id 15 + 10│ hashable = @Id 15 ^^^^^^ This Id opaque wrapping has the type: @@ -9853,12 +9853,12 @@ I need all branches in an `if` to have the same type! mulHashes = \x, y -> hash x * hash y Id := U64 - hash = \$Id n -> n + hash = \@Id n -> n Three := {} - hash = \$Three _ -> 3 + hash = \@Three _ -> 3 - result = mulHashes ($Id 100) ($Three {}) + result = mulHashes (@Id 100) (@Three {}) "# ), indoc!(