Safe Haskell | None |
---|---|

Language | Haskell2010 |

- buffer :: Monad m => Int -> [a] -> Pipe a [a] m r
- locally :: Monad m => (s -> a) -> (b -> s -> t) -> Pipe a b m r -> Pipe s t m r
- compare :: Monad m => (a -> a -> b) -> a -> Pipe a b m r
- compare' :: Monad m => (a -> a -> b) -> Pipe a b m r
- always :: Monad m => a -> Producer a m r
- lastOr :: Monad m => a -> Producer a m () -> Producer a m a

# 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.