Bryan O'Sullivan avatar Bryan O'Sullivan committed d87677c

Apply Nicolas's stream equality fix

Comments (0)

Files changed (2)

Data/Text/Fusion.hs

 {-# INLINE [0] unstream #-}
 {-# RULES "STREAM stream/unstream fusion" forall s. stream (unstream s) = s #-}
 
--- | The empty stream.
-empty :: Stream Char
-empty = Stream next () 0
-    where next _ = Done
-{-# INLINE [0] empty #-}
-
--- | /O(n)/ Determines if two streams are equal.
-eq :: Ord a => Stream a -> Stream a -> Bool
-eq (Stream next1 s1 _) (Stream next2 s2 _) = cmp (next1 s1) (next2 s2)
-    where
-      cmp Done Done = True
-      cmp Done _    = False
-      cmp _    Done = False
-      cmp (Skip s1')     (Skip s2')     = cmp (next1 s1') (next2 s2')
-      cmp (Skip s1')     x2             = cmp (next1 s1') x2
-      cmp x1             (Skip s2')     = cmp x1          (next2 s2')
-      cmp (Yield x1 s1') (Yield x2 s2') = x1 == x2 &&
-                                          cmp (next1 s1') (next2 s2')
-{-# SPECIALISE eq :: Stream Char -> Stream Char -> Bool #-}
-
 streamError :: String -> String -> a
 streamError func msg = P.error $ "Data.Text.Fusion." ++ func ++ ": " ++ msg
 

Data/Text/Fusion/Internal.hs

 {-# INLINE [0] empty #-}
 
 -- | /O(n)/ Determines if two streams are equal.
-eq :: Ord a => Stream a -> Stream a -> Bool
-{-# INLINE eq #-}
+eq :: (Eq a) => Stream a -> Stream a -> Bool
 eq (Stream next1 s1 _) (Stream next2 s2 _) = cmp (next1 s1) (next2 s2)
     where
-      cmp Done Done = True
-      cmp Done _    = False
-      cmp _    Done = False
+      cmp Done Done                     = True
       cmp (Skip s1')     (Skip s2')     = cmp (next1 s1') (next2 s2')
       cmp (Skip s1')     x2             = cmp (next1 s1') x2
       cmp x1             (Skip s2')     = cmp x1          (next2 s2')
+      cmp Done _                        = False
+      cmp _    Done                     = False
       cmp (Yield x1 s1') (Yield x2 s2') = x1 == x2 &&
                                           cmp (next1 s1') (next2 s2')
+{-# INLINE [0] eq #-}
+{-# SPECIALISE eq :: Stream Char -> Stream Char -> Bool #-}
 
 streamList :: [a] -> Stream a
 {-# INLINE streamList #-}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.