~ubuntu-branches/ubuntu/precise/ghc/precise

« back to all changes in this revision

Viewing changes to libraries/base/Text/Show/Functions.hs

  • Committer: Bazaar Package Importer
  • Author(s): Joachim Breitner
  • Date: 2011-01-17 12:49:24 UTC
  • Revision ID: james.westby@ubuntu.com-20110117124924-do1pym1jlf5o636m
Tags: upstream-7.0.1
ImportĀ upstreamĀ versionĀ 7.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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