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