[commit: ghc] master: Add COMPLETE pragmas for TypeRep and ErrorCall pattern synonyms (122c677)

git at git.haskell.org git at git.haskell.org
Tue Feb 28 20:50:40 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/122c67763bd73144bc6f3a6d86f275e6d1e297f9/ghc

>---------------------------------------------------------------

commit 122c67763bd73144bc6f3a6d86f275e6d1e297f9
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Tue Feb 28 11:11:48 2017 -0500

    Add COMPLETE pragmas for TypeRep and ErrorCall pattern synonyms
    
    When programming with the pattern synonyms for `TypeRep`, I noticed that
    I was receiving spurious non-exhaustive pattern-match warnings.  This
    can be easily fixed by adding `COMPLETE` pragmas for them.
    
    Moreover, there's another pattern synonym in `base`: `ErrorCall`. In
    fact, in the original ticket for `COMPLETE` pragmas (#8779), someone
    requested that `ErrorCall` be given a `COMPLETE` pragma as well
    (https://ghc.haskell.org/trac/ghc/ticket/8779#comment:21).  I decided to
    do that as well while I was in town.
    
    Reviewers: bgamari, mpickering, austin, hvr
    
    Reviewed By: bgamari
    
    Subscribers: rwbarton, thomie
    
    Differential Revision: https://phabricator.haskell.org/D3231


>---------------------------------------------------------------

122c67763bd73144bc6f3a6d86f275e6d1e297f9
 libraries/base/Data/Typeable/Internal.hs | 3 +++
 libraries/base/GHC/Exception.hs          | 2 ++
 libraries/base/changelog.md              | 4 ++++
 3 files changed, 9 insertions(+)

diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs
index aa8345b..85a356c 100644
--- a/libraries/base/Data/Typeable/Internal.hs
+++ b/libraries/base/Data/Typeable/Internal.hs
@@ -290,6 +290,9 @@ pattern Con con <- TrTyCon _ con _
 pattern Con' :: forall k (a :: k). TyCon -> [SomeTypeRep] -> TypeRep a
 pattern Con' con ks <- TrTyCon _ con ks
 
+{-# COMPLETE Fun, App, Con  #-}
+{-# COMPLETE Fun, App, Con' #-}
+
 ----------------- Observation ---------------------
 
 -- | Observe the type constructor of a quantified type representation.
diff --git a/libraries/base/GHC/Exception.hs b/libraries/base/GHC/Exception.hs
index be2ee3f..6a77e6e 100644
--- a/libraries/base/GHC/Exception.hs
+++ b/libraries/base/GHC/Exception.hs
@@ -176,6 +176,8 @@ pattern ErrorCall :: String -> ErrorCall
 pattern ErrorCall err <- ErrorCallWithLocation err _ where
   ErrorCall err = ErrorCallWithLocation err ""
 
+{-# COMPLETE ErrorCall #-}
+
 -- | @since 4.0.0.0
 instance Exception ErrorCall
 
diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md
index b8c246a..3bb60fe 100644
--- a/libraries/base/changelog.md
+++ b/libraries/base/changelog.md
@@ -69,6 +69,10 @@
     replaced by `CostCentresJSON` due to the new JSON export format supported by
     the cost centre profiler.
 
+  * The `ErrorCall` pattern synonym has been given a `COMPLETE` pragma so that
+    functions which solely match again `ErrorCall` do not produce
+    non-exhaustive pattern-match warnings (#8779)
+
 ## 4.9.0.0  *May 2016*
 
   * Bundled with GHC 8.0



More information about the ghc-commits mailing list