[GHC] #8984: Improve output of failed GeneralizedNewtypeDeriving coercion due to type roles

GHC ghc-devs at haskell.org
Fri Apr 11 01:57:12 UTC 2014


#8984: Improve output of failed GeneralizedNewtypeDeriving coercion due to type
roles
-------------------------------------------+-------------------------------
       Reporter:  haasn                    |             Owner:
           Type:  feature request          |            Status:  new
       Priority:  normal                   |         Milestone:
      Component:  Compiler (Type checker)  |           Version:  7.8.1
       Keywords:                           |  Operating System:
   Architecture:  Unknown/Multiple         |  Unknown/Multiple
     Difficulty:  Unknown                  |   Type of failure:
     Blocked By:                           |  None/Unknown
Related Tickets:                           |         Test Case:
                                           |          Blocking:
-------------------------------------------+-------------------------------
 When trying to build acme-schoenfinkel (as an example), I came across an
 error like this:

 {{{
 Control/Category/Schoenfinkel.hs:66:48:
     Could not coerce from ‘cat (cat b c,
                                 b) c’ to ‘cat (WrappedSchoenfinkel cat b
 c, b) c’
       because ‘cat (cat b c, b) c’ and ‘cat (WrappedSchoenfinkel cat b c,
                                              b) c’ are different types.
       arising from the coercion of the method ‘app’ from type
                    ‘forall b c. cat (cat b c, b) c’ to type
                    ‘forall b c.
                     WrappedSchoenfinkel cat (WrappedSchoenfinkel cat b c,
 b) c’
     Possible fix:
       use a standalone 'deriving instance' declaration,
         so you can specify the instance context yourself
     When deriving the instance for (ArrowApply
                                       (WrappedSchoenfinkel cat))
 }}}

 It was not immediately clear to me as a user that this was caused due to
 it wanting GNT which was now being blocked by type roles (rightfully so,
 as this instance allows UnsafeCoerce!), and beyond that, what the specific
 rule that triggered this was.

 In this case the failure is due to ‘WrappedSchoenfinkel cat b c’ not being
 nominally equal to ‘cat b c’, in the type ‘(WrappedSchoenfinkel cat b c,
 b)’, which is required to be nominally equal to ‘(cat b c, b)’ because
 it's used as a parameter to the variable ‘cat’.

 Printing a location breakdown and context information similar to this to
 the user would help understanding and debugging roles a lot.

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


More information about the ghc-tickets mailing list