Skip to content
This repository
Newer
Older
100644 78 lines (67 sloc) 2.716 kb
fccc6851 » MLstate
2011-06-21 Initial open-source release
1 (*
2 Copyright © 2011 MLstate
3
6fac5ced » Aqua-Ye
2012-07-09 [cleanup] ocamllib: typo on Opa
4 This file is part of Opa.
fccc6851 » MLstate
2011-06-21 Initial open-source release
5
6fac5ced » Aqua-Ye
2012-07-09 [cleanup] ocamllib: typo on Opa
6 Opa is free software: you can redistribute it and/or modify it under the
fccc6851 » MLstate
2011-06-21 Initial open-source release
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
6fac5ced » Aqua-Ye
2012-07-09 [cleanup] ocamllib: typo on Opa
10 Opa is distributed in the hope that it will be useful, but WITHOUT ANY
fccc6851 » MLstate
2011-06-21 Initial open-source release
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
6fac5ced » Aqua-Ye
2012-07-09 [cleanup] ocamllib: typo on Opa
16 along with Opa. If not, see <http://www.gnu.org/licenses/>.
fccc6851 » MLstate
2011-06-21 Initial open-source release
17 *)
18 (**
19 This module gives you a universal printer
20 that works by runtime introspection of values
21 *)
22
23 type printer = { f : 'a. 'a -> string option }
24 (**
25 A printer is a function that takes anything, checks the runtime
26 representation to see it is knows how to print it and if so,
27 returns the string representation (and it should call DebugPrint
28 to print expressions strictly deeper in the expression)
29 If representation is no the one that the particuliar printer can print
30 then it should return None
31 *)
32
33 val register : printer -> unit
34 (**
35 Define a new printer.
36 Do not give very generic function or else you will screw
37 the printing for everybody
38 *)
39
40 val print : ?depth:int -> 'a -> string
41 (**
42 The main function of this module. Tries to print the value with each
43 of the registered printer, or a default printer if no given printer
44 is suitable
45 *)
46
47 val pp : ?depth:int -> Format.formatter -> 'a -> unit
48 (**
49 Same than [print] but with a format interface
50 *)
51
52 val simple_print : ?depth:int -> 'a -> string
53 (**
54 A variant of [print] attempting to be easier to read on simple values,
55 although possibly harder on complex values.
56 *)
57
58 (** {6 Helpers for defining printing functions} *)
59 val true_ : Obj.t -> bool
60 val false_ : Obj.t -> bool
61 val bool : Obj.t -> bool
62 val string : Obj.t -> bool
63 val option : ?a:(Obj.t -> bool) -> Obj.t -> bool
64
65 (**
66 BEWARE: doesn't work for float arrays
67 The optional tag argument is set to 0 (the array tag).
68 It is possible to customize array tags.
69 *)
70 val array : ?tag:int -> ?a:(Obj.t -> bool) -> Obj.t -> bool
71 val unit : Obj.t -> bool
72 val int : ?plus:(int -> bool) -> Obj.t -> bool
73 val tuple0 : Obj.t -> bool
74 val tuple1 : ?f1:(Obj.t -> bool) -> Obj.t -> bool
75 val tuple2 : ?f1:(Obj.t -> bool) -> ?f2:(Obj.t -> bool) -> Obj.t -> bool
76 val tuple3 : ?f1:(Obj.t -> bool) -> ?f2:(Obj.t -> bool) -> ?f3:(Obj.t -> bool) -> Obj.t -> bool
77 val tuple4 : ?f1:(Obj.t -> bool) -> ?f2:(Obj.t -> bool) -> ?f3:(Obj.t -> bool) -> ?f4:(Obj.t -> bool) -> Obj.t -> bool
78 val tuple_n : (Obj.t -> bool) list -> Obj.t -> bool
Something went wrong with that request. Please try again.