ltk- Leksah tool kit



A simple event mechanism



class (Eq delta, Ord delta, Show delta) => EventSelector delta Source

Every event needs a selector, which should identify the type of event

class EventSelector delta => Event beta delta | beta -> delta, delta -> beta whereSource

Every event needs to know its selector and its source


getSelector :: beta -> deltaSource

class (Monad gamma, Event beta delta) => EventSource alpha beta gamma delta | alpha -> beta, alpha -> gamma whereSource

Everything which is an event source needs this


getHandlers :: alpha -> gamma (Handlers beta gamma delta)Source

setHandlers :: alpha -> Handlers beta gamma delta -> gamma ()Source

myUnique :: alpha -> gamma UniqueSource

canTriggerEvent :: alpha -> delta -> BoolSource

Reimplement this in instances to make triggering of events possible

triggerEvent :: alpha -> beta -> gamma betaSource

Returns the event, so that you may get values back from an event

registerEvent :: alpha -> delta -> Either (beta -> gamma beta) Unique -> gamma (Maybe Unique)Source

use Left to register and Right to unregister returns Unique if registration was successfull, else Nothing

type Handlers beta gamma delta = Map delta [(Unique, beta -> gamma beta)]Source

This shows the implementation of the event mechnism