I think this new (=.) allows to create Codecs for records neatly without Template Haskell.
Example:
-- As if data (,) a b = (,) { fst :: a, snd :: b }
parsePair :: Codec fr fw a -> Codec fr fw b -> Codec fr fw (a, b)
parsePair a b
= (,)
<$> fst =. a
<*> snd =. b
parseFlipped :: Codec fr fw b -> Codec fr fw a -> Codec fr fw (a, b)
parseFlipped b a
= flip (,)
<$> snd =. b
<*> fst =. a
If you agree with this I can try to document it in Data.Codec.
(.=) seems to be the most common choice to map fields in other serialization libraries (JSON, YAML), and I picked the hardly used (=.) to avoid conflicts (assuming that users of Codec might need to use one of these other libraries at the same time).
I think this new
(=.)
allows to createCodec
s for records neatly without Template Haskell.Example:
If you agree with this I can try to document it in
Data.Codec
.(.=)
seems to be the most common choice to map fields in other serialization libraries (JSON, YAML), and I picked the hardly used(=.)
to avoid conflicts (assuming that users ofCodec
might need to use one of these other libraries at the same time).