@@ -79,6 +79,9 @@ module Data.Text.Fusion
79 , takeWhile
79 , takeWhile
80 , dropWhile
80 , dropWhile
82 -- * Searching
85 -- * Searching
@@ -683,6 +686,19 @@ dropWhile p (Stream next0 s0 len) = Stream next (S1 :!: s0) len
683 Yield x s' -> Yield x (S2 :!: s')
686 Yield x s' -> Yield x (S2 :!: s')
684{-# INLINE [0] dropWhile #-}
687{-# INLINE [0] dropWhile #-}
689+isPrefixOf :: (Eq a) => Stream a -> Stream a -> Bool
690+isPrefixOf (Stream next1 s1 _) (Stream next2 s2 _) = loop (next1 s1) (next2 s2)
694+ loop (Skip s1') (Skip s2') = loop (next1 s1') (next2 s2')
695+ loop (Skip s1') x2 = loop (next1 s1') x2
696+ loop x1 (Skip s2') = loop x1 (next2 s2')
697+ loop (Yield x1 s1') (Yield x2 s2') = x1 == x2 &&
698+ loop (next1 s1') (next2 s2')
699+{-# INLINE [0] isPrefixOf #-}
700+{-# SPECIALISE isPrefixOf :: Stream Char -> Stream Char -> Bool #-}
686-- ----------------------------------------------------------------------------
702-- ----------------------------------------------------------------------------
687-- * Searching
703-- * Searching
@@ -811,5 +827,6 @@ zipWith f (Stream next0 sa0 len1) (Stream next1 sb0 len2) = Stream next (sa0 :!:
811 Yield b sb' -> Yield (f a b) (sa' :!: sb' :!: Nothing)
827 Yield b sb' -> Yield (f a b) (sa' :!: sb' :!: Nothing)
812{-# INLINE [0] zipWith #-}
828{-# INLINE [0] zipWith #-}
814errorEmptyList :: String -> a
831errorEmptyList :: String -> a
815errorEmptyList fun = error ("Data.Text.Fusion." ++ fun ++ ": empty list")
832errorEmptyList fun = error ("Data.Text.Fusion." ++ fun ++ ": empty list")