nhc98 version of instance Show (a->b) copied from Prelude
[ghc-base.git] / Text / Show / Functions.hs
1 -----------------------------------------------------------------------------
2 -- |
3 -- Module      :  Text.Show.Functions
4 -- Copyright   :  (c) The University of Glasgow 2001
5 -- License     :  BSD-style (see the file libraries/base/LICENSE)
6 -- 
7 -- Maintainer  :  libraries@haskell.org
8 -- Stability   :  provisional
9 -- Portability :  portable
10 --
11 -- Optional instance of 'Text.Show.Show' for functions:
12 --
13 -- > instance Show (a -> b) where
14 -- >    showsPrec _ _ = showString \"\<function\>\"
15 --
16 -----------------------------------------------------------------------------
17
18 module Text.Show.Functions () where
19
20 import Prelude
21
22 #ifndef __NHC__
23 instance Show (a -> b) where
24         showsPrec _ _ = showString "<function>"
25 #else
26 instance (Show a,Show b) => Show (a->b) where
27   showsPrec d a = showString "<<function>>"
28
29   showsType a = showChar '(' . showsType value  . showString " -> " .
30                                showsType result . showChar ')'
31                 where (value,result) = getTypes undefined
32                       getTypes x = (x,a x)
33 #endif