darkf / darkfo

DarkFO, a post-nuclear RPG remake (of Fallout 2)
Apache License 2.0
135 stars 12 forks source link

Make use of typed unions, especially in Worldmap/Encounters #76

Open darkf opened 7 years ago

darkf commented 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).