[Git][ghc/ghc][master] 2 commits: Enum deriving: reuse predError, succError, toEnumError

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Thu Sep 26 08:16:53 UTC 2024



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
88eaa7ac by Sylvain Henry at 2024-09-26T04:15:24-04:00
Enum deriving: reuse predError, succError, toEnumError

Reuse predError, succError, and toEnumError when deriving Enum instances
to avoid generating different error strings per instance. E.g. before
this patch for every instance for a type FOO we would generate a string:

  "pred{FOO}: tried to take `pred' of first tag in enumeration"#

- - - - -
e9fa1163 by Sylvain Henry at 2024-09-26T04:15:24-04:00
Enum deriving: generate better code (#16364)

Generate better code for Enum.toEnum: check both the lower and the upper
bounds at once with an unsigned comparison.

Initially I've used a type ascription with a call to 'fromIntegral',
hence the slight refactoring of nlAscribe. Using 'fromIntegral' was
problematic (too low in the module hierarchy) so 'enumIntToWord' was
introduced instead.

Combined with the previous commit, T21839c ghc/alloc decrease by 5%

Metric Decrease:
    T21839c

- - - - -


18 changed files:

- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/Tc/Deriv/Generate.hs
- libraries/base/tests/enum01.stdout
- libraries/base/tests/enum01.stdout-alpha-dec-osf3
- libraries/base/tests/enum01.stdout-ws-64
- libraries/base/tests/enum02.stdout
- libraries/base/tests/enum02.stdout-alpha-dec-osf3
- libraries/base/tests/enum02.stdout-mips-sgi-irix
- libraries/base/tests/enum02.stdout-ws-64
- libraries/base/tests/enum02.stdout-x86_64-unknown-openbsd
- libraries/base/tests/enum03.stdout
- libraries/base/tests/enum03.stdout-alpha-dec-osf3
- libraries/base/tests/enum03.stdout-mips-sgi-irix
- libraries/base/tests/enum03.stdout-ws-64
- libraries/base/tests/enum03.stdout-x86_64-unknown-openbsd
- libraries/ghc-internal/codepages/MakeTable.hs
- libraries/ghc-internal/src/GHC/Internal/Enum.hs


Changes:

=====================================
compiler/GHC/Builtin/Names.hs
=====================================
@@ -751,9 +751,13 @@ left_RDR, right_RDR :: RdrName
 left_RDR                = nameRdrName leftDataConName
 right_RDR               = nameRdrName rightDataConName
 
-fromEnum_RDR, toEnum_RDR :: RdrName
+fromEnum_RDR, toEnum_RDR, toEnumError_RDR, succError_RDR, predError_RDR, enumIntToWord_RDR :: RdrName
 fromEnum_RDR            = varQual_RDR gHC_INTERNAL_ENUM (fsLit "fromEnum")
 toEnum_RDR              = varQual_RDR gHC_INTERNAL_ENUM (fsLit "toEnum")
+toEnumError_RDR         = varQual_RDR gHC_INTERNAL_ENUM (fsLit "toEnumError")
+succError_RDR           = varQual_RDR gHC_INTERNAL_ENUM (fsLit "succError")
+predError_RDR           = varQual_RDR gHC_INTERNAL_ENUM (fsLit "predError")
+enumIntToWord_RDR       = varQual_RDR gHC_INTERNAL_ENUM (fsLit "enumIntToWord")
 
 enumFrom_RDR, enumFromTo_RDR, enumFromThen_RDR, enumFromThenTo_RDR :: RdrName
 enumFrom_RDR            = nameRdrName enumFromName
@@ -1300,6 +1304,7 @@ fromIntegralName    = varQual  gHC_INTERNAL_REAL (fsLit "fromIntegral")fromInteg
 realToFracName      = varQual  gHC_INTERNAL_REAL (fsLit "realToFrac")  realToFracIdKey
 mkRationalBase2Name  = varQual  gHC_INTERNAL_REAL  (fsLit "mkRationalBase2")  mkRationalBase2IdKey
 mkRationalBase10Name = varQual  gHC_INTERNAL_REAL  (fsLit "mkRationalBase10") mkRationalBase10IdKey
+
 -- GHC.Internal.Float classes
 floatingClassName, realFloatClassName :: Name
 floatingClassName  = clsQual gHC_INTERNAL_FLOAT (fsLit "Floating")  floatingClassKey


=====================================
compiler/GHC/Hs/Utils.hs
=====================================
@@ -58,7 +58,7 @@ module GHC.Hs.Utils(
   nlHsIntLit, nlHsVarApps,
   nlHsDo, nlHsOpApp, nlHsLam, nlHsPar, nlHsIf, nlHsCase, nlList,
   mkLHsTupleExpr, mkLHsVarTuple, missingTupArg,
-  mkLocatedList,
+  mkLocatedList, nlAscribe,
 
   -- * Bindings
   mkFunBind, mkVarBind, mkHsVarBind, mkSimpleGeneratedFunBind, mkTopFunBind,
@@ -769,6 +769,13 @@ mkClassOpSigs sigs
       = L loc (ClassOpSig anns False nms (dropWildCards ty))
     fiddle sig = sig
 
+
+-- | Type ascription: (e :: ty)
+nlAscribe :: RdrName -> LHsExpr GhcPs -> LHsExpr GhcPs
+nlAscribe ty e = noLocA $ ExprWithTySig noAnn e
+                           $ mkHsWildCardBndrs $ noLocA $ mkHsImplicitSigType
+                           $ nlHsTyVar NotPromoted ty
+
 {- *********************************************************************
 *                                                                      *
     --------- HsWrappers: type args, dict args, casts ---------


=====================================
compiler/GHC/Tc/Deriv/Generate.hs
=====================================
@@ -594,9 +594,7 @@ unliftedCompare lt_op eq_op a_expr b_expr lt eq gt
                         -- mean more tests (dynamically)
         nlHsIf (ascribeBool $ genPrimOpApp a_expr eq_op b_expr) eq gt
   where
-    ascribeBool e = noLocA $ ExprWithTySig noAnn e
-                           $ mkHsWildCardBndrs $ noLocA $ mkHsImplicitSigType
-                           $ nlHsTyVar NotPromoted boolTyCon_RDR
+    ascribeBool = nlAscribe boolTyCon_RDR
 
 nlConWildPat :: DataCon -> LPat GhcPs
 -- The pattern (K {})
@@ -681,7 +679,7 @@ gen_Enum_binds loc (DerivInstTys{dit_rep_tc = tycon}) = do
         untag_Expr [(a_RDR, ah_RDR)] $
         nlHsIf (nlHsApps eq_RDR [nlHsVar maxtag_RDR,
                                nlHsVarApps intDataCon_RDR [ah_RDR]])
-             (illegal_Expr "succ" occ_nm "tried to take `succ' of last tag in enumeration")
+             (nlHsApp (nlHsVar succError_RDR) (nlHsLit (mkHsString occ_nm)))
              (nlHsApp (nlHsVar tag2con_RDR)
                     (nlHsApps plus_RDR [nlHsVarApps intDataCon_RDR [ah_RDR],
                                         nlHsIntLit 1]))
@@ -691,7 +689,7 @@ gen_Enum_binds loc (DerivInstTys{dit_rep_tc = tycon}) = do
         untag_Expr [(a_RDR, ah_RDR)] $
         nlHsIf (nlHsApps eq_RDR [nlHsIntLit 0,
                                nlHsVarApps intDataCon_RDR [ah_RDR]])
-             (illegal_Expr "pred" occ_nm "tried to take `pred' of first tag in enumeration")
+             (nlHsApp (nlHsVar predError_RDR) (nlHsLit (mkHsString occ_nm)))
              (nlHsApp (nlHsVar tag2con_RDR)
                       (nlHsApps plus_RDR
                             [ nlHsVarApps intDataCon_RDR [ah_RDR]
@@ -700,12 +698,16 @@ gen_Enum_binds loc (DerivInstTys{dit_rep_tc = tycon}) = do
 
     to_enum tag2con_RDR maxtag_RDR
       = mkSimpleGeneratedFunBind loc toEnum_RDR (noLocA [a_Pat]) $
-        nlHsIf (nlHsApps and_RDR
-                [nlHsApps ge_RDR [nlHsVar a_RDR, nlHsIntLit 0],
-                 nlHsApps le_RDR [ nlHsVar a_RDR
-                                 , nlHsVar maxtag_RDR]])
+        let to_word = nlHsApp (nlHsVar enumIntToWord_RDR)
+            -- cast to Word to check both bounds (0,maxtag) with one comparison
+        in nlHsIf (nlHsApps le_RDR [ to_word (nlHsVar a_RDR), to_word (nlHsVar maxtag_RDR)])
              (nlHsVarApps tag2con_RDR [a_RDR])
-             (illegal_toEnum_tag occ_nm maxtag_RDR)
+             (nlHsApps toEnumError_RDR
+                       [ nlHsLit (mkHsString occ_nm)
+                       , nlHsVar a_RDR
+                       , mkLHsTupleExpr [nlHsIntLit 0, nlHsVar maxtag_RDR] noAnn
+                       ])
+
 
     enum_from tag2con_RDR maxtag_RDR
       = mkSimpleGeneratedFunBind loc enumFrom_RDR (noLocA [a_Pat]) $
@@ -2537,32 +2539,6 @@ nested_compose_Expr (e:es)
 error_Expr :: FastString -> LHsExpr GhcPs
 error_Expr string = nlHsApp (nlHsVar error_RDR) (nlHsLit (mkHsStringFS string))
 
--- illegal_Expr is used when signalling error conditions in the RHS of a derived
--- method. It is currently only used by Enum.{succ,pred}
-illegal_Expr :: String -> String -> String -> LHsExpr GhcPs
-illegal_Expr meth tp msg =
-   nlHsApp (nlHsVar error_RDR) (nlHsLit (mkHsString (meth ++ '{':tp ++ "}: " ++ msg)))
-
--- illegal_toEnum_tag is an extended version of illegal_Expr, which also allows you
--- to include the value of a_RDR in the error string.
-illegal_toEnum_tag :: String -> RdrName -> LHsExpr GhcPs
-illegal_toEnum_tag tp maxtag =
-   nlHsApp (nlHsVar error_RDR)
-           (nlHsApp (nlHsApp (nlHsVar append_RDR)
-                       (nlHsLit (mkHsString ("toEnum{" ++ tp ++ "}: tag ("))))
-                    (nlHsApp (nlHsApp (nlHsApp
-                           (nlHsVar showsPrec_RDR)
-                           (nlHsIntLit 0))
-                           (nlHsVar a_RDR))
-                           (nlHsApp (nlHsApp
-                               (nlHsVar append_RDR)
-                               (nlHsLit (mkHsString ") is outside of enumeration's range (0,")))
-                               (nlHsApp (nlHsApp (nlHsApp
-                                        (nlHsVar showsPrec_RDR)
-                                        (nlHsIntLit 0))
-                                        (nlHsVar maxtag))
-                                        (nlHsLit (mkHsString ")"))))))
-
 parenify :: LHsExpr GhcPs -> LHsExpr GhcPs
 parenify e@(L _ (HsVar _ _)) = e
 parenify e                   = mkHsPar e


=====================================
libraries/base/tests/enum01.stdout
=====================================
@@ -1,10 +1,10 @@
 Testing Enum Int: 
     (succ (0::Int)) = 1
     (succ (minBound::Int)) = -2147483647
-    (succ (maxBound::Int)) = error "Prelude.Enum.succ{Int}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int)) = error "Enum.succ{Int}: tried to take `succ' of last tag in enumeration"
     pred (1::Int) = 0
     pred (maxBound::Int) = 2147483646
-    pred (minBound::Int) = error "Prelude.Enum.pred{Int}: tried to take `pred' of minBound"
+    pred (minBound::Int) = error "Enum.pred{Int}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int) [1,minBound,maxBound]) = [1,-2147483648,2147483647]
     (map fromEnum [(1::Int),minBound,maxBound]) = [1,-2147483648,2147483647]
     (take 7 [(1::Int)..]) = [1,2,3,4,5,6,7]


=====================================
libraries/base/tests/enum01.stdout-alpha-dec-osf3
=====================================
@@ -1,10 +1,10 @@
 Testing Enum Int: 
     (succ (0::Int)) = 1
     (succ (minBound::Int)) = -9223372036854775807
-    (succ (maxBound::Int)) = error "Prelude.Enum.succ{Int}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int)) = error "Enum.succ{Int}: tried to take `succ' of last tag in enumeration"
     pred (1::Int) = 0
     pred (maxBound::Int) = 9223372036854775806
-    pred (minBound::Int) = error "Prelude.Enum.pred{Int}: tried to take `pred' of minBound"
+    pred (minBound::Int) = error "Enum.pred{Int}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int) [1,minBound,maxBound]) = [1,-9223372036854775808,9223372036854775807]
     (map fromEnum [(1::Int),minBound,maxBound]) = [1,-9223372036854775808,9223372036854775807]
     (take 7 [(1::Int)..]) = [1,2,3,4,5,6,7]


=====================================
libraries/base/tests/enum01.stdout-ws-64
=====================================
@@ -1,10 +1,10 @@
 Testing Enum Int: 
     (succ (0::Int)) = 1
     (succ (minBound::Int)) = -9223372036854775807
-    (succ (maxBound::Int)) = error "Prelude.Enum.succ{Int}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int)) = error "Enum.succ{Int}: tried to take `succ' of last tag in enumeration"
     pred (1::Int) = 0
     pred (maxBound::Int) = 9223372036854775806
-    pred (minBound::Int) = error "Prelude.Enum.pred{Int}: tried to take `pred' of minBound"
+    pred (minBound::Int) = error "Enum.pred{Int}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int) [1,minBound,maxBound]) = [1,-9223372036854775808,9223372036854775807]
     (map fromEnum [(1::Int),minBound,maxBound]) = [1,-9223372036854775808,9223372036854775807]
     (take 7 [(1::Int)..]) = [1,2,3,4,5,6,7]


=====================================
libraries/base/tests/enum02.stdout
=====================================
@@ -1,12 +1,12 @@
 Testing Enum Int8:
     (succ (0::Int8)) = 1
     (succ (minBound::Int8)) = -127
-    (succ (maxBound::Int8)) = error "Enum.succ{Int8}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int8)) = error "Enum.succ{Int8}: tried to take `succ' of last tag in enumeration"
     pred (1::Int8) = 0
     pred (maxBound::Int8) = 126
-    pred (minBound::Int8) = error "Enum.pred{Int8}: tried to take `pred' of minBound"
+    pred (minBound::Int8) = error "Enum.pred{Int8}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int8) [1, fromIntegral (minBound::Int8), fromIntegral (maxBound::Int8)]) = [1,-128,127]
-    (toEnum (maxBound::Int))::Int8 = error "Enum.toEnum{Int8}: tag (2147483647) is outside of bounds (-128,127)"
+    (toEnum (maxBound::Int))::Int8 = error "Enum.toEnum{Int8}: tag (2147483647) is outside of enumeration's range (-128,127)"
     (map fromEnum [(1::Int8),minBound,maxBound]) = [1,-128,127]
     (take 7 [(1::Int8)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Int8)-5)..]) = [122,123,124,125,126,127]
@@ -36,12 +36,12 @@ Testing Enum Int8:
 Testing Enum Int16:
     (succ (0::Int16)) = 1
     (succ (minBound::Int16)) = -32767
-    (succ (maxBound::Int16)) = error "Enum.succ{Int16}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int16)) = error "Enum.succ{Int16}: tried to take `succ' of last tag in enumeration"
     pred (1::Int16) = 0
     pred (maxBound::Int16) = 32766
-    pred (minBound::Int16) = error "Enum.pred{Int16}: tried to take `pred' of minBound"
+    pred (minBound::Int16) = error "Enum.pred{Int16}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int16) [1, fromIntegral (minBound::Int16), fromIntegral (maxBound::Int16)]) = [1,-32768,32767]
-    (toEnum (maxBound::Int))::Int16 = error "Enum.toEnum{Int16}: tag (2147483647) is outside of bounds (-32768,32767)"
+    (toEnum (maxBound::Int))::Int16 = error "Enum.toEnum{Int16}: tag (2147483647) is outside of enumeration's range (-32768,32767)"
     (map fromEnum [(1::Int16),minBound,maxBound]) = [1,-32768,32767]
     (take 7 [(1::Int16)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Int16)-5)..]) = [32762,32763,32764,32765,32766,32767]
@@ -71,10 +71,10 @@ Testing Enum Int16:
 Testing Enum Int32:
     (succ (0::Int32)) = 1
     (succ (minBound::Int32)) = -2147483647
-    (succ (maxBound::Int32)) = error "Enum.succ{Int32}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int32)) = error "Enum.succ{Int32}: tried to take `succ' of last tag in enumeration"
     pred (1::Int32) = 0
     pred (maxBound::Int32) = 2147483646
-    pred (minBound::Int32) = error "Enum.pred{Int32}: tried to take `pred' of minBound"
+    pred (minBound::Int32) = error "Enum.pred{Int32}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int32) [1, fromIntegral (minBound::Int32), fromIntegral (maxBound::Int32)]) = [1,-2147483648,2147483647]
     (toEnum (maxBound::Int))::Int32 = 2147483647
     (map fromEnum [(1::Int32),minBound,maxBound]) = [1,-2147483648,2147483647]
@@ -106,10 +106,10 @@ Testing Enum Int32:
 Testing Enum Int64:
     (succ (0::Int64)) = 1
     (succ (minBound::Int64)) = -9223372036854775807
-    (succ (maxBound::Int64)) = error "Enum.succ{Int64}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int64)) = error "Enum.succ{Int64}: tried to take `succ' of last tag in enumeration"
     pred (1::Int64) = 0
     pred (maxBound::Int64) = 9223372036854775806
-    pred (minBound::Int64) = error "Enum.pred{Int64}: tried to take `pred' of minBound"
+    pred (minBound::Int64) = error "Enum.pred{Int64}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int64) [1, fromIntegral (minBound::Int64), fromIntegral (maxBound::Int64)]) = [1,0,-1]
     (toEnum (maxBound::Int))::Int64 = 2147483647
     (map fromEnum [(1::Int64),fromIntegral (minBound::Int) ,fromIntegral (maxBound::Int)]) = [1,-2147483648,2147483647]


=====================================
libraries/base/tests/enum02.stdout-alpha-dec-osf3
=====================================
@@ -1,12 +1,12 @@
 Testing Enum Int8:
     (succ (0::Int8)) = 1
     (succ (minBound::Int8)) = -127
-    (succ (maxBound::Int8)) = error "Enum.succ{Int8}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int8)) = error "Enum.succ{Int8}: tried to take `succ' of last tag in enumeration"
     pred (1::Int8) = 0
     pred (maxBound::Int8) = 126
-    pred (minBound::Int8) = error "Enum.pred{Int8}: tried to take `pred' of minBound"
+    pred (minBound::Int8) = error "Enum.pred{Int8}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int8) [1, toInt (minBound::Int8), toInt (maxBound::Int8)]) = [1,-128,127]
-    (toEnum (maxBound::Int))::Int8 = error "Enum.toEnum{Int8}: tag (9223372036854775807) is outside of bounds (-128,127)"
+    (toEnum (maxBound::Int))::Int8 = error "Enum.toEnum{Int8}: tag (9223372036854775807) is outside of enumeration's range (-128,127)"
     (map fromEnum [(1::Int8),minBound,maxBound]) = [1,-128,127]
     (take 7 [(1::Int8)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Int8)-5)..]) = [122,123,124,125,126,127]
