Import Upstream version 20180207
[hcoop/debian/mlton.git] / lib / mlton / basic / trace.sig
1 (* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
2 * Jagannathan, and Stephen Weeks.
3 *
4 * MLton is released under a BSD-style license.
5 * See the file MLton-LICENSE for details.
6 *)
7
8 signature TRACE_CONTROL =
9 sig
10 (* controls what tracing info is gathered *)
11 val always: unit -> unit (* always gather info *)
12 val flagged: unit -> unit (* only on flagged functions *)
13 val never: unit -> unit (* never gather info *)
14
15 (* value of newly created flag *)
16 val default: bool ref
17
18 (* turn on/off tracing for given functions *)
19 val on: string list -> unit
20 val off: string list -> unit
21
22 (* turn on/off tracing for all functions *)
23 val all: unit -> unit
24 val none: unit -> unit
25
26 (* returns functions that are on/off *)
27 val whatsOn: unit -> string list
28 val whatsOff: unit -> string list
29 end
30
31 signature TRACE =
32 sig
33 structure Immediate:
34 sig
35 include TRACE_CONTROL
36
37 datatype debug =
38 None
39 | Terminal
40 | Out of Out.t
41
42 (*
43 * If !debug = Terminal, debugging messages are printed to /dev/tty.
44 * If !debug = Out os, then messages will be sent to os.
45 * If !debug = None, then messages will be ignored.
46 *)
47 val debug: debug ref
48 val message: Layout.t -> unit
49 val messageStr: string -> unit
50 (* inChildProcess is called by Process so that trace will know if it
51 * is in a child, and therefore it will prefix all messages with the
52 * pid of the current process.
53 *)
54 val inChildProcess: unit -> unit
55 (* !showTime = true iff messages are preceded by the current time *)
56 val showTime: bool ref
57 end
58 structure Delayed:
59 sig
60 include TRACE_CONTROL
61 val keepAll: bool ref
62 end
63 structure Time: TRACE_CONTROL
64
65 val never: unit -> unit
66 val always: unit -> unit
67 val flagged: unit -> unit
68 val traceable: unit -> string list
69 val outputTraceable: unit -> unit
70 val reset: unit -> unit
71
72 (*---------- Delayed Feedback ----------*)
73 structure Computation: COMPUTATION
74
75 (* clear computation history *)
76 val clear: unit -> unit
77
78 (* get computation history *)
79 val computation: unit -> Computation.t
80
81 (* show computation history *)
82 val history: unit -> unit
83
84 (* show computation history, without arguments or results *)
85 val calls: unit -> unit
86
87 val times: unit -> unit
88
89 (* enter the inspector *)
90 val inspect: unit -> unit
91
92 (*---------- Instrumentation ----------*)
93
94 val traceCall: string -> ('a -> 'b) -> 'a -> 'b
95
96 type info
97 val info: string -> info
98
99 val traceInfo:
100 info
101 * ('a -> Layout.t)
102 * ('b -> Layout.t)
103 * ('a -> bool * ('b -> bool))
104 -> ('a -> 'b)
105 -> ('a -> 'b)
106
107 val traceInfo':
108 info
109 * ('a -> Layout.t)
110 * ('b -> Layout.t)
111 -> ('a -> 'b)
112 -> ('a -> 'b)
113
114 (* type ('a, 'b) check = ('a -> Layout.t) * ('a -> bool * 'b)
115 *
116 * type ('a, 'b) z =
117 * 'a -> ((unit -> Layout.t)
118 * * (unit -> bool)
119 * * 'a
120 * * 'b)
121 *
122 * val traceInfo:
123 * info
124 * * ('a, ('b, unit) check) check
125 * -> ('a -> 'b)
126 * -> 'a
127 * -> 'b
128 *)
129
130 val assertTrue: 'a -> (bool * ('b -> bool))
131
132 val traceAssert:
133 string
134 * ('a -> Layout.t)
135 * ('b -> Layout.t)
136 * ('a -> bool * ('b -> bool))
137 -> ('a -> 'b)
138 -> ('a -> 'b)
139
140 val trace:
141 string
142 * ('a -> Layout.t)
143 * ('b -> Layout.t)
144 -> ('a -> 'b)
145 -> ('a -> 'b)
146
147 val trace0:
148 string
149 * ('a -> Layout.t)
150 -> (unit -> 'a)
151 -> (unit -> 'a)
152
153 val trace2:
154 string
155 * ('a -> Layout.t)
156 * ('b -> Layout.t)
157 * ('c -> Layout.t)
158 -> ('a * 'b -> 'c)
159 -> ('a * 'b -> 'c)
160
161 val trace3:
162 string
163 * ('a -> Layout.t)
164 * ('b -> Layout.t)
165 * ('c -> Layout.t)
166 * ('d -> Layout.t)
167 -> ('a * 'b * 'c -> 'd)
168 -> ('a * 'b * 'c -> 'd)
169
170 val trace4:
171 string
172 * ('a -> Layout.t)
173 * ('b -> Layout.t)
174 * ('c -> Layout.t)
175 * ('d -> Layout.t)
176 * ('e -> Layout.t)
177 -> ('a * 'b * 'c * 'd -> 'e)
178 -> ('a * 'b * 'c * 'd -> 'e)
179
180 val trace5:
181 string
182 * ('a -> Layout.t)
183 * ('b -> Layout.t)
184 * ('c -> Layout.t)
185 * ('d -> Layout.t)
186 * ('e -> Layout.t)
187 * ('f -> Layout.t)
188 -> ('a * 'b * 'c * 'd * 'e -> 'f)
189 -> ('a * 'b * 'c * 'd * 'e -> 'f)
190
191 val traceRec:
192 string
193 * ('a -> Layout.t)
194 * ('b -> Layout.t)
195 -> (('a -> 'b) -> ('a -> 'b))
196 -> 'a -> 'b
197 end