#11548 closed bug (fixed)

Absolutely misleading error message on kind error

Reported by: mniip Owned by: goldfire
Priority: high Milestone: 8.0.1
Component: Compiler (Type checker) Version: 8.0.1-rc1
Keywords: TypeInType Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

module Bug where

import Data.Proxy

fun :: Proxy a -> ()
fun Proxy = ()

bug :: ()
bug = fun (Proxy :: Proxy Maybe)
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )

Bug.hs:9:12: error:
     Expected kind Proxy Maybe,
        but Data.Proxy.Proxy :: Proxy Maybe has kind Proxy Maybe
     In the first argument of fun, namely (Proxy :: Proxy Maybe)
      In the expression: fun (Proxy :: Proxy Maybe)
      In an equation for bug: bug = fun (Proxy :: Proxy Maybe)

7.10 gives the appropriate Couldn't match kind ‘* -> *’ with ‘*’ message.

Change History (8)

comment:1 Changed 22 months ago by bgamari

Component: CompilerCompiler (Type checker)

Note that if you pass -fprint-explicit-kinds the error is a bit better (although arguably still not as clear as 7.10's error),

Bug.hs:9:12: error:
    • Expected kind ‘Proxy * Maybe’,
        but ‘Data.Proxy.Proxy :: Proxy Maybe’ has kind ‘Proxy
                                                          (* -> *) Maybe’
    • In the first argument of ‘fun’, namely ‘(Proxy :: Proxy Maybe)’
      In the expression: fun (Proxy :: Proxy Maybe)
      In an equation for ‘bug’: bug = fun (Proxy :: Proxy Maybe)

Of course, this isn't a great situation; surely the compiler can see that the types as printed are indistinguishable and it should therefore providing kinds as well. I'm not certain of this, but I suspect Richard is already aware of this issue.

comment:2 Changed 22 months ago by mniip

Is Proxy Maybe even a kind? Unless I'm missing something, in this context it is a type, not a kind.

comment:3 Changed 22 months ago by bgamari

A fair point. Yes, "kind" does seem a bit misleading here.

comment:4 Changed 22 months ago by goldfire

Owner: set to goldfire

Yes, I'm already aware of this issue, but another test case is good. Thanks!

comment:5 Changed 22 months ago by RyanGlScott

Possibly a duplicate of #11485?

comment:6 Changed 22 months ago by simonpj

Keywords: TypeInType added

comment:7 Changed 15 months ago by RyanGlScott

For reference, here is the current error message in GHC 8.0.1/HEAD:

    • Couldn't match type ‘* -> *’ with ‘*’
      Expected type: Proxy Maybe
        Actual type: Proxy Maybe
      Use -fprint-explicit-kinds to see the kind arguments
    • In the first argument of ‘fun’, namely ‘(Proxy :: Proxy Maybe)’
      In the expression: fun (Proxy :: Proxy Maybe)
      In an equation for ‘bug’: bug = fun (Proxy :: Proxy Maybe)

I think this is much clearer, and doesn't incorrectly label the type as a kind.

comment:8 Changed 12 months ago by bgamari

Milestone: 8.0.1
Resolution: fixed
Status: newclosed
Version: 8.18.0.1-rc1

This is fixed in 8.0.1.

Note: See TracTickets for help on using tickets.