Functional events and reactive values. An Event is stream of
future values in time order. A Reactive value is a discretly
time-varying value. These two types are closely linked: a reactive
value is defined by an initial value and an event that yields future
values; while an event is simply a future reactive value.

Many of the operations on events and reactive values are packaged as
instances of the standard type classes Monoid, Functor,
Applicative, and Monad.

Although the basic Reactive type describes discretely-changing
values, continuously-changing values are modeled simply as reactive
functions. For convenience, this module defines ReactiveB as a type
composition of Reactive and a constant-optimized representation of
functions of time.

The exact packaging of discrete vs continuous will probably change with
more experience.

Applicative: pure a is an event with a single occurrence,
available from the beginning of time. 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 max
tf tx.

Monad: return a is the same as pure a (as always). 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 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 (%$) :: Reactive a
-> (Time -> a). A reactive value also has a current value and an
event (stream of future values).