on master help sign in
Merge
commit9931741f3d63bce19b66dfd0cf6b28206a49596c authorBryan O'Sullivan <bos@serpentine.com> dateWed 6 Nov 2013, 15:40 (13 years ago) parent77825a2e85fa59
10 files changed+20−101
Data/Text.hs−8 Data/Text/Encoding/Error.hs−4 Data/Text/IO.hs−17 Data/Text/IO/Internal.hs−4 Data/Text/Lazy.hs−8 Data/Text/Lazy/Builder/Int.hs+1−3 Data/Text/Lazy/IO.hs−14 Data/Text/Unsafe.hs+1−5 Data/Text/Unsafe/Base.hs−4 text.cabal+18−34
Data/Text.hs−8
@@ -201,11 +201,7 @@ import Control.Exception (assert)
201201#endif
202202import Data.Char (isSpace)
203203import Data.Data (Data(gfoldl, toConstr, gunfold, dataTypeOf))
204−#if __GLASGOW_HASKELL__ >= 612
205204import Data.Data (mkNoRepType)
206−#else
207−import Data.Data (mkNorepType)
208−#endif
209205import Control.Monad (foldM)
210206import qualified Data.Text.Array as A
211207import qualified Data.List as L
@@ -350,11 +346,7 @@ instance Data Text where
350346 gfoldl f z txt = z pack `f` (unpack txt)
351347 toConstr _ = P.error "Data.Text.Text.toConstr"
352348 gunfold _ _ = P.error "Data.Text.Text.gunfold"
353−#if __GLASGOW_HASKELL__ >= 612
354349 dataTypeOf _ = mkNoRepType "Data.Text.Text"
355−#else
356− dataTypeOf _ = mkNorepType "Data.Text.Text"
357−#endif
358350
359351-- | /O(n)/ Compare two 'Text' values lexicographically.
360352compareText :: Text -> Text -> Ordering
Data/Text/Encoding/Error.hs−4
@@ -39,11 +39,7 @@ module Data.Text.Encoding.Error
3939 ) where
4040
4141import Control.DeepSeq (NFData (..))
42−#if __GLASGOW_HASKELL__ >= 610
4342import Control.Exception (Exception, throw)
44−#else
45−import Control.Exception.Extensible (Exception, throw)
46−#endif
4743import Data.Typeable (Typeable)
4844import Data.Word (Word8)
4945import Numeric (showHex)
Data/Text/IO.hs−17
@@ -46,10 +46,6 @@ import Prelude hiding (appendFile, getContents, getLine, interact,
4646 putStr, putStrLn, readFile, writeFile)
4747import System.IO (Handle, IOMode(..), hPutChar, openFile, stdin, stdout,
4848 withFile)
49−#if __GLASGOW_HASKELL__ <= 610
50−import qualified Data.ByteString.Char8 as B
51−import Data.Text.Encoding (decodeUtf8, encodeUtf8)
52−#else
5349import qualified Control.Exception as E
5450import Control.Monad (liftM2, when)
5551import Data.IORef (readIORef, writeIORef)
@@ -68,7 +64,6 @@ import GHC.IO.Handle.Types (BufferList(..), BufferMode(..), Handle__(..),
6864 HandleType(..), Newline(..))
6965import System.IO (hGetBuffering, hFileSize, hSetBuffering, hTell)
7066import System.IO.Error (isEOFError)
71−#endif
7267
7368-- $performance
7469-- #performance#
@@ -137,9 +132,6 @@ hGetChunk h = wantReadableHandle "hGetChunk" h readSingleChunk
137132-- result to construct its result. For files more than a half of
138133-- available RAM in size, this may result in memory exhaustion.
139134hGetContents :: Handle -> IO Text
140−#if __GLASGOW_HASKELL__ <= 610
141−hGetContents = fmap decodeUtf8 . B.hGetContents
142−#else
143135hGetContents h = do
144136 chooseGoodBuffering h
145137 wantReadableHandle "hGetContents" h readAll
@@ -171,21 +163,13 @@ chooseGoodBuffering h = do
171163 else E.throwIO e
172164 when (d > 0) . hSetBuffering h . BlockBuffering . Just . fromIntegral $ d
173165 _ -> return ()
174−#endif
175166
176167-- | Read a single line from a handle.
177168hGetLine :: Handle -> IO Text
178−#if __GLASGOW_HASKELL__ <= 610
179−hGetLine = fmap decodeUtf8 . B.hGetLine
180−#else
181169hGetLine = hGetLineWith T.concat
182−#endif
183170
184171-- | Write a string to a handle.
185172hPutStr :: Handle -> Text -> IO ()
186−#if __GLASGOW_HASKELL__ <= 610
187−hPutStr h = B.hPutStr h . encodeUtf8
188−#else
189173-- This function is lifted almost verbatim from GHC.IO.Handle.Text.
190174hPutStr h t = do
191175 (buffer_mode, nl) <-
@@ -295,7 +279,6 @@ commitBuffer hdl !raw !sz !count flush release =
295279 wantWritableHandle "commitAndReleaseBuffer" hdl $
296280 commitBuffer' raw sz count flush release
297281{-# INLINE commitBuffer #-}
298−#endif
299282
300283-- | Write a string to a handle, followed by a newline.
301284hPutStrLn :: Handle -> Text -> IO ()
Data/Text/IO/Internal.hs−4
@@ -12,13 +12,10 @@
1212
1313module Data.Text.IO.Internal
1414 (
15−#if __GLASGOW_HASKELL__ >= 612
1615 hGetLineWith
1716 , readChunk
18−#endif
1917 ) where
2018
21−#if __GLASGOW_HASKELL__ >= 612
2219import qualified Control.Exception as E
2320import Data.IORef (readIORef, writeIORef)
2421import Data.Text (Text)
@@ -163,4 +160,3 @@ readChunk hh@Handle__{..} buf = do
163160
164161sizeError :: String -> a
165162sizeError 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)
202202import qualified Data.List as L
203203import Data.Char (isSpace)
204204import Data.Data (Data(gfoldl, toConstr, gunfold, dataTypeOf))
205−#if __GLASGOW_HASKELL__ >= 612
206205import Data.Data (mkNoRepType)
207−#else
208−import Data.Data (mkNorepType)
209−#endif
210206import Data.Monoid (Monoid(..))
211207import Data.String (IsString(..))
212208import qualified Data.Text as T
@@ -341,11 +337,7 @@ instance Data Text where
341337 gfoldl f z txt = z pack `f` (unpack txt)
342338 toConstr _ = error "Data.Text.Lazy.Text.toConstr"
343339 gunfold _ _ = error "Data.Text.Lazy.Text.gunfold"
344−#if __GLASGOW_HASKELL__ >= 612
345340 dataTypeOf _ = mkNoRepType "Data.Text.Lazy.Text"
346−#else
347− dataTypeOf _ = mkNorepType "Data.Text.Lazy.Text"
348−#endif
349341
350342-- | /O(n)/ Convert a 'String' into a 'Text'.
351343--
Data/Text/Lazy/Builder/Int.hs+1−3
@@ -33,9 +33,7 @@ import GHC.Types (Int(..))
3333import Control.Monad.ST
3434
3535#ifdef __GLASGOW_HASKELL__
36−# if __GLASGOW_HASKELL__ < 611
37−import GHC.Integer.Internals
38−# elif defined(INTEGER_GMP)
36+# if defined(INTEGER_GMP)
3937import GHC.Integer.GMP.Internals
4038# elif defined(INTEGER_SIMPLE)
4139import GHC.Integer
Data/Text/Lazy/IO.hs−14
@@ -47,11 +47,6 @@ import System.IO (Handle, IOMode(..), hPutChar, openFile, stdin, stdout,
4747 withFile)
4848import qualified Data.Text.IO as T
4949import 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
5550import qualified Control.Exception as E
5651import Control.Monad (when)
5752import Data.IORef (readIORef)
@@ -65,7 +60,6 @@ import GHC.IO.Handle.Types (Handle__(..), HandleType(..))
6560import System.IO (BufferMode(..), hGetBuffering, hSetBuffering)
6661import System.IO.Error (isEOFError)
6762import System.IO.Unsafe (unsafeInterleaveIO)
68−#endif
6963
7064-- $performance
7165--
@@ -99,9 +93,6 @@ appendFile p = withFile p AppendMode . flip hPutStr
9993-- | Lazily read the remaining contents of a 'Handle'. The 'Handle'
10094-- will be closed after the read completes, or on error.
10195hGetContents :: Handle -> IO Text
102−#if __GLASGOW_HASKELL__ <= 610
103−hGetContents = fmap decodeUtf8 . L8.hGetContents
104−#else
10596hGetContents h = do
10697 chooseGoodBuffering h
10798 wantReadableHandle "hGetContents" h $ \hh -> do
@@ -138,15 +129,10 @@ lazyReadBuffered h hh@Handle__{..} = do
138129 then (hh', empty)
139130 else (hh', L.singleton '\r')
140131 else E.throwIO (augmentIOError e "hGetContents" h)
141−#endif
142132
143133-- | Read a single line from a handle.
144134hGetLine :: Handle -> IO Text
145−#if __GLASGOW_HASKELL__ <= 610
146−hGetLine = fmap (decodeUtf8 . L8.fromChunks . (:[])) . S8.hGetLine
147−#else
148135hGetLine = hGetLineWith L.fromChunks
149−#endif
150136
151137-- | Write a string to a handle.
152138hPutStr :: Handle -> Text -> IO ()
Data/Text/Unsafe.hs+1−5
@@ -34,11 +34,7 @@ import Data.Text.Internal (Text(..))
3434import Data.Text.Unsafe.Base (inlineInterleaveST, inlinePerformIO)
3535import Data.Text.UnsafeChar (unsafeChr)
3636import qualified Data.Text.Array as A
37−#if __GLASGOW_HASKELL__ >= 611
3837import GHC.IO (unsafeDupablePerformIO)
39−#else
40−import GHC.IOBase (unsafeDupablePerformIO)
41−#endif
4238
4339-- | /O(1)/ A variant of 'head' for non-empty 'Text'. 'unsafeHead'
4440-- omits the check for the empty case, so there is an obligation on
@@ -51,7 +47,7 @@ unsafeHead (Text arr off _len)
5147 n = A.unsafeIndex arr (off+1)
5248{-# INLINE unsafeHead #-}
5349
54−-- | /O(1)/ A variant of 'tail' for non-empty 'Text'. 'unsafeHead'
50+-- | /O(1)/ A variant of 'tail' for non-empty 'Text'. 'unsafeTail'
5551-- omits the check for the empty case, so there is an obligation on
5652-- the programmer to provide a proof that the 'Text' is non-empty.
5753unsafeTail :: Text -> Text
Data/Text/Unsafe/Base.hs−4
@@ -18,11 +18,7 @@ module Data.Text.Unsafe.Base
1818
1919import GHC.ST (ST(..))
2020#if defined(__GLASGOW_HASKELL__)
21−# if __GLASGOW_HASKELL__ >= 611
2221import GHC.IO (IO(IO))
23−# else
24−import GHC.IOBase (IO(IO))
25−# endif
2622import GHC.Base (realWorld#)
2723#endif
2824
text.cabal+18−34
@@ -125,36 +125,25 @@ library
125125 Data.Text.Util
126126
127127 build-depends:
128− array,
129− base < 5,
130− bytestring >= 0.9
131− if impl(ghc >= 6.10)
132− build-depends:
133− ghc-prim, base >= 4, deepseq >= 1.1.0.0
134− cpp-options: -DHAVE_DEEPSEQ
135− else
136− build-depends: extensible-exceptions
137− extensions: ScopedTypeVariables
138−
139− ghc-options: -Wall -funbox-strict-fields -O2
140− if impl(ghc >= 6.8)
141− ghc-options: -fwarn-tabs
128+ array >= 0.3,
129+ base >= 4.2 && < 5,
130+ bytestring >= 0.9,
131+ deepseq >= 1.1.0.0,
132+ ghc-prim >= 0.2
133+
134+ cpp-options: -DHAVE_DEEPSEQ
135+ ghc-options: -Wall -fwarn-tabs -funbox-strict-fields -O2
142136 if flag(developer)
143137 ghc-prof-options: -auto-all
144138 ghc-options: -Werror
145139 cpp-options: -DASSERTS
146140
147− if impl(ghc >= 6.11)
148− if flag(integer-simple)
149− cpp-options: -DINTEGER_SIMPLE
150− build-depends: integer-simple >= 0.1 && < 0.5
151− else
152− cpp-options: -DINTEGER_GMP
153− build-depends: integer-gmp >= 0.2
154−
155− if impl(ghc >= 6.9) && impl(ghc < 6.11)
141+ if flag(integer-simple)
142+ cpp-options: -DINTEGER_SIMPLE
143+ build-depends: integer-simple >= 0.1 && < 0.5
144+ else
156145 cpp-options: -DINTEGER_GMP
157− build-depends: integer >= 0.1 && < 0.2
146+ build-depends: integer-gmp >= 0.2
158147
159148test-suite tests
160149 type: exitcode-stdio-1.0
@@ -183,17 +172,12 @@ test-suite tests
183172 test-framework-hunit >= 0.2,
184173 test-framework-quickcheck2 >= 0.2
185174
186− if impl(ghc >= 6.11)
187− if flag(integer-simple)
188− cpp-options: -DINTEGER_SIMPLE
189− build-depends: integer-simple >= 0.1 && < 0.5
190− else
191− cpp-options: -DINTEGER_GMP
192− build-depends: integer-gmp >= 0.2
193−
194− if impl(ghc >= 6.9) && impl(ghc < 6.11)
175+ if flag(integer-simple)
176+ cpp-options: -DINTEGER_SIMPLE
177+ build-depends: integer-simple >= 0.1 && < 0.5
178+ else
195179 cpp-options: -DINTEGER_GMP
196− build-depends: integer >= 0.1 && < 0.2
180+ build-depends: integer-gmp >= 0.2
197181
198182source-repository head
199183 type: git