extensible-effects-1.9.2.2: An Alternative to Monad Transformers

Safe HaskellSafe
LanguageHaskell2010

Control.Monad.Free.Reflection

Synopsis

Documentation

data Free f a Source

The abstract Free datatype. Original work available at http://okmij.org/ftp/Haskell/AlgorithmsH1.html#reflection-without-remorse.

Instances

(MonadBase b m, Typeable (* -> *) m, SetMember ((* -> *) -> * -> *) Lift (Lift m) r) => MonadBase b (Eff r) 
Functor f => Monad (Free f) 
Functor f => Functor (Free f) 
Functor f => Applicative (Free f) 
(Typeable (* -> *) m, MonadIO m, SetMember ((* -> *) -> * -> *) Lift (Lift m) r) => MonadIO (Eff r) 
Typeable ((* -> *) -> * -> *) Free 

freePure :: a -> Free f a Source

Inject a pure value into Free

freeImpure :: f (Free f a) -> Free f a Source

Inject an impure value into Free

freeMap Source

Arguments

:: Functor f 
=> (a -> t)

function to be applied if value is Pure

-> (f (Free f a) -> t)

function to be applied on Impure value

-> Free f a

Free value to be mapped over

-> t

result

Case analysis for the Free construction. Similar in spirit to either and maybe.

data FreeView f a Source

The traditional view of Free constructions

Constructors

Pure a

case embedding pure values

Impure (f (Free f a))

case embedding impure values nested in f. Traditionally this is the Control.Monad.Free.Free constructor, but that's confusing.

Instances

Typeable ((* -> *) -> * -> *) FreeView 

fromView :: FreeView f a -> Free f a Source

A way to get a Free construction from the view by constructing an explicit expression with one element.

toView :: Functor f => Free f a -> FreeView f a Source

A way to evaluate the Free construction to its view (i.e., head normal form). This includes the logic to perform one level of monadic bind as needed from the FreeExp representation.