@@ -473,17 +473,20 @@ toTitle (Stream next0 s0 len) = Stream next (CC (False :*: s0) '\0' '\0') len
473 next (CC s a b) = Yield a (CC s b '\0')
473 next (CC s a b) = Yield a (CC s b '\0')
474{-# INLINE [0] toTitle #-}
474{-# INLINE [0] toTitle #-}
476+data Justify i s = Just1 !i !s
476justifyLeftI :: Integral a => a -> Char -> Stream Char -> Stream Char
479justifyLeftI :: Integral a => a -> Char -> Stream Char -> Stream Char
477justifyLeftI k c (Stream next0 s0 len) =
480justifyLeftI k c (Stream next0 s0 len) =
478− Stream next (s0 :*: S1 :*: 0) (larger (fromIntegral k) len)
481+ Stream next (Just1 0 s0) (larger (fromIntegral k) len)
480− next (s :*: S1 :*: n) =
483+ next (Just1 n s) =
481 case next0 s of
484 case next0 s of
482− Done -> next (s :*: S2 :*: n)
485+ Done -> next (Just2 n s)
483− Skip s' -> Skip (s' :*: S1 :*: n)
486+ Skip s' -> Skip (Just1 n s')
484− Yield x s' -> Yield x (s' :*: S1 :*: n+1)
487+ Yield x s' -> Yield x (Just1 (n+1) s')
485− next (s :*: S2 :*: n)
488+ next (Just2 n s)
486− | n < k = Yield c (s :*: S2 :*: n+1)
489+ | n < k = Yield c (Just2 (n+1) s)
487 | otherwise = Done
490 | otherwise = Done
488 {-# INLINE next #-}
491 {-# INLINE next #-}
489{-# INLINE [0] justifyLeftI #-}
492{-# INLINE [0] justifyLeftI #-}
@@ -651,15 +654,15 @@ minimum (Stream next0 s0 _len) = loop0_minimum s0
651-- * Building streams
654-- * Building streams
653scanl :: (Char -> Char -> Char) -> Char -> Stream Char -> Stream Char
656scanl :: (Char -> Char -> Char) -> Char -> Stream Char -> Stream Char
654−scanl f z0 (Stream next0 s0 len) = Stream next (S1 :*: z0 :*: s0) (len+1) -- HINT maybe too low
657+scanl f z0 (Stream next0 s0 len) = Stream next (Scan1 z0 s0) (len+1) -- HINT maybe too low
656 {-# INLINE next #-}
659 {-# INLINE next #-}
657− next (S1 :*: z :*: s) = Yield z (S2 :*: z :*: s)
660+ next (Scan1 z s) = Yield z (Scan2 z s)
658− next (S2 :*: z :*: s) = case next0 s of
661+ next (Scan2 z s) = case next0 s of
659− Yield x s' -> let !x' = f z x
662+ Yield x s' -> let !x' = f z x
660− in Yield x' (S2 :*: x' :*: s')
663+ in Yield x' (Scan2 x' s')
661− Skip s' -> Skip (S2 :*: z :*: s')
664+ Skip s' -> Skip (Scan2 z s')
662− Done -> Done
665+ Done -> Done
663{-# INLINE [0] scanl #-}
666{-# INLINE [0] scanl #-}
665-- -----------------------------------------------------------------------------
668-- -----------------------------------------------------------------------------
@@ -916,17 +919,17 @@ findIndicesI p (Stream next s0 _len) = loop_findIndex 0 s0
916-- the first argument, instead of a tupling function.
919-- the first argument, instead of a tupling function.
917zipWith :: (a -> a -> b) -> Stream a -> Stream a -> Stream b
920zipWith :: (a -> a -> b) -> Stream a -> Stream a -> Stream b
918zipWith f (Stream next0 sa0 len1) (Stream next1 sb0 len2) =
921zipWith f (Stream next0 sa0 len1) (Stream next1 sb0 len2) =
919− Stream next (sa0 :*: sb0 :*: N) (smaller len1 len2)
922+ Stream next (T3 sa0 sb0 N) (smaller len1 len2)
921− next (sa :*: sb :*: N) = case next0 sa of
924+ next (T3 sa sb N) = case next0 sa of
922− Done -> Done
925+ Done -> Done
923− Skip sa' -> Skip (sa' :*: sb :*: N)
926+ Skip sa' -> Skip (T3 sa' sb N)
924− Yield a sa' -> Skip (sa' :*: sb :*: J a)
927+ Yield a sa' -> Skip (T3 sa' sb (J a))
926− next (sa' :*: sb :*: J a) = case next1 sb of
929+ next (T3 sa' sb (J a)) = case next1 sb of
927− Done -> Done
930+ Done -> Done
928− Skip sb' -> Skip (sa' :*: sb' :*: J a)
931+ Skip sb' -> Skip (T3 sa' sb' (J a))
929− Yield b sb' -> Yield (f a b) (sa' :*: sb' :*: N)
932+ Yield b sb' -> Yield (f a b) (T3 sa' sb' N)
930{-# INLINE [0] zipWith #-}
933{-# INLINE [0] zipWith #-}
932-- | /O(n)/ The 'countCharI' function returns the number of times the
935-- | /O(n)/ The 'countCharI' function returns the number of times the