free-vl-0.1.4: van Laarhoven encoded Free Monad with Extensible Effects

Copyright(C) 2016 Aaron Levin
LicenseBSD-style (see the file LICENSE)
MaintainerAaron Levin <aaron.michael.benjamin.levin@gmail.com>
Stabilityprovisional
Portabilitynon-portable (rank-2 polymorphism)
Safe HaskellNone
LanguageHaskell2010

Control.Monad.Free.VanLaarhovenE

Description

"van Laarhoven encoded Free Monad with extensible effects"

Synopsis

Documentation

(.:.) :: effect m -> Effects effects m -> Effects (effect : effects) m infixr 4 Source

Helper combinator for creating values of 'Effects effects m'

data Effects a m where Source

a customized HList of effects. We need to carry the m param around for type inference.

Constructors

EmptyE :: Effects `[]` m 
ConsE :: effect m -> Effects effects m -> Effects (effect : effects) m 

newtype Free effects a Source

The van Laarhoven-encoded Free Monad with Extensible effects

Constructors

Free 

Fields

runFree :: forall m. Monad m => Effects effects m -> m a
 

Instances

Monad (Free effect) Source 
Functor (Free effect) Source 
Applicative (Free effect) Source 

class HasEffect effects effect where Source

A class to help us fetch effects from our effect stack.

Methods

getEffect :: Effects effects m -> effect m Source

Instances

HasEffect ((:) ((* -> *) -> *) effect effects) effect Source

An instance of HasEffect that handles the case where our desired effect type matches the head of the list. We then return that effect.

HasEffect effects effect => HasEffect ((:) ((* -> *) -> *) notIt effects) effect Source

An instance of HasEffect that handles the case where our desired effect type doesn't match the head of the HList.

iterM :: Monad m => Effects effects m -> Free effects a -> m a Source

Tear down a Free Monad using the supplied effects value.

liftF :: HasEffect effects effect => (forall m. Monad m => effect m -> m a) -> Free effects a Source

A version of lift that can be used with an effect stack.