alan icon indicating copy to clipboard operation
alan copied to clipboard

Either (and Fallible and Maybe) methods

Open dfellis opened this issue 8 months ago • 0 comments

We need to implement helper methods for these three types, where Either's are inherited by all sum types, with a couple of special ones for Fallible and Maybe.

One is a generic function is{T}(Either) -> bool to determine if the actual value is that type or not. (This may be used by the match syntax for destructuring sugar.) Getter and setter syntax already exists for the Either type, though the Getter turns it into a Maybe that you can then extract from, while it may be good to have an "unwrap" style getter, too (or maybe that's what match is for so it's safe).

Fallible and Maybe have a getOr function that safely always returns a value of the specified type that needs to be properly generalized.

dfellis avatar Jun 11 '24 01:06 dfellis