Stability | experimental |
---|---|
Maintainer | David Sorokin <david.sorokin@gmail.com> |
Safe Haskell | Safe-Inferred |
Tested with: GHC 7.6.3
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 = Signal {
- handleSignal :: (a -> Event ()) -> Event (Event ())
- handleSignal_ :: Signal a -> (a -> Event ()) -> Event ()
- data SignalSource a
- newSignalSource :: Simulation (SignalSource a)
- publishSignal :: SignalSource a -> Signal a
- triggerSignal :: SignalSource a -> a -> Event ()
- mapSignal :: (a -> b) -> Signal a -> Signal b
- mapSignalM :: (a -> Event b) -> Signal a -> Signal b
- apSignal :: Event (a -> b) -> Signal a -> Signal b
- filterSignal :: (a -> Bool) -> Signal a -> Signal a
- filterSignalM :: (a -> Event Bool) -> Signal a -> Signal a
- emptySignal :: 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
- arrivalSignal :: Signal a -> Signal (Arrival a)
- newSignalInTimes :: [Double] -> Event (Signal Double)
- newSignalInIntegTimes :: Event (Signal Double)
- newSignalInStartTime :: Event (Signal Double)
- newSignalInStopTime :: Event (Signal Double)
- data SignalHistory a
- signalHistorySignal :: SignalHistory a -> Signal a
- newSignalHistory :: Signal a -> Event (SignalHistory a)
- newSignalHistoryStartingWith :: Maybe a -> Signal a -> Event (SignalHistory a)
- readSignalHistory :: SignalHistory a -> Event (Array Int Double, Array Int a)
- data Signalable a = Signalable {
- readSignalable :: Event a
- signalableChanged_ :: Signal ()
- signalableChanged :: Signalable a -> Signal a
- emptySignalable :: Monoid a => Signalable a
- appendSignalable :: Monoid a => Signalable a -> Signalable a -> Signalable a
Handling and Triggering Signal
The signal that can have disposable handlers.
Signal | |
|
handleSignal_ :: Signal a -> (a -> Event ()) -> Event ()Source
Subscribe the handler to the specified signal.
To subscribe the disposable handlers, use function handleSignal
.
data SignalSource a Source
The signal source that can publish its signal.
newSignalSource :: Simulation (SignalSource a)Source
Create a new signal source.
publishSignal :: SignalSource a -> Signal aSource
Publish the signal.
triggerSignal :: SignalSource a -> a -> Event ()Source
Trigger the signal actuating all its handlers at the current simulation time point.
Useful Combinators
mapSignalM :: (a -> Event 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.
filterSignalM :: (a -> Event Bool) -> Signal a -> Signal aSource
Filter only those signal values that satisfy to the specified predicate.
emptySignal :: Signal aSource
An empty signal which is never triggered.
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.
Signal Arriving
arrivalSignal :: Signal a -> Signal (Arrival a)Source
Transform a signal so that the resulting signal returns a sequence of arrivals saving the information about the time points at which the original signal was received.
Creating Signal in Time Points
newSignalInTimes :: [Double] -> Event (Signal Double)Source
Return a signal that is triggered in the specified time points.
newSignalInIntegTimes :: Event (Signal Double)Source
Return a signal that is triggered in the integration time points.
It should be called with help of runEventInStartTime
.
newSignalInStartTime :: Event (Signal Double)Source
Return a signal that is triggered in the start time.
It should be called with help of runEventInStartTime
.
newSignalInStopTime :: Event (Signal Double)Source
Return a signal that is triggered in the final time.
Signal History
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 -> Event (SignalHistory a)Source
Create a history of the signal values.
newSignalHistoryStartingWith :: Maybe a -> Signal a -> Event (SignalHistory a)Source
Create a history of the signal values starting with the optional initial value.
readSignalHistory :: SignalHistory a -> Event (Array Int Double, Array Int a)Source
Read the history of signal values.
Signalable Computations
data Signalable a Source
Describes a computation that also signals when changing its value.
Signalable | |
|
Functor Signalable | |
Monoid a => Monoid (Signalable a) |
signalableChanged :: Signalable a -> Signal aSource
Return a signal notifying that the value has changed.
emptySignalable :: Monoid a => Signalable aSource
Return an identity.
appendSignalable :: Monoid a => Signalable a -> Signalable a -> Signalable aSource
An associative operation.