Format all lambdas to new syntax

This commit is contained in:
Anthony Bullard 2025-01-15 16:15:24 -06:00
parent 9d37c906fe
commit 1b43ffa579
No known key found for this signature in database
70 changed files with 1105 additions and 669 deletions

View file

@ -1,4 +1,4 @@
il3 \k -> # w#z
il3 |k| # w#z
CCC @C ( # i
t! K) : i
C

View file

@ -1,5 +1,5 @@
launchTheNukes : {} => Result Bool LaunchNukeErr
launchTheNukes = \{} ->
launchTheNukes = |{}|
crash "todo"
launchTheNukes

View file

@ -1,2 +1,2 @@
foo
|> Dict.keepIf \(k, _v) -> List.contains keysToDelete k |> Bool.not
|> Dict.keepIf |(k, _v)| List.contains keysToDelete k |> Bool.not

View file

@ -1,2 +1,2 @@
\({ x, y } as point), (@Location inner as outer) ->
|({ x, y } as point), (@Location inner as outer)|
crash ""

View file

@ -1,3 +1,3 @@
\I { p ?? Y
Y } [] ->
|I { p ?? Y
Y } []|
K # (

View file

@ -1,7 +1,7 @@
_ = crash ""
_ = crash "" ""
_ = crash 15 123
_ = try foo (\_ -> crash "")
_ = try foo (|_| crash "")
_ =
_ = crash ""
crash

View file

@ -1,4 +1,4 @@
launchTheNukes! = \{} ->
launchTheNukes! = |{}|
boom
launchTheNukes! {}

View file

@ -1,4 +1,4 @@
\{} ->
|{}|
echo "Welcome to the DMV!"
age = readInt

View file

@ -3,5 +3,5 @@ table :
height : Pixels,
}
-> Table
table = \{ height } -> crash "not implemented"
table = |{ height }| crash "not implemented"
table

View file

@ -1,4 +1,4 @@
f : (Str)a -> (Str)a
f = \x -> x
f = |x| x
f ("Str", 42)

View file

@ -1,4 +1,4 @@
f : I64 -> (I64, I64)
f = \x -> (x, x + 1)
f = |x| (x, x + 1)
f 42

View file

@ -0,0 +1,4 @@
"a string"
|> Str.toUtf8
|> List.map |byte| byte + 1
|> List.reverse

View file

@ -1,6 +1,6 @@
[
[
!(!(\L -> t))
!(!(|L| t))
M,
],
]

View file

@ -0,0 +1,6 @@
main =
wrappedNotEq : a, a -> Bool
wrappedNotEq = |num1, num2|
num1 != num2
wrappedNotEq 2 3

View file

@ -0,0 +1,4 @@
my_var =
some_var # c
|| other_thing # ^D
final_expr

View file

@ -0,0 +1,85 @@
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-62,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-6 Identifier {
ident: "my_var",
},
@14-62 SpaceBefore(
Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@14-43,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
Stmt(
@14-43 BinOps(
[
(
@14-22 SpaceAfter(
Var {
module_name: "",
ident: "some_var",
},
[
LineComment(
" c",
),
],
),
@30-32 Or,
),
],
@32-43 Var {
module_name: "",
ident: "other_thing",
},
),
),
],
},
@52-62 SpaceBefore(
Var {
module_name: "",
ident: "final_expr",
},
[
LineComment(
" ^D",
),
],
),
),
[
Newline,
],
),
),
],
}

View file

@ -0,0 +1,4 @@
my_var =
some_var# c
||other_thing# ^D
final_expr

View file

@ -0,0 +1,7 @@
main =
parseArgs? {}
|> List.dropFirst 1
|> List.mapTry? Str.toU8
|> List.sum
|> |total| "Sum of numbers: ${Num.to_str total}"
|> Str.toUpper

View file

@ -1,4 +1,4 @@
{
answer: 42,
launchTheNukes!: \{} -> boom,
launchTheNukes!: |{}| boom,
}

View file

@ -1,4 +1,4 @@
maybeEarlyReturn = \x ->
maybeEarlyReturn = |x|
y =
if x > 5 then
return "abc"

View file

@ -1,4 +1,4 @@
maybeEarlyReturn = \x ->
maybeEarlyReturn = |x|
y =
when x is
5 ->

View file

@ -1,4 +1,4 @@
identityFn = \x ->
identityFn = |x|
return x
identityFn 45

View file

@ -1,4 +1,4 @@
f : (Str, Str) -> (Str, Str)
f = \x -> x
f = |x| x
f (1, 2)

View file

@ -1,4 +1,4 @@
f : (Str, Str)a -> (Str, Str)a
f = \x -> x
f = |x| x
f (1, 2)

View file

@ -0,0 +1,4 @@
foo : Int, Float -> Bool
foo = |x, _| 42
42

View file

@ -1,3 +1,3 @@
nextWhileLess : List Bucket, k, U8 -> (U64, U32) where k implements Hash & Eq
nextWhileLess = \buckets, key, shifts -> foo
nextWhileLess = |buckets, key, shifts| foo
nextWhileLess

View file

@ -1,7 +1,7 @@
when
f
is
s if (\t ->
s if (|t|
when
0
is

View file

@ -1,4 +1,4 @@
func = \x ->
func = |x|
when n is
0 -> 0
42

View file

@ -1,4 +1,4 @@
func = \x ->
func = |x|
when n is
0 -> 0
42

File diff suppressed because it is too large Load diff

View file

@ -564,6 +564,7 @@ mod test_snapshots {
pass/nested_list_comment_in_closure_arg.expr,
pass/nested_parens_in_pattern.expr,
pass/nested_when_comment_in_pat.expr,
pass/new_lambda_as_second_statement.moduledefs,
pass/newline_after_equals.expr, // Regression test for https://github.com/roc-lang/roc/issues/51
pass/newline_after_import_str_as.expr,
pass/newline_after_mul.expr,