-
Notifications
You must be signed in to change notification settings - Fork 85
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
Scope the type variables #423
Comments
For a more compelling use-case, I was trying to implement a
fails with
|
I don't think scoped type variables are gonna help with your example. The problem is that currently the type of merge is more or less |
That’s a good point indeed :) .But annotating it with a contract (or using a specialized version of |
Translating the NixPkgs lib, I think I found a good example of this necesity of scoped type variable
In this case the typechecker will throw a type missmatch because:
is infered to be The intuitive way to fix it would have been to add a contract to it. But without scoped types vars, we get:
So, I don't think we have any way right now to staticaly type |
Is your feature request related to a problem? Please describe.
Inside a (typed) polymorphic expression, it isn’t possible to annotate the type of an intermediary expression with the type variable.
For example (because the above is very weirdly phrased), I’d like to write a type annotation for
y
in the following expression, but it isn’t possible:Describe the solution you'd like
Something akin to GHC’s ScopedTypeVariables extension (or IIRC OCaml’s default behavior) making it so that any
forall
brings the newly bound type variables in scope for the whole subexpression.Describe alternatives you've considered
Not annotate the inner expressions. But that’s not cool
The text was updated successfully, but these errors were encountered: