Commits

Bryan O'Sullivan committed 4b6e795

Add streamList/unstreamList fusion rule

Comments (0)

Files changed (1)

Data/Text/Fusion/Common.hs

 {-# INLINE singleton #-}
 
 streamList :: [a] -> Stream a
-{-# INLINE streamList #-}
+{-# INLINE [0] streamList #-}
 streamList [] = empty
 streamList s  = Stream next s unknownLength
     where next []       = Done
           unknownLength = 8 -- random HINT
 
 unstreamList :: Stream a -> [a]
-{-# INLINE unstreamList #-}
+{-# INLINE [0] unstreamList #-}
 unstreamList (Stream next s0 _len) = unfold s0
     where unfold !s = case next s of
                         Done       -> []
                         Skip s'    -> unfold s'
                         Yield x s' -> x : unfold s'
 
+{-# RULES "STREAM streamList/unstreamList fusion" forall s. streamList (unstreamList s) = s #-}
+
 -- ----------------------------------------------------------------------------
 -- * Basic stream functions