event-handlers-0.0.0.3: Event handlers

Data.Handler

Synopsis

Documentation

data HandlerSet m a b Source

A collection of handlers that can be fired in a batch. Consists of a collection of handlers and a sequencing rule that determines how multiple handlers are ordered and their results threaded or aggregated.

data HandlerID Source

An opaque identifier for handlers, useful for removing them from a set later.

emptyHandlerSet :: Monad m => HandlerSet m a ()Source

Create a new handler set with a simple default sequencer (sequenceHandlers ())

emptyHandlerSetWithSequencer :: (a -> [a -> m b] -> m b) -> HandlerSet m a bSource

Create a new handler set using the provided function to coordinate the dispatch of the handlers

setHandlerSequencer :: (a -> [a -> m b] -> m b) -> HandlerSet m a b -> HandlerSet m a bSource

Replace the handler sequencing rule in a HandlerSet.

addHandlerToSet :: (a -> m b) -> HandlerSet m a b -> (HandlerSet m a b, HandlerID)Source

Add a handler to a set and return the updated set and the assigned HandlerID

removeHandlerFromSet :: HandlerID -> HandlerSet m a b -> (HandlerSet m a b, Maybe (a -> m b))Source

Attempt to remove a handler from a set (based on its HandlerID), returning the modified set and the handler removed, if any.

invokeHandlers :: Monad m => HandlerSet m a b -> a -> m bSource

Invoke the handlers in a HandlerSet with the provided input.