tardis-0.3.0.0: Bidirectional state monad transformer

Safe HaskellSafe-Infered

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 whereSource

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 fwSource

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 bwSource

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 aSource

A Tardis is merely a pure state transformation.

Instances

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

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 aSource

Retrieve a specific view of the forwards-traveling state.

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

Retrieve a specific view of the backwards-traveling state.