tardis-0.4.3.0: Bidirectional state monad transformer
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Monad.Tardis.Class

Description

The class definition of a Tardis, as well as a few straightforward combinators based on its primitives.

See Control.Monad.Tardis for the general explanation of what a Tardis is and how to use it.

Synopsis

The MonadTardis class

class (Applicative m, MonadFix m) => MonadTardis bw fw m | m -> bw, m -> fw where Source #

A Tardis is parameterized by two state streams: a 'backwards-traveling' state and a 'forwards-traveling' state. This library consistently puts the backwards-traveling state first whenever the two are seen together.

Minimal complete definition: ("tardis") or ("getPast", "getFuture", "sendPast", and "sendFuture").

Minimal complete definition

Nothing

Methods

getPast :: m fw Source #

Retrieve the current value of the 'forwards-traveling' state, which therefore came forwards from the past. You can think of forwards-traveling state as traveling downwards through your code.

getFuture :: m bw Source #

Retrieve the current value of the 'backwards-traveling' state, which therefore came backwards from the future. You can think of backwards-traveling state as traveling upwards through your code.

sendPast :: bw -> m () Source #

Set the current value of the 'backwards-traveling' state, which will therefore be sent backwards to the past. This value can be retrieved by calls to "getFuture" located above the current location, unless it is overwritten by an intervening "sendPast".

sendFuture :: fw -> m () Source #

Set the current value of the 'forwards-traveling' state, which will therefore be sent forwards to the future. This value can be retrieved by calls to "getPast" located below the current location, unless it is overwritten by an intervening "sendFuture".

tardis :: ((bw, fw) -> (a, (bw, fw))) -> m a Source #

A Tardis is merely a pure state transformation.

Instances

Instances details
MonadFix m => MonadTardis bw fw (TardisT bw fw m) Source # 
Instance details

Defined in Control.Monad.Tardis.Class

Methods

getPast :: TardisT bw fw m fw Source #

getFuture :: TardisT bw fw m bw Source #

sendPast :: bw -> TardisT bw fw m () Source #

sendFuture :: fw -> TardisT bw fw m () Source #

tardis :: ((bw, fw) -> (a, (bw, fw))) -> TardisT bw fw m a Source #

Composite Tardis operations

modifyForwards :: MonadTardis bw fw m => (fw -> fw) -> m () Source #

Modify the forwards-traveling state as it passes through from past to future.

modifyBackwards :: MonadTardis bw fw m => (bw -> bw) -> m () Source #

Modify the backwards-traveling state as it passes through from future to past.

getsPast :: MonadTardis bw fw m => (fw -> a) -> m a Source #

Retrieve a specific view of the forwards-traveling state.

getsFuture :: MonadTardis bw fw m => (bw -> a) -> m a Source #

Retrieve a specific view of the backwards-traveling state.