Stream: ideas

Topic: named arguments


view this post on Zulip Georges Boris (Nov 02 2022 at 19:30):

hey folks! in elixir's typespec we can optionally name arguments for documentation purposes. this doesn't change the function in any way, we can't pass them in random order or anything.

since Roc is a language that will possibly be pipeline-heavy (which means we will probably have functions with multiple arguments instead of receiving a record) maybe it would also benefit from this feature?

while trying to write an example I ended up hating the result :joy: but I thought it might be worth the discussion anyway.

in elixir it would look something like:

@spec parse_string(input :: String, pattern :: String) :: List token

in Roc (idk):

parseString : input :: String -> pattern :: String -> List Token

view this post on Zulip Ayaz Hafiz (Nov 02 2022 at 19:32):

I think it would be nice if those names could be populated from the parameters the implementation expects, rather than having to type them again in a type signature

view this post on Zulip Ayaz Hafiz (Nov 02 2022 at 19:32):

There was some discussion about this in this issue: https://github.com/roc-lang/roc/issues/4301

view this post on Zulip Georges Boris (Nov 02 2022 at 19:46):

yep! that would be a lot better


Last updated: Jun 16 2026 at 16:19 UTC