2 ms·
> The first two lines are tagged unions Are they? But in the Nothing you have 2 identical members (`nothing' without arguments), won't that throw an exception?
by tmtvl 2y ago
> The first two lines are tagged unions
Are they? But in the Nothing you have 2 identical members (`nothing' without arguments), won't that throw an exception?
To borrow Rust syntax (pun intended):
enum Nothing {
nothing,
just
nothing
};
That's just weird.
- marvinborner 2y agoWhen encoding tagged unions as lambdas, the tags are arguments. In this case `Nothing` has two available tags (`nothing` and `just`) and uses the tag `nothing`. `Just` does the same with the tag `just`, only that the tag gets an additional argument (as does its constructor `Just`), such that the value can be extracted afterwards - just like in an enum: enum Maybe<T> { Nothing, Just(T), }
- ezwoodland 2y ago[dead]