@@ -60,6 +60,10 @@ module Data.Text.Fusion
6060 , minimum
6161
6262 -- * Construction
63+ -- ** Scans
64+ , scanl
65+
66+ -- ** Generation and unfolding
6367 , replicate
6468 , unfoldr
6569 , unfoldrN
@@ -540,6 +544,18 @@ minimum (Stream next0 s0 _len) = loop0_minimum s0
540544-- -----------------------------------------------------------------------------
541545-- * Building streams
542546
547+scanl :: (Char -> Char -> Char) -> Char -> Stream Char -> Stream Char
548+scanl f z0 (Stream next0 s0 len) = Stream next (S1 :!: z0 :!: s0) (len+1)
549+ where
550+ {-# INLINE next #-}
551+ next (S1 :!: z :!: s) = Yield z (S2 :!: z :!: s)
552+ next (S2 :!: z :!: s) = case next0 s of
553+ Yield x s' -> let !x' = f z x
554+ in Yield x' (S2 :!: x' :!: s')
555+ Skip s' -> Skip (S2 :!: z :!: s')
556+ Done -> Done
557+{-# INLINE [0] scanl #-}
558+
543559-- -----------------------------------------------------------------------------
544560-- ** Generating and unfolding streams
545561