on master help sign in
Merge
9931741Bryan O'Sullivan
Data/Text.hs−8
@@ -201,11 +201,7 @@ import Control.Exception (assert)
201#endif
201#endif
202import Data.Char (isSpace)
202import Data.Char (isSpace)
203import Data.Data (Data(gfoldl, toConstr, gunfold, dataTypeOf))
203import Data.Data (Data(gfoldl, toConstr, gunfold, dataTypeOf))
204−#if __GLASGOW_HASKELL__ >= 612
205import Data.Data (mkNoRepType)
204import Data.Data (mkNoRepType)
206−#else
207−import Data.Data (mkNorepType)
208−#endif
209import Control.Monad (foldM)
205import Control.Monad (foldM)
210import qualified Data.Text.Array as A
206import qualified Data.Text.Array as A
211import qualified Data.List as L
207import qualified Data.List as L
@@ -350,11 +346,7 @@ instance Data Text where
350 gfoldl f z txt = z pack `f` (unpack txt)
346 gfoldl f z txt = z pack `f` (unpack txt)
351 toConstr _ = P.error "Data.Text.Text.toConstr"
347 toConstr _ = P.error "Data.Text.Text.toConstr"
352 gunfold _ _ = P.error "Data.Text.Text.gunfold"
348 gunfold _ _ = P.error "Data.Text.Text.gunfold"
353−#if __GLASGOW_HASKELL__ >= 612
354 dataTypeOf _ = mkNoRepType "Data.Text.Text"
349 dataTypeOf _ = mkNoRepType "Data.Text.Text"
355−#else
356− dataTypeOf _ = mkNorepType "Data.Text.Text"
357−#endif
358
350
359-- | /O(n)/ Compare two 'Text' values lexicographically.
351-- | /O(n)/ Compare two 'Text' values lexicographically.
360compareText :: Text -> Text -> Ordering
352compareText :: Text -> Text -> Ordering
Data/Text/Encoding/Error.hs−4
@@ -39,11 +39,7 @@ module Data.Text.Encoding.Error
39 ) where
39 ) where
40
40
41import Control.DeepSeq (NFData (..))
41import Control.DeepSeq (NFData (..))
42−#if __GLASGOW_HASKELL__ >= 610
43import Control.Exception (Exception, throw)
42import Control.Exception (Exception, throw)
44−#else
45−import Control.Exception.Extensible (Exception, throw)
46−#endif
47import Data.Typeable (Typeable)
43import Data.Typeable (Typeable)
48import Data.Word (Word8)
44import Data.Word (Word8)
49import Numeric (showHex)
45import Numeric (showHex)
Data/Text/IO.hs−17
@@ -46,10 +46,6 @@ import Prelude hiding (appendFile, getContents, getLine, interact,
46 putStr, putStrLn, readFile, writeFile)
46 putStr, putStrLn, readFile, writeFile)
47import System.IO (Handle, IOMode(..), hPutChar, openFile, stdin, stdout,
47import System.IO (Handle, IOMode(..), hPutChar, openFile, stdin, stdout,
48 withFile)
48 withFile)
49−#if __GLASGOW_HASKELL__ <= 610
50−import qualified Data.ByteString.Char8 as B
51−import Data.Text.Encoding (decodeUtf8, encodeUtf8)
52−#else
53import qualified Control.Exception as E
49import qualified Control.Exception as E
54import Control.Monad (liftM2, when)
50import Control.Monad (liftM2, when)
55import Data.IORef (readIORef, writeIORef)
51import Data.IORef (readIORef, writeIORef)
@@ -68,7 +64,6 @@ import GHC.IO.Handle.Types (BufferList(..), BufferMode(..), Handle__(..),
68 HandleType(..), Newline(..))
64 HandleType(..), Newline(..))
69import System.IO (hGetBuffering, hFileSize, hSetBuffering, hTell)
65import System.IO (hGetBuffering, hFileSize, hSetBuffering, hTell)
70import System.IO.Error (isEOFError)
66import System.IO.Error (isEOFError)
71−#endif
72
67
73-- $performance
68-- $performance
74-- #performance#
69-- #performance#
@@ -137,9 +132,6 @@ hGetChunk h = wantReadableHandle "hGetChunk" h readSingleChunk
137-- result to construct its result. For files more than a half of
132-- result to construct its result. For files more than a half of
138-- available RAM in size, this may result in memory exhaustion.
133-- available RAM in size, this may result in memory exhaustion.
139hGetContents :: Handle -> IO Text
134hGetContents :: Handle -> IO Text
140−#if __GLASGOW_HASKELL__ <= 610
141−hGetContents = fmap decodeUtf8 . B.hGetContents
142−#else
143hGetContents h = do
135hGetContents h = do
144 chooseGoodBuffering h
136 chooseGoodBuffering h
145 wantReadableHandle "hGetContents" h readAll
137 wantReadableHandle "hGetContents" h readAll
@@ -171,21 +163,13 @@ chooseGoodBuffering h = do
171 else E.throwIO e
163 else E.throwIO e
172 when (d > 0) . hSetBuffering h . BlockBuffering . Just . fromIntegral $ d
164 when (d > 0) . hSetBuffering h . BlockBuffering . Just . fromIntegral $ d
173 _ -> return ()
165 _ -> return ()
174−#endif
175
166
176-- | Read a single line from a handle.
167-- | Read a single line from a handle.
177hGetLine :: Handle -> IO Text
168hGetLine :: Handle -> IO Text
178−#if __GLASGOW_HASKELL__ <= 610
179−hGetLine = fmap decodeUtf8 . B.hGetLine
180−#else
181hGetLine = hGetLineWith T.concat
169hGetLine = hGetLineWith T.concat
182−#endif
183
170
184-- | Write a string to a handle.
171-- | Write a string to a handle.
185hPutStr :: Handle -> Text -> IO ()
172hPutStr :: Handle -> Text -> IO ()
186−#if __GLASGOW_HASKELL__ <= 610
187−hPutStr h = B.hPutStr h . encodeUtf8
188−#else
189-- This function is lifted almost verbatim from GHC.IO.Handle.Text.
173-- This function is lifted almost verbatim from GHC.IO.Handle.Text.
190hPutStr h t = do
174hPutStr h t = do
191 (buffer_mode, nl) <-
175 (buffer_mode, nl) <-
@@ -295,7 +279,6 @@ commitBuffer hdl !raw !sz !count flush release =
295 wantWritableHandle "commitAndReleaseBuffer" hdl $
279 wantWritableHandle "commitAndReleaseBuffer" hdl $
296 commitBuffer' raw sz count flush release
280 commitBuffer' raw sz count flush release
297{-# INLINE commitBuffer #-}
281{-# INLINE commitBuffer #-}
298−#endif
299
282
300-- | Write a string to a handle, followed by a newline.
283-- | Write a string to a handle, followed by a newline.
301hPutStrLn :: Handle -> Text -> IO ()
284hPutStrLn :: Handle -> Text -> IO ()
Data/Text/IO/Internal.hs−4
@@ -12,13 +12,10 @@
12
12
13module Data.Text.IO.Internal
13module Data.Text.IO.Internal
14 (
14 (
15−#if __GLASGOW_HASKELL__ >= 612
16 hGetLineWith
15 hGetLineWith
17 , readChunk
16 , readChunk
18−#endif
19 ) where
17 ) where
20
18
21−#if __GLASGOW_HASKELL__ >= 612
22import qualified Control.Exception as E
19import qualified Control.Exception as E
23import Data.IORef (readIORef, writeIORef)
20import Data.IORef (readIORef, writeIORef)
24import Data.Text (Text)
21import Data.Text (Text)
@@ -163,4 +160,3 @@ readChunk hh@Handle__{..} buf = do
163
160
164sizeError :: String -> a
161sizeError :: String -> a
165sizeError loc = error $ "Data.Text.IO." ++ loc ++ ": bad internal buffer size"
162sizeError loc = error $ "Data.Text.IO." ++ loc ++ ": bad internal buffer size"
166−#endif
Data/Text/Lazy.hs−8
@@ -202,11 +202,7 @@ import Data.Int (Int64)
202import qualified Data.List as L
202import qualified Data.List as L
203import Data.Char (isSpace)
203import Data.Char (isSpace)
204import Data.Data (Data(gfoldl, toConstr, gunfold, dataTypeOf))
204import Data.Data (Data(gfoldl, toConstr, gunfold, dataTypeOf))
205−#if __GLASGOW_HASKELL__ >= 612
206import Data.Data (mkNoRepType)
205import Data.Data (mkNoRepType)
207−#else
208−import Data.Data (mkNorepType)
209−#endif
210import Data.Monoid (Monoid(..))
206import Data.Monoid (Monoid(..))
211import Data.String (IsString(..))
207import Data.String (IsString(..))
212import qualified Data.Text as T
208import qualified Data.Text as T
@@ -341,11 +337,7 @@ instance Data Text where
341 gfoldl f z txt = z pack `f` (unpack txt)
337 gfoldl f z txt = z pack `f` (unpack txt)
342 toConstr _ = error "Data.Text.Lazy.Text.toConstr"
338 toConstr _ = error "Data.Text.Lazy.Text.toConstr"
343 gunfold _ _ = error "Data.Text.Lazy.Text.gunfold"
339 gunfold _ _ = error "Data.Text.Lazy.Text.gunfold"
344−#if __GLASGOW_HASKELL__ >= 612
345 dataTypeOf _ = mkNoRepType "Data.Text.Lazy.Text"
340 dataTypeOf _ = mkNoRepType "Data.Text.Lazy.Text"
346−#else
347− dataTypeOf _ = mkNorepType "Data.Text.Lazy.Text"
348−#endif
349
341
350-- | /O(n)/ Convert a 'String' into a 'Text'.
342-- | /O(n)/ Convert a 'String' into a 'Text'.
351--
343--
Data/Text/Lazy/Builder/Int.hs+1−3
@@ -33,9 +33,7 @@ import GHC.Types (Int(..))
33import Control.Monad.ST
33import Control.Monad.ST
34
34
35#ifdef __GLASGOW_HASKELL__
35#ifdef __GLASGOW_HASKELL__
36−# if __GLASGOW_HASKELL__ < 611
37−import GHC.Integer.Internals
38−# elif defined(INTEGER_GMP)
36+# if defined(INTEGER_GMP)
39import GHC.Integer.GMP.Internals
37import GHC.Integer.GMP.Internals
40# elif defined(INTEGER_SIMPLE)
38# elif defined(INTEGER_SIMPLE)
41import GHC.Integer
39import GHC.Integer
Data/Text/Lazy/IO.hs−14
@@ -47,11 +47,6 @@ import System.IO (Handle, IOMode(..), hPutChar, openFile, stdin, stdout,
47 withFile)
47 withFile)
48import qualified Data.Text.IO as T
48import qualified Data.Text.IO as T
49import qualified Data.Text.Lazy as L
49import qualified Data.Text.Lazy as L
50−#if __GLASGOW_HASKELL__ <= 610
51−import Data.Text.Lazy.Encoding (decodeUtf8)
52−import qualified Data.ByteString.Char8 as S8
53−import qualified Data.ByteString.Lazy.Char8 as L8
54−#else
55import qualified Control.Exception as E
50import qualified Control.Exception as E
56import Control.Monad (when)
51import Control.Monad (when)
57import Data.IORef (readIORef)
52import Data.IORef (readIORef)
@@ -65,7 +60,6 @@ import GHC.IO.Handle.Types (Handle__(..), HandleType(..))
65import System.IO (BufferMode(..), hGetBuffering, hSetBuffering)
60import System.IO (BufferMode(..), hGetBuffering, hSetBuffering)
66import System.IO.Error (isEOFError)
61import System.IO.Error (isEOFError)
67import System.IO.Unsafe (unsafeInterleaveIO)
62import System.IO.Unsafe (unsafeInterleaveIO)
68−#endif
69
63
70-- $performance
64-- $performance
71--
65--
@@ -99,9 +93,6 @@ appendFile p = withFile p AppendMode . flip hPutStr
99-- | Lazily read the remaining contents of a 'Handle'. The 'Handle'
93-- | Lazily read the remaining contents of a 'Handle'. The 'Handle'
100-- will be closed after the read completes, or on error.
94-- will be closed after the read completes, or on error.
101hGetContents :: Handle -> IO Text
95hGetContents :: Handle -> IO Text
102−#if __GLASGOW_HASKELL__ <= 610
103−hGetContents = fmap decodeUtf8 . L8.hGetContents
104−#else
105hGetContents h = do
96hGetContents h = do
106 chooseGoodBuffering h
97 chooseGoodBuffering h
107 wantReadableHandle "hGetContents" h $ \hh -> do
98 wantReadableHandle "hGetContents" h $ \hh -> do
@@ -138,15 +129,10 @@ lazyReadBuffered h hh@Handle__{..} = do
138 then (hh', empty)
129 then (hh', empty)
139 else (hh', L.singleton '\r')
130 else (hh', L.singleton '\r')
140 else E.throwIO (augmentIOError e "hGetContents" h)
131 else E.throwIO (augmentIOError e "hGetContents" h)
141−#endif
142
132
143-- | Read a single line from a handle.
133-- | Read a single line from a handle.
144hGetLine :: Handle -> IO Text
134hGetLine :: Handle -> IO Text
145−#if __GLASGOW_HASKELL__ <= 610
146−hGetLine = fmap (decodeUtf8 . L8.fromChunks . (:[])) . S8.hGetLine
147−#else
148hGetLine = hGetLineWith L.fromChunks
135hGetLine = hGetLineWith L.fromChunks
149−#endif
150
136
151-- | Write a string to a handle.
137-- | Write a string to a handle.
152hPutStr :: Handle -> Text -> IO ()
138hPutStr :: Handle -> Text -> IO ()
Data/Text/Unsafe.hs+1−5
@@ -34,11 +34,7 @@ import Data.Text.Internal (Text(..))
34import Data.Text.Unsafe.Base (inlineInterleaveST, inlinePerformIO)
34import Data.Text.Unsafe.Base (inlineInterleaveST, inlinePerformIO)
35import Data.Text.UnsafeChar (unsafeChr)
35import Data.Text.UnsafeChar (unsafeChr)
36import qualified Data.Text.Array as A
36import qualified Data.Text.Array as A
37−#if __GLASGOW_HASKELL__ >= 611
38import GHC.IO (unsafeDupablePerformIO)
37import GHC.IO (unsafeDupablePerformIO)
39−#else
40−import GHC.IOBase (unsafeDupablePerformIO)
41−#endif
42
38
43-- | /O(1)/ A variant of 'head' for non-empty 'Text'. 'unsafeHead'
39-- | /O(1)/ A variant of 'head' for non-empty 'Text'. 'unsafeHead'
44-- omits the check for the empty case, so there is an obligation on
40-- omits the check for the empty case, so there is an obligation on
@@ -51,7 +47,7 @@ unsafeHead (Text arr off _len)
51 n = A.unsafeIndex arr (off+1)
47 n = A.unsafeIndex arr (off+1)
52{-# INLINE unsafeHead #-}
48{-# INLINE unsafeHead #-}
53
49
54−-- | /O(1)/ A variant of 'tail' for non-empty 'Text'. 'unsafeHead'
50+-- | /O(1)/ A variant of 'tail' for non-empty 'Text'. 'unsafeTail'
55-- omits the check for the empty case, so there is an obligation on
51-- omits the check for the empty case, so there is an obligation on
56-- the programmer to provide a proof that the 'Text' is non-empty.
52-- the programmer to provide a proof that the 'Text' is non-empty.
57unsafeTail :: Text -> Text
53unsafeTail :: Text -> Text
Data/Text/Unsafe/Base.hs−4
@@ -18,11 +18,7 @@ module Data.Text.Unsafe.Base
18
18
19import GHC.ST (ST(..))
19import GHC.ST (ST(..))
20#if defined(__GLASGOW_HASKELL__)
20#if defined(__GLASGOW_HASKELL__)
21−# if __GLASGOW_HASKELL__ >= 611
22import GHC.IO (IO(IO))
21import GHC.IO (IO(IO))
23−# else
24−import GHC.IOBase (IO(IO))
25−# endif
26import GHC.Base (realWorld#)
22import GHC.Base (realWorld#)
27#endif
23#endif
28
24
text.cabal+18−34
@@ -125,36 +125,25 @@ library
125 Data.Text.Util
125 Data.Text.Util
126
126
127 build-depends:
127 build-depends:
128− array,
128+ array >= 0.3,
129− base < 5,
129+ base >= 4.2 && < 5,
130− bytestring >= 0.9
130+ bytestring >= 0.9,
131− if impl(ghc >= 6.10)
132− build-depends:
133− ghc-prim, base >= 4, deepseq >= 1.1.0.0
131+ deepseq >= 1.1.0.0,
132+ ghc-prim >= 0.2
133+
134− cpp-options: -DHAVE_DEEPSEQ
134+ cpp-options: -DHAVE_DEEPSEQ
135− else
136− build-depends: extensible-exceptions
137− extensions: ScopedTypeVariables
138−
139− ghc-options: -Wall -funbox-strict-fields -O2
135+ ghc-options: -Wall -fwarn-tabs -funbox-strict-fields -O2
140− if impl(ghc >= 6.8)
141− ghc-options: -fwarn-tabs
142 if flag(developer)
136 if flag(developer)
143 ghc-prof-options: -auto-all
137 ghc-prof-options: -auto-all
144 ghc-options: -Werror
138 ghc-options: -Werror
145 cpp-options: -DASSERTS
139 cpp-options: -DASSERTS
146
140
147− if impl(ghc >= 6.11)
148− if flag(integer-simple)
141+ if flag(integer-simple)
149− cpp-options: -DINTEGER_SIMPLE
142+ cpp-options: -DINTEGER_SIMPLE
150− build-depends: integer-simple >= 0.1 && < 0.5
143+ build-depends: integer-simple >= 0.1 && < 0.5
151− else
144+ else
152− cpp-options: -DINTEGER_GMP
153− build-depends: integer-gmp >= 0.2
154−
155− if impl(ghc >= 6.9) && impl(ghc < 6.11)
156 cpp-options: -DINTEGER_GMP
145 cpp-options: -DINTEGER_GMP
157− build-depends: integer >= 0.1 && < 0.2
146+ build-depends: integer-gmp >= 0.2
158
147
159test-suite tests
148test-suite tests
160 type: exitcode-stdio-1.0
149 type: exitcode-stdio-1.0
@@ -183,17 +172,12 @@ test-suite tests
183 test-framework-hunit >= 0.2,
172 test-framework-hunit >= 0.2,
184 test-framework-quickcheck2 >= 0.2
173 test-framework-quickcheck2 >= 0.2
185
174
186− if impl(ghc >= 6.11)
187− if flag(integer-simple)
175+ if flag(integer-simple)
188− cpp-options: -DINTEGER_SIMPLE
176+ cpp-options: -DINTEGER_SIMPLE
189− build-depends: integer-simple >= 0.1 && < 0.5
177+ build-depends: integer-simple >= 0.1 && < 0.5
190− else
178+ else
191− cpp-options: -DINTEGER_GMP
192− build-depends: integer-gmp >= 0.2
193−
194− if impl(ghc >= 6.9) && impl(ghc < 6.11)
195 cpp-options: -DINTEGER_GMP
179 cpp-options: -DINTEGER_GMP
196− build-depends: integer >= 0.1 && < 0.2
180+ build-depends: integer-gmp >= 0.2
197
181
198source-repository head
182source-repository head
199 type: git
183 type: git