@@ -36,12 +36,12 @@ Testing Enum Int8:
 Testing Enum Int16:
     (succ (0::Int16)) = 1
     (succ (minBound::Int16)) = -32767
-    (succ (maxBound::Int16)) = error "Enum.succ{Int16}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int16)) = error "Enum.succ{Int16}: tried to take `succ' of last tag in enumeration"
     pred (1::Int16) = 0
     pred (maxBound::Int16) = 32766
-    pred (minBound::Int16) = error "Enum.pred{Int16}: tried to take `pred' of minBound"
+    pred (minBound::Int16) = error "Enum.pred{Int16}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int16) [1, toInt (minBound::Int16), toInt (maxBound::Int16)]) = [1,-32768,32767]
-    (toEnum (maxBound::Int))::Int16 = error "Enum.toEnum{Int16}: tag (9223372036854775807) is outside of bounds (-32768,32767)"
+    (toEnum (maxBound::Int))::Int16 = error "Enum.toEnum{Int16}: tag (9223372036854775807) is outside of enumeration's range (-32768,32767)"
     (map fromEnum [(1::Int16),minBound,maxBound]) = [1,-32768,32767]
     (take 7 [(1::Int16)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Int16)-5)..]) = [32762,32763,32764,32765,32766,32767]
@@ -71,12 +71,12 @@ Testing Enum Int16:
 Testing Enum Int32:
     (succ (0::Int32)) = 1
     (succ (minBound::Int32)) = -2147483647
