reactive-banana-1.1.0.1: Library for functional reactive programming (FRP).

Safe HaskellSafe
LanguageHaskell98

Control.Event.Handler

Contents

Synopsis

Synopsis

Event-driven programming in the traditional imperative style.

Documentation

type Handler a = a -> IO () Source

An event handler is a function that takes an event value and performs some computation.

newtype AddHandler a Source

The type AddHandler represents a facility for registering event handlers. These will be called whenever the event occurs.

When registering an event handler, you will also be given an action that unregisters this handler again.

do unregisterMyHandler <- register addHandler myHandler

Constructors

AddHandler 

Fields

register :: Handler a -> IO (IO ())
 

newAddHandler :: IO (AddHandler a, Handler a) Source

Build a facility to register and unregister event handlers. Also yields a function that takes an event handler and runs all the registered handlers.

Example:

do
    (addHandler, fire) <- newAddHandler
    register addHandler putStrLn
    fire "Hello!"

mapIO :: (a -> IO b) -> AddHandler a -> AddHandler b Source

Map the event value with an IO action.

filterIO :: (a -> IO Bool) -> AddHandler a -> AddHandler a Source

Filter event values that don't return True.