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

Copyright(c) 2012 Ian-Woo Kim
LicenseBSD3
MaintainerIan-Woo Kim <ianwookim@gmail.com>
Stabilityexperimental
PortabilityGHC
Safe HaskellSafe-Inferred
LanguageHaskell98

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

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

primitive request coroutine

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

Server type

type CliT req ans = CrtnT req ans Source

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

data CrtnErr Source

type for coroutine status after execution

Constructors

ServerFinished 
Other String 

Instances

(<==|) Source

Arguments

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

server coroutine

-> CliT req ans m r

client coroutine

-> m (Either CrtnErr (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 a Source

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