-    (succ (maxBound::Int32)) = error "Enum.succ{Int32}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int32)) = error "Enum.succ{Int32}: tried to take `succ' of last tag in enumeration"
     pred (1::Int32) = 0
     pred (maxBound::Int32) = 2147483646
-    pred (minBound::Int32) = error "Enum.pred{Int32}: tried to take `pred' of minBound"
+    pred (minBound::Int32) = error "Enum.pred{Int32}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int32) [1, toInt (minBound::Int32), toInt (maxBound::Int32)]) = [1,-2147483648,2147483647]
-    (toEnum (maxBound::Int))::Int32 = error "Enum.toEnum{Int32}: tag (9223372036854775807) is outside of bounds (-2147483648,2147483647)"
+    (toEnum (maxBound::Int))::Int32 = error "Enum.toEnum{Int32}: tag (9223372036854775807) is outside of enumeration's range (-2147483648,2147483647)"
     (map fromEnum [(1::Int32),minBound,maxBound]) = [1,-2147483648,2147483647]
     (take 7 [(1::Int32)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Int32)-5)..]) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647]
@@ -106,10 +106,10 @@ Testing Enum Int32:
 Testing Enum Int64:
     (succ (0::Int64)) = 1
     (succ (minBound::Int64)) = -9223372036854775807
-    (succ (maxBound::Int64)) = error "Enum.succ{Int64}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int64)) = error "Enum.succ{Int64}: tried to take `succ' of last tag in enumeration"
     pred (1::Int64) = 0
     pred (maxBound::Int64) = 9223372036854775806
-    pred (minBound::Int64) = error "Enum.pred{Int64}: tried to take `pred' of minBound"
+    pred (minBound::Int64) = error "Enum.pred{Int64}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int64) [1, toInt (minBound::Int64), toInt (maxBound::Int64)]) = [1,-9223372036854775808,9223372036854775807]
     (toEnum (maxBound::Int))::Int64 = 9223372036854775807
     (map fromEnum [(1::Int64),fromInt (minBound::Int) ,fromInt (maxBound::Int)]) = [1,-9223372036854775808,9223372036854775807]


=====================================
libraries/base/tests/enum02.stdout-mips-sgi-irix
=====================================
@@ -1,12 +1,12 @@
 Testing Enum Int8:
     (succ (0::Int8)) = 1
     (succ (minBound::Int8)) = -127
-    (succ (maxBound::Int8)) = error "Enum.succ{Int8}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int8)) = error "Enum.succ{Int8}: tried to take `succ' of last tag in enumeration"
     pred (1::Int8) = 0
     pred (maxBound::Int8) = 126
-    pred (minBound::Int8) = error "Enum.pred{Int8}: tried to take `pred' of minBound"
+    pred (minBound::Int8) = error "Enum.pred{Int8}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int8) [1, fromIntegral (minBound::Int8), fromIntegral (maxBound::Int8)]) = [1,-128,127]
-    (toEnum (maxBound::Int))::Int8 = error "Enum.toEnum{Int8}: tag (9223372036854775807) is outside of bounds (-128,127)"
+    (toEnum (maxBound::Int))::Int8 = error "Enum.toEnum{Int8}: tag (9223372036854775807) is outside of enumeration's range (-128,127)"
     (map fromEnum [(1::Int8),minBound,maxBound]) = [1,-128,127]
     (take 7 [(1::Int8)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Int8)-5)..]) = [122,123,124,125,126,127]
@@ -36,12 +36,12 @@ Testing Enum Int8:
 Testing Enum Int16:
     (succ (0::Int16)) = 1
     (succ (minBound::Int16)) = -32767
-    (succ (maxBound::Int16)) = error "Enum.succ{Int16}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int16)) = error "Enum.succ{Int16}: tried to take `succ' of last tag in enumeration"
     pred (1::Int16) = 0
     pred (maxBound::Int16) = 32766
-    pred (minBound::Int16) = error "Enum.pred{Int16}: tried to take `pred' of minBound"
+    pred (minBound::Int16) = error "Enum.pred{Int16}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int16) [1, fromIntegral (minBound::Int16), fromIntegral (maxBound::Int16)]) = [1,-32768,32767]
-    (toEnum (maxBound::Int))::Int16 = error "Enum.toEnum{Int16}: tag (9223372036854775807) is outside of bounds (-32768,32767)"
+    (toEnum (maxBound::Int))::Int16 = error "Enum.toEnum{Int16}: tag (9223372036854775807) is outside of enumeration's range (-32768,32767)"
     (map fromEnum [(1::Int16),minBound,maxBound]) = [1,-32768,32767]
     (take 7 [(1::Int16)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Int16)-5)..]) = [32762,32763,32764,32765,32766,32767]
