Hi all,
I’m writing a Haskell web service and PureScript frontend. I’m researching techniques that can serialize to/from Haskell and PureScript data types. So far I’m struggling to find anything that isn’t worrying.
Here’s my survey so far. Hopefully it will be of used to others to avoid spending the time I’ve spent trawling for answers.
-
purescript-bridge - this package generates
PureScript code, but it states that “For compatible JSON
representations you should be using aeson’s generic
encoding/decoding with default options andencodeJson
and
decodeJson
from “Data.Argonaut.Generic.Aeson” in purescript-argonaut-generic-codecs.” However, that package hasn’t been touched since 2017. It has funny parse issues like this, and apparently is unmaintained, and doesn’t useGenerics.Rep
: “I am no longer a PureScript user and did not know about this. But I will definitely merge PRs, making this library fit for future PureScript releases!” purescript-bridge is maintained by the same author. -
purescript-argonaut-aeson-generic supports
the new generics: “It is usingData.Generic.Rep
hence it will
work withpurescirpt-0.12
, unlike
purescript-argonaut-generic-codec which at the moment is based on
Data.Generic
for which generic deriving has been removed from the
purescript compiler in this commit.” But this is alsoapparently buggy, and has an issue that has been reported on this, and not responded to since 2018. Has been fixed 11th Oct 2020, see comment below. - purescript-foreign-generic - is seemingly maintained, as it was last touched in 2019, although it has three open pull requests. There’s some discussion on aeson compatibility, but it’s left unclear and is from last year. So the compatibility with aeson is at best a big question-mark.
- purescript-interop is a 5 years old untouched attempt at Haskell-PS interop, but seems dead.
- purescript-iso is an undocumented but possible Haskell-PS bridge
last touched in 2019.
(I originally put links to all the things I was referring to, but
Discord rejected my comment saying I can only put 2 links in a post
because I’m “new”. So you’ll have to just find the things yourself.)
There’s a pattern here. There are lots of alternatives, and they are all either out of date or unmaintained or buggy, or all three.
Ideally, I would just use aeson’s encoding and PureScript’s aeson-compatible encoding to ferry types between Haskell and PureScript, but my faith is wavering in any libraries providing this in a stable non-buggy way.
My options are:
- I pick up and maintain one of these in my project.
- I find another one that someone else out there is using for real work and doesn’t have blatant outstanding encoding errors.
- I write my own thing.
I’ve been wanting to version my API’s schema in a tightly-controlled way (hashing all types), so I might end up writing template Haskell anyway and generate Data.Argonaut.Core
to decode on the PureScript side.