HeinrichApfelmus/reactive-banana — Issue #20: Three API additions
Author: HeinrichApfelmus
Created: 2011-12-28 09:02:09+00:00
State: open
Labels: feature-request

[Gregory Crosswhite][1] writes that he'd like the following functions added to the API

filterJust :: Event (Maybe a) -> Event a
split :: Event (Either a b) -> (Event a, Event b)
newHandler :: NetworkDescription (Event a, a -> IO ())

I've already added `filterJust`. The definitions for the other two are

split e = (fromLeft <$> filterE isLeft e, fromRight <$> filterE isRight e)

newHandler = do
(event_handler,callback) <- liftIO newAddHandler
event <- fromAddHandler event_handler
return (event,callback)

I'm happy to add them, probably with a different name.

I'm not too keen on `newHandler`, because it's usually not very useful to have the callback function available inside a `NetworkDescription`, but I can see why it might be useful.

[1]: https://github.com/gcross