1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1995
%
\section[Unpretty]{Unpretty-printing data type}
\begin{code}
#include "HsVersions.h"
module Unpretty (
Unpretty(..),
PprStyle(..), -- re-exported from Pretty
uppNil, uppStr, uppPStr, uppChar, uppInt, uppInteger, --UNUSED: uppDouble,
uppSP, uppLbrack, uppRbrack, uppLparen, uppRparen, -- UNUSED: upp'SP,
uppSemi, uppComma, uppEquals,
uppCat, uppBeside, uppBesides, uppAbove, uppAboves,
uppNest, uppSep, uppInterleave, uppIntersperse, --UNUSED: uppHang,
uppShow,
#ifdef __GLASGOW_HASKELL__
uppAppendFile,
IF_ATTACK_PRAGMAS(cAppendFile COMMA)
IF_ATTACK_PRAGMAS(cInt COMMA)
#endif
#ifdef DPH
unprettyToStr,
#endif {- Data Parallel Haskell -}
-- abstract type, to complete the interface...
CSeq, GlobalSwitch
) where
import CharSeq
import Outputable
import Pretty ( PprStyle(..), Pretty(..), GlobalSwitch )
import Util
\end{code}
Same interface as @Pretty@, but doesn't do anything.
The pretty type is redefined here:
\begin{code}
type Unpretty = CSeq
\end{code}
%************************************************
%* *
\subsection{The interface}
%* *
%************************************************
\begin{code}
uppNil :: Unpretty
uppSP, uppLbrack, uppRbrack, uppLparen, uppRparen, uppSemi, uppComma, uppEquals :: Unpretty
--UNUSED: upp'SP :: Unpretty
uppStr :: [Char] -> Unpretty
uppPStr :: FAST_STRING -> Unpretty
uppChar :: Char -> Unpretty
uppInt :: Int -> Unpretty
uppInteger :: Integer -> Unpretty
--UNUSED:uppDouble :: Double -> Unpretty
uppBeside :: Unpretty -> Unpretty -> Unpretty
uppBesides :: [Unpretty] -> Unpretty
ppBesideSP :: Unpretty -> Unpretty -> Unpretty
uppCat :: [Unpretty] -> Unpretty -- i.e., ppBesidesSP
uppAbove :: Unpretty -> Unpretty -> Unpretty
uppAboves :: [Unpretty] -> Unpretty
uppInterleave :: Unpretty -> [Unpretty] -> Unpretty
uppIntersperse :: Unpretty -> [Unpretty] -> Unpretty -- no spaces between
uppSep :: [Unpretty] -> Unpretty
--UNUSED:uppHang :: Unpretty -> Int -> Unpretty -> Unpretty
uppNest :: Int -> Unpretty -> Unpretty
uppShow :: Int -> Unpretty -> [Char]
#ifdef __GLASGOW_HASKELL__
uppAppendFile :: _FILE -> Int -> Unpretty -> PrimIO ()
#endif
\end{code}
%************************************************
%* *
\subsection{The representation}
%* *
%************************************************
\begin{code}
uppShow _ p = cShow p
#ifdef __GLASGOW_HASKELL__
uppAppendFile f _ p = cAppendFile f p
#endif
uppNil = cNil
uppStr s = cStr s
uppPStr s = cPStr s
uppChar c = cCh c
uppInt n = cInt n
uppInteger n = cStr (show n)
--UNUSED:uppDouble n = cStr (show n)
uppSP = cCh ' '
--UNUSED:upp'SP = cStr ", "
uppLbrack = cCh '['
uppRbrack = cCh ']'
uppLparen = cCh '('
uppRparen = cCh ')'
uppSemi = cCh ';'
uppComma = cCh ','
uppEquals = cCh '='
uppInterleave sep ps = uppSep (pi ps)
where
pi [] = []
pi [x] = [x]
pi (x:xs) = (cAppend{-uppBeside-} x sep) : pi xs
\end{code}
\begin{code}
uppIntersperse sep ps = uppBesides (pi ps)
where
pi [] = []
pi [x] = [x]
pi (x:xs) = (cAppend{-uppBeside-} x sep) : pi xs
\end{code}
\begin{code}
uppBeside p1 p2 = p1 `cAppend` p2
uppBesides [] = cNil{-uppNil-}
uppBesides [p] = p
uppBesides (p:ps) = p `cAppend`{-uppBeside-} uppBesides ps
\end{code}
\begin{code}
ppBesideSP p1 p2 = p1 `cAppend` (cCh ' ') `cAppend` p2
\end{code}
@uppCat@ is the name I (WDP) happen to have been using for @ppBesidesSP@.
\begin{code}
uppCat [] = cNil{-uppNil-}
uppCat [p] = p
uppCat (p:ps) = ppBesideSP p (uppCat ps)
uppAbove p1 p2 = p1 `cAppend` (cCh '\n') `cAppend` p2
uppAboves [] = cNil{-uppNil-}
uppAboves [p] = p
uppAboves (p:ps) = p `cAppend` (cCh '\n') `cAppend` (uppAboves ps)
uppNest n p = p
\end{code}
\begin{code}
--UNUSED: uppHang p1 n p2 = ppBesideSP p1 p2
uppSep ps = uppBesides ps
\end{code}
\begin{code}
#ifdef DPH
unprettyToStr:: Unpretty -> String
unprettyToStr thing = uppShow 80 thing
#endif {- Data Parallel Haskell -}
\end{code}
|