[GHC] #9103: hackage's type-level-0.2.4 fails to compile

#9103: hackage's type-level-0.2.4 fails to compile -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.2 checker) | Operating System: Unknown/Multiple Keywords: | Type of failure: GHC rejects Architecture: Unknown/Multiple | valid program Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | -------------------------------------+------------------------------------- Attached trimmed-down dependencyless archive. Steps to reproduce: {{{ $ tar -xzf type-level-0.2.4.tar.gz $ ghci -hide-all-packages -package=base -package=template-haskell Data/TypeLevel.hs }}} The error on 7.8.2 and in -HEAD is: {{{ [6 of 8] Compiling Data.TypeLevel.Num.Ops ( Data/TypeLevel/Num/Ops.hs, interpreted ) Data/TypeLevel/Num/Ops.hs:90:10: Illegal instance declaration for ‘Succ' (x, x) (x, x) D0 D0 True’ The liberal coverage condition fails in class ‘Succ'’ for functional dependency: ‘yh yl yz -> xh xl’ Reason: lhs types ‘D0’, ‘D0’, ‘True’ do not jointly determine rhs types ‘(x, x)’, ‘(x, x)’ In the instance declaration for ‘Succ' (x, x) (x, x) D0 D0 True’ ... }}} Typechecked fine on ghc-7.6.3 {{{ [1 of 8] Compiling Data.TypeLevel.Num.Reps ( Data/TypeLevel/Num/Reps.hs, interpreted ) [2 of 8] Compiling Data.TypeLevel.Num.Sets ( Data/TypeLevel/Num/Sets.hs, interpreted ) [3 of 8] Compiling Data.TypeLevel.Num.Aliases.TH ( Data/TypeLevel/Num/Aliases/TH.hs, interpreted ) [4 of 8] Compiling Data.TypeLevel.Num.Aliases ( Data/TypeLevel/Num/Aliases.hs, interpreted ) Generating and compiling a zillion numerical type aliases, this might take a while [5 of 8] Compiling Data.TypeLevel.Bool ( Data/TypeLevel/Bool.hs, interpreted ) [6 of 8] Compiling Data.TypeLevel.Num.Ops ( Data/TypeLevel/Num/Ops.hs, interpreted ) [7 of 8] Compiling Data.TypeLevel.Num ( Data/TypeLevel/Num.hs, interpreted ) [8 of 8] Compiling Data.TypeLevel ( Data/TypeLevel.hs, interpreted ) Ok, modules loaded: Data.TypeLevel, Data.TypeLevel.Num, Data.TypeLevel.Bool, Data.TypeLevel.Num.Reps, Data.TypeLevel.Num.Aliases, Data.TypeLevel.Num.Sets, Data.TypeLevel.Num.Ops, Data.TypeLevel.Num.Aliases.TH. *Data.TypeLevel> }}} I have failed to decipher an error message, but looks like it tries to instantiate a thing it should not. My apologies if it's not-a-bug. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9103 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9103: hackage's type-level-0.2.4 fails to compile ----------------------------------------------+---------------------------- Reporter: slyfox | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler (Type checker) | Version: 7.8.2 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects valid program | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: #8634 ----------------------------------------------+---------------------------- Changes (by rwbarton): * status: new => closed * resolution: => invalid * related: => #8634 Comment: The error looks correct to me. {{{ class Succ' xh xl yh yl yz | xh xl -> yh yl yz, yh yl yz -> xh xl instance Failure (PredecessorOfZeroError x) => Succ' (x,x) (x,x) D0 D0 True }}} The functional dependency `yh yl yz -> xh xl` is violated because `D0 D0 True` do not determine `(x,x) (x,x)`: `x` is free. An instance of #8634. I'm going to mark this ticket as invalid (since it seems to me that you are considering this as a regression rather than a feature request), but see that ticket and its related tickets for ongoing discussion. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9103#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9103: hackage's type-level-0.2.4 fails to compile ----------------------------------------------+---------------------------- Reporter: slyfox | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler (Type checker) | Version: 7.8.2 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects valid program | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: #8634 ----------------------------------------------+---------------------------- Comment (by augustss): The documentation says 'Both the Paterson Conditions and the Coverage Condition are lifted if you give the -XUndecidableInstances flag'. This doesn't seem to be the case. And why does it matter that x is free? Can't it just be assumed to be universally quantified? It would be nice to get back whatever behaviour the old ghc had, because it did the right thing for this case. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9103#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9103: hackage's type-level-0.2.4 fails to compile ----------------------------------------------+---------------------------- Reporter: slyfox | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler (Type checker) | Version: 7.8.2 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects valid program | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: #8634 ----------------------------------------------+---------------------------- Comment (by simonpj): Would anyone who knows or cares about functional dependencies like to look into this? Thanks! Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9103#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9103: hackage's type-level-0.2.4 fails to compile ----------------------------------------------+---------------------------- Reporter: slyfox | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler (Type checker) | Version: 7.8.2 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects valid program | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: #8634 ----------------------------------------------+---------------------------- Changes (by simonpj): * cc: dreixel, diatchki (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9103#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9103: hackage's type-level-0.2.4 fails to compile -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 (Type checker) | Keywords: Resolution: invalid | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: GHC | Related Tickets: #8634 rejects valid program | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by slyfox): Should the ticket be reopened not to get lost and final decision to be stated? Thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9103#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9103: hackage's type-level-0.2.4 fails to compile -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 (Type checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: GHC | Related Tickets: #8634 rejects valid program | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: closed => new * resolution: invalid => Comment: Yes, I'll re-open it. But lacking someone who cares about functional dependencies, it's a bit in limbo. Fundep enthusiasts, stand forth! Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9103#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9103: hackage's type-level-0.2.4 fails to compile -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.2 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: #8634 | -------------------------------------+------------------------------------- Comment (by jstolarek): I've just run into this problem trying to run this toy example from [[https://wiki.haskell.org/Type_arithmetic|Haskell Wiki]]: {{{#!hs data Zero data Succ a class Add a b ab | a b -> ab, a ab -> b instance Add Zero b b instance (Add a b ab) => Add (Succ a) b (Succ ab) }}} {{{ Illegal instance declaration for ‘Add (Succ a) b (Succ ab)’ The liberal coverage condition fails in class ‘Add’ for functional dependency: ‘a b -> ab’ Reason: lhs types ‘Succ a’, ‘b’ do not jointly determine rhs type ‘Succ ab’ In the instance declaration for ‘Add (Succ a) b (Succ ab)’ }}} Interestingly, replacing empty data declarations of `Zero` and `Succ a` with data kinds makes the code compile: {{{#!hs data Nat = Zero | Succ Nat class Add a b ab | a b -> ab, a ab -> b instance Add Zero b b instance (Add a b ab) => Add (Succ a) b (Succ ab) }}} Why with empty data types this is wrong but with promoted types everything is fine? Also, HEAD complains about redundant constraint: {{{ Redundant constraint: Add a b ab In the instance declaration for ‘Add ('Succ a) b ('Succ ab)’ }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9103#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9103: hackage's type-level-0.2.4 fails to compile -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.2 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: #8634 | -------------------------------------+------------------------------------- Comment (by goldfire): My guess is that !PolyKinds is causing trouble in the not-promoted case. Do you have !PolyKinds enabled? Try running with `-fprint-explicit-kinds`. But, the "redundant constraint" warning is almost certainly wrong. I would post that as a separate bug, which we should try to fix by 7.10, I think. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9103#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9103: hackage's type-level-0.2.4 fails to compile -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.2 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: #8634 | -------------------------------------+------------------------------------- Comment (by jstolarek):
My guess is that PolyKinds is causing trouble in the not-promoted case.
Spot-on. Without `PolyKinds` this works perfectly fine.
But, the "redundant constraint" warning is almost certainly wrong.
Yes. Now that the non-promoted version compiles it produces the same warning. I'll fill a bug report. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9103#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9103: hackage's type-level-0.2.4 fails to compile -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.2 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: #8634 | -------------------------------------+------------------------------------- Comment (by jstolarek):
My guess is that PolyKinds is causing trouble in the not-promoted case.
I have to ask: how did you figure that out? I don;t see anything in the error message (nor in the code) that would suggest PolyKinds are causing the problem. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9103#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9103: hackage's type-level-0.2.4 fails to compile -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.2 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: #8634 | -------------------------------------+------------------------------------- Comment (by simonpj): OK, so aside from the "redundant constraint" problem (now reported as #10100), what's left in this ticket? * The error message looks absolutely right to me. {{{ Data/TypeLevel/Num/Ops.hs:90:10: Illegal instance declaration for ‘Succ' (x, x) (x, x) D0 D0 True’ The liberal coverage condition fails in class ‘Succ'’ for functional dependency: ‘yh yl yz -> xh xl’ Reason: lhs types ‘D0’, ‘D0’, ‘True’ do not jointly determine rhs types ‘(x, x)’, ‘(x, x)’ In the instance declaration for ‘Succ' (x, x) (x, x) D0 D0 True’ }}} * Yes, the user manual about "lifting the Paterson conditions" is wrong: see #8634, comment:14. * If, for some reason, this code is really really what you want, then you need `DysFunctionalDependencies`; for that see #8634. So can we close this ticket? Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9103#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9103: hackage's type-level-0.2.4 fails to compile -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.2 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: #8634 | -------------------------------------+------------------------------------- Comment (by jstolarek): Looking again at my comment:7 I believe it is a bug that enabling `PolyKinds` breaks a correct program. That's of course not related to the original bug and deserves its separate bug report. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9103#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9103: hackage's type-level-0.2.4 fails to compile -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.2 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: #8634 | -------------------------------------+------------------------------------- Comment (by simonpj): OK go ahead an open another ticket, and close this one. But as you'll see with `-fprint-explicit-kinds`, the coverage condition really is violated. You may say it's a bug but I don't see a reasonable way to fix it. (A better error message would be good, I grant you.) Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9103#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9103: hackage's type-level-0.2.4 fails to compile -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.2 checker) | Keywords: Resolution: fixed | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: #8634 | -------------------------------------+------------------------------------- Changes (by jstolarek): * status: new => closed * resolution: => fixed Comment: Replying to [comment:13 simonpj]:
But as you'll see with `-fprint-explicit-kinds`, the coverage condition really is violated. I'm looking at the error message with `-fprint-explicit-kinds` and I don't see how the coverage condition is violated here :-/ {{{ Illegal instance declaration for ‘Add * k * (Succ k a) b (Succ k ab)’ The liberal coverage condition fails in class ‘Add’ for functional dependency: ‘a b -> ab’ Reason: lhs types ‘Succ k a’, ‘b’ do not jointly determine rhs type ‘Succ k ab’ In the instance declaration for ‘Add (Succ a) b (Succ ab)’ }}} But if you say this is correct then I trust your judgement. Closing this ticket.
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9103#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9103: hackage's type-level-0.2.4 fails to compile -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.2 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: #8634 | -------------------------------------+------------------------------------- Changes (by jstolarek): * status: closed => new * resolution: fixed => Comment: Wrong resolution, sorry. Reopening. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9103#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9103: hackage's type-level-0.2.4 fails to compile -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.2 checker) | Keywords: Resolution: invalid | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: #8634 | -------------------------------------+------------------------------------- Changes (by jstolarek): * status: new => closed * resolution: => invalid Comment: ...and closing as invalid. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9103#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

I have to ask: how did you figure that out? I don;t see anything in the error message (nor in the code) that would suggest PolyKinds are causing
#9103: hackage's type-level-0.2.4 fails to compile -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.2 checker) | Keywords: Resolution: invalid | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: #8634 | -------------------------------------+------------------------------------- Comment (by goldfire): Replying to [comment:10 jstolarek]: the problem. I was just trying to figure out what could possibly be different between the two cases. With !PolyKinds on, the empty-datatype method produces an extra degree of freedom, in the kind of the parameter to `Succ`. Seeing nothing else which could be causing difficulty, I thought !PolyKinds would have to be the problem. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9103#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9103: hackage's type-level-0.2.4 fails to compile -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.2 checker) | Keywords: Resolution: invalid | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: #8634 | -------------------------------------+------------------------------------- Comment (by goldfire): I agree with Janek that the coverage condition shouldn't fail there. I've opened a new ticket #10109 to explore that part, as this ticket has gotten a little muddled, and the previous discussion isn't helpful (in my opinion) in understanding #10109. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9103#comment:18 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC