esqueleto-compat: Compatibility operators for Persistent and Esqueleto

[ bsd3, data, library ] [ Propose Tags ]


Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS]
Change log
Dependencies base (>=4.13 && <5), conduit, esqueleto (<4), persistent, resourcet, transformers [details]
License BSD-3-Clause
Copyright 2023 Matt Parsons
Author Matt Parsons
Revised Revision 2 made by parsonsmatt at 2024-05-02T16:39:05Z
Category Data
Home page
Bug tracker
Source repo head: git clone
Uploaded by parsonsmatt at 2023-10-20T16:22:39Z
Distributions NixOS:
Downloads 42 total (6 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-10-20 [all 1 reports]

Readme for esqueleto-compat-

[back to package description]


This library aims to provide compatibility operators that can allow esqueleto and persistent to be imported together.

Operators like ==. and >=. are defined as class members, and you can use them in the same module. Functions like update that are shared in both libraries are given an E suffix for the esqueleto version. And functions for operating on SqlExpr are given an _ suffix when the name would otherwise be a conflict.


import Database.Esqueleto.Compat

foo :: MonadIO m => TableId -> SqlPersistT m ()
foo tableKey = do
    -- Esqueleto:
    updateE $ \table -> do
        set [table ^. TableField =. val "Hello"] table
        where_ $ table ^. TableId ==. val tableKey

    -- Persistent
    update tableKey [TableField =. "Goodbye"]

    -- Esqueleto:
    select $ do
        pure $ exists_ $ do
            t <- from $ table @Table
            where_ $ t ^. TableField ==. val "Hello"

    -- Persistent
    exists [TableField ==. val "Hello"]