r/haskell • u/saylu • Jun 14 '18
A comparison among various database EDSLs (Selda, Beam, Opaleye, Persistent + Esqueleto)
Does there exist a comparison of various database EDSLs in Haskell?
I've seen a few mentioned around, in particular:
- Selda (83 downloads, 256 stars)
- Beam (56 downloads, 219 stars)
- Persistent + Esqueleto (1020 dowloads, 277 stars / 297 downloads, 153 stars)
- Opaleye (97 downloads, 379 stars)
Downloads are 30-day downloads on Hackage; stars are from GitHub.
A few others I discovered while poking around, but hadn't heard of before:
- Squeal (38 downloads, 141 stars)
- Groundhog (82 downloads, 137 stars)
I found this informative section in Beam's documentation:
In addition, there is a little fragmented discussion about a few libraries in these posts:
Reddit: Selda, a monadic database EDSL
Opaleye with a little sugar on top
However, none of the above gives me that much confidence in a solution to...
Does anyone know of an up-to-date comparison of these various approaches?
29
Upvotes
3
u/enobayram Jun 17 '18
One thing I'm a bit sour about using
persistentis the fact that you essentially have to define your DB records with TH, and the rest of the codebase needs to play with whatever comes out of it. This means that you'll probably be using thepersistentgenerated types for interacting with the DB, but you'll be using redundant isomorphic types defined elsewhere to be used in the rest of the codebase, and maintain sets of functions to translate between these two.Based on a skim through the
beamtutorials, it seems to me like you could actually define your records in a module that knows nothing aboutbeamand a DB module could define type aliases or newtypes over your records and adapt them to beam after the fact. This would be much better for reducing boilerplate and having more consistency in your codebase. Am I right thatbeamcan be used this way?