From bc9c1690198ee8a3e7b17a9f70c155413a100ecb Mon Sep 17 00:00:00 2001 From: Matt Parsons Date: Thu, 26 Dec 2024 16:04:05 -0700 Subject: [PATCH] Add Functor and Bifunctor instance for pairs (#416) * Add Functor and Bifunctor instance for pairs * Add since * changelog entry --- changelog.md | 2 ++ src/Database/Esqueleto/Internal/Internal.hs | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index fe9ae1d0e..12f1fb93c 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,8 @@ - @parsonsmatt - [#414](https://github.com/bitemyapp/esqueleto/pull/414) - Derive `Foldable` and `Traversable` for `Value`. + - [#416](https://github.com/bitemyapp/esqueleto/pull/416) + - Derive `Functor` and `Bifunctor` for `:&` - @matthewbauer - [#341](https://github.com/bitemyapp/esqueleto/pull/341/) - Add functions for `NULLS FIRST` and `NULLS LAST` in the Postgresql diff --git a/src/Database/Esqueleto/Internal/Internal.hs b/src/Database/Esqueleto/Internal/Internal.hs index d919ade85..bda9ff8c6 100644 --- a/src/Database/Esqueleto/Internal/Internal.hs +++ b/src/Database/Esqueleto/Internal/Internal.hs @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeApplications #-} @@ -54,6 +55,7 @@ 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 qualified Data.ByteString as B +import Data.Bifunctor (Bifunctor, bimap) import Data.Coerce (coerce) import qualified Data.Conduit as C import qualified Data.Conduit.List as CL @@ -1551,9 +1553,15 @@ data Insertion a -- See the examples at the beginning of this module to see how this -- operator is used in 'JOIN' operations. data (:&) a b = a :& b - deriving (Eq, Show) + deriving (Eq, Show, Functor) infixl 2 :& +-- | +-- +-- @since 3.5.14.0 +instance Bifunctor (:&) where + bimap f g (a :& b) = f a :& g b + -- | Different kinds of locking clauses supported by 'locking'. -- -- Note that each RDBMS has different locking support. The