pipes-3.0.0: Compositional pipelines

Control.Proxy.Core.Correct

Contents

Description

This module provides the correct proxy implementation which strictly enforces the monad transformer laws. You can safely import this module without violating any laws or invariants.

However, I advise that you stick to the Proxy type class API rather than import this module so that your code works with both Proxy implementations and also works with all proxy transformers.

Synopsis

# Types

data ProxyCorrect a' a b' b m r Source #

A ProxyCorrect communicates with an upstream interface and a downstream interface.

The type variables of ProxyCorrect req_a' resp_a req_b' resp_b m r signify:

• req_a' - The request supplied to the upstream interface
• resp_a - The response provided by the upstream interface
• req_b' - The request supplied by the downstream interface
• resp_b - The response provided to the downstream interface
• m  - The base monad
• r  - The final return value

Constructors

 Proxy FieldsunProxy :: m (ProxyF a' a b' b r (ProxyCorrect a' a b' b m r))

Instances

data ProxyF a' a b' b r x Source #

The base functor for the ProxyCorrect type

Constructors

 Request a' (a -> x) Respond b (b' -> x) Pure r

# Run Sessions

The following commands run self-sufficient proxies, converting them back to the base monad.

These are the only functions specific to the ProxyCorrect type. Everything else programs generically over the Proxy type class.

Use runProxyK if you are running proxies nested within proxies. It provides a Kleisli arrow as its result that you can pass to another runProxy / runProxyK command.

runProxy :: Monad m => (() -> ProxyCorrect a' () () b m r) -> m r Source #

Run a self-sufficient ProxyCorrect Kleisli arrow, converting it back to the base monad

runProxyK :: Monad m => (() -> ProxyCorrect a' () () b m r) -> () -> m r Source #

Run a self-sufficient ProxyCorrect Kleisli arrow, converting it back to a Kleisli arrow in the base monad

runPipe :: Monad m => ProxyCorrect a' () () b m r -> m r Source #

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