control-monad-free-0.5.3: Free monads and monad transformers

Control.Monad.Free

Contents

Synopsis

Documentation

Free Monads

class (Functor f, Monad m) => MonadFree f m whereSource

This type class generalizes over encodings of Free Monads.

Methods

freeSource

Arguments

:: m a 
-> m (Either a (f (m a)))

Opens a computation and allows to observe the side effects

wrapSource

Arguments

:: f (m a) 
-> m a

Wraps a side effect into a monadic computation

Instances

Functor f => MonadFree f (Free f) 
Functor f => MonadFree f (C (Free f)) 
(Functor f, Monad m) => MonadFree f (FreeT f m) 

data Free f a Source

Constructors

Impure (f (Free f a)) 
Pure a 

Instances

Functor f => MonadFree f (Free f) 
Functor f => MonadFree f (C (Free f)) 
Functor f => Monad (Free f) 
Functor f => Functor (Free f) 
(Functor f, Foldable f) => Foldable (Free f) 
Traversable f => Traversable (Free f) 
(Eq a, Eq (f (Free f a))) => Eq (Free f a) 
(Ord a, Ord (f (Free f a))) => Ord (Free f a) 
(Show a, Show (f (Free f a))) => Show (Free f a) 
(NFData a, NFData (f (Free f a))) => NFData (Free f a) 

foldFree :: Functor f => (a -> b) -> (f b -> b) -> Free f a -> bSource

evalFree :: (a -> b) -> (f (Free f a) -> b) -> Free f a -> bSource

mapFree :: (Functor f, Functor g) => (f (Free g a) -> g (Free g a)) -> Free f a -> Free g aSource

mapFreeM :: (Traversable f, Functor g, Monad m) => (f (Free g a) -> m (g (Free g a))) -> Free f a -> m (Free g a)Source

mapFreeM' :: (Functor f, Traversable g, Monad m) => (forall a. f a -> m (g a)) -> Free f a -> m (Free g a)Source

Monad Morphisms

foldFreeM :: (Traversable f, Monad m) => (a -> m b) -> (f b -> m b) -> Free f a -> m bSource

induce :: (Functor f, Monad m) => (forall a. f a -> m a) -> Free f a -> m aSource

Free Monad Transformers

newtype FreeT f m a Source

Constructors

FreeT 

Fields

unFreeT :: m (Either a (f (FreeT f m a)))
 

Instances

(Functor f, Monad m) => MonadFree f (FreeT f m) 
Functor f => MonadTrans (FreeT f) 
(Functor f, Monad m) => Monad (FreeT f m) 
(Functor f, Functor m) => Functor (FreeT f m) 
(Traversable m, Traversable f) => Foldable (FreeT f m) 
(Traversable m, Traversable f) => Traversable (FreeT f m) 

foldFreeT :: (Traversable f, Monad m) => (a -> m b) -> (f b -> m b) -> FreeT f m a -> m bSource

foldFreeT' :: (Traversable f, Monad m) => (a -> b) -> (f b -> b) -> FreeT f m a -> m bSource

mapFreeT :: (Functor f, Functor m) => (forall a. m a -> m' a) -> FreeT f m a -> FreeT f m' aSource

Translate between Free monad and Free monad transformer computations

trans :: (Functor f, Monad m) => Free f a -> FreeT f m aSource

trans' :: (Functor f, Monad m) => m (Free f a) -> FreeT f m aSource

untrans :: (Traversable f, Monad m) => FreeT f m a -> m (Free f a)Source

liftFree :: (Functor f, Monad m) => (a -> Free f b) -> a -> FreeT f m bSource