Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,268
    • Issues 4,268
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 408
    • Merge Requests 408
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #8984

Closed
Open
Opened Apr 11, 2014 by haasn@trac-haasn

Improve output of failed GeneralizedNewtypeDeriving coercion due to type roles

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.

Edited Mar 09, 2019 by Simon Peyton Jones
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#8984