
The only possible definition of such a function is something like unsafeShow :: (forall a . Show a => a) -> String unsafeShow a = show (a :: Bool) right? And you'd also need to coerce the argument type in order to use it: putStrLn $ unsafeShow $ unsafeCoerce True Right? Then a nicer definition might be unsafeShow :: Show a => a -> b -> String unsafeShow a b = show (unsafeCoerce b `asTypeOf` a) Here is an example of how to use it to show an overloaded variable without changing the type signature: test :: Eq a => a -> IO () test a = putStrLn $ unsafeShow (undefined :: Int) a Of course, this only works safely if a is an Int: *Main> test (5 :: Int) 5 *Main> test (5 :: Double) 0 / Emil On 2008-01-07 12:56, Lutz Donnerhacke wrote:
* Henning Thielemann wrote:
happen. Paradoxical. It would be interesting if it is possible to tunnel Show class dictionaries through to an 'error' like IO is tunneled to 'trace'.
unsafeShow :: (forall a . Show a => a) -> String _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe