Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Print.ml
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
(******************************************************************************) (* *) (* Monolith *) (* *) (* François Pottier *) (* *) (* Copyright Inria. All rights reserved. This file is distributed under the *) (* terms of the GNU Lesser General Public License as published by the Free *) (* Software Foundation, either version 3 of the License, or (at your *) (* option) any later version, as described in the file LICENSE. *) (* *) (******************************************************************************) include PPrint type 'a printer = 'a -> document let block doc = nest 2 (break 0 ^^ doc) ^^ break 0 let parens doc = lparen ^^ block doc ^^ rparen let raw_apply docs = group (flow (break 1) docs) let apply doc docs = raw_apply (doc :: docs) let toplevel_let pat body = group ( utf8string "let " ^^ pat ^^ utf8string " =" ^^ nest 2 (break 1 ^^ body) ^^ utf8string ";;" ) let output b doc = ToBuffer.pretty 0.9 78 b (group doc) let unit = !^ "()" let bool = OCaml.bool let exn e = !^ (Printexc.to_string e) let char = OCaml.char let string = OCaml.string let int i = utf8format (if i < 0 then "(%d)" else "%d") i let option f = function | None -> !^ "None" | Some x -> parens (!^ "Some " ^^ f x) let result f1 f2 = function | Ok x -> parens (!^ "Ok " ^^ f1 x) | Error x -> parens (!^ "Error " ^^ f2 x) let pair f1 f2 (x1, x2) = OCaml.tuple [ f1 x1; f2 x2 ] let list = OCaml.flowing_list let array = OCaml.flowing_array let comment doc = group ( break 1 ^^ !^ "(* " ^^ doc ^^ !^ " *)" ) let candidate_finds doc = comment (!^ "candidate finds " ^^ doc) let assert_ doc = apply (!^ "assert") [ parens doc ]