Definition of Yampa Event type.
Note on naming conventions used in this module.
Names here might have to be rethought. It's really a bit messy.
In general, the aim has been short and convenient names (like
lMerge) and thus we have tried to stay away from suffixing/
prefixing conventions. E.g.
Event as a common suffix would be very
However, part of the names come from a desire to stay close to similar
functions for the Maybe type. e.g.
In many cases, this use of
Event can could understood to refer to the
Event, not to the type name
Event. Thus this use of
event should not be seen as a suffixing-with-type-name convention. But
that is obviously not easy to see, and, more over, interpreting
as the name of the type might make equally good or better sense. E.g.
fromEvent can also be seen as a function taking an event signal,
which is a partial function on time, to a normal signal. The latter is
then undefined when the source event function is undefined.
In other cases, it has been necessary to somehow stay out of the way of
names used by the prelude or other commonly imported modules/modules
which could be expected to be used heavily in Yampa code. In those cases
E have been added. Examples are
filterE (exists in Prelude)
joinE (exists in Monad). Maybe the suffix isn't necessary in the
Some functions (actually only one currently,
mapFilterE) have got an
suffix just because they're closely related (by name or semantics) to one
which already has an
E suffix. Another candidate would be
joinE. But events carrying pairs could obviously have other
sources than a
joinE, so currently it is called
2003-05-19: Actually, have now changed to
splitE to avoid a clash
with the method
split in the class RandomGen.
E suffix is considered an exception. Maybe we should use
completely different names to avoid the
E suffix. If the functions
are not used that often,
Event might be approriate. Alternatively the
E should be adopted globaly (except if the name already contains
event in some form?).
Arguably, having both a type
Event and a constructor
Event is confusing
since there are more than one constructor. But the name
Event for the
constructor is quite apt. It's really the type name that is wrong. But
no one has found a better name, and changing it would be a really major
undertaking. Yes, the constructor
Event is not exported, but we still
need to talk conceptually about them. On the other hand, if we consider
Event-signals as partial functions on time, maybe it isn't so confusing:
they just don't have a value between events, so
NoEvent does not really
- Either: reveal NoEvent and Event
or: introcuce 'event = Event', call what's now
and call what's now called
fromEvent something else, like
unsafeFromEvent??? Better, dump it! After all, using current
names, 'fromEvent = event undefined'!