Skip to content

Commit

Permalink
Add Functor and Bifunctor instances for (:&)
Browse files Browse the repository at this point in the history
  • Loading branch information
isomorpheme committed May 16, 2024
1 parent 30a5e80 commit b4f302c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion esqueleto.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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.
.
Expand Down
9 changes: 9 additions & 0 deletions src/Database/Esqueleto/Internal/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b4f302c

Please sign in to comment.