@@ -172,6 +172,26 @@ unstream (Stream next0 s0 len)
172{-# INLINE [0] unstream #-}
172{-# INLINE [0] unstream #-}
173{-# RULES "STREAM stream/unstream fusion" forall s. stream (unstream s) = s #-}
173{-# RULES "STREAM stream/unstream fusion" forall s. stream (unstream s) = s #-}
175+-- | The empty stream.
177+empty = Stream next () 0
179+{-# INLINE [0] empty #-}
181+-- | /O(n)/ Determines if two streams are equal.
182+eq :: Ord a => Stream a -> Stream a -> Bool
183+eq (Stream next1 s1 _) (Stream next2 s2 _) = cmp (next1 s1) (next2 s2)
185+ cmp Done Done = True
188+ cmp (Skip s1') (Skip s2') = cmp (next1 s1') (next2 s2')
189+ cmp (Skip s1') x2 = cmp (next1 s1') x2
190+ cmp x1 (Skip s2') = cmp x1 (next2 s2')
191+ cmp (Yield x1 s1') (Yield x2 s2') = x1 == x2 &&
192+ cmp (next1 s1') (next2 s2')
193+{-# SPECIALISE eq :: Stream Char -> Stream Char -> Bool #-}
175streamError :: String -> String -> a
195streamError :: String -> String -> a
176streamError func msg = P.error $ "Data.Text.Fusion." ++ func ++ ": " ++ msg
196streamError func msg = P.error $ "Data.Text.Fusion." ++ func ++ ": " ++ msg