Skip to content

Instantly share code, notes, and snippets.

@parsonsmatt
Created May 28, 2020 01:45
Show Gist options
  • Save parsonsmatt/74305da48ea6946f4860aa98f52795f9 to your computer and use it in GitHub Desktop.
Save parsonsmatt/74305da48ea6946f4860aa98f52795f9 to your computer and use it in GitHub Desktop.
haskell database library comparison

there's kind of a ladder of complexity, where you have safety vs complexity vs how much to learn vs what the lib does for you. hasql and postgresql-simple have a 1 on safety and "what the lib does for you" but also have a 1 on complexity and how much to learn. if you know SQL, you can write raw string queries. But you also don't get any safety or migrations or composability. persistent is a 2 on the "how much to learn", and around a 3 on "how much it does for you." You get migrations, datatype definitions, very safe easy/common-case functions. The functions it gives you are perfectly safe, but you need to use esqueleto or raw SQL for fancy stuff so it's like 3 on safety. There's not a huge amount to learn, maybe it's a 2 here. esqueleto is a lot more powerful, but requires a lot more learning - so it's like a 4 on what it does for you and a 3 on how much to learn. It's not perfectly safe, but it does more safely than persistent, so it gets a 4. beam is complicated and difficult to learn. It has a 5 on how much you need to learn and a 5 on complexity. But it's perfectly safe, if it compiles it runs safely, so it gets a 5 on safety. And it does all of SQL, pretty much, but you have to write a lot of boilerplate, so I'll call it a 4 on "what it does for you". So "Which library is most appropriate for me?" is a bit of a nuanced question. I generally find that persistent+esqueleto gives me the right balance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment