-
Notifications
You must be signed in to change notification settings - Fork 27
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
Improving "leftover constraints" errors #31
Comments
This isn't a bug? The test case never explicitly states what variant type is wanted. The type checker will not guess it. |
A simpler version of the same problem is simply:
|
Hmmm. I see. If I wrote |
What? e -> e? Nothing to do with it? |
The thing is if you write |
Ahh, typo. So does it really matter which one it guesses? Any minimal type that doesn't introduce inconsistency should be ok for this purpose? |
Guessing will introduce really strange results. Remember that |
Quite annoying --- is there a way to generate a meaningful error message for that? |
Well, if there is a leftover constraint like Alternatively I could try do to some sort of guesswork -- it would work out okay if you take the entire constraint system into account. But it really feels like it should at least generate a warning if it's doing that. For example, if you have a bunch of code:
Then the minimal "guess" would be that the type is just |
Did this error actually come up in Bilby? Is it easy to add a type signature to it? |
In that case you mentioned, it makes sense to emit an error -- if you don't say what the type is, you cannot do |
It's extracted from bilby. It's possible to add some annotation but in general, the patterns could be large (consequently the types) and with several levels of pattern matching, it requires quite a bit of thinking to understand where guidance is required. Pattern matching is a big feature in FP and it would resist user to write idiomatic functional-style code in Cogent. |
Thinking about it more, I don't think we can safely guess. If we have a constraint The problem is that we only want to guess if there isn't an obvious solution for One little trick to make things easier is to make a constructor function that specifies the type, e.g:
Then use |
Looks like a fare trick. After applying that trick, I still got lots of leftovers, which does NOT consist of loops or exhaustive constraints. I need to study more on the original code in order to tell what's going on.
|
It looks like this might be another situation where they misused Also, that's a lot of unification variables... |
Not sure that's the case, as |
* compiler: wip - allow type annotations on exprs [skip ci] it won't pass! * compiler: mostly working now * cogent: use type annotation for #31. reenable tc test in ci
* compiler: wip - allow type annotations on exprs [skip ci] it won't pass! * compiler: mostly working now * cogent: use type annotation for #31. reenable tc test in ci
* compiler: wip - allow type annotations on exprs [skip ci] it won't pass! * compiler: mostly working now * cogent: use type annotation for #31. reenable tc test in ci
* compiler: wip - allow type annotations on exprs [skip ci] it won't pass! * compiler: mostly working now * cogent: use type annotation for #31. reenable tc test in ci
No guessing in variant types. For more details see discussions below. Symptom: left-over constraints with an
Exhaustive
constraint. We might want to enhance it in some future.The text was updated successfully, but these errors were encountered: