ltk-0.12.1.0: Leksah tool kit

Safe Haskell | Safe-Inferred

Control.Event

Description

A simple event mechanism

Synopsis

- class (Eq delta, Ord delta, Show delta) => EventSelector delta
- class EventSelector delta => Event beta delta | beta -> delta, delta -> beta where
  - getSelector :: beta -> delta
- class (Monad gamma, Event beta delta) => EventSource alpha beta gamma delta | alpha -> beta, alpha -> gamma where
  - getHandlers :: alpha -> gamma (Handlers beta gamma delta)
  - setHandlers :: alpha -> Handlers beta gamma delta -> gamma ()
  - myUnique :: alpha -> gamma Unique
  - canTriggerEvent :: alpha -> delta -> Bool
  - triggerEvent :: alpha -> beta -> gamma beta
  - registerEvent :: alpha -> delta -> (beta -> gamma beta) -> gamma (Maybe Unique)
  - unregisterEvent :: alpha -> delta -> Unique -> gamma ()
- type Handlers beta gamma delta = Map delta [(Unique, beta -> gamma beta)]
- registerEvents :: EventSource alpha beta gamma delta => alpha -> [delta] -> (beta -> gamma beta) -> gamma [Unique]

# Documentation

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

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

Instances

EventSelector GUIEventSelector |

class EventSelector delta => Event beta delta | beta -> delta, delta -> beta where Source

Every event needs to know its selector and its source

Methods

getSelector :: beta -> deltaSource

Instances

Event GUIEvent GUIEventSelector |

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

Everything which is an event source needs this alpha is the Notifier beta is the event gamma is the monad delta is the event selector

Methods

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

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

myUnique :: alpha -> gamma Unique Source

canTriggerEvent :: alpha -> delta -> Bool Source

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 Args: Notifier, Event

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

unregisterEvent :: alpha -> delta -> Unique -> gamma ()Source

use Left to register and Right to unregister Args: Notifier, EventSelector, Unique

Instances

EventSource Notifier GUIEvent IO GUIEventSelector |

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

This shows the implementation of the event mechnism

registerEvents :: EventSource alpha beta gamma delta => alpha -> [delta] -> (beta -> gamma beta) -> gamma [Unique]Source