on master help sign in
Improve the documentation of intersperseM
a4d9e52Adithya Kumar
src/Streamly/Internal/Data/Stream/IsStream/Common.hs+7
@@ -463,6 +463,13 @@ findIndices p m = fromStreamS $ S.findIndices p (toStreamS m)
463-- >>> Stream.toList $ Stream.trace putChar $ Stream.intersperseM (putChar '.' >> return ',') $ Stream.fromList "hello"
463-- >>> Stream.toList $ Stream.trace putChar $ Stream.intersperseM (putChar '.' >> return ',') $ Stream.fromList "hello"
464-- h.,e.,l.,l.,o"h,e,l,l,o"
464-- h.,e.,l.,l.,o"h,e,l,l,o"
465--
465--
466+-- Be careful about the order of effects. In the above example we used trace
467+-- after the intersperse, if we use it before the intersperse the output would
468+-- be he.l.l.o."h,e,l,l,o".
469+--
470+-- >>> Stream.toList $ Stream.intersperseM (putChar '.' >> return ',') $ Stream.trace putChar $ Stream.fromList "hello"
471+-- he.l.l.o."h,e,l,l,o"
472+--
466-- @since 0.5.0
473-- @since 0.5.0
467{-# INLINE intersperseM #-}
474{-# INLINE intersperseM #-}
468intersperseM :: (IsStream t, MonadAsync m) => m a -> t m a -> t m a
475intersperseM :: (IsStream t, MonadAsync m) => m a -> t m a -> t m a