From b4f302cd63b88065fd62187b6c2ceb3f8d4ac869 Mon Sep 17 00:00:00 2001 From: Daan Rijks Date: Tue, 14 May 2024 16:24:02 +0200 Subject: [PATCH] Add Functor and Bifunctor instances for (:&) --- changelog.md | 6 ++++++ esqueleto.cabal | 2 +- src/Database/Esqueleto/Internal/Internal.hs | 9 +++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 1cf09376b..dc282dbe3 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,9 @@ +3.5.11.3 +======== +- @isomorpheme + - [#393](https://github.com/bitemyapp/esqueleto/pull/393) + - Add Functor and Bifunctor instances for `(:&)` + 3.5.11.2 ======== - @arguri diff --git a/esqueleto.cabal b/esqueleto.cabal index 44ff6fef3..e8e971068 100644 --- a/esqueleto.cabal +++ b/esqueleto.cabal @@ -2,7 +2,7 @@ cabal-version: 1.12 name: esqueleto -version: 3.5.11.2 +version: 3.5.11.3 synopsis: Type-safe EDSL for SQL queries on persistent backends. description: @esqueleto@ is a bare bones, type-safe EDSL for SQL queries that works with unmodified @persistent@ SQL backends. Its language closely resembles SQL, so you don't have to learn new concepts, just new syntax, and it's fairly easy to predict the generated SQL and optimize it for your backend. Most kinds of errors committed when writing SQL are caught as compile-time errors---although it is possible to write type-checked @esqueleto@ queries that fail at runtime. . diff --git a/src/Database/Esqueleto/Internal/Internal.hs b/src/Database/Esqueleto/Internal/Internal.hs index e46516e30..1c9fd33aa 100644 --- a/src/Database/Esqueleto/Internal/Internal.hs +++ b/src/Database/Esqueleto/Internal/Internal.hs @@ -52,6 +52,7 @@ import Data.Semigroup import qualified Control.Monad.Trans.Reader as R import qualified Control.Monad.Trans.State as S import qualified Control.Monad.Trans.Writer as W +import Data.Bifunctor (Bifunctor(bimap, second)) import qualified Data.ByteString as B import Data.Coerce (coerce) import qualified Data.Conduit as C @@ -1442,6 +1443,14 @@ data (:&) a b = a :& b deriving (Eq, Show) infixl 2 :& +-- | @since 3.5.11.3 +instance Functor ((:&) a) where + fmap = second + +-- | @since 3.5.11.3 +instance Bifunctor (:&) where + bimap f g (x :& y) = f x :& g y + -- | Different kinds of locking clauses supported by 'locking'. -- -- Note that each RDBMS has different locking support. The