[commit: ghc] master: Make Exception datatypes into newtypes (b12dba7)

git at git.haskell.org git at git.haskell.org
Wed Aug 5 12:44:16 UTC 2015


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

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

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

commit b12dba7829742de98a483645142c7962b9dd9f3f
Author: RyanGlScott <ryan.gl.scott at gmail.com>
Date:   Wed Aug 5 14:23:12 2015 +0200

    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


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

b12dba7829742de98a483645142c7962b9dd9f3f
 libraries/base/Control/Exception/Base.hs | 10 +++++-----
 libraries/base/GHC/IO/Exception.hs       |  2 +-
 libraries/base/changelog.md              |  3 +++
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/libraries/base/Control/Exception/Base.hs b/libraries/base/Control/Exception/Base.hs
index 4318773..ece5c69 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 9cf78b3..482027b 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 7a4bb71..bad0e8a 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



More information about the ghc-commits mailing list