Stream: announcements

Topic: New lambda syntax has landed


view this post on Zulip Anthony Bullard (Jan 15 2025 at 22:19):

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.

view this post on Zulip Luke Boswell (Jan 15 2025 at 22:20):

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:

view this post on Zulip Anthony Bullard (Jan 16 2025 at 22:56):

UPDATE: On the latest, formatting will convert all lambdas to the new syntax. Please report any issues you have with the formatting!

view this post on Zulip Yunti (Jan 17 2025 at 08:39):

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.

view this post on Zulip Dawid Danieluk (Jan 17 2025 at 10:02):

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).

view this post on Zulip Yunti (Jan 17 2025 at 15:39):

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).

view this post on Zulip Zeljko Nesic (Jan 17 2025 at 17:27):

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:

view this post on Zulip Unshipped9094 (Jan 30 2025 at 03:05):

Am I right in guessing that this is so an effectful function doesn't confuse people with -> vs =>?

view this post on Zulip Anthony Bullard (Jan 30 2025 at 03:05):

That was a big part of it yes


Last updated: Jul 26 2025 at 12:14 UTC