@@ -12,36 +12,13 @@ module Database.PostgreSQL.Simple.Compat
1212 ) where
1313
1414import qualified Control.Exception as E
15- import Data.Monoid
1615import Data.ByteString (ByteString )
17- #if MIN_VERSION_bytestring(0,10,0)
1816import Data.ByteString.Lazy (toStrict )
19- #else
20- import qualified Data.ByteString as B
21- import Data.ByteString.Lazy (toChunks )
22- #endif
2317import Data.ByteString.Builder (Builder , toLazyByteString )
24-
25- #if MIN_VERSION_scientific(0,3,0)
2618import Data.Text.Lazy.Builder.Scientific (scientificBuilder )
27- #else
28- import Data.Scientific (scientificBuilder )
29- #endif
30-
31- #if __GLASGOW_HASKELL__ >= 702
3219import System.IO.Unsafe (unsafeDupablePerformIO )
33- #elif __GLASGOW_HASKELL__ >= 611
34- import GHC.IO (unsafeDupablePerformIO )
35- #else
36- import GHC.IOBase (unsafeDupablePerformIO )
37- #endif
38-
3920import Data.Fixed (Pico )
40- #if MIN_VERSION_base(4,7,0)
4121import Data.Fixed (Fixed (MkFixed ))
42- #else
43- import Unsafe.Coerce (unsafeCoerce )
44- #endif
4522
4623-- | Like 'E.mask', but backported to base before version 4.3.0.
4724--
@@ -51,44 +28,14 @@ import Unsafe.Coerce (unsafeCoerce)
5128-- 'withTransactionMode' function calls the restore callback only once, so we
5229-- don't need that polymorphism.
5330mask :: ((IO a -> IO a ) -> IO b ) -> IO b
54- #if MIN_VERSION_base(4,3,0)
5531mask io = E. mask $ \ restore -> io restore
56- #else
57- mask io = do
58- b <- E. blocked
59- E. block $ io $ \ m -> if b then m else E. unblock m
60- #endif
6132{-# INLINE mask #-}
6233
63- #if !MIN_VERSION_base(4,5,0)
64- infixr 6 <>
65-
66- (<>) :: Monoid m => m -> m -> m
67- (<>) = mappend
68- {-# INLINE (<>) #-}
69- #endif
70-
7134toByteString :: Builder -> ByteString
72- #if MIN_VERSION_bytestring(0,10,0)
7335toByteString x = toStrict (toLazyByteString x)
74- #else
75- toByteString x = B. concat (toChunks (toLazyByteString x))
76- #endif
77-
78- #if MIN_VERSION_base(4,7,0)
7936
8037toPico :: Integer -> Pico
8138toPico = MkFixed
8239
8340fromPico :: Pico -> Integer
8441fromPico (MkFixed i) = i
85-
86- #else
87-
88- toPico :: Integer -> Pico
89- toPico = unsafeCoerce
90-
91- fromPico :: Pico -> Integer
92- fromPico = unsafeCoerce
93-
94- #endif
0 commit comments