-
Notifications
You must be signed in to change notification settings - Fork 71
Multiple Simultaneous Events (Issue #25)
HeinrichApfelmus edited this page Mar 23, 2012
·
3 revisions
Main discussion thread: https://github.com/HeinrichApfelmus/reactive-banana/issues/25
The main reason for disallowing multiple simultaneous events is the intricate interaction with accumE
and apply
. See this comment.
The compromise that is going to be implemented is
-
Add a function
unionWith :: (a -> a -> a) -> Event a -> Event a -> Event a unionWith f e1 e2 = foldr1 f <$> collect (e1 `union` e2)
Example
unionWith (+) [ [1,2], [3] ] [ [4], [] ] = [ [7], [3] ]
-
Remove general
Monoid
instance forEvent
. IntroduceMonoid
instanceinstance Monoid (Event (a -> a)) where mempty = never mappend = unionWith (flip (.))
-
Provide a different type (proposed name
CalmEvent
) in a specialized module that offers the guarantee that it contains only one event at each point in time. Not sure yet whether to implemented it on top of the current semantics or as alternate semantics.See also https://github.com/HeinrichApfelmus/reactive-banana/issues/26.