Module

Control.Monad.Free.Trans

Package
purescript-freet
Repository
purescript-contrib/purescript-freet

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

#FreeT Source

data FreeT :: (Type -> Type) -> (Type -> Type) -> Type -> Typedata FreeT f m a

The free monad transformer for the functor f.

Instances

#freeT Source

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 Source

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 Source

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 Source

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 Source

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 Source

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 Source

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 Source

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.