mapM package:streaming

Replace each element of a stream with the result of a monadic action
>>> S.print $ S.mapM readIORef $ S.chain (\ior -> modifyIORef ior (*100)) $ S.mapM newIORef $ each [1..6]
100
200
300
400
500
600
See also chain for a variant of this which ignores the return value of the function and just uses the side effects.
Reduce a stream to its return value with a monadic action.
>>> S.mapM_ Prelude.print $ each [1..3]
1
2
3
>>> rest <- S.mapM_ Prelude.print $ S.splitAt 3 $ each [1..10]
1
2
3

>>> S.sum rest
49 :> ()
The mapMaybe function is a version of map which can throw out elements. In particular, the functional argument returns something of type Maybe b. If this is Nothing, no element is added on to the result Stream. If it is Just b, then b is included in the result Stream.
Map monadically over a stream, producing a new stream only containing the Just values.