The representation used in this module is based on a close connection
between these two types. A reactive value is defined by an initial
value and an event that yields future values; while an event is given
as a future reactive value.

Documentation

Monoid: mempty is the event that never occurs, and e mappend
e' is the event that combines occurrences from e and e'.

Functor: fmap f e is the event that occurs whenever e occurs,
and whose occurrence values come from applying f to the values from
e.

Applicative: pure a is an event with a single occurrence at time
-Infinity. ef <*> ex is an event whose occurrences are made from
the product of the occurrences of ef and ex. For every occurrence
f at time tf of ef and occurrence x at time tx of ex, ef
<*> ex has an occurrence f x at time tf max tx. N.B.: I
don't expect this instance to be very useful. If ef has nf
instances and ex has nx instances, then ef <*> ex has nf*nx
instances. However, there are only nf+nx possibilities for tf
max tx, so many of the occurrences are simultaneous. If you think
you want to use this instance, consider using Reactive instead.

Monad: return a is the same as pure a (as usual). In e >>= f,
each occurrence of e leads, through f, to a new event. Similarly
for join ee, which is somehow simpler for me to think about. The
occurrences of e >>= f (or join ee) correspond to the union of the
occurrences (temporal interleaving) of all such events. For example,
suppose we're playing Asteroids and tracking collisions. Each collision
can break an asteroid into more of them, each of which has to be tracked
for more collisions. Another example: A chat room has an enter event,
whose occurrences contain new events like speak. An especially useful
monad-based function is joinMaybes, which filters a Maybe-valued
event.

Reactive value: a discretely changing value. Reactive values can be
understood in terms of (a) a simple denotational semantics of reactive
values as functions of time, and (b) the corresponding instances for
functions. The semantics is given by the function at :: ReactiveG t a ->
(t -> a). A reactive value may also be thought of (and in this module
is implemented as) a current value and an event (stream of future values).

The semantics of ReactiveG instances are given by corresponding
instances for the semantic model (functions):