on master help sign in
Apply Nicolas's stream equality fix
37fc6b2Bryan O'Sullivan
Data/Text/Fusion.hs−20
@@ -172,26 +172,6 @@ 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 #-}
174
174
175−-- | The empty stream.
176−empty :: Stream Char
177−empty = Stream next () 0
178− where next _ = Done
179−{-# INLINE [0] empty #-}
180−
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)
184− where
185− cmp Done Done = True
186− cmp Done _ = False
187− cmp _ Done = False
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 #-}
194−
195streamError :: String -> String -> a
175streamError :: String -> String -> a
196streamError func msg = P.error $ "Data.Text.Fusion." ++ func ++ ": " ++ msg
176streamError func msg = P.error $ "Data.Text.Fusion." ++ func ++ ": " ++ msg
197
177
Data/Text/Fusion/Internal.hs+6−5
@@ -67,18 +67,19 @@ empty = Stream next () 0
67{-# INLINE [0] empty #-}
67{-# INLINE [0] empty #-}
68
68
69-- | /O(n)/ Determines if two streams are equal.
69-- | /O(n)/ Determines if two streams are equal.
70−eq :: Ord a => Stream a -> Stream a -> Bool
70+eq :: (Eq a) => Stream a -> Stream a -> Bool
71−{-# INLINE eq #-}
72eq (Stream next1 s1 _) (Stream next2 s2 _) = cmp (next1 s1) (next2 s2)
71eq (Stream next1 s1 _) (Stream next2 s2 _) = cmp (next1 s1) (next2 s2)
73 where
72 where
74− cmp Done Done = True
73+ cmp Done Done = True
75− cmp Done _ = False
76− cmp _ Done = False
77 cmp (Skip s1') (Skip s2') = cmp (next1 s1') (next2 s2')
74 cmp (Skip s1') (Skip s2') = cmp (next1 s1') (next2 s2')
78 cmp (Skip s1') x2 = cmp (next1 s1') x2
75 cmp (Skip s1') x2 = cmp (next1 s1') x2
79 cmp x1 (Skip s2') = cmp x1 (next2 s2')
76 cmp x1 (Skip s2') = cmp x1 (next2 s2')
77+ cmp Done _ = False
78+ cmp _ Done = False
80 cmp (Yield x1 s1') (Yield x2 s2') = x1 == x2 &&
79 cmp (Yield x1 s1') (Yield x2 s2') = x1 == x2 &&
81 cmp (next1 s1') (next2 s2')
80 cmp (next1 s1') (next2 s2')
81+{-# INLINE [0] eq #-}
82+{-# SPECIALISE eq :: Stream Char -> Stream Char -> Bool #-}
82
83
83streamList :: [a] -> Stream a
84streamList :: [a] -> Stream a
84{-# INLINE streamList #-}
85{-# INLINE streamList #-}