Skip to content

Commit

Permalink
Add Functor and Bifunctor instance for pairs (#416)
Browse files Browse the repository at this point in the history
* Add Functor and Bifunctor instance for pairs

* Add since

* changelog entry
  • Loading branch information
parsonsmatt authored Dec 26, 2024
1 parent 28c8130 commit bc9c169
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion src/Database/Esqueleto/Internal/Internal.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeApplications #-}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bc9c169

Please sign in to comment.