2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1995
4 \section[Unpretty]{Unpretty-printing data type}
7 #include "HsVersions.h"
11 PprStyle(..), -- re-exported from Pretty
12 uppNil, uppStr, uppPStr, uppChar, uppInt, uppInteger, --UNUSED: uppDouble,
13 uppSP, uppLbrack, uppRbrack, uppLparen, uppRparen, -- UNUSED: upp'SP,
14 uppSemi, uppComma, uppEquals,
16 uppCat, uppBeside, uppBesides, uppAbove, uppAboves,
17 uppNest, uppSep, uppInterleave, uppIntersperse, --UNUSED: uppHang,
19 #ifdef __GLASGOW_HASKELL__
21 IF_ATTACK_PRAGMAS(cAppendFile COMMA)
22 IF_ATTACK_PRAGMAS(cInt COMMA)
26 #endif {- Data Parallel Haskell -}
28 -- abstract type, to complete the interface...
34 import Pretty ( PprStyle(..), Pretty(..), GlobalSwitch )
38 Same interface as @Pretty@, but doesn't do anything.
40 The pretty type is redefined here:
45 %************************************************
47 \subsection{The interface}
49 %************************************************
53 uppSP, uppLbrack, uppRbrack, uppLparen, uppRparen, uppSemi, uppComma, uppEquals :: Unpretty
54 --UNUSED: upp'SP :: Unpretty
56 uppStr :: [Char] -> Unpretty
57 uppPStr :: FAST_STRING -> Unpretty
58 uppChar :: Char -> Unpretty
59 uppInt :: Int -> Unpretty
60 uppInteger :: Integer -> Unpretty
61 --UNUSED:uppDouble :: Double -> Unpretty
63 uppBeside :: Unpretty -> Unpretty -> Unpretty
64 uppBesides :: [Unpretty] -> Unpretty
65 ppBesideSP :: Unpretty -> Unpretty -> Unpretty
66 uppCat :: [Unpretty] -> Unpretty -- i.e., ppBesidesSP
68 uppAbove :: Unpretty -> Unpretty -> Unpretty
69 uppAboves :: [Unpretty] -> Unpretty
71 uppInterleave :: Unpretty -> [Unpretty] -> Unpretty
72 uppIntersperse :: Unpretty -> [Unpretty] -> Unpretty -- no spaces between
73 uppSep :: [Unpretty] -> Unpretty
74 --UNUSED:uppHang :: Unpretty -> Int -> Unpretty -> Unpretty
75 uppNest :: Int -> Unpretty -> Unpretty
77 uppShow :: Int -> Unpretty -> [Char]
79 #ifdef __GLASGOW_HASKELL__
80 uppAppendFile :: _FILE -> Int -> Unpretty -> PrimIO ()
84 %************************************************
86 \subsection{The representation}
88 %************************************************
93 #ifdef __GLASGOW_HASKELL__
94 uppAppendFile f _ p = cAppendFile f p
103 uppInteger n = cStr (show n)
104 --UNUSED:uppDouble n = cStr (show n)
107 --UNUSED:upp'SP = cStr ", "
116 uppInterleave sep ps = uppSep (pi ps)
120 pi (x:xs) = (cAppend{-uppBeside-} x sep) : pi xs
124 uppIntersperse sep ps = uppBesides (pi ps)
128 pi (x:xs) = (cAppend{-uppBeside-} x sep) : pi xs
132 uppBeside p1 p2 = p1 `cAppend` p2
134 uppBesides [] = cNil{-uppNil-}
136 uppBesides (p:ps) = p `cAppend`{-uppBeside-} uppBesides ps
140 ppBesideSP p1 p2 = p1 `cAppend` (cCh ' ') `cAppend` p2
143 @uppCat@ is the name I (WDP) happen to have been using for @ppBesidesSP@.
146 uppCat [] = cNil{-uppNil-}
148 uppCat (p:ps) = ppBesideSP p (uppCat ps)
150 uppAbove p1 p2 = p1 `cAppend` (cCh '\n') `cAppend` p2
152 uppAboves [] = cNil{-uppNil-}
154 uppAboves (p:ps) = p `cAppend` (cCh '\n') `cAppend` (uppAboves ps)
160 --UNUSED: uppHang p1 n p2 = ppBesideSP p1 p2
162 uppSep ps = uppBesides ps
167 unprettyToStr:: Unpretty -> String
168 unprettyToStr thing = uppShow 80 thing
169 #endif {- Data Parallel Haskell -}