Repository : ssh://darcs.haskell.org//srv/darcs/packages/base On branch : master
http://hackage.haskell.org/trac/ghc/changeset/0e4442c9d0a73fa4bb301b9f02b5fb11cb40f2b7 >--------------------------------------------------------------- commit 0e4442c9d0a73fa4bb301b9f02b5fb11cb40f2b7 Author: Ian Lynagh <[email protected]> Date: Thu Sep 15 19:18:04 2011 +0100 Move some Enum helpers into GHC.Enum They were in GHC.Word, but are also used in GHC.Int >--------------------------------------------------------------- GHC/Enum.lhs | 34 ++++++++++++++++++++++++++++++++++ GHC/Word.hs | 31 ------------------------------- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/GHC/Enum.lhs b/GHC/Enum.lhs index 61ee894..f99e208 100644 --- a/GHC/Enum.lhs +++ b/GHC/Enum.lhs @@ -20,6 +20,7 @@ module GHC.Enum( Bounded(..), Enum(..), boundedEnumFrom, boundedEnumFromThen, + toEnumError, fromEnumError, succError, predError, -- Instances for Bounded and Enum: (), Char, Int @@ -28,6 +29,7 @@ module GHC.Enum( import GHC.Base import GHC.Integer import GHC.Num +import GHC.Show import Data.Tuple () -- for dependencies default () -- Double isn't available yet \end{code} @@ -123,6 +125,38 @@ boundedEnumFromThen n1 n2 i_n2 = fromEnum n2 \end{code} +\begin{code} +------------------------------------------------------------------------ +-- Helper functions +------------------------------------------------------------------------ + +{-# NOINLINE toEnumError #-} +toEnumError :: (Show a) => String -> Int -> (a,a) -> b +toEnumError inst_ty i bnds = + error $ "Enum.toEnum{" ++ inst_ty ++ "}: tag (" ++ + show i ++ + ") is outside of bounds " ++ + show bnds + +{-# NOINLINE fromEnumError #-} +fromEnumError :: (Show a) => String -> a -> b +fromEnumError inst_ty x = + error $ "Enum.fromEnum{" ++ inst_ty ++ "}: value (" ++ + show x ++ + ") is outside of Int's bounds " ++ + show (minBound::Int, maxBound::Int) + +{-# NOINLINE succError #-} +succError :: String -> a +succError inst_ty = + error $ "Enum.succ{" ++ inst_ty ++ "}: tried to take `succ' of maxBound" + +{-# NOINLINE predError #-} +predError :: String -> a +predError inst_ty = + error $ "Enum.pred{" ++ inst_ty ++ "}: tried to take `pred' of minBound" +\end{code} + %********************************************************* %* * diff --git a/GHC/Word.hs b/GHC/Word.hs index 2714898..443f083 100644 --- a/GHC/Word.hs +++ b/GHC/Word.hs @@ -22,7 +22,6 @@ -- #hide module GHC.Word ( Word(..), Word8(..), Word16(..), Word32(..), Word64(..), - toEnumError, fromEnumError, succError, predError, uncheckedShiftL64#, uncheckedShiftRL64# ) where @@ -44,36 +43,6 @@ import GHC.Err import GHC.Float () -- for RealFrac methods ------------------------------------------------------------------------ --- Helper functions ------------------------------------------------------------------------- - -{-# NOINLINE toEnumError #-} -toEnumError :: (Show a) => String -> Int -> (a,a) -> b -toEnumError inst_ty i bnds = - error $ "Enum.toEnum{" ++ inst_ty ++ "}: tag (" ++ - show i ++ - ") is outside of bounds " ++ - show bnds - -{-# NOINLINE fromEnumError #-} -fromEnumError :: (Show a) => String -> a -> b -fromEnumError inst_ty x = - error $ "Enum.fromEnum{" ++ inst_ty ++ "}: value (" ++ - show x ++ - ") is outside of Int's bounds " ++ - show (minBound::Int, maxBound::Int) - -{-# NOINLINE succError #-} -succError :: String -> a -succError inst_ty = - error $ "Enum.succ{" ++ inst_ty ++ "}: tried to take `succ' of maxBound" - -{-# NOINLINE predError #-} -predError :: String -> a -predError inst_ty = - error $ "Enum.pred{" ++ inst_ty ++ "}: tried to take `pred' of minBound" - ------------------------------------------------------------------------- -- type Word ------------------------------------------------------------------------ _______________________________________________ Cvs-libraries mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-libraries
