-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Behavior
constantly re-evaluating when caching is expected
#251
Comments
I also note that if I don't have |
A smaller repro: {-# language BlockArguments #-}
module Main where
import Data.Functor
import Debug.Trace
import Reactive.Banana
import Reactive.Banana.Frameworks
main :: IO ()
main = do
(onChangeCheckbox, changeCheckbox) <- newAddHandler
actuate =<< compile do
onToggle <- fromAddHandler onChangeCheckbox
checked <- stepper False onToggle
let b1 = traceShowId <$> pure "1"
let b' = liftA2 (,) checked b1
reactimate $ return () <$ b' <@ onToggle
changeCheckbox True
changeCheckbox False
changeCheckbox True Note that changing I also tried |
Another weird point: |
I made some progress on understanding this one. Here's a rough diagram of a slightly simplified version of Ollie's example. The black text are latches, with nodes in the tree being The red arrow shows an We need to calculate the value of the entire latch (the root of the tree), so we will go down depth-first, getting each latch's value, per the definition of reactive-banana/reactive-banana/src/Reactive/Banana/Prim/Mid/Combinators.hs Lines 99 to 101 in 58596df
reactive-banana/reactive-banana/src/Reactive/Banana/Prim/Mid/Plumbing.hs Lines 107 to 117 in 58596df
So, say the event occurs at time t=5. When evaluating the whole latch, after getting to the Then, later nodes in the tree (such as our reactive-banana/reactive-banana/src/Reactive/Banana/Prim/Mid/Plumbing.hs Lines 110 to 117 in 58596df
only in a context where t=5 is already written to the |
This was originally reported at https://old.reddit.com/r/haskell/comments/tk1khp/reactivebanana_controlling_behavior_caching/. I've managed to reproduce the bug in the following:
Which prints
Note that "sampling 1" or "sampling 2" has happened multiple times despite the underlying
Behavior
s not changing.As mentioned in the thread, using
liftA3
makes things even worse. If we changeb'
to defined as:We get
which is even more work than before.
The text was updated successfully, but these errors were encountered: