event 0.1 → 0.1.0.1
raw patch · 3 files changed
+11/−2 lines, 3 files
Files
- CHANGELOG.md +4/−0
- event.cabal +1/−1
- src/Control/Concurrent/Event.hs +6/−1
CHANGELOG.md view
@@ -1,3 +1,7 @@+## 0.1.0.1++- Made `on` visible.+ ## 0.1 - Initial revision.
event.cabal view
@@ -1,5 +1,5 @@ name: event-version: 0.1+version: 0.1.0.1 synopsis: Monoidal, monadic and first-class events description: This package can be used to represent events as first-class objects instead of deepening callbacks and
src/Control/Concurrent/Event.hs view
@@ -50,6 +50,7 @@ module Control.Concurrent.Event ( -- * Events Event+ , on , newEvent -- * Triggering events , Trigger@@ -70,7 +71,7 @@ -- -- 'Event's can be triggered with the 'trigger' function and the associated -- type 'Trigger'.-newtype Event a = Event { on :: (a -> IO ()) -> IO Detach }+newtype Event a = Event ((a -> IO ()) -> IO Detach) instance Applicative Event where pure x = Event $ \k -> k x >> pure mempty@@ -95,6 +96,10 @@ instance Semigroup (Event a) where a <> b = Event $ \k -> (<>) <$> on a k <*> on b k++-- |Register an action.+on :: (MonadIO m) => Event a -> (a -> IO ()) -> m Detach+on (Event register) f = liftIO $ register f -- |'Detach' is used to detach an action from an 'Event'. newtype Detach = Detach { detach :: IO () }