Module

Control.Monad.Free.Trans

This module defines a stack-safe implementation of the free monad transformer.

#FreeT

data FreeT f m a

The free monad transformer for the functor f.

Instances

#freeT

freeT :: forall f m a. (Unit -> m (Either a (f (FreeT f m a)))) -> FreeT f m a

Construct a computation of type FreeT.

#liftFreeT

liftFreeT :: forall f m a. Functor f => Monad m => f a -> FreeT f m a

Lift an action from the functor f to a FreeT action.

#hoistFreeT

hoistFreeT :: forall f m n a. Functor f => Functor n => (m ~> n) -> FreeT f m a -> FreeT f n a

Change the underlying Monad for a FreeT action.

#interpret

interpret :: forall f g m a. Functor f => Functor m => (f ~> g) -> FreeT f m a -> FreeT g m a

Change the base functor f for a FreeT action.

#bimapFreeT

bimapFreeT :: forall f g m n a. Functor f => Functor n => (f ~> g) -> (m ~> n) -> FreeT f m a -> FreeT g n a

Change the base functor f and the underlying Monad for a FreeT action.

#substFreeT

substFreeT :: forall a m f g. Monad m => Functor g => (f ~> (FreeT g m)) -> FreeT f m a -> FreeT g m a

Like runFreeT, but for running into some other FreeT without the overhead that MonadRec incurs.

#resume

resume :: forall f m a. Functor f => MonadRec m => FreeT f m a -> m (Either a (f (FreeT f m a)))

Unpack FreeT, exposing the first step of the computation.

#runFreeT

runFreeT :: forall f m a. Functor f => MonadRec m => (f (FreeT f m a) -> m (FreeT f m a)) -> FreeT f m a -> m a

Run a FreeT computation to completion.

Modules