nhc98 version of instance Show (a->b) copied from Prelude
[ghc-base.git] / Text / Show / Functions.hs
index bbd61a1..315d4d3 100644 (file)
@@ -8,13 +8,26 @@
 -- Stability   :  provisional
 -- Portability :  portable
 --
--- Optional instance of Text.Show.Show for functions.
+-- Optional instance of 'Text.Show.Show' for functions:
+--
+-- > instance Show (a -> b) where
+-- >   showsPrec _ _ = showString \"\<function\>\"
 --
 -----------------------------------------------------------------------------
 
-module Text.Show.Functions where
+module Text.Show.Functions () where
 
 import Prelude
 
+#ifndef __NHC__
 instance Show (a -> b) where
        showsPrec _ _ = showString "<function>"
+#else
+instance (Show a,Show b) => Show (a->b) where
+  showsPrec d a = showString "<<function>>"
+
+  showsType a = showChar '(' . showsType value  . showString " -> " .
+                               showsType result . showChar ')'
+                where (value,result) = getTypes undefined
+                      getTypes x = (x,a x)
+#endif