The new lambda syntax is here!
Now instead of this:
\a, b -> (someFunc a) + b
You can write (with all new syntax from the last month):
|a, b| some_func(a) + b
And very soon, ALL lambdas will be formatted to the new style when you run roc format
. This is an unconditional move as there is no change in behavior.
It won't be generally usable until we make a new release of roc and the platforms. We're working on a batch of breaking changes and this is included in with those.
:smiley:
UPDATE: On the latest, formatting will convert all lambdas to the new syntax. Please report any issues you have with the formatting!
As a newcomer to the language it does look pretty weird and unintuitive. I would have never guessed if i saw it in code first, that it was the syntax for lambdas. Im sure there are good reasons why it’s like that which im not aware of yet, as the community seems great at working out things together, but i just wanted to give some honest feedback.
It's the same as Rust lambda syntax, so it's not really that exotic/weird, the only difference here is that rust can use {} for lambda body (but it's optional).
You're right - I suppose it depends on what languages someone is familiar with... It looks like Rust originally had the arrow and then dropped it. I'm sure I'll get used to it (and others who it isn't familiar for).
I also feel that we betrayed "lamda" and that these new notation should be called "pipes" functions or something like that ... but that is just me who is looking at the Haskell and Elm whole day.
One day all those syntax specifics would be obsolete :glowing_star:
Am I right in guessing that this is so an effectful function doesn't confuse people with ->
vs =>
?
That was a big part of it yes
Last updated: Jul 26 2025 at 12:14 UTC