2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
4 \section[Unpretty]{Unpretty-printing data type}
7 #include "HsVersions.h"
12 uppNil, uppStr, uppPStr, uppChar, uppInt, uppInteger,
13 uppSP, upp'SP, uppLbrack, uppRbrack, uppLparen, uppRparen,
14 uppSemi, uppComma, uppEquals,
16 uppBracket, uppParens,
17 uppCat, uppBeside, uppBesides, uppAbove, uppAboves,
18 uppNest, uppSep, uppInterleave, uppIntersperse,
22 -- abstract type, to complete the interface...
26 CHK_Ubiq() -- debugging consistency check
31 Same interface as @Pretty@, but doesn't do anything.
33 The pretty type is redefined here:
38 %************************************************
40 \subsection{The interface}
42 %************************************************
46 uppSP, upp'SP, uppLbrack, uppRbrack, uppLparen, uppRparen, uppSemi, uppComma, uppEquals :: Unpretty
48 uppStr :: [Char] -> Unpretty
49 uppPStr :: FAST_STRING -> Unpretty
50 uppChar :: Char -> Unpretty
51 uppInt :: Int -> Unpretty
52 uppInteger :: Integer -> Unpretty
54 uppBracket :: Unpretty -> Unpretty -- put brackets around it
55 uppParens :: Unpretty -> Unpretty -- put parens around it
57 uppBeside :: Unpretty -> Unpretty -> Unpretty
58 uppBesides :: [Unpretty] -> Unpretty
59 ppBesideSP :: Unpretty -> Unpretty -> Unpretty
60 uppCat :: [Unpretty] -> Unpretty -- i.e., ppBesidesSP
62 uppAbove :: Unpretty -> Unpretty -> Unpretty
63 uppAboves :: [Unpretty] -> Unpretty
65 uppInterleave :: Unpretty -> [Unpretty] -> Unpretty
66 uppIntersperse :: Unpretty -> [Unpretty] -> Unpretty -- no spaces between
67 uppSep :: [Unpretty] -> Unpretty
68 uppNest :: Int -> Unpretty -> Unpretty
70 uppShow :: Int -> Unpretty -> [Char]
72 uppAppendFile :: _FILE -> Int -> Unpretty -> IO ()
75 %************************************************
77 \subsection{The representation}
79 %************************************************
84 uppAppendFile f _ p = cAppendFile f p
92 uppInteger n = cStr (show n)
95 upp'SP{-'-} = cPStr SLIT(", ")
104 uppBracket p = uppBeside uppLbrack (uppBeside p uppRbrack)
105 uppParens p = uppBeside uppLparen (uppBeside p uppRparen)
107 uppInterleave sep ps = uppSep (pi ps)
111 pi (x:xs) = (cAppend{-uppBeside-} x sep) : pi xs
115 uppIntersperse sep ps = uppBesides (pi ps)
119 pi (x:xs) = (cAppend{-uppBeside-} x sep) : pi xs
123 uppBeside p1 p2 = p1 `cAppend` p2
125 uppBesides [] = cNil{-uppNil-}
127 uppBesides (p:ps) = p `cAppend`{-uppBeside-} uppBesides ps
131 ppBesideSP p1 p2 = p1 `cAppend` (cCh ' ') `cAppend` p2
134 @uppCat@ is the name I (WDP) happen to have been using for @ppBesidesSP@.
137 uppCat [] = cNil{-uppNil-}
139 uppCat (p:ps) = ppBesideSP p (uppCat ps)
141 uppAbove p1 p2 = p1 `cAppend` (cCh '\n') `cAppend` p2
143 uppAboves [] = cNil{-uppNil-}
145 uppAboves (p:ps) = p `cAppend` (cCh '\n') `cAppend` (uppAboves ps)
149 uppSep ps = uppBesides ps