@@ -71,12 +71,12 @@ Testing Enum Int16:
 Testing Enum Int32:
     (succ (0::Int32)) = 1
     (succ (minBound::Int32)) = -2147483647
-    (succ (maxBound::Int32)) = error "Enum.succ{Int32}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int32)) = error "Enum.succ{Int32}: tried to take `succ' of last tag in enumeration"
     pred (1::Int32) = 0
     pred (maxBound::Int32) = 2147483646
-    pred (minBound::Int32) = error "Enum.pred{Int32}: tried to take `pred' of minBound"
+    pred (minBound::Int32) = error "Enum.pred{Int32}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int32) [1, fromIntegral (minBound::Int32), fromIntegral (maxBound::Int32)]) = [1,-2147483648,2147483647]
-    (toEnum (maxBound::Int))::Int32 = error "Enum.toEnum{Int32}: tag (9223372036854775807) is outside of bounds (-2147483648,2147483647)"
+    (toEnum (maxBound::Int))::Int32 = error "Enum.toEnum{Int32}: tag (9223372036854775807) is outside of enumeration's range (-2147483648,2147483647)"
     (map fromEnum [(1::Int32),minBound,maxBound]) = [1,-2147483648,2147483647]
     (take 7 [(1::Int32)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Int32)-5)..]) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647]
@@ -106,10 +106,10 @@ Testing Enum Int32:
 Testing Enum Int64:
     (succ (0::Int64)) = 1
     (succ (minBound::Int64)) = -9223372036854775807
-    (succ (maxBound::Int64)) = error "Enum.succ{Int64}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int64)) = error "Enum.succ{Int64}: tried to take `succ' of last tag in enumeration"
     pred (1::Int64) = 0
     pred (maxBound::Int64) = 9223372036854775806
-    pred (minBound::Int64) = error "Enum.pred{Int64}: tried to take `pred' of minBound"
+    pred (minBound::Int64) = error "Enum.pred{Int64}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int64) [1, fromIntegral (minBound::Int64), fromIntegral (maxBound::Int64)]) = [1,-9223372036854775808,9223372036854775807]
     (toEnum (maxBound::Int))::Int64 = 9223372036854775807
     (map fromEnum [(1::Int64),fromIntegral (minBound::Int) ,fromIntegral (maxBound::Int)]) = [1,-9223372036854775808,9223372036854775807]


=====================================
libraries/base/tests/enum02.stdout-ws-64
=====================================
@@ -1,12 +1,12 @@
 Testing Enum Int8:
     (succ (0::Int8)) = 1
     (succ (minBound::Int8)) = -127
-    (succ (maxBound::Int8)) = error "Enum.succ{Int8}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int8)) = error "Enum.succ{Int8}: tried to take `succ' of last tag in enumeration"
     pred (1::Int8) = 0
     pred (maxBound::Int8) = 126
-    pred (minBound::Int8) = error "Enum.pred{Int8}: tried to take `pred' of minBound"
+    pred (minBound::Int8) = error "Enum.pred{Int8}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int8) [1, fromIntegral (minBound::Int8), fromIntegral (maxBound::Int8)]) = [1,-128,127]
-    (toEnum (maxBound::Int))::Int8 = error "Enum.toEnum{Int8}: tag (9223372036854775807) is outside of bounds (-128,127)"
+    (toEnum (maxBound::Int))::Int8 = error "Enum.toEnum{Int8}: tag (9223372036854775807) is outside of enumeration's range (-128,127)"
     (map fromEnum [(1::Int8),minBound,maxBound]) = [1,-128,127]
     (take 7 [(1::Int8)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Int8)-5)..]) = [122,123,124,125,126,127]
@@ -36,12 +36,12 @@ Testing Enum Int8:
 Testing Enum Int16:
     (succ (0::Int16)) = 1
     (succ (minBound::Int16)) = -32767
-    (succ (maxBound::Int16)) = error "Enum.succ{Int16}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int16)) = error "Enum.succ{Int16}: tried to take `succ' of last tag in enumeration"
     pred (1::Int16) = 0
     pred (maxBound::Int16) = 32766
-    pred (minBound::Int16) = error "Enum.pred{Int16}: tried to take `pred' of minBound"
+    pred (minBound::Int16) = error "Enum.pred{Int16}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int16) [1, fromIntegral (minBound::Int16), fromIntegral (maxBound::Int16)]) = [1,-32768,32767]
-    (toEnum (maxBound::Int))::Int16 = error "Enum.toEnum{Int16}: tag (9223372036854775807) is outside of bounds (-32768,32767)"
+    (toEnum (maxBound::Int))::Int16 = error "Enum.toEnum{Int16}: tag (9223372036854775807) is outside of enumeration's range (-32768,32767)"
     (map fromEnum [(1::Int16),minBound,maxBound]) = [1,-32768,32767]
     (take 7 [(1::Int16)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Int16)-5)..]) = [32762,32763,32764,32765,32766,32767]
@@ -71,12 +71,12 @@ Testing Enum Int16:
 Testing Enum Int32:
     (succ (0::Int32)) = 1
     (succ (minBound::Int32)) = -2147483647
-    (succ (maxBound::Int32)) = error "Enum.succ{Int32}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int32)) = error "Enum.succ{Int32}: tried to take `succ' of last tag in enumeration"
     pred (1::Int32) = 0
     pred (maxBound::Int32) = 2147483646
-    pred (minBound::Int32) = error "Enum.pred{Int32}: tried to take `pred' of minBound"
+    pred (minBound::Int32) = error "Enum.pred{Int32}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int32) [1, fromIntegral (minBound::Int32), fromIntegral (maxBound::Int32)]) = [1,-2147483648,2147483647]
-    (toEnum (maxBound::Int))::Int32 = error "Enum.toEnum{Int32}: tag (9223372036854775807) is outside of bounds (-2147483648,2147483647)"
+    (toEnum (maxBound::Int))::Int32 = error "Enum.toEnum{Int32}: tag (9223372036854775807) is outside of enumeration's range (-2147483648,2147483647)"
     (map fromEnum [(1::Int32),minBound,maxBound]) = [1,-2147483648,2147483647]
     (take 7 [(1::Int32)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Int32)-5)..]) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647]
@@ -106,10 +106,10 @@ Testing Enum Int32:
 Testing Enum Int64:
     (succ (0::Int64)) = 1
     (succ (minBound::Int64)) = -9223372036854775807
-    (succ (maxBound::Int64)) = error "Enum.succ{Int64}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int64)) = error "Enum.succ{Int64}: tried to take `succ' of last tag in enumeration"
     pred (1::Int64) = 0
     pred (maxBound::Int64) = 9223372036854775806
-    pred (minBound::Int64) = error "Enum.pred{Int64}: tried to take `pred' of minBound"
+    pred (minBound::Int64) = error "Enum.pred{Int64}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int64) [1, fromIntegral (minBound::Int64), fromIntegral (maxBound::Int64)]) = [1,-9223372036854775808,9223372036854775807]
     (toEnum (maxBound::Int))::Int64 = 9223372036854775807
     (map fromEnum [(1::Int64),fromIntegral (minBound::Int) ,fromIntegral (maxBound::Int)]) = [1,-9223372036854775808,9223372036854775807]


=====================================
libraries/base/tests/enum02.stdout-x86_64-unknown-openbsd
=====================================
@@ -1,12 +1,12 @@
 Testing Enum Int8:
     (succ (0::Int8)) = 1
     (succ (minBound::Int8)) = -127
-    (succ (maxBound::Int8)) = error "Enum.succ{Int8}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int8)) = error "Enum.succ{Int8}: tried to take `succ' of last tag in enumeration"
     pred (1::Int8) = 0
     pred (maxBound::Int8) = 126
-    pred (minBound::Int8) = error "Enum.pred{Int8}: tried to take `pred' of minBound"
+    pred (minBound::Int8) = error "Enum.pred{Int8}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int8) [1, fromIntegral (minBound::Int8), fromIntegral (maxBound::Int8)]) = [1,-128,127]
-    (toEnum (maxBound::Int))::Int8 = error "Enum.toEnum{Int8}: tag (9223372036854775807) is outside of bounds (-128,127)"
+    (toEnum (maxBound::Int))::Int8 = error "Enum.toEnum{Int8}: tag (9223372036854775807) is outside of enumeration's range (-128,127)"
     (map fromEnum [(1::Int8),minBound,maxBound]) = [1,-128,127]
     (take 7 [(1::Int8)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Int8)-5)..]) = [122,123,124,125,126,127]
