From 4c36f3c5519ce8f4c4c4884d1b350f74cd038115 Mon Sep 17 00:00:00 2001 From: parsonsmatt Date: Thu, 26 Dec 2024 15:54:45 -0700 Subject: [PATCH 1/3] Add Functor and Bifunctor instance for pairs --- src/Database/Esqueleto/Internal/Internal.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Database/Esqueleto/Internal/Internal.hs b/src/Database/Esqueleto/Internal/Internal.hs index 1982a10e6..f6c11b622 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 #-} @@ -53,6 +54,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 @@ -1553,9 +1555,12 @@ 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 :& +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 From 4202d51104607cff4060ae375feef23d75a9cbb2 Mon Sep 17 00:00:00 2001 From: parsonsmatt Date: Thu, 26 Dec 2024 15:56:41 -0700 Subject: [PATCH 2/3] Add since --- src/Database/Esqueleto/Internal/Internal.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Database/Esqueleto/Internal/Internal.hs b/src/Database/Esqueleto/Internal/Internal.hs index f6c11b622..6d6dac339 100644 --- a/src/Database/Esqueleto/Internal/Internal.hs +++ b/src/Database/Esqueleto/Internal/Internal.hs @@ -1558,6 +1558,9 @@ data (:&) a b = a :& b deriving (Eq, Show, Functor) infixl 2 :& +-- | +-- +-- @since 3.5.14.0 instance Bifunctor (:&) where bimap f g (a :& b) = f a :& g b From 36a598804192473c18f9dacfd3f100136be10567 Mon Sep 17 00:00:00 2001 From: parsonsmatt Date: Thu, 26 Dec 2024 15:58:20 -0700 Subject: [PATCH 3/3] changelog entry --- changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog.md b/changelog.md index dea9ace02..98e369e57 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 `:&` 3.5.13.2 ========