Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upConfounding behavior of Time signal #145
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Jan 27, 2015
Contributor
This is exactly as mandated by the documentation of Signal.mergeMany: "When multiple updates come in at the same time, the left-most update wins, just like with merge." Where "just like with merge" means, again per the documentation: "If an update comes on both signals at the same time, the left update wins (i.e., the right update is discarded)."
Since in your case both updates arrive exactly when the time from let time = Time.every 30 has an event, only one of the two updates makes it through, namely the left one.
As to why replacing one instance of time with a "new" Time.every 30 changes the behavior, see this thread: https://groups.google.com/d/msg/elm-discuss/KzevSWc0gfU/kfRNiZKLxP8J
|
This is exactly as mandated by the documentation of Since in your case both updates arrive exactly when the As to why replacing one instance of |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Jan 27, 2015
Contributor
So the upshot is that what you are seeing is not a bug, but the specified behavior of mergeMany. One thing, though, is that it is not currently clear from the documentation that a second Time.every 30 gives you completely independent times. From a message (mine) on the linked thread:
"Yes, having two signals both defined as Time.fps 30 not produce identical events is a kind of violation of referential transparency. Likewise with calls of Time.every. Probably that should be mentioned in the documentation."
|
So the upshot is that what you are seeing is not a bug, but the specified behavior of "Yes, having two signals both defined as |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Jan 27, 2015
Contributor
BTW, you might simply want to use fairMerge from http://package.elm-lang.org/packages/Apanatshka/elm-signal-extra/latest/Signal-Extra.
|
BTW, you might simply want to use |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
imeckler
Jan 27, 2015
Contributor
I see, thanks for the quick response. The behavior I was used to from other FRP implementations in the case of simultaneous signals was to trigger the right one just after the left.
What are the intended semantics of Signal? Is it something like Signal a = Stream (Time, a) where the Time is strictly increasing, or is it Stream (Time, a) where the Time is increasing, not necessarily strictly? If it's the former I understand this decision (although it's not clear that those semantics are an appropriate choice), if it's the latter it seems extremely strange to just drop events.
|
I see, thanks for the quick response. The behavior I was used to from other FRP implementations in the case of simultaneous signals was to trigger the right one just after the left. What are the intended semantics of |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Jan 27, 2015
Contributor
This can be an endless topic for philosophical discussion on the mailing list. In fact, it already has been. :)
Anyway, probably not useful to have that discussion here.
|
This can be an endless topic for philosophical discussion on the mailing list. In fact, it already has been. :) Anyway, probably not useful to have that discussion here. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Jan 27, 2015
Contributor
But maybe writing a PR with additional documentation would be useful. Anything that would have helped you to not be surprised by this behavior you ran into.
|
But maybe writing a PR with additional documentation would be useful. Anything that would have helped you to not be surprised by this behavior you ran into. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Jan 27, 2015
Contributor
I tried to address the documentation need in https://github.com/elm-lang/core/pull/146.
I think the issue here can be closed.
@imeckler, I didn't answer your explicit question about the intended semantics of Signal before. The answer is: It is something like Signal a = Stream (Time, a) where the Time is strictly increasing.
|
I tried to address the documentation need in https://github.com/elm-lang/core/pull/146. I think the issue here can be closed. @imeckler, I didn't answer your explicit question about the intended semantics of |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Aug 30, 2015
Contributor
Closing this, since no further activity happened here after the improvement to the docs this triggered.
|
Closing this, since no further activity happened here after the improvement to the docs this triggered. |
imeckler commentedJan 27, 2015
I just happened upon the following extremely confusing behavior. Consider the following program:
If you try running it, you'll notice that the
timefield never changes! Somehow those updates aren't making it to the merged signal. Replacing on of the instances oftimewith a "new"Time.every 30makes things work as expected.