Safe Haskell | None |
---|---|
Language | Haskell98 |
- data Event a
- data Behavior a
- newEvent :: IO (Event a, a -> IO ())
- cacheStateful :: Event a -> Behavior (Event a)
- cacheStateless :: Event a -> Behavior (Event a)
- sample :: Behavior a -> Event a
- foldEvent :: (b -> a -> b) -> b -> Event a -> Event b
- runEvent :: Event (Either (IO ()) res) -> IO res
- runGlobalEvent :: Event (IO ()) -> IO ()
- debug :: String -> Behavior ()
- debugCleanup :: String -> Behavior ()
- hold :: Event a -> Behavior a
- unsafeLiftIO :: IO a -> Behavior a
Documentation
Push based Updater.
Pull based Updater
cacheStateful :: Event a -> Behavior (Event a) Source
cacheStateless :: Event a -> Behavior (Event a) Source
sample :: Behavior a -> Event a Source
This can be thought of as polling a behavior. It will only fire once.
foldEvent :: (b -> a -> b) -> b -> Event a -> Event b Source
This can be implemented using mfix, cacheStateful, ...
If you get into trouble and really need multiple recursively defined
Events you can use mfix to do that.
You should however look at the implementation of foldEvent
and
the SlotMachine example first.
In particular, make sure you understande that you need to use
'sample . hold' on the recursive signal in order to avoid infinite recursion.
runEvent :: Event (Either (IO ()) res) -> IO res Source
'Left io' events will be executed. The first 'Right res' event will end the function and return res.
runGlobalEvent :: Event (IO ()) -> IO () Source
This is just a convenience for use in ghci and in the test cases. It will just run the Event it is given in it's own thread.
debugCleanup :: String -> Behavior () Source
This can be useful to spot when listeners are removed.
hold :: Event a -> Behavior a Source
This just only forwards the first event
It is probably most useful for Events crated using
cacheStateful
unsafeLiftIO :: IO a -> Behavior a Source
Don't execute the io-action returned by newEvent
.
Also, fork; don't block.