[GHC] #9017: Confusing error message with PolyKinds

GHC ghc-devs at haskell.org
Mon Apr 28 10:19:09 UTC 2014


#9017: Confusing error message with PolyKinds
-------------------------------------+------------------------------------
        Reporter:  edsko             |            Owner:
            Type:  bug               |           Status:  new
        Priority:  normal            |        Milestone:
       Component:  Compiler          |          Version:  7.8.2
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:
        Blocking:                    |  Related Tickets:
-------------------------------------+------------------------------------

Comment (by simonpj):

 I agree that this is bad.  We really want more information about what goes
 wrong with the kind equality.

 At the moment, when we get a kind-incompatible type equality, such as `a:k
 ~ b:*`, we generate a "derived" kind equality `k ~ *`.  In this case `k`
 is a skolem constant, so the constraint is insoluble.  But derived
 constraints are discarded before error message generation (for good
 reason) so we only see the type-equality problem.

 We could instead generate a "wanted" kind equality; that would not be
 discarded, and we'd get a better error message:
 {{{
 T9017.hs:8:7:
     Couldn't match kind `k1' with `*'
       `k1' is a rigid type variable bound by
            the type signature for foo :: a b (m b) at T9017.hs:7:8
     When matching types
       a0 :: * -> * -> *
       a :: k1 -> k -> *
     Expected type: a b (m b)
       Actual type: a0 b0 (m0 b0)
     Relevant bindings include foo :: a b (m b) (bound at T9017.hs:8:1)
     In the expression: arr return
     In an equation for `foo': foo = arr return
 }}}
 Could still do with improvement (the foralls in the "bound by" message are
 invisible), but better.

 Sadly, a new wanted constraint should be used to solve the constraint that
 gave rise to it, otherwise we generate the same wanted constraint many
 times.  And that is what happens here: we get two copies of the same error
 messages.

 With some faff we could elimate the dup, but I think it'd better to wait
 for Richard's upcoming work in which he gives us full-on kind equalities.
 Now we can use the kind equality to solve the type equality and all will
 be well.

 Meanwhile I attach my diff.

 Simon

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9017#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list