coroutine-object-0.1.0: Object-oriented programming realization using coroutine

PortabilityGHC
Stabilityexperimental
MaintainerIan-Woo Kim <ianwookim@gmail.com>
Safe HaskellSafe-Inferred

Control.Monad.Trans.Crtn

Description

definition of coroutine

Synopsis

Documentation

data Yld o x Source

yield command functor

Constructors

Yld o x 

Instances

Functor (Yld o) 

type GenT o = FreeT (Yld o)Source

Generator type is single-sided coroutine which only gives an output without getting any request.

yield :: Monad m => o -> GenT o m ()Source

primitive coroutine action yielding an output

newtype Awt a x Source

await command functor for consumer coroutine

Constructors

Awt (a -> x) 

Instances

Functor (Awt g) 

type CnsmT a = FreeT (Awt a)Source

Consumer type is a single-sided coroutine which only gets an input without producing output.

await :: Monad m => CnsmT a m aSource

primitive coroutine action awaiting an input

data Rqst req ans x Source

command functor of general bidirectional coroutine

Constructors

Rqst req (ans -> x) 

Instances

Functor (Rqst req ans) 

type CrtnT req ans = FreeT (Rqst req ans)Source

general symmetric bidirectional coroutine

request :: Monad m => req -> CrtnT req ans m ansSource

primitive request coroutine

type SrvT req ans m = ReaderT req (CrtnT ans req m)Source

Server type

type CliT req ans = CrtnT req ansSource

Coroutine type is regarded as a Client type which can be paired with Server type with opposite request and answer type.

data CrtnErr r Source

type for coroutine status after execution

Instances

Show r => Show (CrtnErr r) 
Error (CrtnErr r) 

(<==|)Source

Arguments

:: Monad m 
=> SrvT req ans m r'

server coroutine

-> CliT req ans m r

client coroutine

-> ErrorT (CrtnErr r') m (SrvT req ans m r', r) 

connecting server and client in error monad

mapStateDown :: (Monad m, Functor f) => s -> FreeT f (StateT s m) a -> FreeT f m aSource

combine state and free monad with base state monad transformer with a base monad m to free monad with the base monad m Think this as fusing down the state monad