Hi! I've wondered since first time seeing haskell code:
fullName : Str, Str -> Str
fullName = \firstName, lastName ->
"\(firstName) \(lastName)"
Why is it necessary for the function name to be repeated? Couldn't _ : Str, Str -> Str work as well? Or are there advantages to doing it like this?
Of course it wouldn't align the : with the = :tear:
I think it is just a design and readability thing. Also, your alternative syntax is missing the variables for the arguments. It just has their type.
But could be something like:
foo = firstName: Str, lastName: Str ->
Though that is missing the return type also.
Oh, you just meant unnamed on the line before.
_ : Str, Str -> Str
fullName = \firstName, lastName ->
...
That could parse too.
I think it also falls under my first comment. Just design and readability and such. Alternatives definitely could be made.
Doesn't Roc let you just write fullName : Str, Str -> Strwhich it treats as a
fullName : Str, Str -> Str
fullName = \_, _ -> panic
?
If it does then using _ instead of the fullName wouldn't work.
Sure sure, but i don't think the specific character there matters, more the general idea of not repeating the name twice.
if you ask me even this might be legit
fullName : Str, Str -> Str
= \firstname, lastname -> "\(firstname) \(lastname)"
Str, Str -> Str
fullName = \firstname, lastname -> "\(firstname) \(lastname)"
gg
I think the alignment of the existing design is really good, it's nice to have the columns of the first type and first argument name close together.
fullName : Str, Str -> Str
fullName = \firstName, lastName ->
Although my preferred way to display it in the editor would be something like this:
Str Str -> Str
fullName = \firstName, lastName ->
Last updated: Jun 16 2026 at 16:19 UTC