Wildcard type annotations

Andres Loeh loeh at iai.uni-bonn.de
Mon Jan 23 12:41:35 EST 2006


Hi Philippa,

> Would it be possibly to support a 'wildcard' type (probably written "_" to 
> match the pattern-matching syntax) that matched any inferred type without 
> requiring any actual degree of polymorphism the way a type variable would? 
> This would allow 'partial' annotations, making it easier to provide the 
> type system with extra information without having to supply potentially 
> complicated parameters that it can infer itself. Possibly the same thing 
> could also be used in a type's constraint to indicate zero or more 
> predicates other than those specified.

I like this idea. There's a Wiki page with not so much information yet
about this feature:

http://haskell.galois.com/cgi-bin/haskell-prime/trac.cgi/wiki/PartialTypeSigs

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.

I think what we need here is a real proposal, because it is a feature
that currently isn't implemented (it might be in EHC, but I don't know
the syntax there). In particular, I'm unclear about the following
questions:

  * 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?

Cheers,
  Andres


More information about the Haskell-prime mailing list