Re: defaulting (was: Program Compiles With GHC 6.6 but not Hat)

Malcolm Wallace <[email protected]> Sat, 18 Nov 2006 10:31:14 +0000
Newsgroups gmane.comp.lang.haskell.hat
Organization Dept of Computer Science, University of York
Message-ID <[email protected]>
Thomas Davie <[email protected]> writes:

>    This brings up something that's been niggling me for a while.  Why  
> can Hat not deal with defaulting?  Surely it could be handled by the  
> first stage of hat-trans being inserting explicit type signatures  
> based on the standard defaulting rules?

We made a deliberate design decision that hat-trans should be entirely
syntax-directed - it does not do type inference.  There are good reasons
for this decision.

  * In a well-designed language, you would not need type information for
    the tracing transformation.  And indeed, Haskell is so well designed
    that you do not, except for this one very small (but very annoying)
    instance.
  * Implementing type inference is difficult enough that we did not
    consider the effort worthwhile for the tiny benefit of being able to
    handle defaulting.
  * In order to be able to handle all the many experimental type-system
    extensions accepted by a compiler like ghc, hat-trans would need to
    replicate ghc's type inference as exactly as possible.  Given the
    number of papers written about this very topic, that would not be an
    easy task!  But in fact, apart from defaulting, it is only necessary
    to _syntactically_ transform type signatures (where they are used),
    and the ghc type system can infer the rest.

Regards,
    Malcolm