Help! Two extremely similar functions, yet one is forced to be div
#371
-
I have been trying to create a small generator library for my own use, and I found that one piece of code I was writing, and encountering errors with, was very similar to an example within the documentation, yet wasn't working as well. This is the code I've been writing:
This fails with the error message:
Adding the A similar piece of code copied straight from the documentation, works perfectly fine without it
Why is the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
Divergence inference is rather conservative. Koka still has room for improvement in this area, and this particular issue seems worth looking into. However, annotating with divergence isn't the end of the world. In general it is hard(impossible) to determine if a program will ever diverge (the halting problem). That doesn't mean that for certain programs it can't be done, but that in general you will likely end up having to annotate divergence, even where you know as a programmer that it will never diverge. Program analyzers are getting better at figuring out some invariants similar to humans, but there is definitely more work to be done. |
Beta Was this translation helpful? Give feedback.
Divergence inference is rather conservative. Koka still has room for improvement in this area, and this particular issue seems worth looking into. However, annotating with divergence isn't the end of the world. In general it is hard(impossible) to determine if a program will ever diverge (the halting problem). That doesn't mean that for certain programs it can't be done, but that in general you will likely end up having to annotate divergence, even where you know as a programmer that it will never diverge. Program analyzers are getting better at figuring out some invariants similar to humans, but there is definitely more work to be done.