Are functions always have a return value? Or is there any keyword equivalent to "void"? I also wondered how Roc handles mutually recursive definitions of functions.
There is {}
, maybe that works? I think it's an empty record, but you can use it as a type as well
{}
is the closest to void, but a function that returns it can't actually do anything in a purely functional language like Roc. What is the function you're trying to define? You probably need it to return something like Task {} []
instead, since that can actually do a side effect.
Mutually recursive functions work in the standard way; you must write all functions involved in a mutual recursion next to each other, but otherwise there are no syntactic restrictions. Only functions can be recursive (respectively, mutually recursive), ground values cannot be recursive. Roc does not support polymorphic recursion.
Thanks so much for the explanation!
Last updated: Jul 05 2025 at 12:14 UTC