File: PPrintTest.ml

package info (click to toggle)
ocaml-pprint 20220103-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 324 kB
  • sloc: ml: 1,705; makefile: 140
file content (62 lines) | stat: -rw-r--r-- 2,027 bytes parent folder | download | duplicates (2)
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
(**************************************************************************)
(*                                                                        *)
(*  PPrint                                                                *)
(*                                                                        *)
(*  François Pottier, Inria Paris                                         *)
(*  Nicolas Pouillard                                                     *)
(*                                                                        *)
(*  Copyright 2007-2019 Inria. All rights reserved. This file is          *)
(*  distributed under the terms of the GNU Library General Public         *)
(*  License, with an exception, as described in the file LICENSE.         *)
(**************************************************************************)

open PPrint

(* This is a test file. It is not, strictly speaking, part of the library. *)

let paragraph (s : string) =
  flow (break 1) (words s)

let document =
  prefix 2 1
    (string "TITLE:")
    (string "PPrint")
  ^^
  hardline
  ^^
  prefix 2 1
    (string "AUTHORS:")
    (utf8string "François Pottier and Nicolas Pouillard")
  ^^
  hardline
  ^^
  prefix 2 1
    (string "ABSTRACT:")
    (
      paragraph "This is an adaptation of Daan Leijen's \"PPrint\" library,
        which itself is based on the ideas developed by Philip Wadler in
        \"A Prettier Printer\". For more information about Wadler's and Leijen's work,
        please consult the following reference:"
      ^^
      nest 2 (
	twice (break 1)
	^^
	separate_map (break 1) (fun s -> nest 2 (url s)) [
	  "http://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf";
	]
      )
      ^^
      twice (break 1)
      ^^
      paragraph "To install PPrint, type \"opam install pprint\"."
      ^^
      twice (break 1)
      ^^
      paragraph "The documentation for PPrint is built by \"make doc\"."
    )
  ^^
  hardline

let () =
  ToChannel.pretty 0.5 80 stdout document;
  flush stdout