A sort of semantic prototype for functional futures, roughly as
described at http://en.wikipedia.org/wiki/Futures_and_promises.
A future is a value that will become knowable only later. This
module gives a way to manipulate them functionally. For instance,
a+b becomes knowable when the later of a and b becomes knowable.
Primitive futures can be things like /the value of the next key you
press, or the value of LambdaPix stock at noon next Monday/.
Composition is via standard type classes: Ord, Functor,
Applicative, Monad, and Monoid. Some comments on the Future
instances of these classes:
- Ord: a min b is whichever of a and b is knowable first. a
max b is whichever of a and b is knowable last.
- Monoid: mempty is a future that never becomes knowable. mappend
is the same as min.
- Functor: apply a function to a future. The result is knowable when
the given future is knowable.
- Applicative: pure gives value knowable since the beginning of
time. '(<*>)' applies a future function to a future argument.
Result available when both are available, i.e., it becomes knowable
when the later of the two futures becomes knowable.
- Monad: return is the same as pure (as always). (>>=)
cascades futures. join resolves a future future value into a
future value.
Futures are parametric over time as well as value types. The time
parameter can be any ordered type.
Please keep in mind that this module specifies the interface and
semantics, rather than a useful implementation. See Data.Future for
an implementation that nearly implements the semantics described here.
On second thought, I'm experimenting with using this module in an
usable implementation of events. See Data.MEvent.
|