@@ -36,12 +36,12 @@ Testing Enum Int8:
 Testing Enum Int16:
     (succ (0::Int16)) = 1
     (succ (minBound::Int16)) = -32767
-    (succ (maxBound::Int16)) = error "Enum.succ{Int16}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int16)) = error "Enum.succ{Int16}: tried to take `succ' of last tag in enumeration"
     pred (1::Int16) = 0
     pred (maxBound::Int16) = 32766
-    pred (minBound::Int16) = error "Enum.pred{Int16}: tried to take `pred' of minBound"
+    pred (minBound::Int16) = error "Enum.pred{Int16}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int16) [1, fromIntegral (minBound::Int16), fromIntegral (maxBound::Int16)]) = [1,-32768,32767]
-    (toEnum (maxBound::Int))::Int16 = error "Enum.toEnum{Int16}: tag (9223372036854775807) is outside of bounds (-32768,32767)"
+    (toEnum (maxBound::Int))::Int16 = error "Enum.toEnum{Int16}: tag (9223372036854775807) is outside of enumeration's range (-32768,32767)"
     (map fromEnum [(1::Int16),minBound,maxBound]) = [1,-32768,32767]
     (take 7 [(1::Int16)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Int16)-5)..]) = [32762,32763,32764,32765,32766,32767]
@@ -71,12 +71,12 @@ Testing Enum Int16:
 Testing Enum Int32:
     (succ (0::Int32)) = 1
     (succ (minBound::Int32)) = -2147483647
-    (succ (maxBound::Int32)) = error "Enum.succ{Int32}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int32)) = error "Enum.succ{Int32}: tried to take `succ' of last tag in enumeration"
     pred (1::Int32) = 0
     pred (maxBound::Int32) = 2147483646
-    pred (minBound::Int32) = error "Enum.pred{Int32}: tried to take `pred' of minBound"
+    pred (minBound::Int32) = error "Enum.pred{Int32}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int32) [1, fromIntegral (minBound::Int32), fromIntegral (maxBound::Int32)]) = [1,-2147483648,2147483647]
-    (toEnum (maxBound::Int))::Int32 = error "Enum.toEnum{Int32}: tag (9223372036854775807) is outside of bounds (-2147483648,2147483647)"
+    (toEnum (maxBound::Int))::Int32 = error "Enum.toEnum{Int32}: tag (9223372036854775807) is outside of enumeration's range (-2147483648,2147483647)"
     (map fromEnum [(1::Int32),minBound,maxBound]) = [1,-2147483648,2147483647]
     (take 7 [(1::Int32)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Int32)-5)..]) = [2147483642,2147483643,2147483644,2147483645,2147483646,2147483647]
@@ -106,10 +106,10 @@ Testing Enum Int32:
 Testing Enum Int64:
     (succ (0::Int64)) = 1
     (succ (minBound::Int64)) = -9223372036854775807
-    (succ (maxBound::Int64)) = error "Enum.succ{Int64}: tried to take `succ' of maxBound"
+    (succ (maxBound::Int64)) = error "Enum.succ{Int64}: tried to take `succ' of last tag in enumeration"
     pred (1::Int64) = 0
     pred (maxBound::Int64) = 9223372036854775806
-    pred (minBound::Int64) = error "Enum.pred{Int64}: tried to take `pred' of minBound"
+    pred (minBound::Int64) = error "Enum.pred{Int64}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Int64) [1, fromIntegral (minBound::Int64), fromIntegral (maxBound::Int64)]) = [1,-9223372036854775808,9223372036854775807]
     (toEnum (maxBound::Int))::Int64 = 9223372036854775807
     (map fromEnum [(1::Int64),fromIntegral (minBound::Int) ,fromIntegral (maxBound::Int)]) = [1,-9223372036854775808,9223372036854775807]


=====================================
libraries/base/tests/enum03.stdout
=====================================
@@ -1,12 +1,12 @@
 Testing Enum Word8:
     (succ (0::Word8)) = 1
     (succ (minBound::Word8)) = 1
-    (succ (maxBound::Word8)) = error "Enum.succ{Word8}: tried to take `succ' of maxBound"
+    (succ (maxBound::Word8)) = error "Enum.succ{Word8}: tried to take `succ' of last tag in enumeration"
     pred (1::Word8) = 0
     pred (maxBound::Word8) = 254
-    pred (minBound::Word8) = error "Enum.pred{Word8}: tried to take `pred' of minBound"
+    pred (minBound::Word8) = error "Enum.pred{Word8}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Word8) [1, fromIntegral (minBound::Word8)::Int, fromIntegral (maxBound::Word8)::Int]) = [1,0,255]
-    (toEnum (maxBound::Int))::Word8 = error "Enum.toEnum{Word8}: tag (2147483647) is outside of bounds (0,255)"
+    (toEnum (maxBound::Int))::Word8 = error "Enum.toEnum{Word8}: tag (2147483647) is outside of enumeration's range (0,255)"
     (map fromEnum [(1::Word8),minBound,maxBound]) = [1,0,255]
     (take 7 [(1::Word8)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Word8)-5)..]) = [250,251,252,253,254,255]
@@ -36,12 +36,12 @@ Testing Enum Word8:
 Testing Enum Word16:
     (succ (0::Word16)) = 1
     (succ (minBound::Word16)) = 1
-    (succ (maxBound::Word16)) = error "Enum.succ{Word16}: tried to take `succ' of maxBound"
+    (succ (maxBound::Word16)) = error "Enum.succ{Word16}: tried to take `succ' of last tag in enumeration"
     pred (1::Word16) = 0
     pred (maxBound::Word16) = 65534
-    pred (minBound::Word16) = error "Enum.pred{Word16}: tried to take `pred' of minBound"
+    pred (minBound::Word16) = error "Enum.pred{Word16}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Word16) [1, fromIntegral (minBound::Word16)::Int, fromIntegral (maxBound::Word16)::Int]) = [1,0,65535]
-    (toEnum (maxBound::Int))::Word16 = error "Enum.toEnum{Word16}: tag (2147483647) is outside of bounds (0,65535)"
+    (toEnum (maxBound::Int))::Word16 = error "Enum.toEnum{Word16}: tag (2147483647) is outside of enumeration's range (0,65535)"
     (map fromEnum [(1::Word16),minBound,maxBound]) = [1,0,65535]
     (take 7 [(1::Word16)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Word16)-5)..]) = [65530,65531,65532,65533,65534,65535]
@@ -71,10 +71,10 @@ Testing Enum Word16:
 Testing Enum Word32:
     (succ (0::Word32)) = 1
     (succ (minBound::Word32)) = 1
-    (succ (maxBound::Word32)) = error "Enum.succ{Word32}: tried to take `succ' of maxBound"
+    (succ (maxBound::Word32)) = error "Enum.succ{Word32}: tried to take `succ' of last tag in enumeration"
     pred (1::Word32) = 0
     pred (maxBound::Word32) = 4294967294
-    pred (minBound::Word32) = error "Enum.pred{Word32}: tried to take `pred' of minBound"
+    pred (minBound::Word32) = error "Enum.pred{Word32}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Word32) [1, fromIntegral (minBound::Word32)::Int, fromIntegral (maxBound::Int32)::Int]) = [1,0,2147483647]
     (toEnum (maxBound::Int))::Word32 = 2147483647
     (map fromEnum [(1::Word32),minBound,fromIntegral (maxBound::Int)]) = [1,0,2147483647]
@@ -107,10 +107,10 @@ Testing Enum Word32:
 Testing Enum Word64:
     (succ (0::Word64)) = 1
     (succ (minBound::Word64)) = 1
-    (succ (maxBound::Word64)) = error "Enum.succ{Word64}: tried to take `succ' of maxBound"
+    (succ (maxBound::Word64)) = error "Enum.succ{Word64}: tried to take `succ' of last tag in enumeration"
     pred (1::Word64) = 0
     pred (maxBound::Word64) = 18446744073709551614
