I'm really new to roc and enjoying it so far. Some of the examples I've seen define arguments in a couple ways, and I can't see from documentation the difference.
As I understand these two are the same?
isSeven : I64 -> Bool
isSeven = \n ->
n == 7
isSeven : I64 -> Bool
isSeven = |n|
n == 7
Is there something subtly different about the two? Is one considered more "idiomatic" (the second seems to be in roc docs)?
There has recently been a lot of changes to the syntax. Both of these notations are identical in what they do, because they ARE effectively the same thing (lambdas)
the \x -> notation is to be replaced with the |x| syntax going forward, but the docs are out of sync with the actual state of the language
Ah thanks, that makes sense! So if I've understood 1 is old, 2 is new, and at some point 2 will probably be the only way to do it?
Yes, that is correct
If you run roc format --migrate ...
the compiler will automatically upgrade your syntax to the latest version :)
Last updated: Jul 06 2025 at 12:14 UTC