| 1 |
(************************************************************************) |
| 2 |
(* * The Rocq Prover / The Rocq Development Team *) |
| 3 |
(* v * Copyright INRIA, CNRS and contributors *) |
| 4 |
(* <O___,, * (see version control and CREDITS file for authors & dates) *) |
| 5 |
(* \VV/ **************************************************************) |
| 6 |
(* // * This file is distributed under the terms of the *) |
| 7 |
(* * GNU Lesser General Public License Version 2.1 *) |
| 8 |
(* * (see LICENSE file for the text of the license) *) |
| 9 |
(************************************************************************) |
| 10 |
|
| 11 |
Require Import Ltac2.Init. |
| 12 |
|
| 13 |
Ltac2 @ external print : message -> unit := "rocq-runtime.plugins.ltac2" "print". |
| 14 |
|
| 15 |
Ltac2 @ external empty : message := "rocq-runtime.plugins.ltac2" "message_empty". |
| 16 |
|
| 17 |
Ltac2 @ external of_string : string -> message := "rocq-runtime.plugins.ltac2" "message_of_string". |
| 18 |
|
| 19 |
Ltac2 @ external to_string : message -> string := "rocq-runtime.plugins.ltac2" "message_to_string". |
| 20 |
|
| 21 |
Ltac2 @ external of_int : int -> message := "rocq-runtime.plugins.ltac2" "message_of_int". |
| 22 |
|
| 23 |
Ltac2 @ external of_ident : ident -> message := "rocq-runtime.plugins.ltac2" "message_of_ident". |
| 24 |
|
| 25 |
Ltac2 @ external of_constr : constr -> message := "rocq-runtime.plugins.ltac2" "message_of_constr". |
| 26 |
(** Prints at level 8 (surrounding with parentheses to print syntax |
| 27 |
above that level such as applications). |
| 28 |
Panics if there is more than one goal under focus. *) |
| 29 |
|
| 30 |
Ltac2 @ external of_lconstr : constr -> message := "rocq-runtime.plugins.ltac2" "message_of_lconstr". |
| 31 |
(** Prints at level 200 (no surrounding parentheses). |
| 32 |
Panics if there is more than one goal under focus. *) |
| 33 |
|
| 34 |
Ltac2 @external of_preterm : preterm -> message := "rocq-runtime.plugins.ltac2" "message_of_preterm". |
| 35 |
(** Prints at level 8. Panics if there is more than one goal under focus. *) |
| 36 |
|
| 37 |
Ltac2 @external of_lpreterm : preterm -> message := "rocq-runtime.plugins.ltac2" "message_of_lpreterm". |
| 38 |
(** Prints at level 200. Panics if there is more than one goal under focus. *) |
| 39 |
|
| 40 |
Ltac2 @ external of_exn : exn -> message := "rocq-runtime.plugins.ltac2" "message_of_exn". |
| 41 |
(** Panics if there is more than one goal under focus. *) |
| 42 |
|
| 43 |
Ltac2 @external of_exninfo : exninfo -> message := "rocq-runtime.plugins.ltac2" "message_of_exninfo". |
| 44 |
(** Print the (Ltac2 and OCaml) backtrace info if it was recorded. *) |
| 45 |
|
| 46 |
Ltac2 @ external concat : message -> message -> message := "rocq-runtime.plugins.ltac2" "message_concat". |
| 47 |
|
| 48 |
(** Boxing primitives. They are translated to OCaml "Format" boxes, |
| 49 |
see https://ocaml.org/docs/formatting-text **) |
| 50 |
|
| 51 |
Ltac2 @external force_new_line : message := "rocq-runtime.plugins.ltac2" "message_force_new_line". |
| 52 |
(** Force writing on a new line after this. |
| 53 |
Warning: partially reinitialises the pretty-printing engine, |
| 54 |
potentially leading to bad printing afterwards. |
| 55 |
Prefer using a break hint inside a vertical box. *) |
| 56 |
|
| 57 |
Ltac2 @external break : int -> int -> message := "rocq-runtime.plugins.ltac2" "message_break". |
| 58 |
(** General break hint: [break n i] either prints [n] spaces or splits |
| 59 |
the line adding [i] to the current indentation. *) |
| 60 |
|
| 61 |
Ltac2 @external space : message := "rocq-runtime.plugins.ltac2" "message_space". |
| 62 |
(** Breaking space. Equivalent to [break 1 0]. *) |
| 63 |
|
| 64 |
Ltac2 @external hbox : message -> message := "rocq-runtime.plugins.ltac2" "message_hbox". |
| 65 |
(** Horizontal box. Break hints in a horizontal box never split the |
| 66 |
line (nested boxes inside the horizontal box may allow line |
| 67 |
splitting). *) |
| 68 |
|
| 69 |
Ltac2 @external vbox : int -> message -> message := "rocq-runtime.plugins.ltac2" "message_vbox". |
| 70 |
(** Vertical box. Every break hint in a vertical box splits the line. |
| 71 |
The [int] is added to the current indentation when splitting the line. *) |
| 72 |
|
| 73 |
Ltac2 @external hvbox : int -> message -> message := "rocq-runtime.plugins.ltac2" "message_hvbox". |
| 74 |
(** Horizontal/vertical box. Behaves as a horizontal box if it fits on |
| 75 |
a single line, otherwise behaves as a vertical box (using the |
| 76 |
given [int]). *) |
| 77 |
|
| 78 |
Ltac2 @external hovbox : int -> message -> message := "rocq-runtime.plugins.ltac2" "message_hovbox". |
| 79 |
(** Horizonal-or-vertical box. Prints as much as possible on each |
| 80 |
line, splitting the line at break hints when there is no more room |
| 81 |
on the line (see "Printing Width" option). The [int] is added to |
| 82 |
the indentation when splitting the line. *) |
| 83 |
|
| 84 |
Module Format. |
| 85 |
|
| 86 |
(** Only for internal use. *) |
| 87 |
|
| 88 |
Ltac2 @ external stop : ('a, 'b, 'c, 'a) format := "rocq-runtime.plugins.ltac2" "format_stop". |
| 89 |
|
| 90 |
Ltac2 @ external string : ('a, 'b, 'c, 'd) format -> |
| 91 |
(string -> 'a, 'b, 'c, 'd) format := "rocq-runtime.plugins.ltac2" "format_string". |
| 92 |
|
| 93 |
Ltac2 @ external int : ('a, 'b, 'c, 'd) format -> |
| 94 |
(int -> 'a, 'b, 'c, 'd) format := "rocq-runtime.plugins.ltac2" "format_int". |
| 95 |
|
| 96 |
Ltac2 @ external constr : ('a, 'b, 'c, 'd) format -> |
| 97 |
(constr -> 'a, 'b, 'c, 'd) format := "rocq-runtime.plugins.ltac2" "format_constr". |
| 98 |
|
| 99 |
Ltac2 @ external ident : ('a, 'b, 'c, 'd) format -> |
| 100 |
(ident -> 'a, 'b, 'c, 'd) format := "rocq-runtime.plugins.ltac2" "format_ident". |
| 101 |
|
| 102 |
Ltac2 @ external message : ('a, 'b, 'c, 'd) format -> |
| 103 |
(message -> 'a, 'b, 'c, 'd) format := "rocq-runtime.plugins.ltac2" "format_message". |
| 104 |
|
| 105 |
Ltac2 @ external literal : string -> ('a, 'b, 'c, 'd) format -> |
| 106 |
('a, 'b, 'c, 'd) format := "rocq-runtime.plugins.ltac2" "format_literal". |
| 107 |
|
| 108 |
Ltac2 @ external alpha : ('a, 'b, 'c, 'd) format -> |
| 109 |
(('b -> 'r -> 'c) -> 'r -> 'a, 'b, 'c, 'd) format := "rocq-runtime.plugins.ltac2" "format_alpha". |
| 110 |
|
| 111 |
Ltac2 @ external alpha0 : ('a, 'b, 'c, 'd) format -> |
| 112 |
(('r -> 'c) -> 'r -> 'a, 'b, 'c, 'd) format := "rocq-runtime.plugins.ltac2" "format_alpha0". |
| 113 |
|
| 114 |
Ltac2 @ external kfprintf : (message -> 'r) -> ('a, unit, message, 'r) format -> 'a := |
| 115 |
"rocq-runtime.plugins.ltac2" "format_kfprintf". |
| 116 |
|
| 117 |
Ltac2 @ external ikfprintf : ('v -> 'r) -> 'v -> ('a, unit, 'v, 'r) format -> 'a := |
| 118 |
"rocq-runtime.plugins.ltac2" "format_ikfprintf". |
| 119 |
|
| 120 |
End Format. |