on master help sign in
Get 'replicateM' to specialize
3d1ed12Artyom Kazak
src/Streamly/Streams/StreamD.hs+3−2
@@ -273,7 +273,7 @@ import qualified Control.Monad.Catch as MC
273import Streamly.Mem.Array.Types (Array(..))
273import Streamly.Mem.Array.Types (Array(..))
274import Streamly.Fold.Types (Fold(..))
274import Streamly.Fold.Types (Fold(..))
275import Streamly.Pipe.Types (Pipe(..), PipeState(..))
275import Streamly.Pipe.Types (Pipe(..), PipeState(..))
276−import Streamly.SVar (MonadAsync, defState, adaptState)
276+import Streamly.SVar (MonadAsync, defState, adaptState, State)
277
277
278import Streamly.Streams.StreamD.Type
278import Streamly.Streams.StreamD.Type
279
279
@@ -366,10 +366,11 @@ repeat :: Monad m => a -> Stream m a
366repeat x = Stream (\_ _ -> return $ Yield x ()) ()
366repeat x = Stream (\_ _ -> return $ Yield x ()) ()
367
367
368{-# INLINE_NORMAL replicateM #-}
368{-# INLINE_NORMAL replicateM #-}
369−replicateM :: Monad m => Int -> m a -> Stream m a
369+replicateM :: forall m a. Monad m => Int -> m a -> Stream m a
370replicateM n p = Stream step n
370replicateM n p = Stream step n
371 where
371 where
372 {-# INLINE_LATE step #-}
372 {-# INLINE_LATE step #-}
373+ step :: State K.Stream m a -> Int -> m (Step Int a)
373 step _ i | i <= 0 = return Stop
374 step _ i | i <= 0 = return Stop
374 | otherwise = do
375 | otherwise = do
375 x <- p
376 x <- p