Stream: beginners

Topic: what is the syntax to define a function of no parameters?


view this post on Zulip Greg Wilson (Mar 12 2024 at 01:50):

Subject line says it all...

view this post on Zulip Luke Boswell (Mar 12 2024 at 02:36):

theAnswer : {} -> U8
theAnswer = \{} -> 42

expect theAnswer {} == 42

view this post on Zulip Luke Boswell (Mar 12 2024 at 02:37):

The {} is a unit or empty value.

view this post on Zulip witoldsz (Mar 14 2024 at 10:43):

The function with no arguments is essentially like a value. As Luke said, you can use a unit, i.e. empty value, but since Roc is a pure functional language, it does not make much of a difference comparing to simple values.


Last updated: Jul 06 2025 at 12:14 UTC