The templatepg package

TemplatePG provides PostgreSQL access from Haskell via the
PostgreSQL protocol. It also provides a higher-level Template
Haskell interface. It eliminates a class of runtime errors by
checking queries against a PostgreSQL database at compile-time.
This also reduces boilerplate code for dealing with query
results, as the type and number of result columns are known at
compile-time.