on master help sign in
Improve the documentation of intersperseM
commita4d9e5278eac4e8726887e96d9d33eb667f9827d authorAdithya Kumar <adithya@composewell.com> dateMon 21 Feb 2022, 00:15 (5 years ago) parent7594bb7
1 file changed+7
src/Streamly/Internal/Data/Stream/IsStream/Common.hs+7
src/Streamly/Internal/Data/Stream/IsStream/Common.hs+7
@@ -463,6 +463,13 @@ findIndices p m = fromStreamS $ S.findIndices p (toStreamS m)
463463-- >>> Stream.toList $ Stream.trace putChar $ Stream.intersperseM (putChar '.' >> return ',') $ Stream.fromList "hello"
464464-- h.,e.,l.,l.,o"h,e,l,l,o"
465465--
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+--
466473-- @since 0.5.0
467474{-# INLINE intersperseM #-}
468475intersperseM :: (IsStream t, MonadAsync m) => m a -> t m a -> t m a