Safe Haskell | Safe |
---|---|
Language | Haskell98 |
- type Handler a = a -> IO ()
- newtype AddHandler a = AddHandler {}
- newAddHandler :: IO (AddHandler a, Handler a)
- mapIO :: (a -> IO b) -> AddHandler a -> AddHandler b
- filterIO :: (a -> IO Bool) -> AddHandler a -> AddHandler a
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
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
.