
On Fri, Jul 10, 2009 at 04:47:49PM +0200, Svein Ove Aas wrote:
I can't comment on this exact bug, but in general the Monad instance for Event is semantically broken.
There's a perfectly reasonable joinE function, yes, but as I understand it combining it with the perfectly reasonable Applicative instance produces an illegal monad. Thus, in general, you should avoid the Monad instance and use joinE directly when required.
For what it's worth, the same problem appears to be present if I use joinE directly instead of join/>>=. I've experimented a lot with variations on joinE's implementation. If it is going to be possible for one input packet to result in multiple output packets, I'm going to need some function from Event (Event a) to Event a. switchE is clearly not it. joinE seems to be the right idea, although I'm unclear on the semantics when an inner event has occurrences predating its own occurrence in the Event (Event a). Chris