Hi,
I have not been successful in destructuring Results. If, for example, I try
somefunc : Result Str Str -> Str
somefunc = \ra ->
when ra is
OK a -> a
Err r -> r
I get
── TYPE MISMATCH in sequence.roc ───────────────────────────────────────────────
The branches of this when expression don't match the condition:
8│> when ra is
9│ OK a -> a
10│ Err r -> r
This ra value is a:
Result Str Str
But the branch patterns have type:
[
Err *,
OK *,
]
The branches must be cases of the when condition's type!
Am I doing something wrong?
Thanks!
Hi @Ben Plotke,
It needs to be Ok
instead of OK
I've seen several similar issues over the last couple of days, what do you think of a tool like this to prevent them?
Anton said:
Hi Ben Plotke,
It needs to beOk
instead ofOK
:face_palm: :laughing: :sob:
Anton said:
I've seen several similar issues over the last couple of days, what do you think of a tool like this to prevent them?
I'd use it
Thanks!
Last updated: Jul 06 2025 at 12:14 UTC