7 | --------------------------------------------------------------------------------
8 | -- Symbols
9 | --------------------------------------------------------------------------------
11 | ||| Creates a single-line document from the given character.
12 | |||
13 | ||| @c A printable non-control character.
18 | ||| A single space character.
19 | export
23 | export
27 | export
31 | export
35 | export
39 | export
43 | export
47 | export
51 | export
55 | export
59 | export
63 | export
67 | export
71 | export
75 | export
79 | export
83 | export
87 | export
91 | export
95 | --------------------------------------------------------------------------------
96 | -- Enclosing Documents
97 | --------------------------------------------------------------------------------
99 | ||| Encloses the document between two other documents using `(<+>)`.
100 | export
104 | ||| Encolses a document in single quotes.
105 | export
109 | ||| Encolses a document in double quotes.
110 | export
114 | ||| Encolses a document in parentheses.
115 | export
119 | ||| Encolses a document in parentheses if `b` equals `True`.
120 | export
124 | ||| Encolses a document in angles (`<` and `>`).
125 | export
129 | ||| Encolses a document in curly braces.
130 | export
134 | ||| Encolses a document in brackets.
135 | export
139 | --------------------------------------------------------------------------------
140 | -- Combining Documents
141 | --------------------------------------------------------------------------------
143 | ||| Tries to layout the first document on a single line, replacing
144 | ||| it with the alternative if a) it does not fit the page with or b)
145 | ||| it inherently is placed on several lines.
146 | |||
147 | ||| This combinator is very useful for pretty printing Idris values
148 | ||| (data constructors, lists, records), because we typically try to
149 | ||| place them on a single line if and only if they fit the page width
150 | ||| and none of their arguments is placed on several lines.
151 | export
159 | ||| Concatenates two documents horizontally with a single space between them.
166 | ||| Concatenates two documents horizontally with a space between them, if both
167 | ||| documents are not empty.
177 | export
181 | ||| Concatenate a sequence of documents horizontally using `(<+>)`.
182 | export
187 | ||| Concatenate a sequence of documents horizontally using `(<++>)`.
188 | export
193 | ||| Concatenate a list of documents vertically.
194 | export
199 | ||| Tries to layout the two documents horizontally, but appends
200 | ||| the second indented by the given number of spaces below the
201 | ||| first if the horizontal version exceeds the width limit.
202 | export
206 | ||| Like `hang` but separates the two documents by a space in case of
207 | ||| a horizontal alignment.
208 | export
212 | ||| Tries to layout the two documents horizontally, but appends
213 | ||| the second indented by the given number of spaces below the
214 | ||| first if the horizontal version exceeds the width limit, or
215 | ||| if needs several lines.
216 | export
220 | ||| Like `hang'` but separates the two documents by a space in case of
221 | ||| a horizontal alignment.
222 | export
226 | ||| Tries to separate the given documents horizontally, but
227 | ||| concatenates them vertically if the horizontal layout exceeds the
228 | ||| width limit.
229 | export
233 | ||| Tries to separate the given documents horizontally, but
234 | ||| concatenates them vertically if the horizontal layout exceeds the
235 | ||| width limit, or horizontal layout leads to a multiline document.
236 | export
240 | ||| Add the given document only when condition is true
241 | export
246 | --------------------------------------------------------------------------------
247 | -- Lists of Documents
248 | --------------------------------------------------------------------------------
250 | ||| Pretty prints a list of documents separated by the given delimiter
251 | ||| and wrapping them in opening and closing symbols.
252 | |||
253 | ||| If it fits the page width, the document is layed out horizontally,
254 | ||| otherwise it's layed out vertically with leading commas.
255 | |||
256 | ||| Horizontal layout for `generalList "[" "]" "," [1,2,3]:
257 | |||
258 | ||| ```
259 | ||| [1, 2, 3]
260 | ||| ```
261 | |||
262 | ||| Vertical layout:
263 | |||
264 | ||| ```
265 | ||| [ 1
266 | ||| , 2
267 | ||| , 3
268 | ||| ]
269 | ||| ```
270 | export
277 | ||| Pretty prints a list of documents separated by commas
278 | ||| and wrapping them in brackets.
279 | |||
280 | ||| If it fits the page width, the document is layed out horizontally,
281 | ||| otherwise it's layed out vertically with leading delimiters.
282 | |||
283 | ||| Horizontal layout:
284 | |||
285 | ||| ```
286 | ||| [1, 2, 3]
287 | ||| ```
288 | |||
289 | ||| Vertical layout:
290 | |||
291 | ||| ```
292 | ||| [ 1
293 | ||| , 2
294 | ||| , 3
295 | ||| ]
296 | ||| ```
301 | ||| Pretty prints a `SnocList` of documents separated by commas
302 | ||| and wrapping them in brackets.
303 | |||
304 | ||| If it fits the page width, the document is layed out horizontally,
305 | ||| otherwise it's layed out vertically with leading commas.
306 | |||
307 | ||| Horizontal layout:
308 | |||
309 | ||| ```
310 | ||| [<1, 2, 3]
311 | ||| ```
312 | |||
313 | ||| Vertical layout:
314 | |||
315 | ||| ```
316 | ||| [<1
317 | ||| , 2
318 | ||| , 3
319 | ||| ]
320 | ||| ```
321 | export
325 | ||| Pretty prints a list of documents separated by commas
326 | ||| and wrapping them in parentheses.
327 | |||
328 | ||| Horizontal layout:
329 | |||
330 | ||| ```
331 | ||| (x, y, z)
332 | ||| ```
333 | |||
334 | ||| Vertical layout:
335 | |||
336 | ||| ```
337 | ||| ( x
338 | ||| , y
339 | ||| , z
340 | ||| )
341 | ||| ]
342 | export
346 | ||| Pretty prints a list of documents separated by commas
347 | ||| and wrapping them in curly braces.
348 | |||
349 | ||| Horizontal layout:
350 | |||
351 | ||| ```
352 | ||| {x, y, z}
353 | ||| ```
354 | |||
355 | ||| Vertical layout:
356 | |||
357 | ||| ```
358 | ||| { x
359 | ||| , y
360 | ||| , z
361 | ||| }
362 | ||| ]
363 | export