pipes-misc-0.3.0.0: Miscellaneous utilities for pipes, required by glazier-tutorial

Safe HaskellNone
LanguageHaskell2010

Pipes.Misc.Util

Synopsis

Documentation

buffer :: Monad m => Int -> [a] -> Pipe a [a] m r Source #

Given a size and a initial tail, create a pipe that will buffer the output of a producer. This pipe is stateful, and will only buffer until the immediate connecting producer is finished.

forever $ do
  a <- await
  yield a >-> buffer 2 [] -- will only ever result a producer of single 'a : []'.
(forever $ do
  a <- await
  yield a
) >-> buffer 2 [] -- will buffer properly and produce '[latest, old]'

locally :: Monad m => (s -> a) -> (b -> s -> t) -> Pipe a b m r -> Pipe s t m r Source #

Run a pipe in a larger stream, using view function and modify function of the larger stream.

compare :: Monad m => (a -> a -> b) -> a -> Pipe a b m r Source #

Given comparison function and an initial value. yield the result of comparing the value await with the previously awaited value.

compare' :: Monad m => (a -> a -> b) -> Pipe a b m r Source #

Given comparison function yield the result of comparing the value await with the first awaited value.

always :: Monad m => a -> Producer a m r Source #

constantly yields the given value

lastOr :: Monad m => a -> Producer a m () -> Producer a m a Source #

Makes the Producer return/pure the last value yielded, or the input value if nothing was yielded