[Haskell-cafe] Strange type error with associated type synonyms

Simon Peyton-Jones simonpj at microsoft.com
Wed May 27 15:42:22 EDT 2009


Claus made a suggestion about type error messages:

| Apart from bracketing fully applied type synonyms, the error message
| could be improved by providing the missing bit of information about
| 'Memo':
|
|     D:\home\Haskell\tmp\desktop\types.hs:11:11:
|         Couldn't match expected type `Memo d1'
|                against inferred type `Memo d'
|         (type Memo d :: * -> *)
|         In the second argument of `(.)', namely `appl'
|         In the expression: abst . appl
|         In the definition of `f': f = abst . appl

I've implemented this idea; note the "NB" line below:

NoMatchErr.hs:20:11:
    Couldn't match expected type `Memo d'
           against inferred type `Memo d1'
      NB: `Memo' is a (non-injective) type function
    In the second argument of `(.)', namely `appl'
    In the expression: abst . appl
    In the definition of `f': f = abst . appl

(Rather than give its kind, I thought it was better to focus on the reason for the mis-match, namely the non-injectivity.)

Simon


More information about the Haskell-Cafe mailing list