Should something like this work?
SomeType : [
A { name: Str, other: U64 },
B { name: Str, somethingElse: List U32 },
]
var : SomeType
var = A { name: "test", other: 32 }
main =
when var is
A { name } | B { name } ->
Stdout.line name
In current roc, the two instances of name
in the match will not unify because the underlying record type has different fields.
Oh, actually even if the records are the same, it still doesn't work in current roc. So really any record in general blocks |
from being used.
I would expect, as a beginner, that any disjoints within a when
case to be exactly equivalent to if those disjoints were each given their own case (with the case body essentially just being duplicated in terms of semantic effect).
Last updated: Jul 06 2025 at 12:14 UTC