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

CopyrightCopyright (c) 2009-2015, 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.10.1

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 :: Ref m a -> Signal m a Source

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

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

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

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

Create a new reference.

newRef0 :: (MonadDES m, MonadRef0 m) => a -> m (Ref m a) Source

Create a new reference within more low level computation than Simulation.

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

Read the value of a reference.

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

Write a new value into the reference.

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

Mutate the contents of the reference.