Improving the experience of JSON in Haskell
In my last post, I talked about how Haskell
newtypes
are great tools for modeling JSON data when writing API clients in Haskell, and I included some examples on how to write customToJSON
andFromJSON
methods that incorporated thesenewtypes
. That post generated some discussion on Lobsters, from which I learned about this interesting library called autodocodec. Given the advantages laid out in that discussion, I decided to give that library a try on my project’s codebase, and it worked so well that, so I ended up refactoring basically all of my types to use autodocodec to generate JSON parsers for my types. In fact, I enjoyed the experience of using autodocodec so much that I thought it was worth blogging about.
Source: Improving the experience of JSON in Haskell with autodocodec and bifunctors, an article by Dylan Martin.