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 adjacently tagged non-nullary sums #19

Closed samhh closed 1 year ago

samhh commented 1 year ago

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

For any given tag and any arbitrary sibling data at any given content tag:

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

<->

{ tag: 'Sun' } | { tag: 'Rain', value: { mm: number } }

This would potentially interoperate with how fp-ts sums are encoded.

How to handle nullary members? Absent content tag? null?