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, 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, 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)
103 uppBracket p = uppBeside uppLbrack (uppBeside p uppRbrack)
104 uppParens p = uppBeside uppLparen (uppBeside p uppRparen)
106 uppInterleave sep ps = uppSep (pi ps)
110 pi (x:xs) = (cAppend{-uppBeside-} x sep) : pi xs
114 uppIntersperse sep ps = uppBesides (pi ps)
118 pi (x:xs) = (cAppend{-uppBeside-} x sep) : pi xs
122 uppBeside p1 p2 = p1 `cAppend` p2
124 uppBesides [] = cNil{-uppNil-}
126 uppBesides (p:ps) = p `cAppend`{-uppBeside-} uppBesides ps
130 ppBesideSP p1 p2 = p1 `cAppend` (cCh ' ') `cAppend` p2
133 @uppCat@ is the name I (WDP) happen to have been using for @ppBesidesSP@.
136 uppCat [] = cNil{-uppNil-}
138 uppCat (p:ps) = ppBesideSP p (uppCat ps)
140 uppAbove p1 p2 = p1 `cAppend` (cCh '\n') `cAppend` p2
142 uppAboves [] = cNil{-uppNil-}
144 uppAboves (p:ps) = p `cAppend` (cCh '\n') `cAppend` (uppAboves ps)
148 uppSep ps = uppBesides ps