extensible-effects-1.11.1.0: 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

Functor f => Monad (Free f) Source # 

Methods

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

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

return :: a -> Free f a #

fail :: String -> Free f a #

Functor f => Functor (Free f) Source # 

Methods

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

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

Functor f => Applicative (Free f) Source # 

Methods

pure :: a -> Free f a #

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

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

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

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.

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.