-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Meta-issue: using a generic function type as a type argument or as a bound is an error #29484
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
Comments
I'm not sure where this constraint comes from, is it simply a matter of avoiding to support a potentially complex corner of the language? What I wrote in the informal specification of generic function type aliases already in the introduction was that this feature is intended to allow actual type arguments and bounds (among other things) to be generic function types. After all, we could already express the type-level functions (like In 'Static Analysis' it says that type parameter bounds cannot be of kind It's worth noting that there is no abstraction over several aspects of generic function types. In particular, when the statically known type of a first-class function is a generic function type then that function will be generic at run-time, and it will take exactly as many type arguments as we know about statically, with exactly the same bounds. Similarly, with a non-generic static function type (other than I also noted that the example code above suggests that a lone |
My original generic method proposal was for prenex, predicative polymorphism. We relaxed that to be just predicative, but my intention was that we would stay in the predicative fragment. Since we have agreed to make type bounds behave invariantly (that is, So I'm fairly strongly in favor of at least starting in the predicative fragment, and only expanding to the impredicative fragment when and if we have convinced ourselves of that it's decidable and worth any opportunity cost that we would pay. [1] http://www2.tcs.ifi.lmu.de/lehre/SS07/Typen/pierce93bounded.pdf |
OK, that makes sense. This actually means that generic function types can be used in the following situations, and only in those situation (where
If a list of generic functions is needed then we can embed it into the nominal type universe using a wrapper class:
|
Obsolete. |
It is a static error to use a generic function as a type argument, or as a bound to a generic.
Example:
The text was updated successfully, but these errors were encountered: