A pleasant PostgreSQL database layer for Haskell
Haskell
42
187 commits
updated Sep 14, 2026
This library is a pleasant layer on top of postgresql-simple to safely expand the fields of a table when
writing SQL queries.
It aims to be a convenient middle-ground between rigid ORMs and hand-rolled SQL query strings. Here is its philosophy:
IsString instance exists.
Don't force yourself to use the higher-level API if the lower-level combinators work for you, and if those don't either, “Just Write SQL”™.Its dependency footprint is optimised for my own setups, and as such it makes use of text, vector and pg-transact.
This library aims to be thoroughly tested, by the means of Oleg Grenrus' cabal-docspec and more traditional tests for database roundtrips.
I aim to produce and maintain a decent documentation, therefore do not hesitate to raise an issue if you feel that something is badly explained and should be improved.
Safe SQL generation is a complex subject, and it is far from being the objective of this library. The main topic it addresses is listing the fields of a table, which is definitely something easier. This is why every level of this wrapper is fully exposed, so that you can drop down a level at your convience.
It is my personal belief, firmly rooted in experience, that we should not aim to produce statically-checked SQL and have it "verified" by the compiler. The techniques that would allow that in Haskell are still far from being optimised and ergonomic. As such, this library makes no effort to produce semantically valid SQL queries, because one would have to encode the semantics of SQL in the type system (or in a rule engine of some sort), and this is clearly not the kind of things I want to spend my youth on.
Each function is tested for its output with doctests, and the ones that cannot (due to database connections) are tested in the more traditional test-suite.
The conclusion is : Test your DB queries. Test the encoding/decoding. Make roundtrip tests for your data-structures.
I wish to thank
Haskell
95.2%
Nix
2.2%
Makefile
1.9%
A pleasant PostgreSQL database layer for Haskell
Haskell
42
187 commits
updated Sep 14, 2026
This library is a pleasant layer on top of postgresql-simple to safely expand the fields of a table when
writing SQL queries.
It aims to be a convenient middle-ground between rigid ORMs and hand-rolled SQL query strings. Here is its philosophy:
IsString instance exists.
Don't force yourself to use the higher-level API if the lower-level combinators work for you, and if those don't either, “Just Write SQL”™.Its dependency footprint is optimised for my own setups, and as such it makes use of text, vector and pg-transact.
This library aims to be thoroughly tested, by the means of Oleg Grenrus' cabal-docspec and more traditional tests for database roundtrips.
I aim to produce and maintain a decent documentation, therefore do not hesitate to raise an issue if you feel that something is badly explained and should be improved.
Safe SQL generation is a complex subject, and it is far from being the objective of this library. The main topic it addresses is listing the fields of a table, which is definitely something easier. This is why every level of this wrapper is fully exposed, so that you can drop down a level at your convience.
It is my personal belief, firmly rooted in experience, that we should not aim to produce statically-checked SQL and have it "verified" by the compiler. The techniques that would allow that in Haskell are still far from being optimised and ergonomic. As such, this library makes no effort to produce semantically valid SQL queries, because one would have to encode the semantics of SQL in the type system (or in a rule engine of some sort), and this is clearly not the kind of things I want to spend my youth on.
Each function is tested for its output with doctests, and the ones that cannot (due to database connections) are tested in the more traditional test-suite.
The conclusion is : Test your DB queries. Test the encoding/decoding. Make roundtrip tests for your data-structures.
I wish to thank
Haskell
95.2%
Nix
2.2%
Makefile
1.9%