supervisor-0.1.1.0: Control an internal monad execution for trace generation, backtrakcking, testing and other purposes

Safe HaskellNone

Control.Monad.Supervisor

Description

A supervisor monad that explore the execution tree of an internal monad and define extra behaviours thanks to flexible instance definitions for each particular purpose. It can inject new behaviours for backtracking, trace generation, testing, transaction rollbacks etc The supervisor monad is used in the package MFlow to control the routing, tracing, state management, back button management and navigation in general

Synopsis

Documentation

(!>) :: c -> String -> cSource

data Control a Source

The internal computation can be reexecuted, proceed forward or backward

Constructors

Control a 
Forward a 
Backward 

Instances

newtype Sup s m a Source

The supervisor add a Control wrapper that is interpreted by the monad instance

Constructors

Sup 

Fields

runSup :: m (Control a)
 

Instances

Supervise s m => MonadState s (Sup s m) 
MonadTrans (Sup s) 
Supervise s m => Monad (Sup s m)

The Supervisor Monad is in essence an Identity monad transformer when executing Forward.

(MonadIO m, Supervise s m) => MonadIO (Sup s m) 

class MonadState s m => Supervise s m whereSource

The supervise class add two general modifiers that can be applied:

Methods

supBackSource

Arguments

:: s 
-> m ()

Called before initiating backtracking in a control point When the computation goes back, by default the state is kepth. This procedure can change that behaviour. The state passed is the one before the computation was executed.

superviseSource

Arguments

:: s 
-> m (Control a) 
-> m (Control a)

When the conputation has been executed this method is an opportunity for modifying the result By default: supervise _= id

breturn :: Monad m => a -> Sup s m aSource

Flag the computation that executes breturn as a control point.

When the computation is going back, it will be re-executed (see the monad definition)