Ticket #1633 (closed feature request: fixed)

Opened 6 years ago

Last modified 4 years ago

Improve error message for kind mismatches

Reported by: guest Owned by:
Priority: normal Milestone: 6.12 branch
Component: Documentation Version: 6.6.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: typecheck/should_fail/T1633 Blocked By:
Blocking: Related Tickets:

Description

ext :: Ev st Request res -> ServerPart (EvPar res st) Request Result
ext x = Handle $ \req -> do f <- ask
                            liftIO $ f x req

That's from HAppS/Protocols/HTTP.hs

While trying to bend my head around the involved types, feeling understanding already creeping somewhere, I, in a desperate attempt, copied the code into my source and changed it to

ext' :: Ev st Request res -> ServerPart (EvPar res st) Request Result
ext' x = Handle $ \req -> req

hoping to get a clean, expressive and enlightening type error,

I got this:

    Kind mis-match
    Expected kind `* -> *', but `Result' has kind `*'
    In the type `ServerPart (EvPar res st) Request Result'
    In the type `Ev st Request res
                 -> ServerPart (EvPar res st) Request Result'
    In the type signature for `ext'':
      ext' :: Ev st Request res
              -> ServerPart (EvPar res st) Request Result

Which made me wonder, google and then groan, as I couldn't even figure out what the heck a kind-mismatch is or means, not to mention why ghc points me to the type instead of the code.

My request is for the documentation section "Error messages and their meaning" aka "RTF this if you got that". The terminology of some ghc errors is just begging for references to papers.

Change History

Changed 6 years ago by chevalier@…

A kind is to a type what a type is to a value. The error message is saying that the type ServerPart (EvPar res st) Request Result is ill-formed. Since the error message only concerns the type, not the code, that's why the error message doesn't mention the code. In this case, the error is saying that you're using a type (Result) in a context where a type constructor is expected (analogous to applying the constant 1 to an argument). Looking at the type definition for ServerPart should be enlightening.

Changed 6 years ago by ross

  • type changed from proposal to feature request

Changed 6 years ago by igloo

  • milestone set to 6.8

Changed 6 years ago by simonpj

  • milestone changed from 6.8 branch to 6.10 branch

I think we ought at least to be able to improve the error message a bit -- something like "Request is not applied to enough arguments".

Let's try to do this for 6.10.

Simon

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple

Changed 4 years ago by igloo

  • milestone changed from 6.10 branch to 6.12 branch

Changed 4 years ago by simonmar

  • summary changed from Now where does this error come from to Improve error message for kind mismatches

Adding a more descriptive description

Changed 4 years ago by simonpj

  • status changed from new to closed
  • testcase set to typecheck/should_fail/T1633
  • resolution set to fixed

Fixed by

Wed May 13 16:11:30 BST 2009  simonpj@microsoft.com
  * Improve error reporting for kind errors (fix Trac #1633)
  
  A long-standing improvement to the error message for kinds. Now instead of
      Expected kind `* -> *', but `Int' has kind `*'
  we get
      The first argument of `T' should have kind `* -> *',
      but `Int' has kind `*'

Simon

Note: See TracTickets for help on using tickets.