Improve error messages for type functions
authorsimonpj@microsoft.com <unknown>
Tue, 12 May 2009 17:12:29 +0000 (17:12 +0000)
committersimonpj@microsoft.com <unknown>
Tue, 12 May 2009 17:12:29 +0000 (17:12 +0000)
commitda2e18b9ab29131bda1ac8e3962dc50b635589a5
treed98d015e604d728c4acc752f2290b0b5abbe552b
parenteb6e1243d28a5acd967b981893a6cc96f145207f
Improve error messages for type functions

Following a suggestion of Claus Reinke, this patch improves the error
messages involving type functions.  Here's the relevant note from TcTyFuns.

Note [Non-injective type functions]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It's very confusing to get a message like
     Couldn't match expected type `Depend s'
            against inferred type `Depend s1'
so pp_open_tc adds:
       NB: `Depend' is a (non-injective) type function

Currently we add this independently for each argument, so we also get
     Couldn't match expected type `a'
            against inferred type `Dual (Dual a)'
       NB: `Dual' is a (non-injective) type function
which is arguably redundant.  But on the other hand, it's probably
a good idea for the programmer to know the error involves type functions
so I've left it in for now.  The obvious alternative is to only add
this NB in the case of matching (T ...) ~ (T ...).
compiler/typecheck/TcTyFuns.lhs
compiler/types/TyCon.lhs