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