16

I've managed to construct the following "minimal" example that shows my problem.

Provided the PatternSynonyms extension is enabled

data Vec = Vec Int Int

pattern Ve x y = Vec x y

f :: (Vec, Vec) -> Vec
f (v@(Ve a b), Ve c d)
    | a > b     = Vec c d
    | otherwise = v

I get a warning for the function f saying

  Warning: Pattern match(es) are non-exhaustive
  In an equation for `f': Patterns not matched: (_, _)

If I replaced every Ve with Vec it wouldn't complain. How does my singular pattern synonym interfere here?

Cactus
  • 27,075
  • 9
  • 69
  • 149
Luka Horvat
  • 4,283
  • 3
  • 30
  • 48

1 Answers1

14

It is not implemented yet, see #8779. I'm not an expect here, but I know that exhaustiveness checks are hard to implement in a lot of cases, like GADT or guards. Probably it is problematic for pattern synonyms too.

Yuras
  • 13,856
  • 1
  • 45
  • 58
  • I'm sure there's stuff I haven't considered, but it seems pretty weird that this doesn't work. I would have assumed that a simple macro expansion would be enough for synonyms of any kind. Don't see how that would interfere with exhaustiveness checks. Thanks for the link. – Luka Horvat Nov 21 '14 at 21:25
  • 4
    @Luka It's not that it's impossible, but someone has to do the work. Pattern synonyms are a totally volunteer effort. And you are free to contribute an improved pattern checker, of course. :) – augustss Nov 21 '14 at 23:09