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

Safe HaskellNone
LanguageHaskell2010

Pipes.Misc

Description

Miscellaneous utilities for pipes, required by glazier-tutorial

Synopsis

Documentation

fromInputSTM :: Input a -> Producer' a STM () Source #

Like Pipes.Concurrent.fromInput, but stays in STM. Using hoist atomically to convert to IO monad seems to work. Do not use unsafeHoist atomically.

toOutputSTM :: Output a -> Consumer' a STM () Source #

Like Pipes.Concurrent.toOutput, but stays in STM. Using hoist atomically to convert to IO monad seems to work. Do not use unsafeHoist atomically.

batch :: Input a -> Input (NonEmpty a) Source #

Reads as much as possible from an input and return a list of all unblocked values read. Blocks if the first value read is blocked.

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]'

store :: MonadState s m => Getter a b -> Setter' s b -> Pipe a a m r Source #

Store the output of the pipe into a MonadState.

retrieve :: MonadState s m => Getter s b -> Pipe a (b, a) m r Source #

Yields a view into the stored value.

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.