Changes between Version 4 and Version 5 of Ticket #86

Feb 3, 2006 11:38:57 AM (10 years ago)


  • Ticket #86 – Description

    v4 v5  
    1 Short idea: _ in place of a type is "match anything" (by analogy to the wildcard pattern). This is /not/ the type (exists a.a), contrary to suggestions on the mailing list, as a) we wish to end up with a more specific type via inference and b) the existential type would have issues in a predicative type system (which includes the current rank-n implementations). Essentially, in checking the annotation we infer as normal for the _ and accept whatever is inferred.
    3 Note that _ *is not a type*. It's part of the type annotation, but should never be propagated "upwards" by the typechecker - only the type inferred for its position.
    5 There are some further possible extensions to this idea:
    7  1. Allow _ in class contexts to mean one or both of "and additional constraints" or "some type variable that will be inferred". Currently this isn't a well-developed idea, I haven't thought much about it - I like the idea of having a way to say "please don't fall over if I missed out a constraint" though.
    8  1. Allow "metavariables" (no longer actually meta due to being in the type system, of course) which might be written _a and appear multiple times in the same annotation always meaning the same type.
    9   * Add some kind of binder for metavariables and give them lexical scope much as can be done with ordinary type variables. If we do this, top-level bindings would also make sense and allow us to name types we'd like inferred for us before using them as part of type declarations
    10   * Allow some kind of constraints between metavariables (Frank Atanassow mentioned this to me on #haskell-blah)
    12 Pros:
    14  * Allows type annotations to convey information they need to without forcing the programmer to infer things the compiler should for them
    15  * Can be used to get a complete type before filling in a permanent annotation
    16  * Helps scale type annotations to cope with increasingly large types
    17  * Metavariables provide similar readability benefits to type annotations while being more change-resistant due to inference
    19 Cons:
    21  * It's a new and untested feature
    22  * It could encourage sloppy programming style
    23  * Readability benefits are also untested
     1See PartialTypeAnnotations.