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