Ticket #2994 (closed feature request: fixed)

Opened 4 years ago

Last modified 4 years ago

give better error messages for instance declarations with the wrong number of parameters

Reported by: rwbarton Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.11
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: typecheck/should_fail/T2994 Blocked By:
Blocking: Related Tickets:

Description

Consider the following erroneous program which tries to define an instance of MonadReader.

import Control.Monad.Reader

newtype Reader' r a = Reader' (r -> a)

instance MonadReader (Reader' r)

This instance declaration is wrong, because the MonadReader type class has two parameters. But ghc's error message is not very helpful:

/tmp/err.hs:5:21:
    `Reader' r' is not applied to enough type arguments
    Expected kind `*', but `Reader' r' has kind `* -> *'
    In the instance declaration for `MonadReader (Reader' r)'

While if I give too many arguments, e.g., instance MonadReader r r (Reader' r), I always get a good error message, even if the kinds of some of the leading types are wrong:

    Kind error: `MonadReader' is applied to too many type arguments
    In the instance declaration for `MonadReader r r (Reader' r)'

So it'd be great if the error message for giving too few type arguments could be more like that one.

Change History

Changed 4 years ago by simonpj

  • status changed from new to closed
  • difficulty set to Unknown
  • resolution set to fixed
  • testcase set to typecheck/should_fail/T2994

Your wish is my command.

I spent way too long on this, but it was fun.

Wed Feb  4 15:07:36 GMT 2009  simonpj@microsoft.com
  * Improve error reports for kind checking (Trac #2994)

Let's not merge to 6.10. It's an unforced change, and quite a lot of lines of code are touched.

Simon

Note: See TracTickets for help on using tickets.