on master help sign in
Fix a bug in zipWithM rule that causes effects to run only once.
commita4464a87961f441b1661a5defe2aff42790b8347 authorPranay Sashank <pranaysashank@gmail.com> dateFri 2 Aug 2019, 01:34 (7 years ago) parentde908d6
1 file changed+3−1
src/Streamly/Streams/StreamD.hs+3−1
src/Streamly/Streams/StreamD.hs+3−1
@@ -11,6 +11,7 @@
1111{-# LANGUAGE ViewPatterns #-}
1212{-# LANGUAGE RankNTypes #-}
1313{-# LANGUAGE MagicHash #-}
14+{-# LANGUAGE TypeApplications #-}
1415
1516#include "inline.hs"
1617
@@ -255,6 +256,7 @@ import Control.Monad.Catch (MonadCatch)
255256import Control.Monad.IO.Class (MonadIO(..))
256257import Control.Monad.Trans (MonadTrans(lift))
257258import Data.Bits (shiftR, shiftL, (.|.), (.&.))
259+import Data.Functor.Identity (Identity)
258260import Data.Maybe (fromJust, isJust)
259261import Data.Word (Word32)
260262import Foreign.Ptr (Ptr)
@@ -2353,7 +2355,7 @@ zipWithM f (Stream stepa ta) (Stream stepb tb) = Stream step (ta, tb, Nothing)
23532355 Stop -> return Stop
23542356
23552357{-# RULES "zipWithM xs xs"
2356− forall f xs. zipWithM f xs xs = mapM (\x -> f x x) xs #-}
2358+ forall f xs. zipWithM @Identity f xs xs = mapM (\x -> f x x) xs #-}
23572359
23582360{-# INLINE zipWith #-}
23592361zipWith :: Monad m => (a -> b -> c) -> Stream m a -> Stream m b -> Stream m c