@@ -89,6 +89,10 @@ module Streamly.Internal.Data.Stream.StreamK.Type
92 -- * Interleave
96 -- * Interleave
93 , interleave
97 , interleave
94 , interleaveFst
98 , interleaveFst
@@ -1375,6 +1379,30 @@ foldlS step = go
1375reverse :: Stream m a -> Stream m a
1379reverse :: Stream m a -> Stream m a
1376reverse = foldlS (flip cons) nil
1380reverse = foldlS (flip cons) nil
1382+------------------------------------------------------------------------------
1383+-- Runnining effects
1384+------------------------------------------------------------------------------
1386+-- | Run an action before evaluating the stream.
1387+{-# INLINE before #-}
1388+before :: Monad m => m b -> Stream m a -> Stream m a
1389+before action stream =
1390+ mkStream $ \st yld sng stp ->
1391+ action >> foldStreamShared st yld sng stp stream
1393+-- | concat . fromEffect
1394+{-# INLINE concatEffect #-}
1395+concatEffect :: Monad m => m (Stream m a) -> Stream m a
1396+concatEffect action =
1397+ mkStream $ \st yld sng stp ->
1398+ action >>= foldStreamShared st yld sng stp
1400+{-# INLINE concatMapEffect #-}
1401+concatMapEffect :: Monad m => (b -> Stream m a) -> m b -> Stream m a
1402+concatMapEffect f action =
1403+ mkStream $ \st yld sng stp ->
1404+ action >>= foldStreamShared st yld sng stp . f
1378------------------------------------------------------------------------------
1406------------------------------------------------------------------------------
1379-- Lifting inner monad
1407-- Lifting inner monad
1380------------------------------------------------------------------------------
1408------------------------------------------------------------------------------