Stream: compiler development

Topic: Higher order functions


view this post on Zulip JRI98 (Jul 19 2025 at 17:05):

Hello. I was working on implementing support for higher order functions in types but I have a question.
What is this supposed to parse to?

f : a, (b, c -> d) -> e

Is the second argument:

view this post on Zulip Joshua Warner (Jul 19 2025 at 17:27):

That's supposed to parse to a function with two arguments. If it parsed to a tuple, there would be no way to write a function with multiple arguments - but since it's parsing as a function, if what you wanted was actually a tuple, you just write (b, (c -> d)).

view this post on Zulip JRI98 (Jul 19 2025 at 17:29):

And what if it was like this?

f : a, (b, c -> d, e) -> f

Does it turn into a tuple with 2 elements? b, c -> d ; e

view this post on Zulip Joshua Warner (Jul 19 2025 at 17:31):

Does it turn into a tuple with 2 elements?

That sounds right. Agreed it looks a bit weird tho.

view this post on Zulip Joshua Warner (Jul 19 2025 at 17:31):

We probably ought to force that to format as ((b, c -> d), e)

view this post on Zulip JRI98 (Jul 19 2025 at 17:31):

Yeah it's not nice to the eyes

view this post on Zulip Kiryl Dziamura (Jul 19 2025 at 17:33):

I remember I had the same question two (omg) years ago: https://github.com/roc-lang/roc/issues/6426 :sweat_smile:


Last updated: Jul 26 2025 at 12:14 UTC