Stability | experimental |
---|---|

Maintainer | David Sorokin <david.sorokin@gmail.com> |

Safe Haskell | None |

Tested with: GHC 7.0.3

This module defines a variable that is bound to the event queue and that keeps the history of changes storing the values in an array.

- data Var a
- varQueue :: Var a -> EventQueue
- varChanged :: Var a -> Signal a
- varChanged_ :: Var a -> Signal ()
- newVar :: EventQueue -> a -> Simulation (Var a)
- readVar :: Var a -> Dynamics a
- writeVar :: Var a -> a -> Dynamics ()
- modifyVar :: Var a -> (a -> a) -> Dynamics ()
- freezeVar :: Var a -> Dynamics (Array Int Double, Array Int a)

# Documentation

Like the `Ref`

reference but keeps the history of changes in
different time points. The `Var`

variable is safe in the hybrid
simulation and when you use different event queues, but this variable is
slower than references.

varQueue :: Var a -> EventQueueSource

Return the bound event queue.

varChanged :: Var a -> Signal aSource

Return a signal that notifies about every change of the variable state.

varChanged_ :: Var a -> Signal ()Source

Return a signal that notifies about every change of the variable state.

newVar :: EventQueue -> a -> Simulation (Var a)Source

Create a new variable bound to the specified event queue.

readVar :: Var a -> Dynamics aSource

Read the value of a variable, forcing the bound event queue to raise the events in case of need.