on master help sign in
Clean up some unhelpful warnings

--HG-- extra : convert_revision : f5e0b803b664c1ac5c5014ad3815b7e0f40a39b8

commit42244c91a3fdcca9eacfe3708d899e7c647bb8d0 authorBryan O'Sullivan <bos@serpentine.com> dateSun 1 Mar 2009, 05:27 (18 years ago) parent3a4bbe6
3 files changed+19−22
Data/Text.hs+4−4 Data/Text/Fusion.hs+11−13 Data/Text/Lazy/Fusion.hs+4−5
Data/Text.hs+4−4
@@ -146,7 +146,7 @@ module Data.Text
146146import Prelude (Char, Bool(..), Functor(..), Int, Maybe(..), String,
147147 Eq(..), Ord(..), (++),
148148 Read(..), Show(..),
149− (&&), (||), (+), (-), (<), (>), (<=), (>=), (.), ($),
149+ (&&), (||), (+), (-), (.), ($),
150150 not, return, otherwise)
151151import Control.Exception (assert)
152152import Data.Char (isSpace)
@@ -245,10 +245,10 @@ append (Text arr1 off1 len1) (Text arr2 off2 len2) = Text (A.run x) 0 len
245245 copy arr2 off2 (len2+off2) arr len1
246246 return arr
247247 where
248− copy arr i max arr' j
249− | i >= max = return ()
248+ copy arr i top arr' j
249+ | i >= top = return ()
250250 | 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)
252252{-# INLINE append #-}
253253
254254{-# RULES
Data/Text/Fusion.hs+11−13
@@ -105,14 +105,12 @@ module Data.Text.Fusion
105105import Prelude (Bool(..), Char, Either(..), Eq(..), Maybe(..), Monad(..),
106106 Num(..), Ord(..), String, ($), (++), (.), (&&),
107107 fromIntegral, otherwise)
108−import Control.Monad (liftM2)
109−import Control.Monad.ST (runST)
110108import qualified Data.List as L
111109import GHC.Exts (Int(..), (+#))
112110import Data.Bits ((.&.), shiftR)
113111import Data.Char (ord)
114112import Data.Text.Internal (Text(..))
115−import Data.Text.UnsafeChar (unsafeChr, unsafeWrite, unsafeWriteRev)
113+import Data.Text.UnsafeChar (unsafeChr, unsafeWrite)
116114import qualified Data.Text.Array as A
117115import Data.Text.Fusion.Internal
118116import qualified Data.Text.Internal as I
@@ -154,18 +152,18 @@ reverseStream (Text arr off len) = Stream next (off+len-1) len
154152-- | /O(n)/ Convert a 'Stream Char' into a 'Text'.
155153unstream :: Stream Char -> Text
156154unstream (Stream next0 s0 len)
157− | len == 0 = I.empty
155+ | len == 0 = I.empty
158156 | otherwise = I.textP (P.fst a) 0 (P.snd a)
159157 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))
161159 loop arr !top !s !i
162160 | i + 1 >= top = case next0 s of
163− Done -> liftM2 (,) (A.unsafeFreeze arr) (return i)
161+ Done -> return (arr, i)
164162 _ -> do
165163 arr' <- A.unsafeNew (top*2)
166164 A.copy arr arr' >> loop arr' (top*2) s i
167165 | otherwise = case next0 s of
168− Done -> liftM2 (,) (A.unsafeFreeze arr) (return i)
166+ Done -> return (arr, i)
169167 Skip s' -> loop arr top s' i
170168 Yield x s' -> unsafeWrite arr i x >>= loop arr top s'
171169{-# INLINE [0] unstream #-}
@@ -377,14 +375,14 @@ reverse (Stream next s len0)
377375 m = n - 0x10000
378376 lo = fromIntegral $ (m `shiftR` 10) + 0xD800
379377 hi = fromIntegral $ (m .&. 0x3FF) + 0xDC00
380− write s i len marr
378+ write t j l mar
381379 | n < 0x10000 = do
382− A.unsafeWrite marr i (fromIntegral n)
383− loop s (i-1) len marr
380+ A.unsafeWrite mar j (fromIntegral n)
381+ loop t (j-1) l mar
384382 | otherwise = do
385− A.unsafeWrite marr (i-1) lo
386− A.unsafeWrite marr i hi
387− loop s (i-2) len marr
383+ A.unsafeWrite mar (j-1) lo
384+ A.unsafeWrite mar j hi
385+ loop t (j-2) l mar
388386{-# INLINE [0] reverse #-}
389387
390388-- ----------------------------------------------------------------------------
Data/Text/Lazy/Fusion.hs+4−5
@@ -21,8 +21,7 @@ import Data.Text.Fusion.Internal
2121import Data.Text.Lazy.Internal
2222import qualified Data.Text.Internal as I
2323import 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)
2625import Data.Text.Unsafe (iter)
2726
2827default(Int)
@@ -50,8 +49,8 @@ unstreamChunks chunkSize (Stream next s0 len0)
5049 Skip s' -> outer s'
5150 Yield x s' -> I.Text arr 0 len `chunk` outer s''
5251 where (arr,(s'',len)) = A.run2 fill
53− fill = do arr <- A.unsafeNew unknownLength
54− inner arr unknownLength x s' 0
52+ fill = do a <- A.unsafeNew unknownLength
53+ inner a unknownLength x s' 0
5554 unknownLength = 4
5655 inner marr len x s i
5756 | i + 1 >= chunkSize = return (marr, (s,i))
@@ -64,7 +63,7 @@ unstreamChunks chunkSize (Stream next s0 len0)
6463 case next s of
6564 Done -> do i' <- unsafeWrite marr i x
6665 return (marr,(s,i'))
67− Skip s' -> inner marr len x s i
66+ Skip s' -> inner marr len x s' i
6867 Yield x' s' -> unsafeWrite marr i x >>= inner marr len x' s'
6968{-# INLINE [0] unstreamChunks #-}
7069