freer-simple-1.2.1.2: A friendly effect system for Haskell.
Copyright (c) 2016 Allele Dev; 2017 Ixperta Solutions s.r.o.; 2017 Alexis King
License BSD3
Maintainer Alexis King <lexi.lambda@gmail.com>
Stability experimental
Portability GHC specific language extensions.
Safe Haskell None
Language Haskell2010

Control.Monad.Freer.Coroutine

Description

An effect to compose functions with the ability to yield.

Using http://okmij.org/ftp/Haskell/extensible/Eff1.hs as a starting point.

Synopsis

Yield Control

data Yield a b c Source #

A type representing a yielding of control.

Type variables have following meaning:

a
The current type.
b
The input to the continuation function.
c
The output of the continuation.

Constructors

Yield a (b -> c)

Instances

Instances details
Functor ( Yield a b) Source #
Instance details

Defined in Control.Monad.Freer.Coroutine

Methods

fmap :: (a0 -> b0) -> Yield a b a0 -> Yield a b b0 Source #

(<$) :: a0 -> Yield a b b0 -> Yield a b a0 Source #

yield :: Member ( Yield a b) effs => a -> (b -> c) -> Eff effs c Source #

Lifts a value and a function into the Coroutine effect.

Handle Yield Effect

data Status effs a b r Source #

Represents status of a coroutine.

Constructors

Done r

Coroutine is done with a result value of type r .

Continue a (b -> Eff effs ( Status effs a b r))

Reporting a value of the type a , and resuming with the value of type b , possibly ending with a value of type x .

runC :: Eff ( Yield a b ': effs) r -> Eff effs ( Status effs a b r) Source #

Launch a coroutine and report its status.

interposeC :: Member ( Yield a b) effs => Eff effs r -> Eff effs ( Status effs a b r) Source #

Launch a coroutine and report its status, without handling (removing) Yield from the typelist. This is useful for reducing nested coroutines.

replyC :: Yield a b c -> (c -> Eff effs ( Status effs a b r)) -> Eff effs ( Status effs a b r) Source #

Reply to a coroutine effect by returning the Continue constructor.