extensible-effects- An Alternative to Monad Transformers

Safe HaskellSafe




data Free f a Source

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


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


:: 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


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

data FreeView f a Source

The traditional view of Free constructions


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.

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.