unsplash / sum-types-io-ts

io-ts bindings for @unsplash/sum-types.
https://unsplash.github.io/sum-types-io-ts/
MIT License
2 stars 1 forks source link

Support externally tagged non-nullary sums #21

Closed samhh closed 1 year ago

samhh commented 1 year ago

Borrowing terminology from Serde: https://serde.rs/enum-representations.html#externally-tagged

For any given tag and any given data:

Sum.Member<'Sun'> | Sum.Member<'Rain', { mm: number }>

<->

{ Sun: null } | { Rain: { mm: number } }

A challenge here is in how the outcome can be affected by in which order the members attempt deserialisation; consider { Sun: null, Rain: { mm: number } }.