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

« back to all changes in this revision

Viewing changes to libraries/base/Text/Show.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
{-# OPTIONS_GHC -XNoImplicitPrelude #-}
 
2
-----------------------------------------------------------------------------
 
3
-- |
 
4
-- Module      :  Text.Show
 
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
-- Converting values to readable strings:
 
13
-- the 'Show' class and associated functions.
 
14
--
 
15
-----------------------------------------------------------------------------
 
16
 
 
17
module Text.Show (
 
18
   ShowS,               -- String -> String
 
19
   Show(
 
20
      showsPrec,        -- :: Int -> a -> ShowS
 
21
      show,             -- :: a   -> String
 
22
      showList          -- :: [a] -> ShowS 
 
23
    ),
 
24
   shows,               -- :: (Show a) => a -> ShowS
 
25
   showChar,            -- :: Char -> ShowS
 
26
   showString,          -- :: String -> ShowS
 
27
   showParen,           -- :: Bool -> ShowS -> ShowS
 
28
   showListWith,        -- :: (a -> ShowS) -> [a] -> ShowS 
 
29
 ) where
 
30
 
 
31
#ifdef __GLASGOW_HASKELL__
 
32
import GHC.Show
 
33
#endif
 
34
 
 
35
-- | Show a list (using square brackets and commas), given a function
 
36
-- for showing elements.
 
37
showListWith :: (a -> ShowS) -> [a] -> ShowS
 
38
showListWith = showList__
 
39
 
 
40
#ifndef __GLASGOW_HASKELL__
 
41
showList__ :: (a -> ShowS) ->  [a] -> ShowS
 
42
showList__ _     []     s = "[]" ++ s
 
43
showList__ showx (x:xs) s = '[' : showx x (showl xs)
 
44
  where
 
45
    showl []     = ']' : s
 
46
    showl (y:ys) = ',' : showx y (showl ys)
 
47
#endif