grapefruit-frp-0.1.0.7: Functional Reactive Programming core

FRP.Grapefruit.Signal.Discrete

Description

This module is about discrete signals.

For a general introduction to signals, see the documentation of FRP.Grapefruit.Signal.

Synopsis

# Discrete signal type

data DSignal era val Source #

The type of discrete signals.

A discrete signal is a sequence of values assigned to discrete times. A pair of a time and a corresponding value is called an occurrence. You can think of DSignal era val as being equivalent to Map (Time era) val where Time era is the type of all times of the given era. However, an occurence at the starting time of the era is not possible. In contrast to Map, a discrete signal may cover infinitely many values.

Discrete signals can describe sequences of events. For example, the sequence of all key presses could be described by a discrete signal of characters. Discrete signals are also used in conjunction with sampling.

The discrete signal instances of Functor and Monoid provide the following method definitions:

       fmap    = map
mempty  = empty
mappend = union
mconcat = unions


Instances

# Connectors

consumer :: (val -> IO ()) -> Consumer DSignal val Source #

Converts an event handler into a discrete signal consumer.

If a discrete signal is consumed with such a consumer, the handler is called at each occurence with the occuring value as its argument.

producer :: ((val -> IO ()) -> Setup) -> Producer DSignal val Source #

Converts an event handler registration into a discrete signal producer.

Applying the argument of producer to an event handler has to yield a setup which makes the handler be called with a certain value everytime the produced signal shall have an occurence of this value.