@@ -48,7 +48,7 @@ module Data.Text.Fusion
4848 ) where
4949
5050import Prelude (Bool(..), Char, Eq(..), Maybe(..), Monad(..), Int,
51− Num(..), Ord(..), String, ($), (++), (&&),
51+ Num(..), Ord(..), ($), (&&),
5252 fromIntegral, otherwise)
5353import Data.Bits ((.&.), shiftR)
5454import Data.Char (ord)
@@ -181,17 +181,9 @@ unfoldrN n = S.unfoldrNI n
181181-------------------------------------------------------------------------------
182182-- ** Indexing streams
183183
184−-- | /O(1)/ stream index (subscript) operator, starting from 0.
184+-- | /O(n)/ stream index (subscript) operator, starting from 0.
185185index :: Stream Char -> Int -> Char
186−index (Stream next s0 _len) n0
187− | n0 < 0 = streamError "index" "Negative index"
188− | otherwise = loop_index n0 s0
189− where
190− loop_index !n !s = case next s of
191− Done -> streamError "index" "Index too large"
192− Skip s' -> loop_index n s'
193− Yield x s' | n == 0 -> x
194− | otherwise -> loop_index (n-1) s'
186+index = S.indexI
195187{-# INLINE [0] index #-}
196188
197189-- | The 'findIndex' function takes a predicate and a stream and
@@ -261,6 +253,3 @@ count a (Stream next s0 _len) = loop 0 s0
261253 Yield x s' | a == x -> loop (i+1) s'
262254 | otherwise -> loop i s'
263255{-# INLINE [0] count #-}
264−
265−streamError :: String -> String -> a
266−streamError func msg = P.error $ "Data.Text.Fusion." ++ func ++ ": " ++ msg