From 811bf3ff4977e169901d81695f1f2340ce3dcb80 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Sat, 18 Jul 2009 15:10:49 +0000 Subject: [PATCH] Make chr say what its argument was, if it's a bad argument --- GHC/Base.lhs | 7 +++++-- GHC/Show.lhs-boot | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 GHC/Show.lhs-boot diff --git a/GHC/Base.lhs b/GHC/Base.lhs index 3806d78..449a861 100644 --- a/GHC/Base.lhs +++ b/GHC/Base.lhs @@ -101,6 +101,7 @@ import GHC.Classes import GHC.Generics import GHC.Ordering import GHC.Prim +import {-# SOURCE #-} GHC.Show import {-# SOURCE #-} GHC.Err -- These two are not strictly speaking required by this module, but they are @@ -535,8 +536,10 @@ instance Ord Char where -- | The 'Prelude.toEnum' method restricted to the type 'Data.Char.Char'. chr :: Int -> Char -chr (I# i#) | int2Word# i# `leWord#` int2Word# 0x10FFFF# = C# (chr# i#) - | otherwise = error "Prelude.chr: bad argument" +chr i@(I# i#) + | int2Word# i# `leWord#` int2Word# 0x10FFFF# = C# (chr# i#) + | otherwise + = error ("Prelude.chr: bad argument: " ++ showSignedInt (I# 9#) i "") unsafeChr :: Int -> Char unsafeChr (I# i#) = C# (chr# i#) diff --git a/GHC/Show.lhs-boot b/GHC/Show.lhs-boot new file mode 100644 index 0000000..b01d165 --- /dev/null +++ b/GHC/Show.lhs-boot @@ -0,0 +1,10 @@ +\begin{code} +{-# OPTIONS_GHC -XNoImplicitPrelude #-} + +module GHC.Show (showSignedInt) where + +import GHC.Types + +showSignedInt :: Int -> Int -> [Char] -> [Char] +\end{code} + -- 1.7.10.4