summaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorRyanGlScott <ryan.gl.scott@gmail.com>2015-08-05 14:23:12 +0200
committerBen Gamari <ben@smart-cactus.org>2015-08-05 14:45:16 +0200
commitb12dba7829742de98a483645142c7962b9dd9f3f (patch)
tree4e56d779d649d67305ba99e0fe4cf579f2ee24fc /libraries
parentecb1752ffa12dfa71053f640e6cce64d15e47e8f (diff)
downloadhaskell-b12dba7829742de98a483645142c7962b9dd9f3f.tar.gz
Make Exception datatypes into newtypes
Certain instances of `Exception` are simply datatypes with only one argument, which should be `newtype`s. Reviewers: ekmett, hvr, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1131 GHC Trac Issues: #10738
Diffstat (limited to 'libraries')
-rw-r--r--libraries/base/Control/Exception/Base.hs10
-rw-r--r--libraries/base/GHC/IO/Exception.hs2
-rw-r--r--libraries/base/changelog.md3
3 files changed, 9 insertions, 6 deletions
diff --git a/libraries/base/Control/Exception/Base.hs b/libraries/base/Control/Exception/Base.hs
index 4318773d35..ece5c69dd5 100644
--- a/libraries/base/Control/Exception/Base.hs
+++ b/libraries/base/Control/Exception/Base.hs
@@ -297,7 +297,7 @@ bracketOnError before after thing =
-- |A pattern match failed. The @String@ gives information about the
-- source location of the pattern.
-data PatternMatchFail = PatternMatchFail String
+newtype PatternMatchFail = PatternMatchFail String
instance Show PatternMatchFail where
showsPrec _ (PatternMatchFail err) = showString err
@@ -311,7 +311,7 @@ instance Exception PatternMatchFail
-- multiple constructors, where some fields are in one constructor
-- but not another. The @String@ gives information about the source
-- location of the record selector.
-data RecSelError = RecSelError String
+newtype RecSelError = RecSelError String
instance Show RecSelError where
showsPrec _ (RecSelError err) = showString err
@@ -323,7 +323,7 @@ instance Exception RecSelError
-- |An uninitialised record field was used. The @String@ gives
-- information about the source location where the record was
-- constructed.
-data RecConError = RecConError String
+newtype RecConError = RecConError String
instance Show RecConError where
showsPrec _ (RecConError err) = showString err
@@ -337,7 +337,7 @@ instance Exception RecConError
-- multiple constructors, where some fields are in one constructor
-- but not another. The @String@ gives information about the source
-- location of the record update.
-data RecUpdError = RecUpdError String
+newtype RecUpdError = RecUpdError String
instance Show RecUpdError where
showsPrec _ (RecUpdError err) = showString err
@@ -349,7 +349,7 @@ instance Exception RecUpdError
-- |A class method without a definition (neither a default definition,
-- nor a definition in the appropriate instance) was called. The
-- @String@ gives information about which method it was.
-data NoMethodError = NoMethodError String
+newtype NoMethodError = NoMethodError String
instance Show NoMethodError where
showsPrec _ (NoMethodError err) = showString err
diff --git a/libraries/base/GHC/IO/Exception.hs b/libraries/base/GHC/IO/Exception.hs
index 9cf78b39c1..482027b742 100644
--- a/libraries/base/GHC/IO/Exception.hs
+++ b/libraries/base/GHC/IO/Exception.hs
@@ -118,7 +118,7 @@ allocationLimitExceeded = toException AllocationLimitExceeded
-----
-- |'assert' was applied to 'False'.
-data AssertionFailed = AssertionFailed String
+newtype AssertionFailed = AssertionFailed String
instance Exception AssertionFailed
diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md
index 7a4bb71208..bad0e8af01 100644
--- a/libraries/base/changelog.md
+++ b/libraries/base/changelog.md
@@ -48,6 +48,9 @@
* New function `GHC.IO.interruptible` used to correctly implement
`Control.Exception.allowInterrupt` (#9516)
+ * Made `PatternMatchFail`, `RecSelError`, `RecConError`, `RecUpdError`,
+ `NoMethodError`, and `AssertionFailed` newtypes (#10738)
+
## 4.8.1.0 *TBA*
* Bundled with GHC 7.10.2