tardis-0.4.1.0: Bidirectional state monad transformer

Safe HaskellSafe
LanguageHaskell98

Control.Monad.Tardis.Class

Contents

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 #

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").

Methods

getPast :: m fw #

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 #

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 () #

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 () #

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 #

A Tardis is merely a pure state transformation.

Instances

MonadFix m => MonadTardis bw fw (TardisT bw fw m) # 

Methods

getPast :: TardisT bw fw m fw #

getFuture :: TardisT bw fw m bw #

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

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

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

Composite Tardis operations

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

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

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

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

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

Retrieve a specific view of the forwards-traveling state.

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

Retrieve a specific view of the backwards-traveling state.