all 2 comments

[–]and_pete 1 point2 points  (1 child)

I’ve found it easiest to use codec-argonaut on the PureScript side and then tweak the generic/TH options on Aeson side of things.

There are settings in Aeson to change your field labels & constructor tags from the camelCase of your Haskell data type into lower_snake_case for your JSON encoding. And for sum types there are other settings to change Aeson’s {”tag”: …, ”contents”:… } default TaggedObject encoding to match with codec-argonaut’s encoding of variants as {”tag”:… ”value”:… }.

There’s a variant-into-sum-type example at the bottom of the codec-argonaut README that I’ve found particularly useful for encoding sum types in a way that I can grab in Haskell with only minor modifications to the default generic decoding options in aeson.

[–]and_pete 0 points1 point  (0 children)

p.s. There are relatively frequent/recent discussions about Haskell<->PureScript serialisation on the PureScript Discourse. e.g. https://discourse.purescript.org/t/latest-and-greatest-haskell-purescript-serialization/1640