diff --git a/hasql.cabal b/hasql.cabal index 0de2dd1..7c030e4 100644 --- a/hasql.cabal +++ b/hasql.cabal @@ -88,6 +88,7 @@ library bytestring >= 0.10 && < 0.11, hashable >= 1.2 && < 1.3, -- control: + semigroups >= 0.18 && < 0.20, data-default-class >= 0.0.1 && < 0.1, profunctors >= 5.1 && < 6, contravariant-extras == 0.3.*, diff --git a/library/Hasql/Commands.hs b/library/Hasql/Commands.hs index b7469f7..2eee535 100644 --- a/library/Hasql/Commands.hs +++ b/library/Hasql/Commands.hs @@ -18,6 +18,8 @@ newtype Commands = Commands (DList BB.Builder) deriving (Monoid) +instance Semigroup Commands + asBytes :: Commands -> ByteString asBytes (Commands list) = BL.toStrict $ BB.toLazyByteString $ foldMap (<> BB.char7 ';') $ list diff --git a/library/Hasql/Encoders.hs b/library/Hasql/Encoders.hs index 853472d..8f277d8 100644 --- a/library/Hasql/Encoders.hs +++ b/library/Hasql/Encoders.hs @@ -106,7 +106,7 @@ import qualified Hasql.Prelude as Prelude -- newtype Params a = Params (Params.Params a) - deriving (Contravariant, Divisible, Monoid) + deriving (Contravariant, Divisible, Monoid, Semigroup) -- | -- Encode no parameters. diff --git a/library/Hasql/Encoders/Params.hs b/library/Hasql/Encoders/Params.hs index a9cdb9a..c421ee3 100644 --- a/library/Hasql/Encoders/Params.hs +++ b/library/Hasql/Encoders/Params.hs @@ -13,6 +13,8 @@ newtype Params a = Params (Op (DList (LibPQ.Oid, Bool -> Maybe ByteString)) a) deriving (Contravariant, Divisible, Monoid) +instance Semigroup (Params a) + run :: Params a -> a -> DList (LibPQ.Oid, Bool -> Maybe ByteString) run (Params (Op op)) params = {-# SCC "run" #-} diff --git a/library/Hasql/Prelude.hs b/library/Hasql/Prelude.hs index b3f8488..3dc0c7c 100644 --- a/library/Hasql/Prelude.hs +++ b/library/Hasql/Prelude.hs @@ -16,7 +16,7 @@ where -- base-prelude ------------------------- -import BasePrelude as Exports hiding (assert, left, right, isLeft, isRight, error) +import BasePrelude as Exports hiding (assert, left, right, isLeft, isRight, error, (<>), First(..), Last(..)) -- transformers ------------------------- @@ -53,6 +53,10 @@ import Contravariant.Extras as Exports import Control.Monad.Trans.Either as Exports import Data.Either.Combinators as Exports +-- semigroups +------------------------- +import Data.Semigroup as Exports + -- hashable ------------------------- import Data.Hashable as Exports (Hashable(..))