aivika-0.3: A multi-paradigm simulation library

Stabilityexperimental
MaintainerDavid Sorokin <david.sorokin@gmail.com>
Safe HaskellSafe-Infered

Simulation.Aivika.Dynamics.Var

Description

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.

Synopsis

Documentation

data Var a Source

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.

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.

writeVar :: Var a -> a -> Dynamics ()Source

Write a new value into the variable.

modifyVar :: Var a -> (a -> a) -> Dynamics ()Source

Mutate the contents of the variable, forcing the bound event queue to raise all pending events in case of need.

freezeVar :: Var a -> Dynamics (Array Int Double, Array Int a)Source

Freeze the variable and return in arrays the time points and corresponded values when the variable had changed.