unsplash/sum-types

Add io-ts codec

samhh opened this issue · 5 comments

samhh commented

Can probably make use of serialization. Will need to decode the discriminant and be provided a codec for the value (or not if there isn't one - probably overloaded like mkConstructor).

samhh commented

Suddenly noticing that there's some overlap between this and (de)serialization. Ideally:

  • encode == serialize
  • decode == fallible deserialize over foreign data
samhh commented

We may need to be careful about using any libraries until we've addressed #5?

We may need to be careful about using any libraries until we've addressed #5?

Good point. I also wonder whether the io-ts part would be better as a separate package (in the spirit of small modules that do one thing)?

samhh commented

Possibly, something like sum-types-io-ts-bindings. I suppose it doesn't need access to anything more primitive than the preexisting serialization functions. 👍