PatternSynonyms confuse exhaustiveness check
I just noticed some odd behaviour when (ab)using pattern synonyms in the following code (whose style I don't really endorse):
{-# LANGUAGE PatternSynonyms, LambdaCase #-}
module PatSyn1 where
import System.Directory (doesFileExist)
pattern Found = True
pattern NotFound = False
readConfigFile :: FilePath -> IO ()
readConfigFile filePath = doesFileExist filePath >>= \case
Found -> putStrLn =<< readFile filePath
NotFound -> putStrLn "File does not exist."
pattern Void = ()
foo :: () -> ()
foo Void = ()
Results in
/home/hvr/Haskell/PatSyn1.hs:(11,54)-(13,47): Warning:
Pattern match(es) are non-exhaustive
In a case alternative: Patterns not matched: _
/home/hvr/Haskell/PatSyn1.hs:19:1-13: Warning:
Pattern match(es) are non-exhaustive
In an equation for ‘foo’: Patterns not matched: _
Trac metadata
Trac field | Value |
---|---|
Version | 7.10.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |