index-core-1.0.1: Indexed Types

Safe HaskellSafe-Infered

Control.IMonad.Trans

Contents

Description

This module is the indexed equivalent to Control.Monad.Trans.Class from the transformers package.

Synopsis

Monad Transformers

Indexed monad transformers transform computations in a base indexed monad into a higher indexed monad layered on top of the base monad.

Note that this does not lift ordinary monads. To do that you must first convert the ordinary monad to a restricted monad using the u function from Control.IMonad.Restrict and then use liftI like so:

 -- Using indexed do notation provided by Control.IMonad.Do
 do x <- indexedActionInHigherMonad
    liftI $ u $ ordinaryActionInBaseMonad x

class IMonadTrans t whereSource

An indexed monad transformer.

All instances must satisfy the monad transformer laws:

 liftI . returnI = returnI

 liftI . (f >?> g) = (liftI . f) >?> (liftI . g)

Methods

liftI :: IMonad m => m a :-> t m aSource

liftU :: (Monad m, IMonadTrans t) => m a -> t (U m) (a := i) iSource

Lifts ordinary monads for restricted monad transformers

 liftU = liftI . u