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
32 Same interface as @Pretty@, but doesn't do anything.
34 The pretty type is redefined here:
39 %************************************************
41 \subsection{The interface}
43 %************************************************
47 uppSP, upp'SP, uppLbrack, uppRbrack, uppLparen, uppRparen, uppSemi, uppComma, uppEquals :: Unpretty
49 uppStr :: [Char] -> Unpretty
50 uppPStr :: FAST_STRING -> Unpretty
51 uppChar :: Char -> Unpretty
52 uppInt :: Int -> Unpretty
53 uppInteger :: Integer -> Unpretty
55 uppBracket :: Unpretty -> Unpretty -- put brackets around it
56 uppParens :: Unpretty -> Unpretty -- put parens around it
58 uppBeside :: Unpretty -> Unpretty -> Unpretty
59 uppBesides :: [Unpretty] -> Unpretty
60 ppBesideSP :: Unpretty -> Unpretty -> Unpretty
61 uppCat :: [Unpretty] -> Unpretty -- i.e., ppBesidesSP
63 uppAbove :: Unpretty -> Unpretty -> Unpretty
64 uppAboves :: [Unpretty] -> Unpretty
66 uppInterleave :: Unpretty -> [Unpretty] -> Unpretty
67 uppIntersperse :: Unpretty -> [Unpretty] -> Unpretty -- no spaces between
68 uppSep :: [Unpretty] -> Unpretty
69 uppNest :: Int -> Unpretty -> Unpretty
71 uppShow :: Int -> Unpretty -> [Char]
73 uppPutStr :: Handle -> Int -> Unpretty -> IO ()
76 %************************************************
78 \subsection{The representation}
80 %************************************************
85 uppPutStr f _ p = _scc_ "uppPutStr" (cPutStr f p)
93 uppInteger n = cStr (show n)
96 upp'SP{-'-} = uppBeside uppComma uppSP
105 uppBracket p = uppBeside uppLbrack (uppBeside p uppRbrack)
106 uppParens p = uppBeside uppLparen (uppBeside p uppRparen)
108 uppInterleave sep ps = uppSep (pi ps)
112 pi (x:xs) = (cAppend{-uppBeside-} x sep) : pi xs
116 uppIntersperse sep ps = uppBesides (pi ps)
120 pi (x:xs) = (cAppend{-uppBeside-} x sep) : pi xs
124 uppBeside p1 p2 = p1 `cAppend` p2
126 uppBesides [] = cNil{-uppNil-}
128 uppBesides (p:ps) = p `cAppend`{-uppBeside-} uppBesides ps
132 ppBesideSP p1 p2 = p1 `cAppend` (cCh ' ') `cAppend` p2
135 @uppCat@ is the name I (WDP) happen to have been using for @ppBesidesSP@.
138 uppCat [] = cNil{-uppNil-}
140 uppCat (p:ps) = ppBesideSP p (uppCat ps)
142 uppAbove p1 p2 = p1 `cAppend` (cCh '\n') `cAppend` p2
144 uppAboves [] = cNil{-uppNil-}
146 uppAboves (p:ps) = p `cAppend` (cCh '\n') `cAppend` (uppAboves ps)
150 uppSep ps = uppBesides ps