@@ -28,67 +28,30 @@ import Data.Text.Lazy.Builder.Scientific (scientificBuilder)
2828import Data.Scientific (scientificBuilder )
2929#endif
3030
31- #if __GLASGOW_HASKELL__ >= 702
3231import System.IO.Unsafe (unsafeDupablePerformIO )
33- #elif __GLASGOW_HASKELL__ >= 611
34- import GHC.IO (unsafeDupablePerformIO )
35- #else
36- import GHC.IOBase (unsafeDupablePerformIO )
37- #endif
3832
3933import Data.Fixed (Pico )
40- #if MIN_VERSION_base(4,7,0)
4134import Data.Fixed (Fixed (MkFixed ))
42- #else
43- import Unsafe.Coerce (unsafeCoerce )
44- #endif
4535
46- -- | Like 'E.mask', but backported to base before version 4.3.0.
47- --
48- -- Note that the restore callback is monomorphic, unlike in 'E.mask'. This
49- -- could be fixed by changing the type signature, but it would require us to
50- -- enable the RankNTypes extension (since 'E.mask' has a rank-3 type). The
51- -- 'withTransactionMode' function calls the restore callback only once, so we
52- -- don't need that polymorphism.
36+ -- | Like 'E.mask', but with a monomorphic restore callback, unlike in
37+ -- 'E.mask'. This could be fixed by changing the type signature, but
38+ -- it would require us to enable the RankNTypes extension (since
39+ -- 'E.mask' has a rank-3 type). The 'withTransactionMode' function
40+ -- calls the restore callback only once, so we don't need that
41+ -- polymorphism.
5342mask :: ((IO a -> IO a ) -> IO b ) -> IO b
54- #if MIN_VERSION_base(4,3,0)
55- mask 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
43+ mask io = E. mask io
6144{-# INLINE mask #-}
6245
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-
7146toByteString :: Builder -> ByteString
7247#if MIN_VERSION_bytestring(0,10,0)
7348toByteString x = toStrict (toLazyByteString x)
7449#else
7550toByteString x = B. concat (toChunks (toLazyByteString x))
7651#endif
7752
78- #if MIN_VERSION_base(4,7,0)
79-
8053toPico :: Integer -> Pico
8154toPico = MkFixed
8255
8356fromPico :: Pico -> Integer
8457fromPico (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