Commit b12dba78 authored by Ryan Scott's avatar Ryan Scott Committed by Ben Gamari
Browse files

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
parent ecb1752f
......@@ -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
......
......@@ -118,7 +118,7 @@ allocationLimitExceeded = toException AllocationLimitExceeded
-----
-- |'assert' was applied to 'False'.
data AssertionFailed = AssertionFailed String
newtype AssertionFailed = AssertionFailed String
instance Exception AssertionFailed
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment