on master help sign in
Clean up some unhelpful warnings
42244c9Bryan O'Sullivan
Data/Text.hs+4−4
@@ -146,7 +146,7 @@ module Data.Text
146import Prelude (Char, Bool(..), Functor(..), Int, Maybe(..), String,
146import Prelude (Char, Bool(..), Functor(..), Int, Maybe(..), String,
147 Eq(..), Ord(..), (++),
147 Eq(..), Ord(..), (++),
148 Read(..), Show(..),
148 Read(..), Show(..),
149− (&&), (||), (+), (-), (<), (>), (<=), (>=), (.), ($),
149+ (&&), (||), (+), (-), (.), ($),
150 not, return, otherwise)
150 not, return, otherwise)
151import Control.Exception (assert)
151import Control.Exception (assert)
152import Data.Char (isSpace)
152import Data.Char (isSpace)
@@ -245,10 +245,10 @@ append (Text arr1 off1 len1) (Text arr2 off2 len2) = Text (A.run x) 0 len
245 copy arr2 off2 (len2+off2) arr len1
245 copy arr2 off2 (len2+off2) arr len1
246 return arr
246 return arr
247 where
247 where
248− copy arr i max arr' j
248+ copy arr i top arr' j
249− | i >= max = return ()
249+ | i >= top = return ()
250 | otherwise = do A.unsafeWrite arr' j (arr `A.unsafeIndex` i)
250 | otherwise = do A.unsafeWrite arr' j (arr `A.unsafeIndex` i)
251− copy arr (i+1) max arr' (j+1)
251+ copy arr (i+1) top arr' (j+1)
252{-# INLINE append #-}
252{-# INLINE append #-}
253
253
254{-# RULES
254{-# RULES
Data/Text/Fusion.hs+11−13
@@ -105,14 +105,12 @@ module Data.Text.Fusion
105import Prelude (Bool(..), Char, Either(..), Eq(..), Maybe(..), Monad(..),
105import Prelude (Bool(..), Char, Either(..), Eq(..), Maybe(..), Monad(..),
106 Num(..), Ord(..), String, ($), (++), (.), (&&),
106 Num(..), Ord(..), String, ($), (++), (.), (&&),
107 fromIntegral, otherwise)
107 fromIntegral, otherwise)
108−import Control.Monad (liftM2)
109−import Control.Monad.ST (runST)
110import qualified Data.List as L
108import qualified Data.List as L
111import GHC.Exts (Int(..), (+#))
109import GHC.Exts (Int(..), (+#))
112import Data.Bits ((.&.), shiftR)
110import Data.Bits ((.&.), shiftR)
113import Data.Char (ord)
111import Data.Char (ord)
114import Data.Text.Internal (Text(..))
112import Data.Text.Internal (Text(..))
115−import Data.Text.UnsafeChar (unsafeChr, unsafeWrite, unsafeWriteRev)
113+import Data.Text.UnsafeChar (unsafeChr, unsafeWrite)
116import qualified Data.Text.Array as A
114import qualified Data.Text.Array as A
117import Data.Text.Fusion.Internal
115import Data.Text.Fusion.Internal
118import qualified Data.Text.Internal as I
116import qualified Data.Text.Internal as I
@@ -154,18 +152,18 @@ reverseStream (Text arr off len) = Stream next (off+len-1) len
154-- | /O(n)/ Convert a 'Stream Char' into a 'Text'.
152-- | /O(n)/ Convert a 'Stream Char' into a 'Text'.
155unstream :: Stream Char -> Text
153unstream :: Stream Char -> Text
156unstream (Stream next0 s0 len)
154unstream (Stream next0 s0 len)
157− | len == 0 = I.empty
155+ | len == 0 = I.empty
158 | otherwise = I.textP (P.fst a) 0 (P.snd a)
156 | otherwise = I.textP (P.fst a) 0 (P.snd a)
159 where
157 where
160− a = runST (A.unsafeNew len >>= (\arr -> loop arr len s0 0))
158+ a = A.run2 (A.unsafeNew len >>= (\arr -> loop arr len s0 0))
161 loop arr !top !s !i
159 loop arr !top !s !i
162 | i + 1 >= top = case next0 s of
160 | i + 1 >= top = case next0 s of
163− Done -> liftM2 (,) (A.unsafeFreeze arr) (return i)
161+ Done -> return (arr, i)
164 _ -> do
162 _ -> do
165 arr' <- A.unsafeNew (top*2)
163 arr' <- A.unsafeNew (top*2)
166 A.copy arr arr' >> loop arr' (top*2) s i
164 A.copy arr arr' >> loop arr' (top*2) s i
167 | otherwise = case next0 s of
165 | otherwise = case next0 s of
168− Done -> liftM2 (,) (A.unsafeFreeze arr) (return i)
166+ Done -> return (arr, i)
169 Skip s' -> loop arr top s' i
167 Skip s' -> loop arr top s' i
170 Yield x s' -> unsafeWrite arr i x >>= loop arr top s'
168 Yield x s' -> unsafeWrite arr i x >>= loop arr top s'
171{-# INLINE [0] unstream #-}
169{-# INLINE [0] unstream #-}
@@ -377,14 +375,14 @@ reverse (Stream next s len0)
377 m = n - 0x10000
375 m = n - 0x10000
378 lo = fromIntegral $ (m `shiftR` 10) + 0xD800
376 lo = fromIntegral $ (m `shiftR` 10) + 0xD800
379 hi = fromIntegral $ (m .&. 0x3FF) + 0xDC00
377 hi = fromIntegral $ (m .&. 0x3FF) + 0xDC00
380− write s i len marr
378+ write t j l mar
381 | n < 0x10000 = do
379 | n < 0x10000 = do
382− A.unsafeWrite marr i (fromIntegral n)
380+ A.unsafeWrite mar j (fromIntegral n)
383− loop s (i-1) len marr
381+ loop t (j-1) l mar
384 | otherwise = do
382 | otherwise = do
385− A.unsafeWrite marr (i-1) lo
383+ A.unsafeWrite mar (j-1) lo
386− A.unsafeWrite marr i hi
384+ A.unsafeWrite mar j hi
387− loop s (i-2) len marr
385+ loop t (j-2) l mar
388{-# INLINE [0] reverse #-}
386{-# INLINE [0] reverse #-}
389
387
390-- ----------------------------------------------------------------------------
388-- ----------------------------------------------------------------------------
Data/Text/Lazy/Fusion.hs+4−5
@@ -21,8 +21,7 @@ import Data.Text.Fusion.Internal
21import Data.Text.Lazy.Internal
21import Data.Text.Lazy.Internal
22import qualified Data.Text.Internal as I
22import qualified Data.Text.Internal as I
23import qualified Data.Text.Array as A
23import qualified Data.Text.Array as A
24−import qualified Data.Text.Encoding.Utf16 as U16
25−import Data.Text.UnsafeChar (unsafeChr, unsafeWrite)
24+import Data.Text.UnsafeChar (unsafeWrite)
26import Data.Text.Unsafe (iter)
25import Data.Text.Unsafe (iter)
27
26
28default(Int)
27default(Int)
@@ -50,8 +49,8 @@ unstreamChunks chunkSize (Stream next s0 len0)
50 Skip s' -> outer s'
49 Skip s' -> outer s'
51 Yield x s' -> I.Text arr 0 len `chunk` outer s''
50 Yield x s' -> I.Text arr 0 len `chunk` outer s''
52 where (arr,(s'',len)) = A.run2 fill
51 where (arr,(s'',len)) = A.run2 fill
53− fill = do arr <- A.unsafeNew unknownLength
52+ fill = do a <- A.unsafeNew unknownLength
54− inner arr unknownLength x s' 0
53+ inner a unknownLength x s' 0
55 unknownLength = 4
54 unknownLength = 4
56 inner marr len x s i
55 inner marr len x s i
57 | i + 1 >= chunkSize = return (marr, (s,i))
56 | i + 1 >= chunkSize = return (marr, (s,i))
@@ -64,7 +63,7 @@ unstreamChunks chunkSize (Stream next s0 len0)
64 case next s of
63 case next s of
65 Done -> do i' <- unsafeWrite marr i x
64 Done -> do i' <- unsafeWrite marr i x
66 return (marr,(s,i'))
65 return (marr,(s,i'))
67− Skip s' -> inner marr len x s i
66+ Skip s' -> inner marr len x s' i
68 Yield x' s' -> unsafeWrite marr i x >>= inner marr len x' s'
67 Yield x' s' -> unsafeWrite marr i x >>= inner marr len x' s'
69{-# INLINE [0] unstreamChunks #-}
68{-# INLINE [0] unstreamChunks #-}
70
69