Commits

Bryan O'Sullivan committed f8c1e64

Clean up some unhelpful warnings

Comments (0)

Files changed (3)

 import Prelude (Char, Bool(..), Functor(..), Int, Maybe(..), String,
                 Eq(..), Ord(..), (++),
                 Read(..), Show(..),
-                (&&), (||), (+), (-), (<), (>), (<=), (>=), (.), ($),
+                (&&), (||), (+), (-), (.), ($),
                 not, return, otherwise)
 import Control.Exception (assert)
 import Data.Char (isSpace)
         copy arr2 off2 (len2+off2) arr len1
         return arr
             where
-              copy arr i max arr' j
-                  | i >= max  = return ()
+              copy arr i top arr' j
+                  | i >= top  = return ()
                   | otherwise = do A.unsafeWrite arr' j (arr `A.unsafeIndex` i)
-                                   copy arr (i+1) max arr' (j+1)
+                                   copy arr (i+1) top arr' (j+1)
 {-# INLINE append #-}
 
 {-# RULES

Data/Text/Fusion.hs

 import Prelude (Bool(..), Char, Either(..), Eq(..), Maybe(..), Monad(..),
                 Num(..), Ord(..), String, ($), (++), (.), (&&),
                 fromIntegral, otherwise)
-import Control.Monad (liftM2)
-import Control.Monad.ST (runST)
 import qualified Data.List as L
 import GHC.Exts (Int(..), (+#))
 import Data.Bits ((.&.), shiftR)
 import Data.Char (ord)
 import Data.Text.Internal (Text(..))
-import Data.Text.UnsafeChar (unsafeChr, unsafeWrite, unsafeWriteRev)
+import Data.Text.UnsafeChar (unsafeChr, unsafeWrite)
 import qualified Data.Text.Array as A
 import Data.Text.Fusion.Internal
 import qualified Data.Text.Internal as I
 -- | /O(n)/ Convert a 'Stream Char' into a 'Text'.
 unstream :: Stream Char -> Text
 unstream (Stream next0 s0 len)
-    | len == 0 = I.empty
+    | len == 0  = I.empty
     | otherwise = I.textP (P.fst a) 0 (P.snd a)
     where
-      a = runST (A.unsafeNew len >>= (\arr -> loop arr len s0 0))
+      a = A.run2 (A.unsafeNew len >>= (\arr -> loop arr len s0 0))
       loop arr !top !s !i
           | i + 1 >= top = case next0 s of
-                            Done -> liftM2 (,) (A.unsafeFreeze arr) (return i)
+                            Done -> return (arr, i)
                             _    -> do
                               arr' <- A.unsafeNew (top*2)
                               A.copy arr arr' >> loop arr' (top*2) s i
           | otherwise = case next0 s of
-               Done       -> liftM2 (,) (A.unsafeFreeze arr) (return i)
+               Done       -> return (arr, i)
                Skip s'    -> loop arr top s' i
                Yield x s' -> unsafeWrite arr i x >>= loop arr top s'
 {-# INLINE [0] unstream #-}
                   m = n - 0x10000
                   lo = fromIntegral $ (m `shiftR` 10) + 0xD800
                   hi = fromIntegral $ (m .&. 0x3FF) + 0xDC00
-                  write s i len marr
+                  write t j l mar
                       | n < 0x10000 = do
-                          A.unsafeWrite marr i (fromIntegral n)
-                          loop s (i-1) len marr
+                          A.unsafeWrite mar j (fromIntegral n)
+                          loop t (j-1) l mar
                       | otherwise = do
-                          A.unsafeWrite marr (i-1) lo
-                          A.unsafeWrite marr i hi
-                          loop s (i-2) len marr
+                          A.unsafeWrite mar (j-1) lo
+                          A.unsafeWrite mar j hi
+                          loop t (j-2) l mar
 {-# INLINE [0] reverse #-}
 
 -- ----------------------------------------------------------------------------

Data/Text/Lazy/Fusion.hs

 import Data.Text.Lazy.Internal
 import qualified Data.Text.Internal as I
 import qualified Data.Text.Array as A
-import qualified Data.Text.Encoding.Utf16 as U16
-import Data.Text.UnsafeChar (unsafeChr, unsafeWrite)
+import Data.Text.UnsafeChar (unsafeWrite)
 import Data.Text.Unsafe (iter)
 
 default(Int)
                 Skip s'    -> outer s'
                 Yield x s' -> I.Text arr 0 len `chunk` outer s''
                   where (arr,(s'',len)) = A.run2 fill
-                        fill = do arr <- A.unsafeNew unknownLength
-                                  inner arr unknownLength x s' 0
+                        fill = do a <- A.unsafeNew unknownLength
+                                  inner a unknownLength x s' 0
                         unknownLength = 4
     inner marr len x s i
         | i + 1 >= chunkSize = return (marr, (s,i))
             case next s of
               Done        -> do i' <- unsafeWrite marr i x
                                 return (marr,(s,i'))
-              Skip s'     -> inner marr len x s i
+              Skip s'     -> inner marr len x s' i
               Yield x' s' -> unsafeWrite marr i x >>= inner marr len x' s' 
 {-# INLINE [0] unstreamChunks #-}