pipes-2.5.0: Compositional pipelines

Control.Proxy.Class

Description

This module provides an abstract interface to Proxy-like behavior, so that multiple proxy implementations can share the same library of utility proxies.

Synopsis

# Proxy composition

class Channel p where Source #

The Channel class defines an interface to a bidirectional flow of information.

Laws:

• (>->) and idT form a category:
idT >-> f = f

f >-> idT = f

(f >-> g) >-> h = f >-> (g >-> h)

Minimal complete definition:

• idT
• (>->) or (<-<).

Minimal complete definition

idT

Methods

idT :: Monad m => a' -> p a' a a' a m r Source #

idT acts like a 'T'ransparent proxy, passing all requests further upstream, and passing all responses further downstream.

(>->) :: Monad m => (b' -> p a' a b' b m r) -> (c' -> p b' b c' c m r) -> c' -> p a' a c' c m r infixl 7 Source #

Compose two proxies, satisfying all requests from downstream with responses from upstream.

(<-<) :: Monad m => (c' -> p b' b c' c m r) -> (b' -> p a' a b' b m r) -> c' -> p a' a c' c m r infixr 7 Source #

Compose two proxies, satisfying all requests from downstream with responses from upstream.

Instances

# Proxy request and respond

class Interact p where Source #

The Interact class defines the ability to:

• Request input using the request command
• Replace existing request commands using (\>\)
• Respond with output using the respond command
• Replace existing respond commands using (/>/)

Laws:

• (\>\) and request form a category:
request \>\ f = f

f \>\ request = f

(f \>\ g) \>\ h = f \>\ (g \>\ h)
• (/>/) and respond form a category:
respond />/ f = f

f />/ respond = f

(f />/ g) />/ h = f />/ (g />/ h)

Minimal complete definition:

• request,
• (\>\) or (/</),
• respond, and
• (/>/) or (\<\).

Minimal complete definition

Methods

request :: Monad m => a' -> p a' a x' x m a Source #

request input from upstream, passing an argument with the request

request a' passes a' as a parameter to upstream that upstream may use to decide what response to return. request binds the upstream's response to its own return value.

(\>\) :: Monad m => (b' -> p a' a x' x m b) -> (c' -> p b' b x' x m c) -> c' -> p a' a x' x m c infixl 8 Source #

f \>\ g replaces all requests in g with f.

(/</) :: Monad m => (c' -> p b' b x' x m c) -> (b' -> p a' a x' x m b) -> c' -> p a' a x' x m c infixr 8 Source #

f /</ g replaces all requests in f with g.

respond :: Monad m => a -> p x' x a' a m a' Source #

respond with an output for downstream and bind downstream's next request

respond b satisfies a downstream request by supplying the value b respond blocks until downstream requests a new value and binds the argument from the next request as its return value.

(/>/) :: Monad m => (a -> p x' x b' b m a') -> (b -> p x' x c' c m b') -> a -> p x' x c' c m a' infixr 8 Source #

f />/ g replaces all responds in f with g.

(\<\) :: Monad m => (b -> p x' x c' c m b') -> (a -> p x' x b' b m a') -> a -> p x' x c' c m a' infixl 8 Source #

f \<\ g replaces all responds in g with f.

Instances