reactive-banana-1.3.2.0: Library for functional reactive programming (FRP).
Safe HaskellSafe-Inferred
LanguageHaskell98

Control.Event.Handler

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

Instances

Instances details
Functor AddHandler Source # 
Instance details

Defined in Control.Event.Handler

Methods

fmap :: (a -> b) -> AddHandler a -> AddHandler b #

(<$) :: a -> AddHandler b -> AddHandler a #

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.