-
Notifications
You must be signed in to change notification settings - Fork 645
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
Instance declaration possibly not total #4194
Comments
@nicolabotta Thank you for reporting, this does indeed seem weird. |
@edwinb Any idea what could cause this? |
Replacing the last block of code with
makes the program type check but it is not clear to me what it means. What is actually declared to be partial here? |
@nicolabotta It seems that somehow the named implementation itself is seen to be non-total, and I have no idea why. |
Probably the totality checker can’t see through toDouble. You can always %assert_total if you know better than it.
… 14 nov. 2017 kl. 08:06 skrev nicolabotta ***@***.***>:
Replacing the last block of code with
> using implementation EqNonNegDouble
> partial
> implementation [OrdNonNegDouble] Ord NonNegDouble where
> compare x y = compare (toDouble x) (toDouble y)
makes the program type check but it is not clear to me what it means. What is actually declared to be partial here?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@melted I have tried replacing it with a hole as well. |
@melted Implementing
does not improve things. |
How to do so? |
|
@ahmadsalim That's the point, thanks. And, to me, it is not even clear what it means for an interface declaration to be possibly not total! |
@nicolabotta Yes, I believe this is truly a bug. I am just mentioning what the tool says which is that there is some kind of recursive path from the instance declaration to itself, which is to say surprising. |
This may be to do with the fact that instances are elaborated as functions which build a dictionary for the instance, and it relies on some inlining to make sure that recursive calls to methods don't build dictionaries recursively forever. I will take a closer look. |
@edwinb Great, thanks! If this issue is fixed, I should be able to move to Idris 1.1.1. For the time being I am stuck with 0.99. |
I'm still looking at why this happens, but here's one thing to note at least - the intended syntax for stating which parent implementations to use for a named instance is:
This resolves the totality problem. However - the "using implementation" notation should behave in exactly the same way in this context. I will dig further. |
Oh. It turns it it is working exactly the same way, but the totality checker is running at the wrong time because the top level "using implementation" declaration isn't being handled properly. The fix is one line, and on its way... |
Thanks Edwin, I will now try to get IdrisLibs to 1.1 and report my findings! |
@edwinb I have almost managed to port IdrisLibs to 1.1.2 using named implementations! The good news is that the port is trivial and requires virtually no modification of the legacy code. One only has to nest the original code in (often nested) https://gitlab.pik-potsdam.de/botta/IdrisLibs/blob/towards1.1.1/NonNegDouble/Properties.lidr to https://gitlab.pik-potsdam.de/botta/IdrisLibs/blob/master/NonNegDouble/Properties.lidr The new code is obviously not as clean as the original one and the nested But it's still much better than renouncing to Sigma types altogether, I believe. Anyway, thanks againg for fixing this bug! |
The skeleton
fails to type check with
Is this the expected behavior? Any idea how to avoid the errors?
The text was updated successfully, but these errors were encountered: