@@ -1,4 +1,4 @@
1−{-# LANGUAGE DeriveDataTypeable, DeriveFunctor, GeneralizedNewtypeDeriving #-}
1+{-# LANGUAGE CPP, DeriveDataTypeable, DeriveFunctor, GeneralizedNewtypeDeriving #-}
22
33------------------------------------------------------------------------------
44-- |
@@ -33,7 +33,9 @@ module Database.PostgreSQL.Simple.Types
3333import Control.Arrow (first)
3434import Data.ByteString (ByteString)
3535import Data.Hashable (Hashable(hashWithSalt))
36+import Data.Foldable (toList)
3637import Data.Monoid (Monoid(..))
38+import Data.Semigroup
3739import Data.String (IsString(..))
3840import Data.Typeable (Typeable)
3941import Data.ByteString.Builder ( stringUtf8 )
@@ -88,11 +90,16 @@ instance Read Query where
8890instance IsString Query where
8991 fromString = Query . toByteString . stringUtf8
9092
93+instance Semigroup Query where
94+ Query a <> Query b = Query (B.append a b)
95+ {-# INLINE (<>) #-}
96+ sconcat xs = Query (B.concat $ map fromQuery $ toList xs)
97+
9198instance Monoid Query where
9299 mempty = Query B.empty
93− mappend (Query a) (Query b) = Query (B.append a b)
94− {-# INLINE mappend #-}
95− mconcat xs = Query (B.concat (map fromQuery xs))
100+#if !(MIN_VERSION_base(4,11,0))
101+ mappend = (<>)
102+#endif
96103
97104-- | Wrap a list of values for use in an @IN@ clause. Replaces a
98105-- single \"@?@\" character with a parenthesized list of rendered