summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2017-02-28 11:11:48 -0500
committerBen Gamari <ben@smart-cactus.org>2017-02-28 15:43:38 -0500
commit122c67763bd73144bc6f3a6d86f275e6d1e297f9 (patch)
tree0cccb5985fa176efa38013c068fe61f3337d6ff6
parent3e33d334f3a328f049eb2fdb10b04c36e8d6cbef (diff)
downloadhaskell-122c67763bd73144bc6f3a6d86f275e6d1e297f9.tar.gz
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
-rw-r--r--libraries/base/Data/Typeable/Internal.hs3
-rw-r--r--libraries/base/GHC/Exception.hs2
-rw-r--r--libraries/base/changelog.md4
3 files changed, 9 insertions, 0 deletions
diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs
index aa8345b512..85a356c52b 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 be2ee3f4c9..6a77e6e50b 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 b8c246a3a7..3bb60fedc3 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