aivika-transformers-2.0: Transformers for the Aivika simulation library

CopyrightCopyright (c) 2009-2014, David Sorokin <david.sorokin@gmail.com>
LicenseBSD3
MaintainerDavid Sorokin <david.sorokin@gmail.com>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Simulation.Aivika.Trans.Ref

Description

Tested with: GHC 7.8.3

This module defines an updatable reference that depends on the event queue.

Synopsis

Documentation

data Ref m a Source

The Ref type represents a mutable variable similar to the IORef variable but only dependent on the event queue, which allows synchronizing the reference with the model explicitly through the Event monad.

Instances

refChanged :: MonadComp m => Ref m a -> Signal m a Source

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

refChanged_ :: MonadComp m => Ref m a -> Signal m () Source

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

newRef :: MonadComp m => a -> Simulation m (Ref m a) Source

Create a new reference.

readRef :: MonadComp m => Ref m a -> Event m a Source

Read the value of a reference.

writeRef :: MonadComp m => Ref m a -> a -> Event m () Source

Write a new value into the reference.

modifyRef :: MonadComp m => Ref m a -> (a -> a) -> Event m () Source

Mutate the contents of the reference.