I think it would be nice if Roc supported some form of pattern matching in conditions like isOk = \result -> result == Ok _ to avoid the need for when … is ….
Rust has if let <pattern> = <value> {} syntax and sometimes I missed it in elm.
Might not be a feature to make the language cleaner though. Most of the time a helper function would be cleaner.
What do you think?
That's pretty much just:
when <value> is
<pattern> -> ...
_ -> ...
in roc I'm pretty sure every if needs an else branch
so this situation if it was implemented could just be sugar for that when, but the if would still need an else for the catch all case
You're right I wasn't precise enought. My use case actually doesn't directly imply ifs. It would rather be an operator (or extension of ==) :
result == Ok _ or result ~= Ok _ if we want to use a different operator.
when result is
Ok _ -> True
_ -> False
oh cool, that reminds me of what you can do with elixir
This basically hint for the need of a Hole!
_ This is the hole
and everything works in the hole
Last updated: Jun 16 2026 at 16:19 UTC