pipes-2.5.0: Compositional pipelines

Safe HaskellSafe-Inferred

Control.Proxy.Pipe

Contents

Description

This module provides an API compatible with Control.Pipe

Consult Control.Pipe.Core for more extensive documentation and Control.Pipe.Tutorial for an extended tutorial.

Synopsis

Types

type Pipe a b = Proxy () a () bSource

The type variables of Pipe a b m r signify:

  • a - The type of input received from upstream pipes
  • b - The type of output delivered to downstream pipes
  • m - The base monad
  • r - The type of the return value

type Producer b = Pipe () bSource

A pipe that produces values

type Consumer a = Pipe a CSource

A pipe that consumes values

type Pipeline = Pipe () CSource

A self-contained pipeline that is ready to be run

Create Pipes

await :: Monad m => Pipe a b m aSource

Wait for input from upstream

await blocks until input is available

yield :: Monad m => b -> Pipe a b m ()Source

Deliver output downstream

yield restores control back downstream and binds the result to await.

pipe :: Monad m => (a -> b) -> Pipe a b m rSource

Convert a pure function into a pipe

Compose Pipes

(<+<) :: Monad m => Pipe b c m r -> Pipe a b m r -> Pipe a c m rSource

Corresponds to (<<<)/(.) from Control.Category

(>+>) :: Monad m => Pipe a b m r -> Pipe b c m r -> Pipe a c m rSource

Corresponds to (>>>) from Control.Category

idP :: Monad m => Pipe a a m rSource

Corresponds to id from Control.Category

Run Pipes

runPipe :: Monad m => Pipeline m r -> m rSource

Run the Pipe monad transformer, converting it back to the base monad