Open darkf opened 7 years ago
A good example is https://hackernoon.com/tagged-unions-react-and-redux-55e262e4d0ea where we can use typed unions like ADTs in other languages, e.g.:
type Foo = {tag: 'A', x: T} | {tag: 'B', y: U}
and then discriminate based on tag (which will be type narrowed by conditionals).
tag
A good example is https://hackernoon.com/tagged-unions-react-and-redux-55e262e4d0ea where we can use typed unions like ADTs in other languages, e.g.:
and then discriminate based on
tag
(which will be type narrowed by conditionals).