I’m very proud to announce Squeal, a new database library for Haskell.
Squeal is the culmination of my Haskell experience for the last 4 years. It’s been a fun road and I’ve learned so much from so many friends and strangers in the community. So Squeal is dedicated to them.
State of the Haskell Database
- Persistent by Greg Weber and Michael Snoyman is amazing, especially combined with Esqueleto by Felipe Lessa. It offers a lot of safety and uses Template Haskell to define schemas, with multiple backend support and a huge ecosystem.
- Opaleye by Tom Ellis is a modernization of the HaskellDB library by Leijen and Meijer. In addition, it’s influenced by research by David Spivak who has written fabulous material on category theory and databases. Opaleye is famous for having an Arrow based query builder.
- The *sql-simple suite of libraries is probably the workhorse of the Haskell database world. They are very powerful.
- Hasql by Nikita Volkov is a very interesting modern database library. It’s split into a granular ecosystem of composable libraries. Squeal uses one of those pieces, the postgresql-binary package for fast encoding and decoding of parameters and result values.
- HDBC by John Goerzen and Nicolas Wu is a venerable multibackend library.
- I wish I knew more about Beam and Groundhog. They seem cool but I haven’t looked too much into them.
- The most modern database libraries for Haskell are the ones that use dependent typing to achieve safety and correctness. I think maybe the oldest contribution was in Power of Pi by Oury and Swierstra. This was elaborated on by Eisenberg in Dependent Types in Haskell. It turns out full dependent types are not strictly necessary though. One approach was fleshed out in a mind altering blog post by Renzo Carbonara called Opaleye’s sugar on top. This approach was actually implemented in the form of the Tisch library. Since then, the DbRecord library and Selda joined this race.
So, with all the options out there what is the motivation for one more? For me, I think I wanted to scratch an itch. I wanted to see how far I could push GHC in a practical library. Squeal makes use of lots of features and ideas in Haskell such as:
- Indexed monads
Squeal is still experimental and I would love to get some real users and contributors. Send me bug reports and feature requests. There are still many missing features that I have plans to include.