|Version 2 (modified by 11 years ago) (diff),|
NEEDS TO BE FURTHER EDITED BY THE ORIGINAL CREATOR TO CLARIFY ORIGINAL INTENTION
The possibility to omit parts of type signatures.
Support a 'wildcard' type (probably written "_" to match the pattern-matching syntax) that matchs any inferred type (an anonymous type variable), without requiring any actual degree of polymorphism the way a real type variable does. I.e. Unlike a normal type variable, no attempt would be made to generalize underscore to a universally quantified variable. It stands for a specific but unspecified type.
This allows 'partial' annotations, making it easier to provide the type system with extra information, but without having to supply potentially complicated parameters that it can infer itself. Possibly the same thing can also be used in a type context to indicate zero or more predicates other than those specified.
Reasons for doing this include that parts of a signature can be obvious and bulky, and the consequent clutter can obscure the important or interesting part of the signature.
- does _ only work for types, or also for class contexts?
- how would the exact syntax be?
- if you have multiple underscores, they're all different, I guess; but wouldn't you want also to be able to say that a type is "_a → _a" for some "_a"?
- are there any interactions with typechecking of rank-n types or GADTs?
- The disadvantage of the current Haskell solution is that it is so much "all or nothing". You cannot have the benefits of inference without losing the benefits of documentation. For complex class contexts (and even more for implicit parameters), it would be extremely helpful to have the possiblity to omit parts of a type signature, and even in normal situations it can be helpful.
- Not implemented(?)