-    pred (minBound::Word64) = error "Enum.pred{Word64}: tried to take `pred' of minBound"
+    pred (minBound::Word64) = error "Enum.pred{Word64}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Word64) [1, fromIntegral (minBound::Word64)::Int, maxBound::Int]) = [1,0,2147483647]
     (toEnum (maxBound::Int))::Word64 = 2147483647
     (map fromEnum [(1::Word64),minBound,fromIntegral (maxBound::Int)]) = [1,0,2147483647]


=====================================
libraries/base/tests/enum03.stdout-alpha-dec-osf3
=====================================
@@ -1,12 +1,12 @@
 Testing Enum Word8:
     (succ (0::Word8)) = 1
     (succ (minBound::Word8)) = 1
-    (succ (maxBound::Word8)) = error "Enum.succ{Word8}: tried to take `succ' of maxBound"
+    (succ (maxBound::Word8)) = error "Enum.succ{Word8}: tried to take `succ' of last tag in enumeration"
     pred (1::Word8) = 0
     pred (maxBound::Word8) = 254
-    pred (minBound::Word8) = error "Enum.pred{Word8}: tried to take `pred' of minBound"
+    pred (minBound::Word8) = error "Enum.pred{Word8}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Word8) [1, fromIntegral (minBound::Word8)::Int, fromIntegral (maxBound::Word8)::Int]) = [1,0,255]
-    (toEnum (maxBound::Int))::Word8 = error "Enum.toEnum{Word8}: tag (9223372036854775807) is outside of bounds (0,255)"
+    (toEnum (maxBound::Int))::Word8 = error "Enum.toEnum{Word8}: tag (9223372036854775807) is outside of enumeration's range (0,255)"
     (map fromEnum [(1::Word8),minBound,maxBound]) = [1,0,255]
     (take 7 [(1::Word8)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Word8)-5)..]) = [250,251,252,253,254,255]
@@ -36,12 +36,12 @@ Testing Enum Word8:
 Testing Enum Word16:
     (succ (0::Word16)) = 1
     (succ (minBound::Word16)) = 1
-    (succ (maxBound::Word16)) = error "Enum.succ{Word16}: tried to take `succ' of maxBound"
+    (succ (maxBound::Word16)) = error "Enum.succ{Word16}: tried to take `succ' of last tag in enumeration"
     pred (1::Word16) = 0
     pred (maxBound::Word16) = 65534
-    pred (minBound::Word16) = error "Enum.pred{Word16}: tried to take `pred' of minBound"
+    pred (minBound::Word16) = error "Enum.pred{Word16}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Word16) [1, fromIntegral (minBound::Word16)::Int, fromIntegral (maxBound::Word16)::Int]) = [1,0,65535]
-    (toEnum (maxBound::Int))::Word16 = error "Enum.toEnum{Word16}: tag (9223372036854775807) is outside of bounds (0,65535)"
+    (toEnum (maxBound::Int))::Word16 = error "Enum.toEnum{Word16}: tag (9223372036854775807) is outside of enumeration's range (0,65535)"
     (map fromEnum [(1::Word16),minBound,maxBound]) = [1,0,65535]
     (take 7 [(1::Word16)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Word16)-5)..]) = [65530,65531,65532,65533,65534,65535]
@@ -71,12 +71,12 @@ Testing Enum Word16:
 Testing Enum Word32:
     (succ (0::Word32)) = 1
     (succ (minBound::Word32)) = 1
-    (succ (maxBound::Word32)) = error "Enum.succ{Word32}: tried to take `succ' of maxBound"
+    (succ (maxBound::Word32)) = error "Enum.succ{Word32}: tried to take `succ' of last tag in enumeration"
     pred (1::Word32) = 0
     pred (maxBound::Word32) = 4294967294
-    pred (minBound::Word32) = error "Enum.pred{Word32}: tried to take `pred' of minBound"
+    pred (minBound::Word32) = error "Enum.pred{Word32}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Word32) [1, fromIntegral (minBound::Word32)::Int, fromIntegral (maxBound::Int32)::Int]) = [1,0,2147483647]
-    (toEnum (maxBound::Int))::Word32 = error "Enum.toEnum{Word32}: tag (9223372036854775807) is outside of bounds (0,4294967295)"
+    (toEnum (maxBound::Int))::Word32 = error "Enum.toEnum{Word32}: tag (9223372036854775807) is outside of enumeration's range (0,4294967295)"
     (map fromEnum [(1::Word32),minBound,fromIntegral (maxBound::Int)]) = [1,0,4294967295]
     fromEnum (maxBound::Word32) = 4294967295
     (take 7 [(1::Word32)..]) = [1,2,3,4,5,6,7]
@@ -107,10 +107,10 @@ Testing Enum Word32:
 Testing Enum Word64:
     (succ (0::Word64)) = 1
     (succ (minBound::Word64)) = 1
-    (succ (maxBound::Word64)) = error "Enum.succ{Word64}: tried to take `succ' of maxBound"
+    (succ (maxBound::Word64)) = error "Enum.succ{Word64}: tried to take `succ' of last tag in enumeration"
     pred (1::Word64) = 0
     pred (maxBound::Word64) = 18446744073709551614
-    pred (minBound::Word64) = error "Enum.pred{Word64}: tried to take `pred' of minBound"
+    pred (minBound::Word64) = error "Enum.pred{Word64}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Word64) [1, fromIntegral (minBound::Word64)::Int, maxBound::Int]) = [1,0,9223372036854775807]
     (toEnum (maxBound::Int))::Word64 = 9223372036854775807
     (map fromEnum [(1::Word64),minBound,fromIntegral (maxBound::Int)]) = [1,0,9223372036854775807]


=====================================
libraries/base/tests/enum03.stdout-mips-sgi-irix
=====================================
@@ -1,12 +1,12 @@
 Testing Enum Word8:
     (succ (0::Word8)) = 1
     (succ (minBound::Word8)) = 1
-    (succ (maxBound::Word8)) = error "Enum.succ{Word8}: tried to take `succ' of maxBound"
+    (succ (maxBound::Word8)) = error "Enum.succ{Word8}: tried to take `succ' of last tag in enumeration"
     pred (1::Word8) = 0
     pred (maxBound::Word8) = 254
-    pred (minBound::Word8) = error "Enum.pred{Word8}: tried to take `pred' of minBound"
+    pred (minBound::Word8) = error "Enum.pred{Word8}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Word8) [1, fromIntegral (minBound::Word8)::Int, fromIntegral (maxBound::Word8)::Int]) = [1,0,255]
-    (toEnum (maxBound::Int))::Word8 = error "Enum.toEnum{Word8}: tag (9223372036854775807) is outside of bounds (0,255)"
+    (toEnum (maxBound::Int))::Word8 = error "Enum.toEnum{Word8}: tag (9223372036854775807) is outside of enumeration's range (0,255)"
     (map fromEnum [(1::Word8),minBound,maxBound]) = [1,0,255]
     (take 7 [(1::Word8)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Word8)-5)..]) = [250,251,252,253,254,255]
@@ -36,12 +36,12 @@ Testing Enum Word8:
 Testing Enum Word16:
     (succ (0::Word16)) = 1
     (succ (minBound::Word16)) = 1
-    (succ (maxBound::Word16)) = error "Enum.succ{Word16}: tried to take `succ' of maxBound"
+    (succ (maxBound::Word16)) = error "Enum.succ{Word16}: tried to take `succ' of last tag in enumeration"
     pred (1::Word16) = 0
     pred (maxBound::Word16) = 65534
-    pred (minBound::Word16) = error "Enum.pred{Word16}: tried to take `pred' of minBound"
+    pred (minBound::Word16) = error "Enum.pred{Word16}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Word16) [1, fromIntegral (minBound::Word16)::Int, fromIntegral (maxBound::Word16)::Int]) = [1,0,65535]
-    (toEnum (maxBound::Int))::Word16 = error "Enum.toEnum{Word16}: tag (9223372036854775807) is outside of bounds (0,65535)"
+    (toEnum (maxBound::Int))::Word16 = error "Enum.toEnum{Word16}: tag (9223372036854775807) is outside of enumeration's range (0,65535)"
     (map fromEnum [(1::Word16),minBound,maxBound]) = [1,0,65535]
     (take 7 [(1::Word16)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Word16)-5)..]) = [65530,65531,65532,65533,65534,65535]
@@ -71,12 +71,12 @@ Testing Enum Word16:
 Testing Enum Word32:
     (succ (0::Word32)) = 1
     (succ (minBound::Word32)) = 1
