3 ms·
> Isn't Union Types just the same as "Sum Types" (as in Haskell etc.)? No, Union Types are untagged, Sum types are tagged. One consequence is that Sum types c
by dragonwriter 4y ago
> Isn't Union Types just the same as "Sum Types" (as in Haskell etc.)?
No, Union Types are untagged, Sum types are tagged.
One consequence is that Sum types can be nested in a way that doesn't work for Union Types.
E.g., with a Sum type like Maybe a = Some a | None, you can have a Maybe (Maybe a) which expands to None | Some (None) | Some (Some a)
Whereas with a union like Maybe a = None | a; Maybe (Maybe a) would be identical to Maybe a.
- deleted 4y ago[deleted]