I'd like to start a discussion about ${subj}
The fact that functions like query from postgresql-simple operate in IO monad, whereas the functions in this library use mtl's MonadError (e.g. queryNamed) which makes it a bit harder to handle SqlErrors (thrown by postgresql-simple via throwIO) when using wrappers from this library.
I recently used MonadBaseControl + lifted-base to be able to get access to SqlError thrown by a query and rethrow it in our application monad which also uses MonadError.
Would it be a good idea to take advantage of the fact that potgresql-functions run in IO
and modify the existing PgNamedError by adding new constructor like this?
data PgNameError =
...
SqlError Database.PostgreSQL.Simple.SqlError
... and then wrapping calls to postgresql-simple query functions in some exception catching code and rethrowing them inside MonadError?
Advantage: In that case we could work with SqlErrors directly via our App's MonadError instance without resorting to its MonadBaseControl IO instance