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,321
    • Issues 4,321
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 359
    • Merge Requests 359
  • 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
  • #12185

Closed
Open
Opened Jun 10, 2016 by Eric Crockett@crockeeaReporter

Can't call rank-2 function with type family constraint

The following code compiles with 7.10.3:

newtype Bar r = Pow r deriving (Eq)
instance (Foo r) => Foo (Bar r)

type family Ctx a where Ctx t = (Foo (Bar t), Eq (Bar t))

run :: (forall t . (Ctx t) => t -> Int) -> Int
run g = undefined

foo :: (Foo (Bar t)) => t -> Int
foo = undefined

main :: IO ()
main = print $ run foo

but fails in 8.0.1 with

    • Could not deduce (Foo t) arising from a use of ‘foo’
      from the context: Ctx t
        bound by a type expected by the context:
                   Ctx t => t -> Int
        at Main.hs:19:16-22
      Possible fix:
        add (Foo t) to the context of
          a type expected by the context:
            Ctx t => t -> Int
    • In the first argument of ‘run’, namely ‘foo’
      In the second argument of ‘($)’, namely ‘run foo’
      In the expression: print $ run foo

This code seems valid to me: when I call run foo, foo is specialized to (Foo (Bar t), Eq (Bar t)) => t -> Int), which meets the requirement of the argument to run.

Trac metadata
Trac field Value
Version 8.0.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#12185