Skip to content
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

On the delay-recommendation in Hang / Stack Overflow -section #24

Open
gspia opened this issue Jun 19, 2018 · 3 comments
Open

On the delay-recommendation in Hang / Stack Overflow -section #24

gspia opened this issue Jun 19, 2018 · 3 comments

Comments

@gspia
Copy link

gspia commented Jun 19, 2018

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 the rec-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 delays 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.)

@ElvishJerricco
Copy link

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.

@ryantrinkle
Copy link
Member

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.

@gspia
Copy link
Author

gspia commented Jun 20, 2018

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants