[GHC] #11464: Type casts cause confusing error

GHC ghc-devs at haskell.org
Wed Jan 20 14:17:35 UTC 2016


#11464: Type casts cause confusing error
-------------------------------------+-------------------------------------
           Reporter:  simonpj        |             Owner:
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  7.10.3
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Try this
 {{{
 instance Eq (Either a)
 }}}
 GHC HEAD gives
 {{{
 Foo.hs:9:10: error:
     • Illegal instance declaration for ‘Eq (Either a)’
         (All instance types must be of the form (T a1 ... an)
          where a1 ... an are *distinct type variables*,
          and each type variable appears at most once in the instance head.
          Use FlexibleInstances if you want to disable this.)
     • In the instance declaration for ‘Eq (Either a)’

 Foo.hs:9:14: error:
     • Expecting one more argument to ‘Either a’
       Expected a type, but ‘Either a’ has kind ‘* -> *’
     • In the first argument of ‘Eq’, namely ‘Either a’
       In the instance declaration for ‘Eq (Either a)’
 }}}
 The second is right  but the first is outright misleading.

 Reason: we elaborate to
 {{{
 Eq (Either a |> g)
 }}}
 where `g` is a type-level kind cast; it's insoluble and gives rise to the
 second error.  But the elaborated type confuses `checkValidInstHead`.

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


More information about the ghc-tickets mailing list