Skip to content

Invalid redundant pattern matches with -XTypeFamilyDependencies

The following code triggers a warning about a redundant pattern match for foo:

{-# LANGUAGE TypeFamilies, TypeFamilyDependencies #-}

type family F r s = f | f -> r s

type instance F (Bar h (Foo r)) (Bar h (Foo s)) = Bar h (Bar r s)

data Bar s b
data Foo a

foo :: (F cr cu ~ Bar h (Bar r u), 
        F cu cs ~ Bar (Foo h) (Bar u s))
    => Bar h (Bar r u) -> Bar (Foo h) (Bar u s) -> Foo (cr -> cs)
foo = undefined
warning: [-Woverlapping-patterns]
    Pattern match is redundant
    In an equation for ‘foo’: foo = ..

This warning seems invalid to me: I'm not sure how a single definition could constitute a redundant pattern match. Moreover, if I try to address the warning by removing the "redundant" pattern, the code (of course) fails to compile because there is no accompanying binding for the signature of foo.

Trac metadata
Trac field Value
Version 8.0.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information