Skip to content

Commit

Permalink
Merge pull request #7520 from gamebox/format-new-lambdas
Browse files Browse the repository at this point in the history
Format all lambdas to new syntax
  • Loading branch information
gamebox authored Jan 16, 2025
2 parents 7e8c9e3 + 1b43ffa commit d3c400b
Show file tree
Hide file tree
Showing 70 changed files with 1,105 additions and 669 deletions.
4 changes: 2 additions & 2 deletions crates/compiler/builtins/roc/Bool.roc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Eq implements
## `Bool` implements the `Eq` ability.
Bool := [True, False] implements [Eq { is_eq: bool_is_eq }]

bool_is_eq = \@Bool(b1), @Bool(b2) -> structural_eq(b1, b2)
bool_is_eq = |@Bool(b1), @Bool(b2)| structural_eq(b1, b2)

## The boolean true value.
true : Bool
Expand Down Expand Up @@ -115,7 +115,7 @@ not : Bool -> Bool
## expect "Apples" != "Oranges"
## ```
is_not_eq : a, a -> Bool where a implements Eq
is_not_eq = \a, b -> structural_not_eq(a, b)
is_not_eq = |a, b| structural_not_eq(a, b)

# INTERNAL COMPILER USE ONLY: used to lower calls to `is_eq` to structural
# equality via the `Eq` low-level for derived types.
Expand Down
10 changes: 5 additions & 5 deletions crates/compiler/builtins/roc/Decode.roc
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ DecoderFormatting implements
## _ -> { result: Err(TooShort), rest: bytes }
## ```
custom : (List U8, fmt -> DecodeResult val) -> Decoder val fmt where fmt implements DecoderFormatting
custom = \decode -> @Decoder(decode)
custom = |decode| @Decoder(decode)

## Decode a `List U8` utf-8 bytes using a specific [Decoder] function
decode_with : List U8, Decoder val fmt, fmt -> DecodeResult val where fmt implements DecoderFormatting
decode_with = \bytes, @Decoder(decode), fmt -> decode(bytes, fmt)
decode_with = |bytes, @Decoder(decode), fmt| decode(bytes, fmt)

## Decode a `List U8` utf-8 bytes and return a [DecodeResult](#DecodeResult)
## ```roc
Expand All @@ -139,7 +139,7 @@ decode_with = \bytes, @Decoder(decode), fmt -> decode(bytes, fmt)
## actual.result == expected
## ```
from_bytes_partial : List U8, fmt -> DecodeResult val where val implements Decoding, fmt implements DecoderFormatting
from_bytes_partial = \bytes, fmt -> decode_with(bytes, decoder, fmt)
from_bytes_partial = |bytes, fmt| decode_with(bytes, decoder, fmt)

## Decode a `List U8` utf-8 bytes and return a [Result] with no leftover bytes
## expected. If successful returns `Ok val`, however, if there are bytes
Expand All @@ -153,7 +153,7 @@ from_bytes_partial = \bytes, fmt -> decode_with(bytes, decoder, fmt)
## actual == expected
## ```
from_bytes : List U8, fmt -> Result val [Leftover (List U8)]DecodeError where val implements Decoding, fmt implements DecoderFormatting
from_bytes = \bytes, fmt ->
from_bytes = |bytes, fmt|
when from_bytes_partial(bytes, fmt) is
{ result, rest } ->
if List.is_empty(rest) then
Expand All @@ -165,4 +165,4 @@ from_bytes = \bytes, fmt ->

## Transform the `val` of a [DecodeResult]
map_result : DecodeResult a, (a -> b) -> DecodeResult b
map_result = \{ result, rest }, mapper -> { result: Result.map_ok(result, mapper), rest }
map_result = |{ result, rest }, mapper| { result: Result.map_ok(result, mapper), rest }
Loading

0 comments on commit d3c400b

Please sign in to comment.