pipes-2.5.0: Compositional pipelines

Safe HaskellSafe-Inferred

Control.Proxy.Class

Contents

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 whereSource

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:

Methods

idT :: Monad m => a' -> p a' a a' a m rSource

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 rSource

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 rSource

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

Instances

Proxy request and respond

class Interact p whereSource

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:

 request \>\ f = f

 f \>\ request = f

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

 f />/ respond = f

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

Minimal complete definition:

Methods

request :: Monad m => a' -> p a' a x' x m aSource

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 cSource

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 cSource

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

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