[project @ 2002-05-09 13:16:29 by simonmar]
[ghc-base.git] / Text / Show.hs
1 {-# OPTIONS -fno-implicit-prelude #-}
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 -- The Show class and associated functions.
13 --
14 -----------------------------------------------------------------------------
15
16 module Text.Show (
17    ShowS,               -- String -> String
18    Show(
19       showsPrec,        -- :: Int -> a -> ShowS
20       show,             -- :: a   -> String
21       showList          -- :: [a] -> ShowS 
22     ),
23    shows,               -- :: (Show a) => a -> ShowS
24    showChar,            -- :: Char -> ShowS
25    showString,          -- :: String -> ShowS
26    showParen,           -- :: Bool -> ShowS -> ShowS
27    showListWith,        -- :: (a -> ShowS) -> [a] -> ShowS 
28  ) where
29
30 #ifdef __GLASGOW_HASKELL__
31 import GHC.Show
32 #endif   
33
34 #ifdef __GLASGOW_HASKELL__
35 showListWith :: (a -> ShowS) -> [a] -> ShowS 
36 showListWith = showList__
37 #else
38 showList__ :: (a -> ShowS) ->  [a] -> ShowS
39 showList__ _     []     s = "[]" ++ s
40 showList__ showx (x:xs) s = '[' : showx x (showl xs)
41   where
42     showl []     = ']' : s
43     showl (y:ys) = ',' : showx y (showl ys)
44 #endif