-
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
Discrepancy in model and implementation #271
Comments
The comment on It's trying to convey that at the moment the event-of-events fires, if the event that it contains also fires, that inner event's value will not be present. In plainer English: Hope that helped somewhat. In my opinion, we should maybe rework the "semantics" comment of |
I see. Consider this code: testCase = [Just n | n <- [0..5]]
listing event = accumE [] ((\x -> (++ [x])) <$> event)
nested event = switchE never (observeE (listing event <$ filterE even event))
interpret nested testCase This gives Note that However, when collapsed with I guess |
That output looks right to me. Could you explain why |
I should have stayed with the list semantics.. observeE (listingE event <$ filterE even event)
= [.., (Time 2, listingE event (Time 2) ,..]
= [.., (Time 2, [(Time 2, [2]), (Time 3, [2, 3]), (Time 4, [2, 3, 4]), (Time 5, [2, 3, 4, 5])] ), ..] Then, switchE never (observeE (listingE event <$ filterE even event))
= [.., (Time 3, [2, 3]), (Time 4, [2, 3, 4]), ..] so I think the fourth element should be |
At (the end of the moment at) time 2, we switch to a new |
I do not understand why external switching would cause changes to the event. In fact, I found the discrepancy between the Model and the Combinators module. import Reactive.Banana.Combinators as C
testCase = [Just n | n <- [0..5]]
listingE event = C.accumE [] ((\x -> (++ [x])) <$> event)
evenE event = C.filterJust $ (\n -> n <$ guard (even n)) <$> event
nested event = C.switchE never (C.observeE (listingE event <$ evenE event))
C.interpret nested testCase gives while import Reactive.Banana.Model qualified as M
testCase = [Just n | n <- [0..5]]
listingE event = M.accumE [] ((\x -> (++ [x])) <$> event)
evenE event = M.filterJust $ (\n -> n <$ guard (even n)) <$> event
nested event = M.switchE M.never (M.observeE (listingE event <$ evenE event))
M.interpret nested testCase gives I wonder which one is implemented wrong. EDIT: Failing test |
Huh, yes, I see what you mean now. Sorry it took so long for me to understand. I agree with your assessment; the model seems correct to me, too. |
once
vs. switchE
So, what needs to be fixed to correct the semantics? |
I think we just need to rewrite the comment on
|
Oh, I think that would be fine for a documentation, I was commenting on fixing the Failing test. |
Oh, I think that's a puzzle for @HeinrichApfelmus or another intrepid adventurer. If I had to speculate, it seems we're building the event too late. We ought to build it the moment it's switched to, even if we only start observing its values in the next. ... wait, heh, I think I'm starting to lean towards the model being incorrect. The preceding paragraph seems a little nonsense - we delay rebuilding the network until the end of a moment because it's inefficient to do it "live". But either way, great find! |
This note seems relevant:
|
Does the Moment here means in logical time, or something else? |
Yes, the logical time |
If I understood correctly, |
Just discovered this while trying to conjure
Event a -> Event (Event a)
up for convenience.Documentation states the semantics as:
Note the
time0 <= t
constraint, which means event occurrence atMoment
time is accepted.However,
once
is defined usingswitchE
.Now, from
switchE
we haveThe
trim
function only allows event occurrencetime1 < timex
.Since the
intervals ee
should start with[(time0, time1, e0), ..]
, bytrim
occurrence ofe0
beforetime0
is cut off!According to this documentation,
switchE e (never <$ e1)
should not produce any value at theMoment
time (time0
).Hence,
once
should drop event occurrence at theMoment
time /time0
.I am utterly confused here, which one is right?
The text was updated successfully, but these errors were encountered: