[GHC] #9103: hackage's type-level-0.2.4 fails to compile
GHC
ghc-devs at haskell.org
Wed Feb 18 13:28:22 UTC 2015
#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
More information about the ghc-tickets
mailing list