[GHC] #12185: Can't call rank-2 function with type family constraint

#12185: Can't call rank-2 function with type family constraint -------------------------------------+------------------------------------- Reporter: crockeea | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 (Type checker) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: GHC rejects Unknown/Multiple | valid program Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- 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`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12185 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12185: Can't call rank-2 function with type family constraint -------------------------------------+------------------------------------- Reporter: crockeea | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: duplicate | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * resolution: => duplicate Comment: Ha! Happily this is the same problem as #12175, and hence already fixed. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12185#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12185: Can't call rank-2 function with type family constraint
-------------------------------------+-------------------------------------
Reporter: crockeea | Owner:
Type: bug | Status: closed
Priority: normal | Milestone:
Component: Compiler (Type | Version: 8.0.1
checker) |
Resolution: duplicate | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: GHC rejects | Unknown/Multiple
valid program | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#12185: Can't call rank-2 function with type family constraint -------------------------------------+------------------------------------- Reporter: crockeea | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: duplicate | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | typecheck/should_compile/T12185 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * testcase: => typecheck/should_compile/T12185 Comment: I've added a regression test though -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12185#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC