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 HaskellSafe
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 #

Helper combinator for creating values of 'Effects effects m'

data Effects a m where #

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 #

The van Laarhoven-encoded Free Monad with Extensible effects

Constructors

Free 

Fields

Instances

Monad (Free effect) # 

Methods

(>>=) :: Free effect a -> (a -> Free effect b) -> Free effect b #

(>>) :: Free effect a -> Free effect b -> Free effect b #

return :: a -> Free effect a #

fail :: String -> Free effect a #

Functor (Free effect) # 

Methods

fmap :: (a -> b) -> Free effect a -> Free effect b #

(<$) :: a -> Free effect b -> Free effect a #

Applicative (Free effect) # 

Methods

pure :: a -> Free effect a #

(<*>) :: Free effect (a -> b) -> Free effect a -> Free effect b #

(*>) :: Free effect a -> Free effect b -> Free effect b #

(<*) :: Free effect a -> Free effect b -> Free effect a #

class HasEffect effects effect where #

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

Minimal complete definition

getEffect

Methods

getEffect :: Effects effects m -> effect m #

Instances

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

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

Methods

getEffect :: Effects ((((* -> *) -> *) ': effect) effects) m -> effect m #

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

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

Methods

getEffect :: Effects ((((* -> *) -> *) ': notIt) effects) m -> effect m #

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

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 #

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