Bartosz Milewski wrote:
I'm reading Conal Elliot's paper, Push-Pull FRP. At some point he needs an
unambiguous choice operator, essentially to implement select: a future that
waits for one of its future arguments to fire. His implementation of unamb
creates two threads racing on a shared MVar. By his own admission, this is
very inefficient. My question is, is there a better implementation?

The thing about unambiguous choice is that it goes beyond the dynamic semantics of the Haskell language. To implement it, you either need a new evaluation model built into the compiler, or you have to fake it somehow and that is likely to be inefficient.


Also note that Conal's paper describes just one possible implementation of FRP. My reactive-banana library uses an implementation that doesn't require unambiguous choice at all. For a basic model, see

http://hackage.haskell.org/packages/archive/reactive-banana/latest/doc/html/Reactive-Banana-Model.html

The key idea is to keep all events synchronous and to reify some cases of "this event does not occur right now".


Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to