[GHC] #9747: Odd failure to deduce a constraint

#9747: Odd failure to deduce a constraint -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Keywords: TypeFamilies | Operating System: ConstraintKinds | Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: Difficulty: Unknown | None/Unknown Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Using a type family to build a compound constraint that includes several constraints produced by applying another type family results in a type checker error like, {{{ Could not deduce (ConFun l a, ConFun l b) arising from a use of ‘bar’ from the context (ConFun l a, ConFun l b) bound by the type signature for baz :: (ConFun l a, ConFun l b) => Proxy l -> HList '[a, b] -> () }}} An example program is given at, https://gist.github.com/acowley/a001bd092599b5914bad -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9747 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9747: Odd failure to deduce a constraint -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: bug | Status: infoneeded Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: TypeFamilies Operating System: | ConstraintKinds Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: | Difficulty: Unknown None/Unknown | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by goldfire): * status: new => infoneeded Comment: Works for me, on GHC 7.8.3. If you're still seeing this error, try enabling `-fprint-explicit-kinds` -- my guess is that you'll get some helpful information. Can you give more instructions on how to reproduce? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9747#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9747: Odd failure to deduce a constraint -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: bug | Status: infoneeded Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: TypeFamilies Operating System: | ConstraintKinds Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: | Difficulty: Unknown None/Unknown | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by acowley): Sorry I wasn't clear, you need to uncomment the definition of `baz` to see the error. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9747#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9747: Odd failure to deduce a constraint -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: fixed | Keywords: TypeFamilies Operating System: | ConstraintKinds Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: | Difficulty: Unknown None/Unknown | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: infoneeded => closed * resolution: => fixed Comment: It's a bug in GHC 7.8.3, fixed in upcoming 7.8.4 and HEAD, and not present in 7.8.2. Both say {{{ T9747.hs:35:8: Type family ‘ConFun’ should have 2 arguments, but has been given 1 In the type signature for ‘bar’: bar :: HListAll (ConFun l) ts => Proxy l -> HList ts -> () }}} And that's right! This works though {{{ type family ConFun (t :: *) :: * -> Constraint data Tag type instance ConFun Tag = Group class (Show a, Eq a, Ord a) => Group a bar :: HListAll (ConFun l) ts => Proxy l -> HList ts -> () bar _ _ = () baz :: (ConFun l a, ConFun l b) => Proxy l -> HList [a,b] -> () baz = bar }}} I've eta-reduced `ConFun`, but then I had to give a fresh name to the RHS via the class decl for `Group`. I'll add the working version as a regression test. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9747#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9747: Odd failure to deduce a constraint -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: fixed | Keywords: TypeFamilies Operating System: | ConstraintKinds Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: | Difficulty: Unknown None/Unknown | Blocked By: Test Case: indexed- | Related Tickets: types/should_compile/T9747 | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by simonpj): * testcase: => indexed-types/should_compile/T9747 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9747#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9747: Odd failure to deduce a constraint -------------------------------------+------------------------------------- Reporter: acowley | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: fixed | Keywords: TypeFamilies Operating System: | ConstraintKinds Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: | Difficulty: Unknown None/Unknown | Blocked By: Test Case: indexed- | Related Tickets: types/should_compile/T9747 | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by acowley): Thank you! That is precisely the error I expected to see. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9747#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9747: Odd failure to deduce a constraint
-------------------------------------+-------------------------------------
Reporter: acowley | Owner:
Type: bug | Status: closed
Priority: normal | Milestone:
Component: Compiler | Version: 7.8.3
Resolution: fixed | Keywords: TypeFamilies
Operating System: | ConstraintKinds
Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: | Difficulty: Unknown
None/Unknown | Blocked By:
Test Case: indexed- | Related Tickets:
types/should_compile/T9747 |
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones
participants (1)
-
GHC