pipes-3.1.0: Compositional pipelines

Safe HaskellSafe
LanguageHaskell98

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 

Fields

Instances

MonadIOP ProxyCorrect Source # 

Methods

liftIO_P :: MonadIO m => IO r -> ProxyCorrect a' a b' b m r Source #

Interact ProxyCorrect Source # 

Methods

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

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

Proxy ProxyCorrect Source # 

Methods

request :: Monad m => a' -> ProxyCorrect a' a b' b m a Source #

respond :: Monad m => b -> ProxyCorrect a' a b' b m b' Source #

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

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

return_P :: Monad m => r -> ProxyCorrect a' a b' b m r Source #

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

lift_P :: Monad m => m r -> ProxyCorrect a' a b' b m r Source #

hoist_P :: Monad m => (forall r. m r -> n r) -> ProxyCorrect a' a b' b m r' -> ProxyCorrect a' a b' b n r' Source #

MonadTrans (ProxyCorrect a' a b' b) Source # 

Methods

lift :: Monad m => m a -> ProxyCorrect a' a b' b m a #

MFunctor (ProxyCorrect a' a b' b) Source # 

Methods

hoist :: Monad m => (forall c. m c -> n c) -> ProxyCorrect a' a b' b m b -> ProxyCorrect a' a b' b n b Source #

Monad m => Monad (ProxyCorrect a' a b' b m) Source # 

Methods

(>>=) :: ProxyCorrect a' a b' b m a -> (a -> ProxyCorrect a' a b' b m b) -> ProxyCorrect a' a b' b m b #

(>>) :: ProxyCorrect a' a b' b m a -> ProxyCorrect a' a b' b m b -> ProxyCorrect a' a b' b m b #

return :: a -> ProxyCorrect a' a b' b m a #

fail :: String -> ProxyCorrect a' a b' b m a #

Monad m => Functor (ProxyCorrect a' a b' b m) Source # 

Methods

fmap :: (a -> b) -> ProxyCorrect a' a b' b m a -> ProxyCorrect a' a b' b m b #

(<$) :: a -> ProxyCorrect a' a b' b m b -> ProxyCorrect a' a b' b m a #

Monad m => Applicative (ProxyCorrect a' a b' b m) Source # 

Methods

pure :: a -> ProxyCorrect a' a b' b m a #

(<*>) :: ProxyCorrect a' a b' b m (a -> b) -> ProxyCorrect a' a b' b m a -> ProxyCorrect a' a b' b m b #

(*>) :: ProxyCorrect a' a b' b m a -> ProxyCorrect a' a b' b m b -> ProxyCorrect a' a b' b m b #

(<*) :: ProxyCorrect a' a b' b m a -> ProxyCorrect a' a b' b m b -> ProxyCorrect a' a b' b m a #

MonadIO m => MonadIO (ProxyCorrect a' a b' b m) Source # 

Methods

liftIO :: IO a -> ProxyCorrect a' a b' b m a #

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