@@ -1,4 +1,4 @@
1−{-# LANGUAGE DeriveDataTypeable, DeriveFunctor, GeneralizedNewtypeDeriving #-}
1+{-# LANGUAGE CPP, DeriveDataTypeable, DeriveFunctor, GeneralizedNewtypeDeriving #-}
3------------------------------------------------------------------------------
3------------------------------------------------------------------------------
@@ -33,7 +33,9 @@ module Database.PostgreSQL.Simple.Types
33import Control.Arrow (first)
33import Control.Arrow (first)
34import Data.ByteString (ByteString)
34import Data.ByteString (ByteString)
35import Data.Hashable (Hashable(hashWithSalt))
35import Data.Hashable (Hashable(hashWithSalt))
36+import Data.Foldable (toList)
36import Data.Monoid (Monoid(..))
37import Data.Monoid (Monoid(..))
37import Data.String (IsString(..))
39import Data.String (IsString(..))
38import Data.Typeable (Typeable)
40import Data.Typeable (Typeable)
39import Data.ByteString.Builder ( stringUtf8 )
41import Data.ByteString.Builder ( stringUtf8 )
@@ -88,11 +90,16 @@ instance Read Query where
88instance IsString Query where
90instance IsString Query where
89 fromString = Query . toByteString . stringUtf8
91 fromString = Query . toByteString . stringUtf8
93+instance Semigroup Query where
94+ Query a <> Query b = Query (B.append a b)
96+ sconcat xs = Query (B.concat $ map fromQuery $ toList xs)
91instance Monoid Query where
98instance Monoid Query where
92 mempty = Query B.empty
99 mempty = Query B.empty
93− mappend (Query a) (Query b) = Query (B.append a b)
100+#if !(MIN_VERSION_base(4,11,0))
94− {-# INLINE mappend #-}
101+ mappend = (<>)
95− mconcat xs = Query (B.concat (map fromQuery xs))
102+#endif
97-- | Wrap a list of values for use in an @IN@ clause. Replaces a
104-- | Wrap a list of values for use in an @IN@ clause. Replaces a
98-- single \"@?@\" character with a parenthesized list of rendered
105-- single \"@?@\" character with a parenthesized list of rendered