persistent-sql-lifted: Monad classes for running queries with Persistent and Esqueleto

[ database, library, mit ] [ Propose Tags ] [ Report a vulnerability ]

This package introduces two classes: MonadSqlBackend for monadic contexts in which a SqlBackend is available, and MonadSqlTx for contexts in which we can execute a SQL transaction.

Additionally, this package provides variants of query-running utilities from Persistent and Esqueleto which are concretized to use SqlBackend, generalized to a MonadSqlBackend m constraint rather than "ReaderT backend", and wrapped in checkpointCallStack so that exceptions will include call stacks.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.1.0, 0.2.0.0, 0.3.0.0, 0.4.0.0, 0.4.1.0, 0.4.2.0, 0.4.3.0, 0.4.3.1
Change log CHANGELOG.md
Dependencies annotated-exception (>=0.2.0.4), base (>=4.16.4.0 && <5), containers (>=0.6.5.1), esqueleto (>=3.6.0.0), mtl (>=2.2.2), persistent (>=2.14.5.0), random (>=1.2.1.1), text (>=1.2.5.0), unliftio-core (>=0.2.1.0), vector (>=0.12.3.1) [details]
License MIT
Author
Maintainer Freckle Education
Category Database
Home page https://github.com/freckle/persistent-sql-lifted#readme
Bug tracker https://github.com/freckle/persistent-sql-lifted/issues
Source repo head: git clone https://github.com/freckle/persistent-sql-lifted
Uploaded by PatrickBrisbin at 2025-03-28T20:41:03Z
Distributions NixOS:0.1.0.0
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 141 total (20 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2025-03-28 [all 1 reports]

Readme for persistent-sql-lifted-0.4.2.0

[back to package description]

persistent-sql-lifted

This package introduces two classes:

  • MonadSqlBackend m, for monadic contexts m in which a SqlBackend is available

  • MonadSqlBackend db m, for monadic contexts m in which we can execute a SQL transaction of type db a and get a result m a. (The type db should have an instance of MonadSqlBackend.)

Additionally, this package provides variants of query-running utilities from persistent and esqueleto which are

  1. Concretized to use SqlBackend;
  2. Generalized to a MonadSqlBackend m constraint rather than ReaderT backend m;
  3. Wrapped in checkpointCallStack so that exceptions will include call stacks.

How to migrate from vanilla persistent/esqueleto:

  • Instead of SqlPersistT, use a MonadSqlBackend constraint.
  • Define an instance of MonadSqlTx for your application Monad that specifies how your application runs database transactions, e.g. by running runSqlPool.
  • Instead of calling runSqlPool directly from the rest of your application code, use the runSqlTx method from the MonadSqlTx class.

For constructing SQL expressions, you may which to import the utilities from Database.Persist.Sql.Lifted.Expression et al rather than getting them from Esqueleto. This allows you to import the specific bits you need piecemeal and without having to hide the unlifted versions of query-running functions that this package replaces. Moreover, this package contains some additional utilities.