@@ -98,7 +98,7 @@ module Data.Text.Fusion.Common
9898 , zipWith
9999 ) where
100100
101−import Prelude (Bool(..), Char, Either(..), Eq(..), Int, Integral, Maybe(..),
101+import Prelude (Bool(..), Char, Eq(..), Int, Integral, Maybe(..),
102102 Ord(..), String, (.), ($), (+), (-), (*), (++), (&&),
103103 fromIntegral, otherwise)
104104import qualified Data.List as L
@@ -157,20 +157,22 @@ snoc (Stream next0 xs0 len) w = Stream next (J xs0) (len+1)
157157 next N = Done
158158{-# INLINE [0] snoc #-}
159159
160+data E l r = L {-# UNPACK #-} !l
161+ | R {-# UNPACK #-} !r
162+
160163-- | /O(n)/ Appends one Stream to the other.
161164append :: Stream Char -> Stream Char -> Stream Char
162165append (Stream next0 s01 len1) (Stream next1 s02 len2) =
163− Stream next (Left s01) (len1 + len2)
166+ Stream next (L s01) (len1 + len2)
164167 where
165− {-# INLINE next #-}
166− next (Left s1) = case next0 s1 of
167− Done -> Skip (Right s02)
168− Skip s1' -> Skip (Left s1')
169− Yield x s1' -> Yield x (Left s1')
170− next (Right s2) = case next1 s2 of
168+ next (L s1) = case next0 s1 of
169+ Done -> Skip (R s02)
170+ Skip s1' -> Skip (L s1')
171+ Yield x s1' -> Yield x (L s1')
172+ next (R s2) = case next1 s2 of
171173 Done -> Done
172− Skip s2' -> Skip (Right s2')
173− Yield x s2' -> Yield x (Right s2')
174+ Skip s2' -> Skip (R s2')
175+ Yield x s2' -> Yield x (R s2')
174176{-# INLINE [0] append #-}
175177
176178-- | /O(1)/ Returns the first character of a Text, which must be non-empty.
@@ -283,7 +285,6 @@ isSingleton (Stream next s0 _len) = loop 0 s0
283285map :: (Char -> Char) -> Stream Char -> Stream Char
284286map f (Stream next0 s0 len) = Stream next s0 len
285287 where
286− {-# INLINE next #-}
287288 next !s = case next0 s of
288289 Done -> Done
289290 Skip s' -> Skip s'