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

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

Safe Haskell | None |

Tested with: GHC 7.4.1

This module defines the signal which we can subscribe handlers to. These handlers can be disposed. The signal is triggered in the current time point actuating the corresponded computations from the handlers.

- data Signal a
- data SignalSource a
- newSignalSource :: EventQueue -> Simulation (SignalSource a)
- newSignalSourceWithUpdate :: Dynamics () -> Simulation (SignalSource a)
- publishSignal :: SignalSource a -> Signal a
- triggerSignal :: SignalSource a -> a -> Dynamics ()
- handleSignal :: Signal a -> (a -> Dynamics ()) -> Simulation (Simulation ())
- handleSignal_ :: Signal a -> (a -> Dynamics ()) -> Simulation ()
- updateSignal :: Signal a -> Dynamics ()
- awaitSignal :: Signal a -> Process a
- mapSignal :: (a -> b) -> Signal a -> Signal b
- composeSignal :: (a -> Dynamics b) -> Signal a -> Signal b
- apSignal :: Dynamics (a -> b) -> Signal a -> Signal b
- filterSignal :: (a -> Bool) -> Signal a -> Signal a
- merge2Signals :: Signal a -> Signal a -> Signal a
- merge3Signals :: Signal a -> Signal a -> Signal a -> Signal a
- merge4Signals :: Signal a -> Signal a -> Signal a -> Signal a -> Signal a
- merge5Signals :: Signal a -> Signal a -> Signal a -> Signal a -> Signal a -> Signal a
- data SignalHistory a
- signalHistorySignal :: SignalHistory a -> Signal a
- newSignalHistory :: Signal a -> Simulation (SignalHistory a)
- readSignalHistory :: SignalHistory a -> Dynamics (Array Int Double, Array Int a)

# Documentation

data SignalSource a Source

The signal source that can publish its signal.

newSignalSource :: EventQueue -> Simulation (SignalSource a)Source

Create a new signal source when the state depends on the event queue.

newSignalSourceWithUpdate :: Dynamics () -> Simulation (SignalSource a)Source

Create a new signal source with the specified update computation.

publishSignal :: SignalSource a -> Signal aSource

Publish the signal.

triggerSignal :: SignalSource a -> a -> Dynamics ()Source

Trigger the signal actuating all its handlers at the current simulation time point.

handleSignal :: Signal a -> (a -> Dynamics ()) -> Simulation (Simulation ())Source

Subscribe the handler to the specified signal and return a nested computation that, being applied, unsubscribes the handler from this signal.

handleSignal_ :: Signal a -> (a -> Dynamics ()) -> Simulation ()Source

Subscribe the handler to the specified signal.
To subscribe the disposable handlers, use function `handleSignal`

.

updateSignal :: Signal a -> Dynamics ()Source

Update the signal to its actual state.

awaitSignal :: Signal a -> Process aSource

Await the signal.

composeSignal :: (a -> Dynamics b) -> Signal a -> Signal bSource

Compose the signal.

filterSignal :: (a -> Bool) -> Signal a -> Signal aSource

Filter only those signal values that satisfy to the specified predicate.

merge2Signals :: Signal a -> Signal a -> Signal aSource

Merge two signals.

merge5Signals :: Signal a -> Signal a -> Signal a -> Signal a -> Signal a -> Signal aSource

Merge five signals.

data SignalHistory a Source

Represents the history of the signal values.

signalHistorySignal :: SignalHistory a -> Signal aSource

The signal for which the history is created.

newSignalHistory :: Signal a -> Simulation (SignalHistory a)Source

Create a history of the signal values.

readSignalHistory :: SignalHistory a -> Dynamics (Array Int Double, Array Int a)Source

Read the history of signal values.