Open
Description
In #1485 (comment) @jiegillet brought up the idea of representing decoders and encoders in a single type inspired by tomland
's Codec
:
About module for encoding and decoding, it's an out-there suggestion but, the way
tomland
encodes and decodestoml
is with a bi-directional codec, something likedata Codec a = Codec { fromDhall :: Expr Src Void -> Extractor Src Void a toDhall :: a -> Expr Src Void dhallType :: Expr Src Void }It's pretty nice to keep the symmetry, and this way you always have to implement both encoders and decoders at the same time.
What I'm wondering right now is what we would do about types where there is no bijection between Dhall and Haskell, like Word
.
I also wonder how the types would work out for the combined record and union de-and-encoders and their helpers like constructor
and encodeConstructor
.