Search code examples
haskellreactive-programmingfrpreactive-banana

What is the equivalent of reactive-web's flatMap in Haskell's reactive-banana?


I'm looking for the function in reactive-banana that will choose from which event stream to emit next depending on the incoming value of another event stream or signal (Behaviour ?). In the library for scala, reactive-web this is done with:

 flatMap[U](f: T => EventStream[U]): EventStream[U] 

thanks !


Solution

  • This is dynamic event switching. Unfortunately, in that formulation, it has many problems, and so is not included in reactive-banana. However, a variant of dynamic event switching will be added soon. For now, you'll have to do without it.

    In particular, flatMap is Scala's name for the monadic bind function; a Monad instance for behaviours is problematic because it provides the dynamic event switching functionality that leads to the time leak explained in the article I linked.