in the show instance for Exception, print the type of dynamic exceptions
authorSimon Marlow <simonmar@microsoft.com>
Thu, 6 Apr 2006 11:24:44 +0000 (11:24 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Thu, 6 Apr 2006 11:24:44 +0000 (11:24 +0000)
Unfortunately this requires some recursve module hackery to get at
the show instance for Typeable.

libraries/base/Data/Dynamic.hs-boot
libraries/base/Data/Typeable.hs-boot [new file with mode: 0644]
libraries/base/GHC/Dynamic.hs [new file with mode: 0644]
libraries/base/GHC/Dynamic.hs-boot [new file with mode: 0644]
libraries/base/GHC/IOBase.lhs

index 822ef67..63c81b9 100644 (file)
@@ -1,3 +1,5 @@
 {-# OPTIONS -fno-implicit-prelude #-}
 module Data.Dynamic where
+import {-# SOURCE #-} Data.Typeable (TypeRep)
 data Dynamic
+dynTypeRep :: Dynamic -> TypeRep
diff --git a/libraries/base/Data/Typeable.hs-boot b/libraries/base/Data/Typeable.hs-boot
new file mode 100644 (file)
index 0000000..4250e56
--- /dev/null
@@ -0,0 +1,3 @@
+{-# OPTIONS -fno-implicit-prelude #-}
+module Data.Typeable where
+data TypeRep
diff --git a/libraries/base/GHC/Dynamic.hs b/libraries/base/GHC/Dynamic.hs
new file mode 100644 (file)
index 0000000..e86b027
--- /dev/null
@@ -0,0 +1,11 @@
+{-# OPTIONS -fno-implicit-prelude #-}
+module GHC.Dynamic (
+       Dynamic, TypeRep, dynTypeRep, showsTypeRep
+  ) where
+
+import Data.Dynamic    ( Dynamic, dynTypeRep )
+import Data.Typeable   ( TypeRep )
+import GHC.Show ( ShowS, shows )
+
+showsTypeRep :: TypeRep -> ShowS
+showsTypeRep = shows
diff --git a/libraries/base/GHC/Dynamic.hs-boot b/libraries/base/GHC/Dynamic.hs-boot
new file mode 100644 (file)
index 0000000..a926421
--- /dev/null
@@ -0,0 +1,10 @@
+{-# OPTIONS -fno-implicit-prelude #-}
+module GHC.Dynamic (
+       Dynamic, TypeRep, dynTypeRep, showsTypeRep
+  ) where
+
+import {-# SOURCE #-} Data.Dynamic     ( Dynamic, dynTypeRep )
+import {-# SOURCE #-} Data.Typeable    ( TypeRep )
+import GHC.Show                ( ShowS )
+
+showsTypeRep :: TypeRep -> ShowS
index 78a334d..27f7dab 100644 (file)
@@ -55,7 +55,7 @@ import GHC.List
 import GHC.Read
 
 #ifndef __HADDOCK__
-import {-# SOURCE #-} Data.Dynamic
+import {-# SOURCE #-} GHC.Dynamic
 #endif
 
 -- ---------------------------------------------------------------------------
@@ -743,7 +743,7 @@ instance Show Exception where
   showsPrec _ (RecConError err)                 = showString err
   showsPrec _ (RecUpdError err)                 = showString err
   showsPrec _ (AssertionFailed err)      = showString err
-  showsPrec _ (DynException _err)        = showString "unknown exception"
+  showsPrec _ (DynException err)         = showString "exception :: " . showsTypeRep (dynTypeRep err)
   showsPrec _ (AsyncException e)        = shows e
   showsPrec _ (BlockedOnDeadMVar)       = showString "thread blocked indefinitely"
   showsPrec _ (BlockedIndefinitely)     = showString "thread blocked indefinitely"