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