Opened 5 years ago

Closed 4 years ago

#9227 closed bug (duplicate)

Coverage Condition cannot be turned off

Reported by: augustss Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.8.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: #1241, #2247, #8356, #8634 Differential Rev(s):
Wiki Page:

Description

Compile this program

{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
module Bug1 where

class C a b | a -> b

data A a = A
data B a = B

instance C (A a) (B b)

and observe the error message

Bug1.hs:9:10:
    Illegal instance declaration for `C (A a) (B b)'
      The coverage condition fails in class `C'
        for functional dependency: `a -> b'
      Reason: lhs type `A a' does not determine rhs type `B b'
    In the instance declaration for `C (A a) (B b)'

Then read manual, sec 7.6.3.3:

Both the Paterson Conditions and the Coverage Condition are lifted if you give the -XUndecidableInstances flag

Compile again with -XUndecidableInstances. Observe the exact same error message.

Either the compiler or the documentation is wrong. I certainly hope it is the compiler, because it worked in 7.6 and was quite useful.

Change History (3)

comment:1 Changed 5 years ago by rwbarton

Without the Coverage Condition, functional dependencies are not actually functional at all. See #1241 for the original change, and #2247, #8356, #8634 (and probably others) for further discussion.

Indeed, it looks like the documentation has not been updated.

comment:2 Changed 5 years ago by augustss

That may be so, but in many circumstances the old behaviour worked fine. So there should be a flag to bring it back.

comment:3 Changed 4 years ago by thomie

Resolution: duplicate
Status: newclosed
Note: See TracTickets for help on using tickets.