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 uppCat, uppBeside, uppBesides, uppAbove, uppAboves,
17 uppNest, uppSep, uppInterleave, uppIntersperse,
21 -- abstract type, to complete the interface...
25 CHK_Ubiq() -- debugging consistency check
30 Same interface as @Pretty@, but doesn't do anything.
32 The pretty type is redefined here:
37 %************************************************
39 \subsection{The interface}
41 %************************************************
45 uppSP, uppLbrack, uppRbrack, uppLparen, uppRparen, uppSemi, uppComma, uppEquals :: Unpretty
47 uppStr :: [Char] -> Unpretty
48 uppPStr :: FAST_STRING -> Unpretty
49 uppChar :: Char -> Unpretty
50 uppInt :: Int -> Unpretty
51 uppInteger :: Integer -> Unpretty
53 uppBeside :: Unpretty -> Unpretty -> Unpretty
54 uppBesides :: [Unpretty] -> Unpretty
55 ppBesideSP :: Unpretty -> Unpretty -> Unpretty
56 uppCat :: [Unpretty] -> Unpretty -- i.e., ppBesidesSP
58 uppAbove :: Unpretty -> Unpretty -> Unpretty
59 uppAboves :: [Unpretty] -> Unpretty
61 uppInterleave :: Unpretty -> [Unpretty] -> Unpretty
62 uppIntersperse :: Unpretty -> [Unpretty] -> Unpretty -- no spaces between
63 uppSep :: [Unpretty] -> Unpretty
64 uppNest :: Int -> Unpretty -> Unpretty
66 uppShow :: Int -> Unpretty -> [Char]
68 uppAppendFile :: _FILE -> Int -> Unpretty -> PrimIO ()
71 %************************************************
73 \subsection{The representation}
75 %************************************************
80 uppAppendFile f _ p = cAppendFile f p
88 uppInteger n = cStr (show n)
99 uppInterleave sep ps = uppSep (pi ps)
103 pi (x:xs) = (cAppend{-uppBeside-} x sep) : pi xs
107 uppIntersperse sep ps = uppBesides (pi ps)
111 pi (x:xs) = (cAppend{-uppBeside-} x sep) : pi xs
115 uppBeside p1 p2 = p1 `cAppend` p2
117 uppBesides [] = cNil{-uppNil-}
119 uppBesides (p:ps) = p `cAppend`{-uppBeside-} uppBesides ps
123 ppBesideSP p1 p2 = p1 `cAppend` (cCh ' ') `cAppend` p2
126 @uppCat@ is the name I (WDP) happen to have been using for @ppBesidesSP@.
129 uppCat [] = cNil{-uppNil-}
131 uppCat (p:ps) = ppBesideSP p (uppCat ps)
133 uppAbove p1 p2 = p1 `cAppend` (cCh '\n') `cAppend` p2
135 uppAboves [] = cNil{-uppNil-}
137 uppAboves (p:ps) = p `cAppend` (cCh '\n') `cAppend` (uppAboves ps)
141 uppSep ps = uppBesides ps