-    (succ (maxBound::Word32)) = error "Enum.succ{Word32}: tried to take `succ' of maxBound"
+    (succ (maxBound::Word32)) = error "Enum.succ{Word32}: tried to take `succ' of last tag in enumeration"
     pred (1::Word32) = 0
     pred (maxBound::Word32) = 4294967294
-    pred (minBound::Word32) = error "Enum.pred{Word32}: tried to take `pred' of minBound"
+    pred (minBound::Word32) = error "Enum.pred{Word32}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Word32) [1, fromIntegral (minBound::Word32)::Int, fromIntegral (maxBound::Int32)::Int]) = [1,0,2147483647]
-    (toEnum (maxBound::Int))::Word32 = error "Enum.toEnum{Word32}: tag (9223372036854775807) is outside of bounds (0,4294967295)"
+    (toEnum (maxBound::Int))::Word32 = error "Enum.toEnum{Word32}: tag (9223372036854775807) is outside of enumeration's range (0,4294967295)"
     (map fromEnum [(1::Word32),minBound,fromIntegral (maxBound::Int)]) = [1,0,4294967295]
     fromEnum (maxBound::Word32) = 4294967295
     (take 7 [(1::Word32)..]) = [1,2,3,4,5,6,7]
@@ -107,10 +107,10 @@ Testing Enum Word32:
 Testing Enum Word64:
     (succ (0::Word64)) = 1
     (succ (minBound::Word64)) = 1
-    (succ (maxBound::Word64)) = error "Enum.succ{Word64}: tried to take `succ' of maxBound"
+    (succ (maxBound::Word64)) = error "Enum.succ{Word64}: tried to take `succ' of last tag in enumeration"
     pred (1::Word64) = 0
     pred (maxBound::Word64) = 18446744073709551614
-    pred (minBound::Word64) = error "Enum.pred{Word64}: tried to take `pred' of minBound"
+    pred (minBound::Word64) = error "Enum.pred{Word64}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Word64) [1, fromIntegral (minBound::Word64)::Int, maxBound::Int]) = [1,0,9223372036854775807]
     (toEnum (maxBound::Int))::Word64 = 9223372036854775807
     (map fromEnum [(1::Word64),minBound,fromIntegral (maxBound::Int)]) = [1,0,9223372036854775807]


=====================================
libraries/base/tests/enum03.stdout-ws-64
=====================================
@@ -1,12 +1,12 @@
 Testing Enum Word8:
     (succ (0::Word8)) = 1
     (succ (minBound::Word8)) = 1
-    (succ (maxBound::Word8)) = error "Enum.succ{Word8}: tried to take `succ' of maxBound"
+    (succ (maxBound::Word8)) = error "Enum.succ{Word8}: tried to take `succ' of last tag in enumeration"
     pred (1::Word8) = 0
     pred (maxBound::Word8) = 254
-    pred (minBound::Word8) = error "Enum.pred{Word8}: tried to take `pred' of minBound"
+    pred (minBound::Word8) = error "Enum.pred{Word8}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Word8) [1, fromIntegral (minBound::Word8)::Int, fromIntegral (maxBound::Word8)::Int]) = [1,0,255]
-    (toEnum (maxBound::Int))::Word8 = error "Enum.toEnum{Word8}: tag (9223372036854775807) is outside of bounds (0,255)"
+    (toEnum (maxBound::Int))::Word8 = error "Enum.toEnum{Word8}: tag (9223372036854775807) is outside of enumeration's range (0,255)"
     (map fromEnum [(1::Word8),minBound,maxBound]) = [1,0,255]
     (take 7 [(1::Word8)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Word8)-5)..]) = [250,251,252,253,254,255]
@@ -36,12 +36,12 @@ Testing Enum Word8:
 Testing Enum Word16:
     (succ (0::Word16)) = 1
     (succ (minBound::Word16)) = 1
-    (succ (maxBound::Word16)) = error "Enum.succ{Word16}: tried to take `succ' of maxBound"
+    (succ (maxBound::Word16)) = error "Enum.succ{Word16}: tried to take `succ' of last tag in enumeration"
     pred (1::Word16) = 0
     pred (maxBound::Word16) = 65534
-    pred (minBound::Word16) = error "Enum.pred{Word16}: tried to take `pred' of minBound"
+    pred (minBound::Word16) = error "Enum.pred{Word16}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Word16) [1, fromIntegral (minBound::Word16)::Int, fromIntegral (maxBound::Word16)::Int]) = [1,0,65535]
-    (toEnum (maxBound::Int))::Word16 = error "Enum.toEnum{Word16}: tag (9223372036854775807) is outside of bounds (0,65535)"
+    (toEnum (maxBound::Int))::Word16 = error "Enum.toEnum{Word16}: tag (9223372036854775807) is outside of enumeration's range (0,65535)"
     (map fromEnum [(1::Word16),minBound,maxBound]) = [1,0,65535]
     (take 7 [(1::Word16)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Word16)-5)..]) = [65530,65531,65532,65533,65534,65535]
@@ -71,12 +71,12 @@ Testing Enum Word16:
 Testing Enum Word32:
     (succ (0::Word32)) = 1
     (succ (minBound::Word32)) = 1
-    (succ (maxBound::Word32)) = error "Enum.succ{Word32}: tried to take `succ' of maxBound"
+    (succ (maxBound::Word32)) = error "Enum.succ{Word32}: tried to take `succ' of last tag in enumeration"
     pred (1::Word32) = 0
     pred (maxBound::Word32) = 4294967294
-    pred (minBound::Word32) = error "Enum.pred{Word32}: tried to take `pred' of minBound"
+    pred (minBound::Word32) = error "Enum.pred{Word32}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Word32) [1, fromIntegral (minBound::Word32)::Int, fromIntegral (maxBound::Int32)::Int]) = [1,0,2147483647]
-    (toEnum (maxBound::Int))::Word32 = error "Enum.toEnum{Word32}: tag (9223372036854775807) is outside of bounds (0,4294967295)"
+    (toEnum (maxBound::Int))::Word32 = error "Enum.toEnum{Word32}: tag (9223372036854775807) is outside of enumeration's range (0,4294967295)"
     (map fromEnum [(1::Word32),minBound,fromIntegral (maxBound::Int)]) = [1,0,4294967295]
     fromEnum (maxBound::Word32) = 4294967295
     (take 7 [(1::Word32)..]) = [1,2,3,4,5,6,7]
@@ -107,10 +107,10 @@ Testing Enum Word32:
 Testing Enum Word64:
     (succ (0::Word64)) = 1
     (succ (minBound::Word64)) = 1
-    (succ (maxBound::Word64)) = error "Enum.succ{Word64}: tried to take `succ' of maxBound"
+    (succ (maxBound::Word64)) = error "Enum.succ{Word64}: tried to take `succ' of last tag in enumeration"
     pred (1::Word64) = 0
     pred (maxBound::Word64) = 18446744073709551614
-    pred (minBound::Word64) = error "Enum.pred{Word64}: tried to take `pred' of minBound"
+    pred (minBound::Word64) = error "Enum.pred{Word64}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Word64) [1, fromIntegral (minBound::Word64)::Int, maxBound::Int]) = [1,0,9223372036854775807]
     (toEnum (maxBound::Int))::Word64 = 9223372036854775807
     (map fromEnum [(1::Word64),minBound,fromIntegral (maxBound::Int)]) = [1,0,9223372036854775807]


=====================================
libraries/base/tests/enum03.stdout-x86_64-unknown-openbsd
=====================================
@@ -1,12 +1,12 @@
 Testing Enum Word8:
     (succ (0::Word8)) = 1
     (succ (minBound::Word8)) = 1
-    (succ (maxBound::Word8)) = error "Enum.succ{Word8}: tried to take `succ' of maxBound"
+    (succ (maxBound::Word8)) = error "Enum.succ{Word8}: tried to take `succ' of last tag in enumeration"
     pred (1::Word8) = 0
     pred (maxBound::Word8) = 254
-    pred (minBound::Word8) = error "Enum.pred{Word8}: tried to take `pred' of minBound"
+    pred (minBound::Word8) = error "Enum.pred{Word8}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Word8) [1, fromIntegral (minBound::Word8)::Int, fromIntegral (maxBound::Word8)::Int]) = [1,0,255]
-    (toEnum (maxBound::Int))::Word8 = error "Enum.toEnum{Word8}: tag (9223372036854775807) is outside of bounds (0,255)"
+    (toEnum (maxBound::Int))::Word8 = error "Enum.toEnum{Word8}: tag (9223372036854775807) is outside of enumeration's range (0,255)"
     (map fromEnum [(1::Word8),minBound,maxBound]) = [1,0,255]
     (take 7 [(1::Word8)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Word8)-5)..]) = [250,251,252,253,254,255]
