Safe Haskell | None |
---|---|

Language | Haskell98 |

- data SF a b
- iPre :: a -> SF a a
- arr :: Arrow a => forall b c. (b -> c) -> a b c
- (>>>) :: Category k cat => cat a b -> cat b c -> cat a c
- first :: Arrow a => forall b c d. a b c -> a (b, d) (c, d)
- loop :: ArrowLoop a => forall b d c. a (b, d) (c, d) -> a b c
- integral :: VectorSpace a s => SF a a
- data Event a
- switch :: SF a (b, Event c) -> (c -> SF a b) -> SF a b
- type Time = Double
- time :: SF a Time

# Signal function

Signal function that transforms a signal carrying values of some type `a`

into a signal carrying values of some type `b`

. You can think of it as
(Signal a -> Signal b). A signal is, conceptually, a
function from `Time`

to value.

# Stateless combinators

first :: Arrow a => forall b c d. a b c -> a (b, d) (c, d)

Send the first component of the input through the argument arrow, and copy the rest unchanged to the output.

# Stateful combinators

integral :: VectorSpace a s => SF a a Source

Integration using the rectangle rule.

## Switching upon certain events

A single possible event occurrence, that is, a value that may or may not occur. Events are used to represent values that are not produced continuously, such as mouse clicks (only produced when the mouse is clicked, as opposed to mouse positions, which are always defined).

switch :: SF a (b, Event c) -> (c -> SF a b) -> SF a b Source

Basic switch.

By default, the first signal function is applied.

Whenever the second value in the pair actually is an event, the value carried by the event is used to obtain a new signal function to be applied *at that time and at future times*.

Until that happens, the first value in the pair is produced in the output signal.

Important note: at the time of switching, the second signal function is applied immediately. If that second SF can also switch at time zero, then a double (nested) switch might take place. If the second SF refers to the first one, the switch might take place infinitely many times and never be resolved.

Remember: The continuation is evaluated strictly at the time of switching!

## Time (NOTE: integral 1 over time. Not really necessary.)

Time is used both for time intervals (duration), and time w.r.t. some agreed reference point in time.