@@ -92,7 +92,7 @@ import qualified Prelude as P
92import Data.Text.Fusion.Internal
92import Data.Text.Fusion.Internal
94singleton :: Char -> Stream Char
94singleton :: Char -> Stream Char
95−singleton c = Stream next False 1
95+singleton c = Stream next False 1 -- HINT maybe too low
96 where next False = Yield c True
96 where next False = Yield c True
97 next True = Done
97 next True = Done
98{-# INLINE singleton #-}
98{-# INLINE singleton #-}
@@ -103,7 +103,7 @@ streamList [] = empty
103streamList s = Stream next s unknownLength
103streamList s = Stream next s unknownLength
104 where next [] = Done
104 where next [] = Done
105 next (x:xs) = Yield x xs
105 next (x:xs) = Yield x xs
106− unknownLength = 8
106+ unknownLength = 8 -- random HINT
108unstreamList :: Stream a -> [a]
108unstreamList :: Stream a -> [a]
109{-# INLINE unstreamList #-}
109{-# INLINE unstreamList #-}
@@ -118,7 +118,7 @@ unstreamList (Stream next s0 _len) = unfold s0
119-- | /O(n)/ Adds a character to the front of a Stream Char.
119-- | /O(n)/ Adds a character to the front of a Stream Char.
120cons :: Char -> Stream Char -> Stream Char
120cons :: Char -> Stream Char -> Stream Char
121−cons w (Stream next0 s0 len) = Stream next (S2 :!: s0) (len+2)
121+cons w (Stream next0 s0 len) = Stream next (S2 :!: s0) (len+2) -- HINT maybe too high
123 {-# INLINE next #-}
123 {-# INLINE next #-}
124 next (S2 :!: s) = Yield w (S1 :!: s)
124 next (S2 :!: s) = Yield w (S1 :!: s)
@@ -130,7 +130,7 @@ cons w (Stream next0 s0 len) = Stream next (S2 :!: s0) (len+2)
131-- | /O(n)/ Adds a character to the end of a stream.
131-- | /O(n)/ Adds a character to the end of a stream.
132snoc :: Stream Char -> Char -> Stream Char
132snoc :: Stream Char -> Char -> Stream Char
133−snoc (Stream next0 xs0 len) w = Stream next (Just xs0) (len+2)
133+snoc (Stream next0 xs0 len) w = Stream next (Just xs0) (len+2) -- HINT maybe too high
135 {-# INLINE next #-}
135 {-# INLINE next #-}
136 next (Just xs) = case next0 xs of
136 next (Just xs) = case next0 xs of
@@ -173,7 +173,7 @@ uncons :: Stream Char -> Maybe (Char, Stream Char)
173uncons (Stream next s0 len) = loop_uncons s0
173uncons (Stream next s0 len) = loop_uncons s0
175 loop_uncons !s = case next s of
175 loop_uncons !s = case next s of
176− Yield x s1 -> Just (x, Stream next s1 (len-1))
176+ Yield x s1 -> Just (x, Stream next s1 (len-1)) -- HINT maybe too high
177 Skip s' -> loop_uncons s'
177 Skip s' -> loop_uncons s'
178 Done -> Nothing
178 Done -> Nothing
179{-# INLINE [0] uncons #-}
179{-# INLINE [0] uncons #-}
@@ -196,7 +196,7 @@ last (Stream next s0 _len) = loop0_last s0
196-- | /O(1)/ Returns all characters after the head of a Stream Char, which must
196-- | /O(1)/ Returns all characters after the head of a Stream Char, which must
197-- be non-empty.
197-- be non-empty.
198tail :: Stream Char -> Stream Char
198tail :: Stream Char -> Stream Char
199−tail (Stream next0 s0 len) = Stream next (False :!: s0) (len-1)
199+tail (Stream next0 s0 len) = Stream next (False :!: s0) (len-1) -- HINT maybe too high
201 {-# INLINE next #-}
201 {-# INLINE next #-}
202 next (False :!: s) = case next0 s of
202 next (False :!: s) = case next0 s of
@@ -213,7 +213,7 @@ tail (Stream next0 s0 len) = Stream next (False :!: s0) (len-1)
213-- | /O(1)/ Returns all but the last character of a Stream Char, which
213-- | /O(1)/ Returns all but the last character of a Stream Char, which
214-- must be non-empty.
214-- must be non-empty.
215init :: Stream Char -> Stream Char
215init :: Stream Char -> Stream Char
216−init (Stream next0 s0 len) = Stream next (Nothing :!: s0) (len-1)
216+init (Stream next0 s0 len) = Stream next (Nothing :!: s0) (len-1) -- HINT maybe too high
218 {-# INLINE next #-}
218 {-# INLINE next #-}
219 next (Nothing :!: s) = case next0 s of
219 next (Nothing :!: s) = case next0 s of
@@ -252,7 +252,7 @@ lengthI (Stream next s0 _len) = loop_length 0 s0
252-- | /O(n)/ 'map' @f @xs is the Stream Char obtained by applying @f@ to each element of
252-- | /O(n)/ 'map' @f @xs is the Stream Char obtained by applying @f@ to each element of
254map :: (Char -> Char) -> Stream Char -> Stream Char
254map :: (Char -> Char) -> Stream Char -> Stream Char
255−map f (Stream next0 s0 len) = Stream next s0 len
255+map f (Stream next0 s0 len) = Stream next s0 len -- HINT depends on f
257 {-# INLINE next #-}
257 {-# INLINE next #-}
258 next !s = case next0 s of
258 next !s = case next0 s of
@@ -269,7 +269,7 @@ map f (Stream next0 s0 len) = Stream next s0 len
269-- | /O(n)/ Take a character and place it between each of the
269-- | /O(n)/ Take a character and place it between each of the
270-- characters of a 'Stream Char'.
270-- characters of a 'Stream Char'.
271intersperse :: Char -> Stream Char -> Stream Char
271intersperse :: Char -> Stream Char -> Stream Char
272−intersperse c (Stream next0 s0 len) = Stream next (s0 :!: Nothing :!: S1) len
272+intersperse c (Stream next0 s0 len) = Stream next (s0 :!: Nothing :!: S1) len -- HINT maybe too low
274 {-# INLINE next #-}
274 {-# INLINE next #-}
275 next (s :!: Nothing :!: S1) = case next0 s of
275 next (s :!: Nothing :!: S1) = case next0 s of
@@ -448,7 +448,7 @@ minimum (Stream next0 s0 _len) = loop0_minimum s0
448-- * Building streams
448-- * Building streams
450scanl :: (Char -> Char -> Char) -> Char -> Stream Char -> Stream Char
450scanl :: (Char -> Char -> Char) -> Char -> Stream Char -> Stream Char
451−scanl f z0 (Stream next0 s0 len) = Stream next (S1 :!: z0 :!: s0) (len+1)
451+scanl f z0 (Stream next0 s0 len) = Stream next (S1 :!: z0 :!: s0) (len+1) -- HINT maybe too low
453 {-# INLINE next #-}
453 {-# INLINE next #-}
454 next (S1 :!: z :!: s) = Yield z (S2 :!: z :!: s)
454 next (S1 :!: z :!: s) = Yield z (S2 :!: z :!: s)
@@ -470,7 +470,7 @@ scanl f z0 (Stream next0 s0 len) = Stream next (S1 :!: z0 :!: s0) (len+1)
470-- return a final value for the accumulator, because the nature of
470-- return a final value for the accumulator, because the nature of
471-- streams precludes it.
471-- streams precludes it.
472mapAccumL :: (a -> b -> (a,b)) -> a -> Stream b -> Stream b
472mapAccumL :: (a -> b -> (a,b)) -> a -> Stream b -> Stream b
473−mapAccumL f z0 (Stream next0 s0 len) = Stream next (s0 :!: z0) len
473+mapAccumL f z0 (Stream next0 s0 len) = Stream next (s0 :!: z0) len -- HINT depends on f
475 {-# INLINE next #-}
475 {-# INLINE next #-}
476 next (s :!: z) = case next0 s of
476 next (s :!: z) = case next0 s of
@@ -486,7 +486,7 @@ mapAccumL f z0 (Stream next0 s0 len) = Stream next (s0 :!: z0) len
486replicate :: Int -> Char -> Stream Char
486replicate :: Int -> Char -> Stream Char
487replicate n c
487replicate n c
488 | n < 0 = empty
488 | n < 0 = empty
489− | otherwise = Stream next 0 n
489+ | otherwise = Stream next 0 n -- HINT maybe too low
491 {-# INLINE next #-}
491 {-# INLINE next #-}
492 next i | i >= n = Done
492 next i | i >= n = Done
@@ -500,7 +500,7 @@ replicate n c
500-- (a,b), in which case, a is the next Char in the string, and b is
500-- (a,b), in which case, a is the next Char in the string, and b is
501-- the seed value for further production.
501-- the seed value for further production.
502unfoldr :: (a -> Maybe (Char,a)) -> a -> Stream Char
502unfoldr :: (a -> Maybe (Char,a)) -> a -> Stream Char
503−unfoldr f s0 = Stream next s0 1
503+unfoldr f s0 = Stream next s0 1 -- HINT maybe too low
505 {-# INLINE next #-}
505 {-# INLINE next #-}
506 next !s = case f s of
506 next !s = case f s of
@@ -514,7 +514,7 @@ unfoldr f s0 = Stream next s0 1
514-- 'unfoldr' when the length of the result is known.
514-- 'unfoldr' when the length of the result is known.
515unfoldrNI :: Integral a => a -> (b -> Maybe (Char,b)) -> b -> Stream Char
515unfoldrNI :: Integral a => a -> (b -> Maybe (Char,b)) -> b -> Stream Char
516unfoldrNI n f s0 | n < 0 = empty
516unfoldrNI n f s0 | n < 0 = empty
517− | otherwise = Stream next (0 :!: s0) (fromIntegral (n*2))
517+ | otherwise = Stream next (0 :!: s0) (fromIntegral (n*2)) -- HINT maybe too high
519 {-# INLINE next #-}
519 {-# INLINE next #-}
520 next (z :!: s) = case f s of
520 next (z :!: s) = case f s of
@@ -530,7 +530,7 @@ unfoldrNI n f s0 | n < 0 = empty
530-- stream of length @n@, or the stream itself if @n@ is greater than the
530-- stream of length @n@, or the stream itself if @n@ is greater than the
531-- length of the stream.
531-- length of the stream.
532take :: Integral a => a -> Stream Char -> Stream Char
532take :: Integral a => a -> Stream Char -> Stream Char
533−take n0 (Stream next0 s0 len) = Stream next (n0 :!: s0) len
533+take n0 (Stream next0 s0 len) = Stream next (n0 :!: s0) (min 0 (len - fromIntegral n0)) -- HINT maybe too high
535 {-# INLINE next #-}
535 {-# INLINE next #-}
536 next (n :!: s) | n <= 0 = Done
536 next (n :!: s) | n <= 0 = Done
@@ -545,7 +545,7 @@ take n0 (Stream next0 s0 len) = Stream next (n0 :!: s0) len
545-- length of the stream.
545-- length of the stream.
546drop :: Integral a => a -> Stream Char -> Stream Char
546drop :: Integral a => a -> Stream Char -> Stream Char
547drop n0 (Stream next0 s0 len) =
547drop n0 (Stream next0 s0 len) =
548− Stream next (Just ((max 0 n0)) :!: s0) (len - fromIntegral n0)
548+ Stream next (Just ((max 0 n0)) :!: s0) (len - fromIntegral n0) -- HINT maybe too high
550 {-# INLINE next #-}
550 {-# INLINE next #-}
551 next (Just !n :!: s)
551 next (Just !n :!: s)
@@ -563,7 +563,7 @@ drop n0 (Stream next0 s0 len) =
563-- | takeWhile, applied to a predicate @p@ and a stream, returns the
563-- | takeWhile, applied to a predicate @p@ and a stream, returns the
564-- longest prefix (possibly empty) of elements that satisfy p.
564-- longest prefix (possibly empty) of elements that satisfy p.
565takeWhile :: (Char -> Bool) -> Stream Char -> Stream Char
565takeWhile :: (Char -> Bool) -> Stream Char -> Stream Char
566−takeWhile p (Stream next0 s0 len) = Stream next s0 len
566+takeWhile p (Stream next0 s0 len) = Stream next s0 len -- HINT maybe too high
568 {-# INLINE next #-}
568 {-# INLINE next #-}
569 next !s = case next0 s of
569 next !s = case next0 s of
@@ -575,7 +575,7 @@ takeWhile p (Stream next0 s0 len) = Stream next s0 len
576-- | dropWhile @p @xs returns the suffix remaining after takeWhile @p @xs.
576-- | dropWhile @p @xs returns the suffix remaining after takeWhile @p @xs.
577dropWhile :: (Char -> Bool) -> Stream Char -> Stream Char
577dropWhile :: (Char -> Bool) -> Stream Char -> Stream Char
578−dropWhile p (Stream next0 s0 len) = Stream next (S1 :!: s0) len
578+dropWhile p (Stream next0 s0 len) = Stream next (S1 :!: s0) len -- HINT maybe too high
580 {-# INLINE next #-}
580 {-# INLINE next #-}
581 next (S1 :!: s) = case next0 s of
581 next (S1 :!: s) = case next0 s of
@@ -642,7 +642,7 @@ find p (Stream next s0 _len) = loop_find s0
642-- returns a stream containing those characters that satisfy the
642-- returns a stream containing those characters that satisfy the
643-- predicate.
643-- predicate.
644filter :: (Char -> Bool) -> Stream Char -> Stream Char
644filter :: (Char -> Bool) -> Stream Char -> Stream Char
645−filter p (Stream next0 s0 len) = Stream next s0 len
645+filter p (Stream next0 s0 len) = Stream next s0 len -- HINT maybe too high
647 {-# INLINE next #-}
647 {-# INLINE next #-}
648 next !s = case next0 s of
648 next !s = case next0 s of