reflex-frp.org
reflex-frp.org copied to clipboard
On the delay-recommendation in Hang / Stack Overflow -section
Is there any chances to extend the example so that it would also show, how to apply the delay
,
at hang-stack-overflow-section?
The delay
eats NominalDiffTime
and it is not outright obvious, what value it should be given.
I had a this kind of situation, where ev2 <- delay 0 ev1
worked and was required. The runtime errors at ghci
referred to "bag -problems in Spider/Internal" and once to "ghc loop" when I was doing changes / trying to find a working combination.
So,
- If there are typical symptons that can be seen, say in ghci, maybe mention those?
- Is it possible to describe, why the given example needs
delay
? I mean, why therec
-block isn't enough as such as shown at the moment? - What parameter to give to
delay
? Is 0 ok?
BTW: it seems that those delay
s area needed every now and then. If 0 is ok and enough in this kind of situations, is there room for frameDelay = delay 0
in the reflex-lib? (With the idea that it wouldn't confuse the user? The proposed name here probably isn't good.)
I have never encountered a scenario where delay 0
was needed to solve a cycle. It's an easy trap to fall in but I think it's bad practice. If delaying solves your problem, it means there's a cycle that simply doesn't need to be there. For instance, in that section of documentation, the cycle is introduced by using a dynamic's own updated
event as the second argument to its holdDyn
. That means that the only thing triggering the event is itself, which makes no sense.
Yeah, I would say that any time you're using delay
to fix a loop, you still have a bug after doing that. A causality loop is where an Event
is able to potentially cause itself to fire, which is a paradox; the correct solution is to figure out why the code creates that paradox, and change it so that it doesn't create it anymore.
Ok thanks @ElvishJerricco @ryantrinkle , luckily the title of this issue is ok as should the whole delay-section/recommendation be revised to reflect what you wrote above? This doc is something that people probably will read and it would be a bit sad if it instructs to apply bad habits.
(Or, is the delay just meant to be a temporary solution to find out where the problem is? Or is there some other way/idea on how to use delay in that kind of situations? If yes, then there probably still is something to re-write/clarify.)
(And now I have to find out where I used that delay and try to fix it.)