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 = ...@@ -297,7 +297,7 @@ bracketOnError before after thing =
-- |A pattern match failed. The @String@ gives information about the -- |A pattern match failed. The @String@ gives information about the
-- source location of the pattern. -- source location of the pattern.
data PatternMatchFail = PatternMatchFail String newtype PatternMatchFail = PatternMatchFail String
instance Show PatternMatchFail where instance Show PatternMatchFail where
showsPrec _ (PatternMatchFail err) = showString err showsPrec _ (PatternMatchFail err) = showString err
...@@ -311,7 +311,7 @@ instance Exception PatternMatchFail ...@@ -311,7 +311,7 @@ instance Exception PatternMatchFail
-- multiple constructors, where some fields are in one constructor -- multiple constructors, where some fields are in one constructor
-- but not another. The @String@ gives information about the source -- but not another. The @String@ gives information about the source
-- location of the record selector. -- location of the record selector.
data RecSelError = RecSelError String newtype RecSelError = RecSelError String
instance Show RecSelError where instance Show RecSelError where
showsPrec _ (RecSelError err) = showString err showsPrec _ (RecSelError err) = showString err
...@@ -323,7 +323,7 @@ instance Exception RecSelError ...@@ -323,7 +323,7 @@ instance Exception RecSelError
-- |An uninitialised record field was used. The @String@ gives -- |An uninitialised record field was used. The @String@ gives
-- information about the source location where the record was -- information about the source location where the record was
-- constructed. -- constructed.
data RecConError = RecConError String newtype RecConError = RecConError String
instance Show RecConError where instance Show RecConError where
showsPrec _ (RecConError err) = showString err showsPrec _ (RecConError err) = showString err
...@@ -337,7 +337,7 @@ instance Exception RecConError ...@@ -337,7 +337,7 @@ instance Exception RecConError
-- multiple constructors, where some fields are in one constructor -- multiple constructors, where some fields are in one constructor
-- but not another. The @String@ gives information about the source -- but not another. The @String@ gives information about the source
-- location of the record update. -- location of the record update.
data RecUpdError = RecUpdError String newtype RecUpdError = RecUpdError String
instance Show RecUpdError where instance Show RecUpdError where
showsPrec _ (RecUpdError err) = showString err showsPrec _ (RecUpdError err) = showString err
...@@ -349,7 +349,7 @@ instance Exception RecUpdError ...@@ -349,7 +349,7 @@ instance Exception RecUpdError
-- |A class method without a definition (neither a default definition, -- |A class method without a definition (neither a default definition,
-- nor a definition in the appropriate instance) was called. The -- nor a definition in the appropriate instance) was called. The
-- @String@ gives information about which method it was. -- @String@ gives information about which method it was.
data NoMethodError = NoMethodError String newtype NoMethodError = NoMethodError String
instance Show NoMethodError where instance Show NoMethodError where
showsPrec _ (NoMethodError err) = showString err showsPrec _ (NoMethodError err) = showString err
......
...@@ -118,7 +118,7 @@ allocationLimitExceeded = toException AllocationLimitExceeded ...@@ -118,7 +118,7 @@ allocationLimitExceeded = toException AllocationLimitExceeded
----- -----
-- |'assert' was applied to 'False'. -- |'assert' was applied to 'False'.
data AssertionFailed = AssertionFailed String newtype AssertionFailed = AssertionFailed String
instance Exception AssertionFailed instance Exception AssertionFailed
......
...@@ -48,6 +48,9 @@ ...@@ -48,6 +48,9 @@
* New function `GHC.IO.interruptible` used to correctly implement * New function `GHC.IO.interruptible` used to correctly implement
`Control.Exception.allowInterrupt` (#9516) `Control.Exception.allowInterrupt` (#9516)
* Made `PatternMatchFail`, `RecSelError`, `RecConError`, `RecUpdError`,
`NoMethodError`, and `AssertionFailed` newtypes (#10738)
## 4.8.1.0 *TBA* ## 4.8.1.0 *TBA*
* Bundled with GHC 7.10.2 * 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