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

Mapped nullary tag is an inverse map upon the tag #17

Closed samhh closed 1 year ago

samhh commented 1 year ago

A discovery worth documenting (https://github.com/unsplash/unsplash-web/pull/10389#discussion_r1280540272).

getCodecFromMappedNullaryTag builds a codec from:

The biggest difference is that in the former a is the member tag whereas in the latter it'd (typically) be the sum itself.

Finding the common ground between these could substantially reduce the boilerplate needed to write these mapped codecs.

samhh commented 1 year ago

I suppose it's getCodecFromPrimitiveMappedNullaryTag?