Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 5.5k
    • Issues 5.5k
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 631
    • Merge requests 631
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Model experiments
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #12185

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
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking