Safe Haskell | Safe-Infered |
---|
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.
- class (Applicative m, MonadFix m) => MonadTardis bw fw m | m -> bw, m -> fw where
- modifyForwards :: MonadTardis bw fw m => (fw -> fw) -> m ()
- modifyBackwards :: MonadTardis bw fw m => (bw -> bw) -> m ()
- getsPast :: MonadTardis bw fw m => (fw -> a) -> m a
- getsFuture :: MonadTardis bw fw m => (bw -> a) -> m a
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).
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.
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.
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.
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.