Applies a function f to the given input signal
Type signature:
<'a,'b,'closure>(||)(('closure)('a) -> 'b, sig<'a>) -> sig<'b>
f : ('closure)('a) -> 'b | The mapping function |
s : sig<'a> | The input signal |
The signal transformed by the mapping function
Applies the function on the given signal for the purpose of performing side effects.
Type signature:
<'a,'closure>(||)(('closure)('a) -> unit, sig<'a>) -> unit
f : ('closure)('a) -> unit | The function to call |
s : sig<'a> | The input signal |
Unit
Filters a signal using the given predicate function. If the function returns true, the signal is filtered and the output signal will contain nothing. If the function returns false, the signal is unfiltered and the output signal will be the same as the input signal.
Type signature:
<'a,'closure>(||)(('closure)('a') -> bool, sig<'a>) -> sig<'a>
f : ('closure)('a) -> bool | The predicate function |
s : sig<'a> | The input signal |
The filtered output signal.
Merges streams of the same type together. If sigA has a value, then sigA is returned. Otherwise sigB is returned.
Type signature:
merge<'a>(||)(sig<'a>, sig<'a>) -> sig<'a>
sigA : sig<'a> | The first signal to merge |
sigB : sig<'b> | The second signal to merge |
A signal of the two merged streams
Merges multiple signals together. The leftmost stream holding a value is the value held by the return signal. If none of the given signals holds a value, then the return stream will hold nothing.
Type signature:
<'a;n>(||)(list<sig<'a>;n>) -> sig<'a>
sigs : list<sig<'a>;n> | A list of signals to merge together. |
Joins streams of two types together. If sigA has a value, then Prelude:left is used to construct the output signal. Otherwise if sigB has a value then Prelude:right is used to construct the output signal. If neither sigA or sigB holds a value, then the output signal also holds no value.
Type signature:
<'a,'b>(||)(sig<'a>, sig<'b>) -> sig<either<'a,'b>>
sigA : sig<'a> | The first signal to join |
sigB : sig<'b> | The second signal to join |
A signal of the two joined streams.
Maps a signal of some type to a signal of units. If sig holds a value, then the output signal holds unit. Otherwise the output signal holds nothing.
Type signature:
<'a>(||)(sig<'a>) -> sig<unit>
s : sig<'a> | The signal to convert to a unit signal |
A signal of units.
Creates a past dependent signal. If the incoming signal contains a value, f will be called on the value and the previous state and the return value from this function determines the new state. The state is held in a reference. foldP stands for fold over the past.
Type signature:
foldP<'a,'state,'closure>(||)(('closure)('a,'state)->'state, 'state ref, sig<'a>) -> sig<'state>
f : ('closure)('a,'state) -> 'state | The folding function |
state0 : 'state ref | A reference to the mutable state |
incoming : sig<'a> | The signal of incoming values |
A signal containing the state just returned by f, or nothing if the input signal contained nothing.
Drop values that have been repeated on the given signal.
Type signature:
<'a>(||)(sig<'a>, maybe<'a> ref) -> sig<'a>
maybePrevValue : maybe<'a> ref | A reference holding the previous value or none if there hasn't been a previous value yet |
incoming : sig<'a> | The incoming signal |
A filtered signal where two values in a row will not be repeated.
Constantly emmits the value held in the latch. The value held in the latch is updated if it receives a value on the incoming signal.
<'a>(||)(sig<'a>, 'a ref) -> sig<'a>
prevValue : 'a ref | Holds the previous values that the latch received |
incoming : sig<'a> | The incoming latch update signal |
A signal which constantly emmits the value last received on the incoming signal.
Applys a mapping function to two signals. The function is evaluated when a value arrives on either signal. If no value is held by either of the input signals, then the output signal holds no value.
<'a,'b,'c,'closure>(||)(('closure)('a,'b)->'c, sig<'a>, sig<'b>, ('a*'b) ref) -> sig<'c>
f : ('closure)('a,'b) -> 'c | The mapping function |
state : ('a * 'b) ref | Holds the last values received from the signals. |
incomingA : sig<'a> | The first signal |
incomingB : sig<'b> | The second signal |
The mapped signal
Records values in a list as they come in through the incoming signal.
<'a;n>(||)(sig<'a>, list<'a;n> ref) -> sig<list<'a;n>>
pastValues : list<'a;n> ref | Previous values recorded from the signal |
incoming : sig<'a> | Incoming values to record |
A signal holding the list of previous values
Gives a signal holding a specific value.
<'a>(||)('a) -> sig<'a>
val : 'a | The value that will be held within the signal |
A signal containing the given value
Performs a meta analysis on a signal, and outputs this result in a signal. The output signal will hold a value of nothing when there is no value on the input signal, and will return just the value if there is a value on the input signal. The output signal will always hold a value, which makes it useful for many applications.
<'a>(||)(sig<'a>) -> sig<maybe<'a>>
sigA : sig<'a> | The signal on which the meta analysis will be performed |
A signal of either nothing or just the value of the input signal
The opposite of the meta function. If the input signal holds a value of nothing, then the output signal will not hold a value. If the input signal holds just a value, then the output signal will hold that value.
<'a>(||)(sig<maybe<'a>>) -> sig<'a>
sigA : sig<maybe<'a>> | The signal to "make concrete" |
A signal that holds a value in the case of the input signal holding just a value, and holds no value otherwise.
Zips two signals together, so that if a value is received on either signal, then the output signal will also contain the latest value from the other signal. If no value is held by either of the input signals, then the output signal holds no value.
<'a,'b>(||)(sig<'a>, sig<'b>, ('a * 'b) ref) -> sig<'a * 'b>
state : ('a * 'b) ref | The state holding the past values of the signals |
sigA : sig<'a> | The first signal to zip |
sigB : sig<'b> | The second signal to zip |
A zipped signal.
Unzips two signals apart, so that the tuple on the incoming signal is split into two signals.
<'a,'b>(||)(sig<'a * 'b>) -> (sig<'a> * sig<'b>)
incoming : sig<'a> | The signal to unzip |
Two signals inside a tuple
If a value is carried on the incoming signal, then the output signal holds a value of val2 if the value stored in state is equal to val1; otherwise, the output signal holds a value of val1. If no value is carried on the incoming signal, then no value is outputted on the return signal.
<'a,'b>(||)('a, 'a, 'a ref, sig<'b>) -> sig<'a>
val1 : 'a | The first value to toggle between |
val2 : 'a | The second value to toggle between |
state : 'a ref | Holds the previous value outputted on the return signal |
incoming : sig<'b> | The signal which will trigger a toggle |
A signal containing either val1 or val2, depending on what was previously value carried on the output signal.