monad-coroutine-0.5.1: Coroutine monad transformer for suspending and resuming monadic computations

Control.Monad.Coroutine.SuspensionFunctors

Contents

Description

This module defines suspension functors for use with the Control.Monad.Coroutine module.

Synopsis

Suspension functors

data Yield x y Source

The Yield functor instance is equivalent to (,) but more descriptive.

Constructors

Yield x y 

Instances

newtype Await x y Source

The Await functor instance is equivalent to (->) but more descriptive.

Constructors

Await (x -> y) 

Instances

data Request request response x Source

The Request functor instance combines a Yield of a request with an Await for a response.

Constructors

Request request (response -> x) 

Instances

data EitherFunctor l r x Source

Combines two alternative functors into one, applying one or the other. Used for nested coroutines.

Constructors

LeftF (l x) 
RightF (r x) 

Instances

(Functor l, Functor r) => Functor (EitherFunctor l r) 
(Functor p, Functor s) => ChildFunctor (EitherFunctor p s) 

yield :: Monad m => x -> Coroutine (Yield x) m ()Source

Suspend yielding a value.

await :: Monad m => Coroutine (Await x) m xSource

Suspend until a value is provided.

request :: Monad m => x -> Coroutine (Request x y) m ySource

Suspend yielding a request and awaiting the response.