git.iko.soy/typeable/postgresql-simple
on master help sign in
Use the new infix synonym for mappend (<>)

Define it in Compat to support base < 4.5 Also, tweak Compat's doc comment, as we no longer use regex (see a2a04b3d).

commite4f2e4aec45218fd5bbef3668a66b3c630925dc3 authorJoey Adams <joeyadams3.14159@gmail.com> dateSat 5 Jan 2013, 18:22 (14 years ago) parent9f69c5c
2 files changed+16−7
src/Database/PostgreSQL/Simple.hs+4−5 src/Database/PostgreSQL/Simple/Compat.hs+12−2
src/Database/PostgreSQL/Simple.hs+4−5
@@ -133,10 +133,10 @@ import Data.ByteString (ByteString)
133133import Data.Int (Int64)
134134import qualified Data.IntMap as IntMap
135135import Data.List (intersperse)
136−import Data.Monoid (mappend, mconcat)
136+import Data.Monoid (mconcat)
137137import Data.Typeable (Typeable)
138138import Database.PostgreSQL.Simple.BuiltinTypes ( oid2typname )
139−import Database.PostgreSQL.Simple.Compat ( mask )
139+import Database.PostgreSQL.Simple.Compat ( mask, (<>) )
140140import Database.PostgreSQL.Simple.FromField (ResultError(..))
141141import Database.PostgreSQL.Simple.FromRow (FromRow(..))
142142import Database.PostgreSQL.Simple.Ok
@@ -325,7 +325,7 @@ buildQuery conn q template xs = zipParams (split template) <$> mapM sub xs
325325 sub (Many ys) = mconcat <$> mapM sub ys
326326 split s = fromByteString h : if B.null t then [] else split (B.tail t)
327327 where (h,t) = B.break (=='?') s
328− zipParams (t:ts) (p:ps) = t `mappend` p `mappend` zipParams ts ps
328+ zipParams (t:ts) (p:ps) = t <> p <> zipParams ts ps
329329 zipParams [t] [] = t
330330 zipParams _ _ = fmtError (show (B.count '?' template) ++
331331 " '?' characters, but " ++
@@ -499,8 +499,7 @@ doFold FoldOptions{..} conn _template q a f = do
499499 where
500500 go = do
501501 -- FIXME: what about name clashes with already-declared cursors?
502− _ <- execute_ conn ("DECLARE fold NO SCROLL CURSOR FOR "
503− `mappend` q)
502+ _ <- execute_ conn ("DECLARE fold NO SCROLL CURSOR FOR " <> q)
504503 loop a `finally` execute_ conn "CLOSE fold"
505504
506505-- FIXME: choose the Automatic chunkSize more intelligently
src/Database/PostgreSQL/Simple/Compat.hs+12−2
@@ -1,11 +1,13 @@
11{-# LANGUAGE CPP #-}
2−-- | This is a module of its own, because it uses the CPP extension, which
3−-- doesn't play well with the regex string literal in Simple.hs .
2+-- | This is a module of its own, partly because it uses the CPP extension,
3+-- which doesn't play well with backslash-broken string literals.
44module Database.PostgreSQL.Simple.Compat
55 ( mask
6+ , (<>)
67 ) where
78
89import qualified Control.Exception as E
10+import Data.Monoid
911
1012-- | Like 'E.mask', but backported to base before version 4.3.0.
1113--
@@ -23,3 +25,11 @@ mask io = do
2325 E.block $ io $ \m -> if b then m else E.unblock m
2426#endif
2527{-# INLINE mask #-}
28+
29+#if !MIN_VERSION_base(4,5,0)
30+infixr 6 <>
31+
32+(<>) :: Monoid m => m -> m -> m
33+(<>) = mappend
34+{-# INLINE (<>) #-}
35+#endif