Hello! I'm using this approach to write bidirectional parser and pretty-printer for TOML:
Now I want to be able to encode and decode sum types. And Alternative type class looks like a good pattern for such things. But, unfortunately, I can't figure out clean way to do it.
Maybe you could give some ideas and tips regarding how to deal with sum types in this approach? I can introduce dirty hacks and workarounds without problems, but it would be great to have some idiomatic and clean solution!
In examples for codec library I see only record types, no sum types, so I'm a little bit confused by this problem 🤔
Hello! I'm using this approach to write bidirectional parser and pretty-printer for TOML:
Now I want to be able to encode and decode sum types. And
Alternativetype class looks like a good pattern for such things. But, unfortunately, I can't figure out clean way to do it.Maybe you could give some ideas and tips regarding how to deal with sum types in this approach? I can introduce dirty hacks and workarounds without problems, but it would be great to have some idiomatic and clean solution!
In examples for
codeclibrary I see only record types, no sum types, so I'm a little bit confused by this problem 🤔