restaumatic / purescript-specular

A Reflex-Dom inspired UI library for PureScript
MIT License
132 stars 10 forks source link

New Incremental backend #66

Closed zyla closed 4 years ago

zyla commented 4 years ago

This PR replaces the FRP machinery with a new implementation, inspired by Jane Street's Incremental.

The main thing it fixes is sharing. In the current implementation, if we have

d :: Dynamic A
f :: A -> B

d2 = map f d

then when d changes, f will be recomputed once for each subscriber of d2. With the new backend, it will be computed once per change (as it should).

This is really significant when we consider more complex dependency network, and many subscribers (think 100s of tiny GUI widgets). In production we've seen cases where a function was unnecessarily computed 600 times.

Additionally the new backend is written with performance in mind. In particular:

TODO:

kozak commented 4 years ago

Might be worth adding a mention of Jane Streets Incremental to the readme :)