Skip to content
  • Matthew Pickering's avatar
    COMPLETE pragmas for enhanced pattern exhaustiveness checking · 1a3f1eeb
    Matthew Pickering authored
    This patch adds a new pragma so that users can specify `COMPLETE` sets of
    `ConLike`s in order to sate the pattern match checker.
    
    A function which matches on all the patterns in a complete grouping
    will not cause the exhaustiveness checker to emit warnings.
    
    ```
    pattern P :: ()
    pattern P = ()
    
    {-# COMPLETE P #-}
    
    foo P = ()
    ```
    
    This example would previously have caused the checker to warn that
    all cases were not matched even though matching on `P` is sufficient to
    make `foo` covering. With the addition of the pragma, the compiler
    will recognise that matching on `P` alone is enough and not emit
    any warnings.
    
    Reviewers: goldfire, gkaracha, alanz, austin, bgamari
    
    Reviewed By: alanz
    
    Subscribers: lelf, nomeata, gkaracha, thomie
    
    Differential Revision: https://phabricator.haskell.org/D2669
    
    GHC Trac Issues: #8779
    1a3f1eeb