@@ -36,12 +36,12 @@ Testing Enum Word8:
 Testing Enum Word16:
     (succ (0::Word16)) = 1
     (succ (minBound::Word16)) = 1
-    (succ (maxBound::Word16)) = error "Enum.succ{Word16}: tried to take `succ' of maxBound"
+    (succ (maxBound::Word16)) = error "Enum.succ{Word16}: tried to take `succ' of last tag in enumeration"
     pred (1::Word16) = 0
     pred (maxBound::Word16) = 65534
-    pred (minBound::Word16) = error "Enum.pred{Word16}: tried to take `pred' of minBound"
+    pred (minBound::Word16) = error "Enum.pred{Word16}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Word16) [1, fromIntegral (minBound::Word16)::Int, fromIntegral (maxBound::Word16)::Int]) = [1,0,65535]
-    (toEnum (maxBound::Int))::Word16 = error "Enum.toEnum{Word16}: tag (9223372036854775807) is outside of bounds (0,65535)"
+    (toEnum (maxBound::Int))::Word16 = error "Enum.toEnum{Word16}: tag (9223372036854775807) is outside of enumeration's range (0,65535)"
     (map fromEnum [(1::Word16),minBound,maxBound]) = [1,0,65535]
     (take 7 [(1::Word16)..]) = [1,2,3,4,5,6,7]
     (take 7 [((maxBound::Word16)-5)..]) = [65530,65531,65532,65533,65534,65535]
@@ -71,12 +71,12 @@ Testing Enum Word16:
 Testing Enum Word32:
     (succ (0::Word32)) = 1
     (succ (minBound::Word32)) = 1
-    (succ (maxBound::Word32)) = error "Enum.succ{Word32}: tried to take `succ' of maxBound"
+    (succ (maxBound::Word32)) = error "Enum.succ{Word32}: tried to take `succ' of last tag in enumeration"
     pred (1::Word32) = 0
     pred (maxBound::Word32) = 4294967294
-    pred (minBound::Word32) = error "Enum.pred{Word32}: tried to take `pred' of minBound"
+    pred (minBound::Word32) = error "Enum.pred{Word32}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Word32) [1, fromIntegral (minBound::Word32)::Int, fromIntegral (maxBound::Int32)::Int]) = [1,0,2147483647]
-    (toEnum (maxBound::Int))::Word32 = error "Enum.toEnum{Word32}: tag (9223372036854775807) is outside of bounds (0,4294967295)"
+    (toEnum (maxBound::Int))::Word32 = error "Enum.toEnum{Word32}: tag (9223372036854775807) is outside of enumeration's range (0,4294967295)"
     (map fromEnum [(1::Word32),minBound,fromIntegral (maxBound::Int)]) = [1,0,4294967295]
     fromEnum (maxBound::Word32) = 4294967295
     (take 7 [(1::Word32)..]) = [1,2,3,4,5,6,7]
@@ -107,10 +107,10 @@ Testing Enum Word32:
 Testing Enum Word64:
     (succ (0::Word64)) = 1
     (succ (minBound::Word64)) = 1
-    (succ (maxBound::Word64)) = error "Enum.succ{Word64}: tried to take `succ' of maxBound"
+    (succ (maxBound::Word64)) = error "Enum.succ{Word64}: tried to take `succ' of last tag in enumeration"
     pred (1::Word64) = 0
     pred (maxBound::Word64) = 18446744073709551614
-    pred (minBound::Word64) = error "Enum.pred{Word64}: tried to take `pred' of minBound"
+    pred (minBound::Word64) = error "Enum.pred{Word64}: tried to take `pred' of first tag in enumeration"
     (map (toEnum::Int->Word64) [1, fromIntegral (minBound::Word64)::Int, maxBound::Int]) = [1,0,9223372036854775807]
     (toEnum (maxBound::Int))::Word64 = 9223372036854775807
     (map fromEnum [(1::Word64),minBound,fromIntegral (maxBound::Int)]) = [1,0,9223372036854775807]


=====================================
libraries/ghc-internal/codepages/MakeTable.hs
=====================================
@@ -33,7 +33,7 @@ main :: IO ()
 main = do
     moduleName:outFile:files <- getArgs
     let badFiles = -- These fail with an error like
-                   --     MakeTable: Enum.toEnum{Word8}: tag (33088) is outside of bounds (0,255)
+                   --     MakeTable: Enum.toEnum{Word8}: tag (33088) is outside of enumeration's range (0,255)
                    -- I have no idea what's going on, so for now we just
                    -- skip them.
                    ["CPs/CP932.TXT",


=====================================
libraries/ghc-internal/src/GHC/Internal/Enum.hs
=====================================
@@ -22,14 +22,20 @@
 
 #include "MachDeps.h"
 
-module GHC.Internal.Enum(
-        Bounded(..), Enum(..),
-        boundedEnumFrom, boundedEnumFromThen,
-        toEnumError, fromEnumError, succError, predError,
-
-        -- Instances for Bounded and Enum: (), Char, Int
-
-   ) where
+module GHC.Internal.Enum
+  ( Bounded(..)
+  , Enum(..)
+  , boundedEnumFrom
+  , boundedEnumFromThen
+  , toEnumError
+  , fromEnumError
+  , succError
+  , predError
+  , enumIntToWord
+
+  -- Instances for Bounded and Enum: (), Char, Int
+  )
+where
 
 import GHC.Internal.Base hiding ( many )
 import GHC.Internal.Char
@@ -246,11 +252,11 @@ Alternatives might be
 
 {-# NOINLINE toEnumError #-}
 toEnumError :: (Show a) => String -> Int -> (a,a) -> b
-toEnumError inst_ty i bnds =
+toEnumError inst_ty i (mi,ma) =
     errorWithoutStackTrace $ "Enum.toEnum{" ++ inst_ty ++ "}: tag (" ++
             show i ++
-            ") is outside of bounds " ++
-            show bnds
+            ") is outside of enumeration's range (" ++
+            show mi ++ "," ++ show ma ++ ")"
 
 {-# NOINLINE fromEnumError #-}
 fromEnumError :: (Show a) => String -> a -> b
@@ -263,12 +269,12 @@ fromEnumError inst_ty x =
 {-# NOINLINE succError #-}
 succError :: String -> a
 succError inst_ty =
-    errorWithoutStackTrace $ "Enum.succ{" ++ inst_ty ++ "}: tried to take `succ' of maxBound"
+    errorWithoutStackTrace $ "Enum.succ{" ++ inst_ty ++ "}: tried to take `succ' of last tag in enumeration"
 
 {-# NOINLINE predError #-}
 predError :: String -> a
 predError inst_ty =
-    errorWithoutStackTrace $ "Enum.pred{" ++ inst_ty ++ "}: tried to take `pred' of minBound"
+    errorWithoutStackTrace $ "Enum.pred{" ++ inst_ty ++ "}: tried to take `pred' of first tag in enumeration"
 
 ------------------------------------------------------------------------
 -- Tuples
@@ -565,10 +571,10 @@ instance  Bounded Int where
 -- | @since base-2.01
 instance  Enum Int  where
     succ x
-       | x == maxBound  = errorWithoutStackTrace "Prelude.Enum.succ{Int}: tried to take `succ' of maxBound"
+       | x == maxBound  = succError "Int"
        | otherwise      = x + 1
     pred x
-       | x == minBound  = errorWithoutStackTrace "Prelude.Enum.pred{Int}: tried to take `pred' of minBound"
+       | x == minBound  = predError "Int"
        | otherwise      = x - 1
 
     toEnum   x = x
@@ -1088,6 +1094,9 @@ enumNegDeltaToNatural x0 ndelta lim = go x0
          | x >= ndelta = x : go (x-ndelta)
          | otherwise   = [x]
 
+-- | Convert an Int into a Word (used in derived Enum instances)
+enumIntToWord :: Int -> Word
+enumIntToWord (I# i) = W# (int2Word# i)
 
 -- Instances from GHC.Types
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c20d51867c824e32c61bd1e002680bef268e4f51...e9fa116326c56859e26c6a713788a756c1318cda

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c20d51867c824e32c61bd1e002680bef268e4f51...e9fa116326c56859e26c6a713788a756c1318cda
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240926/4770f436/attachment-0001.html>


More information about the ghc-commits mailing list