Release coccinelle-0.2.5-rc2
[bpt/coccinelle.git] / commons / common.mli
CommitLineData
34e49164
C
1(*###########################################################################*)
2(* Globals *)
3(*###########################################################################*)
4
5(* Some conventions:
6 *
ae4735db
C
7 * When I have some _xxx variables before some functions, it's
8 * because I want to show that those functions internally use a global
34e49164
C
9 * variable. That does not mean I want people to modify this global.
10 * In fact they are kind of private, but I still want to show them.
11 * Maybe one day OCaml will have an effect type system so I don't need this.
ae4735db
C
12 *
13 * The variables that are called _init_xxx show the internal init
34e49164 14 * side effect of the module (like static var trick used in C/C++)
ae4735db 15 *
34e49164 16 * Why not split the functionnalities of this file in different files ?
ae4735db 17 * Because when I write ocaml script I want simply to load one
34e49164
C
18 * file, common.ml, and that's it. Cf common_extra.ml for more on this.
19 *)
20
21
22(*****************************************************************************)
23(* Flags *)
24(*****************************************************************************)
ae4735db 25(* see the corresponding section for the use of those flags. See also
34e49164
C
26 * the "Flags and actions" section at the end of this file.
27 *)
28
29(* if set then will not do certain finalize so faster to go back in replay *)
30val debugger : bool ref
31
32type prof = PALL | PNONE | PSOME of string list
33val profile : prof ref
485bce71
C
34val show_trace_profile : bool ref
35
34e49164
C
36
37val verbose_level : int ref
38
39(* forbid pr2_once to do the once "optimisation" *)
40val disable_pr2_once : bool ref
41
42
43
44(* works with new_temp_file *)
45val save_tmp_files : bool ref
46
47
48
49(*****************************************************************************)
50(* Module side effect *)
51(*****************************************************************************)
ae4735db 52(*
34e49164
C
53 * I define a few unit tests via some let _ = example (... = ...).
54 * I also initialize the random seed, cf _init_random .
55 * I also set Gc.stack_size, cf _init_gc_stack .
56*)
57
58(*****************************************************************************)
59(* Semi globals *)
60(*****************************************************************************)
61(* cf the _xxx variables in this file *)
62
63(*###########################################################################*)
64(* Basic features *)
65(*###########################################################################*)
66
67type filename = string
485bce71 68type dirname = string
34e49164
C
69
70(* Trick in case you dont want to do an 'open Common' while still wanting
71 * more pervasive types than the one in Pervasives. Just do the selective
72 * open Common.BasicType.
73 *)
74module BasicType : sig
75 type filename = string
76end
77
78(* Same spirit. Trick found in Jane Street core lib, but originated somewhere
79 * else I think: the ability to open nested modules. *)
80module Infix : sig
81 val ( +> ) : 'a -> ('a -> 'b) -> 'b
82 val ( =~ ) : string -> string -> bool
83 val ( ==~ ) : string -> Str.regexp -> bool
84end
85
86
87(*
88 * Another related trick, found via Jon Harrop to have an extended standard
89 * lib is to do something like
ae4735db 90 *
34e49164
C
91 * module List = struct
92 * include List
93 * val map2 : ...
94 * end
ae4735db 95 *
34e49164
C
96 * And then can put this "module extension" somewhere to open it.
97 *)
98
99
100
ae4735db
C
101(* This module defines the Timeout and UnixExit exceptions.
102 * You have to make sure that those exn are not intercepted. So
34e49164 103 * avoid exn handler such as try (...) with _ -> cos Timeout will not bubble up
ae4735db
C
104 * enough. In such case, add a case before such as
105 * with Timeout -> raise Timeout | _ -> ...
34e49164
C
106 * The same is true for UnixExit (see below).
107 *)
108
109(*****************************************************************************)
110(* Debugging/logging *)
111(*****************************************************************************)
112
113val _tab_level_print: int ref
114val indent_do : (unit -> 'a) -> 'a
115val reset_pr_indent : unit -> unit
116
117(* The following functions first indent _tab_level_print spaces.
118 * They also add the _prefix_pr, for instance used in MPI to show which
119 * worker is talking.
708f4980 120 * update: for pr2, it can also print into a log file.
ae4735db 121 *
34e49164 122 * The use of 2 in pr2 is because 2 is under UNIX the second descriptor
ae4735db 123 * which corresponds to stderr.
34e49164
C
124 *)
125val _prefix_pr : string ref
708f4980 126
34e49164 127val pr : string -> unit
34e49164 128val pr_no_nl : string -> unit
34e49164 129val pr_xxxxxxxxxxxxxxxxx : unit -> unit
708f4980
C
130
131(* pr2 print on stderr, but can also in addition print into a file *)
132val _chan_pr2: out_channel option ref
ae4735db 133val print_to_stderr : bool ref
708f4980
C
134val pr2 : string -> unit
135val pr2_no_nl : string -> unit
34e49164
C
136val pr2_xxxxxxxxxxxxxxxxx : unit -> unit
137
138(* use Dumper.dump *)
139val pr2_gen: 'a -> unit
140val dump: 'a -> string
141
142(* see flag: val disable_pr2_once : bool ref *)
143val _already_printed : (string, bool) Hashtbl.t
144val pr2_once : string -> unit
3a314143 145val clear_pr2_once : unit -> unit
34e49164 146
708f4980
C
147val mk_pr2_wrappers: bool ref -> (string -> unit) * (string -> unit)
148
149
978fd7e5 150val redirect_stdout_opt : filename option -> (unit -> 'a) -> 'a
34e49164 151val redirect_stdout_stderr : filename -> (unit -> unit) -> unit
3a314143
C
152val redirect_stdin : filename -> (unit -> 'a) -> 'a
153val redirect_stdin_opt : filename option -> (unit -> 'a) -> 'a
34e49164 154
708f4980
C
155val with_pr2_to_string: (unit -> unit) -> string list
156
34e49164
C
157val fprintf : out_channel -> ('a, out_channel, unit) format -> 'a
158val printf : ('a, out_channel, unit) format -> 'a
159val eprintf : ('a, out_channel, unit) format -> 'a
160val sprintf : ('a, unit, string) format -> 'a
161
162(* alias *)
163val spf : ('a, unit, string) format -> 'a
164
165(* default = stderr *)
ae4735db 166val _chan : out_channel ref
34e49164 167(* generate & use a /tmp/debugml-xxx file *)
ae4735db 168val start_log_file : unit -> unit
34e49164
C
169
170(* see flag: val verbose_level : int ref *)
171val log : string -> unit
172val log2 : string -> unit
173val log3 : string -> unit
174val log4 : string -> unit
175
176val if_log : (unit -> unit) -> unit
177val if_log2 : (unit -> unit) -> unit
178val if_log3 : (unit -> unit) -> unit
179val if_log4 : (unit -> unit) -> unit
180
181val pause : unit -> unit
182
183(* was used by fix_caml *)
184val _trace_var : int ref
185val add_var : unit -> unit
186val dec_var : unit -> unit
187val get_var : unit -> int
188
189val print_n : int -> string -> unit
190val printerr_n : int -> string -> unit
191
192val _debug : bool ref
193val debugon : unit -> unit
194val debugoff : unit -> unit
195val debug : (unit -> unit) -> unit
196
197(* see flag: val debugger : bool ref *)
198
199
200(*****************************************************************************)
201(* Profiling (cpu/mem) *)
202(*****************************************************************************)
203
204val get_mem : unit -> unit
205val memory_stat : unit -> string
206
207val timenow : unit -> string
208
209val _count1 : int ref
210val _count2 : int ref
211val _count3 : int ref
212val _count4 : int ref
213val _count5 : int ref
214
215val count1 : unit -> unit
216val count2 : unit -> unit
217val count3 : unit -> unit
218val count4 : unit -> unit
219val count5 : unit -> unit
220val profile_diagnostic_basic : unit -> string
221
222val time_func : (unit -> 'a) -> 'a
223
224
225
226(* see flag: type prof = PALL | PNONE | PSOME of string list *)
227(* see flag: val profile : prof ref *)
228
229val _profile_table : (string, (float ref * int ref)) Hashtbl.t ref
230val profile_code : string -> (unit -> 'a) -> 'a
231val profile_diagnostic : unit -> string
232
485bce71
C
233val profile_code_exclusif : string -> (unit -> 'a) -> 'a
234val profile_code_inside_exclusif_ok : string -> (unit -> 'a) -> 'a
235
34e49164
C
236val report_if_take_time : int -> string -> (unit -> 'a) -> 'a
237
238(* similar to profile_code but print some information during execution too *)
239val profile_code2 : string -> (unit -> 'a) -> 'a
240
241(*****************************************************************************)
242(* Test *)
243(*****************************************************************************)
244
245val example : bool -> unit
246(* generate failwith <string> when pb *)
ae4735db 247val example2 : string -> bool -> unit
34e49164 248(* use Dumper to report when pb *)
ae4735db 249val assert_equal : 'a -> 'a -> unit
34e49164
C
250
251val _list_bool : (string * bool) list ref
252val example3 : string -> bool -> unit
253val test_all : unit -> unit
254
b1b2de81 255
34e49164 256(* regression testing *)
ae4735db 257type score_result = Ok | Pb of string
b1b2de81
C
258type score = (string (* usually a filename *), score_result) Hashtbl.t
259type score_list = (string (* usually a filename *) * score_result) list
34e49164 260val empty_score : unit -> score
ae4735db 261val regression_testing :
34e49164 262 score -> filename (* old score file on disk (usually in /tmp) *) -> unit
b1b2de81
C
263val regression_testing_vs: score -> score -> score
264val total_scores : score -> int (* good *) * int (* total *)
34e49164 265val print_score : score -> unit
b1b2de81 266val print_total_score: score -> unit
34e49164
C
267
268
269(* quickcheck spirit *)
270type 'a gen = unit -> 'a
271
272(* quickcheck random generators *)
273val ig : int gen
274val lg : 'a gen -> 'a list gen
275val pg : 'a gen -> 'b gen -> ('a * 'b) gen
276val polyg : int gen
277val ng : string gen
278
279val oneofl : 'a list -> 'a gen
280val oneof : 'a gen list -> 'a gen
281val always : 'a -> 'a gen
282val frequency : (int * 'a gen) list -> 'a gen
283val frequencyl : (int * 'a) list -> 'a gen
284
285val laws : string -> ('a -> bool) -> 'a gen -> 'a option
286
ae4735db 287(* example of use:
34e49164
C
288 * let b = laws "unit" (fun x -> reverse [x] = [x]) ig
289 *)
290
291val statistic_number : 'a list -> (int * 'a) list
292val statistic : 'a list -> (int * 'a) list
293
294val laws2 :
295 string -> ('a -> bool * 'b) -> 'a gen -> 'a option * (int * 'b) list
296
297(*****************************************************************************)
298(* Persistence *)
299(*****************************************************************************)
300
0708f913 301(* just wrappers around Marshal *)
34e49164 302val get_value : filename -> 'a
485bce71 303val read_value : filename -> 'a (* alias *)
34e49164
C
304val write_value : 'a -> filename -> unit
305val write_back : ('a -> 'b) -> filename -> unit
306
0708f913
C
307(* wrappers that also use profile_code *)
308val marshal__to_string: 'a -> Marshal.extern_flags list -> string
309val marshal__from_string: string -> int -> 'a
310
34e49164
C
311(*****************************************************************************)
312(* Counter *)
313(*****************************************************************************)
314val _counter : int ref
315val _counter2 : int ref
316val _counter3 : int ref
317
318val counter : unit -> int
319val counter2 : unit -> int
320val counter3 : unit -> int
321
322type timestamp = int
323
324(*****************************************************************************)
325(* String_of and (pretty) printing *)
326(*****************************************************************************)
327
328val string_of_string : (string -> string) -> string
329val string_of_list : ('a -> string) -> 'a list -> string
330val string_of_unit : unit -> string
331val string_of_array : ('a -> string) -> 'a array -> string
332val string_of_option : ('a -> string) -> 'a option -> string
333
334val print_bool : bool -> unit
335val print_option : ('a -> 'b) -> 'a option -> unit
336val print_list : ('a -> 'b) -> 'a list -> unit
337val print_between : (unit -> unit) -> ('a -> unit) -> 'a list -> unit
338
339(* use Format internally *)
340val pp_do_in_box : (unit -> unit) -> unit
341val pp_f_in_box : (unit -> 'a) -> 'a
342val pp_do_in_zero_box : (unit -> unit) -> unit
343val pp : string -> unit
344
345(* convert something printed using Format to print into a string *)
346val format_to_string : (unit -> unit) (* printer *) -> string
347
348(* works with _tab_level_print enabling to mix some calls to pp, pr2
349 * and indent_do to sometimes use advanced indentation pretty printing
350 * (with the pp* functions) and sometimes explicit and simple indendation
351 * printing (with pr* and indent_do) *)
352val adjust_pp_with_indent : (unit -> unit) -> unit
353val adjust_pp_with_indent_and_header : string -> (unit -> unit) -> unit
354
0708f913 355
ae4735db 356val mk_str_func_of_assoc_conv:
0708f913
C
357 ('a * string) list -> (string -> 'a) * ('a -> string)
358
34e49164
C
359(*****************************************************************************)
360(* Macro *)
361(*****************************************************************************)
362
363(* was working with my macro.ml4 *)
364val macro_expand : string -> unit
365
366(*****************************************************************************)
367(* Composition/Control *)
368(*****************************************************************************)
369
370val ( +> ) : 'a -> ('a -> 'b) -> 'b
371val ( +!> ) : 'a ref -> ('a -> 'a) -> unit
372val ( $ ) : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c
373
374val compose : ('a -> 'b) -> ('c -> 'a) -> 'c -> 'b
375val flip : ('a -> 'b -> 'c) -> 'b -> 'a -> 'c
376
377val curry : ('a * 'b -> 'c) -> 'a -> 'b -> 'c
378val uncurry : ('a -> 'b -> 'c) -> 'a * 'b -> 'c
379
380val id : 'a -> 'a
381val do_nothing : unit -> unit
382
383val forever : (unit -> unit) -> unit
384
385val applyn : int -> ('a -> 'a) -> 'a -> 'a
386
387class ['a] shared_variable_hook :
388 'a ->
389 object
390 val mutable data : 'a
391 val mutable registered : (unit -> unit) list
392 method get : 'a
393 method modify : ('a -> 'a) -> unit
394 method register : (unit -> unit) -> unit
395 method set : 'a -> unit
396 end
397
398val fixpoint : ('a -> 'a) -> 'a -> 'a
399val fixpoint_for_object : ((< equal : 'a -> bool; .. > as 'a) -> 'a) -> 'a -> 'a
400
401val add_hook : ('a -> ('a -> 'b) -> 'b) ref -> ('a -> ('a -> 'b) -> 'b) -> unit
402val add_hook_action : ('a -> unit) -> ('a -> unit) list ref -> unit
403val run_hooks_action : 'a -> ('a -> unit) list ref -> unit
404
405type 'a mylazy = (unit -> 'a)
406
407(* emacs spirit *)
408val save_excursion : 'a ref -> (unit -> 'b) -> 'b
708f4980
C
409val save_excursion_and_disable : bool ref -> (unit -> 'b) -> 'b
410val save_excursion_and_enable : bool ref -> (unit -> 'b) -> 'b
34e49164
C
411
412(* emacs spirit *)
413val unwind_protect : (unit -> 'a) -> (exn -> 'b) -> 'a
414
415(* java spirit *)
416val finalize : (unit -> 'a) -> (unit -> 'b) -> 'a
417
418val memoized : ('a, 'b) Hashtbl.t -> 'a -> (unit -> 'b) -> 'b
419
91eba41f
C
420val cache_in_ref : 'a option ref -> (unit -> 'a) -> 'a
421
34e49164
C
422
423(* take file from which computation is done, an extension, and the function
ae4735db 424 * and will compute the function only once and then save result in
34e49164
C
425 * file ^ extension
426 *)
ae4735db
C
427val cache_computation :
428 ?verbose:bool -> ?use_cache:bool -> filename -> string (* extension *) ->
34e49164
C
429 (unit -> 'a) -> 'a
430
ae4735db
C
431(* a more robust version where the client describes the dependencies of the
432 * computation so it will relaunch the computation in 'f' if needed.
34e49164
C
433 *)
434val cache_computation_robust :
ae4735db
C
435 filename ->
436 string (* extension for marshalled object *) ->
437 (filename list * 'x) ->
438 string (* extension for marshalled dependencies *) ->
439 (unit -> 'a) ->
34e49164 440 'a
ae4735db 441
34e49164
C
442
443
444val once : ('a -> unit) -> ('a -> unit)
445
446val before_leaving : ('a -> unit) -> 'a -> 'a
447
448(* do some finalize, signal handling, unix exit conversion, etc *)
449val main_boilerplate : (unit -> unit) -> unit
450
451
452(* cf also the timeout function below that are control related too *)
453
454
455(*****************************************************************************)
456(* Concurrency *)
457(*****************************************************************************)
458
459(* how ensure really atomic file creation ? hehe :) *)
ae4735db 460exception FileAlreadyLocked
34e49164
C
461val acquire_file_lock : filename -> unit
462val release_file_lock : filename -> unit
463
464(*****************************************************************************)
465(* Error managment *)
466(*****************************************************************************)
467exception Todo
468exception Impossible
469exception Here
470exception ReturnExn
471
0708f913 472exception Multi_found
91eba41f 473
34e49164
C
474exception WrongFormat of string
475
476
477val internal_error : string -> 'a
478val myassert : bool -> unit
479val warning : string -> 'a -> 'a
480val error_cant_have : 'a -> 'b
481
482val exn_to_s : exn -> string
91eba41f
C
483(* alias *)
484val string_of_exn : exn -> string
34e49164 485
ae4735db 486type error = Error of string
b1b2de81
C
487
488type evotype = unit
489val evoval : evotype
490
34e49164
C
491(*****************************************************************************)
492(* Environment *)
493(*****************************************************************************)
494
495val check_stack_size: int -> unit
496val check_stack_nbfiles: int -> unit
ae4735db 497
34e49164
C
498(* internally common.ml set Gc. parameters *)
499val _init_gc_stack : unit
500
501(*****************************************************************************)
502(* Arguments and command line *)
503(*****************************************************************************)
504
505type arg_spec_full = Arg.key * Arg.spec * Arg.doc
506type cmdline_options = arg_spec_full list
507
508
509type options_with_title = string * string * arg_spec_full list
510type cmdline_sections = options_with_title list
511
512
ae4735db 513(* A wrapper around Arg modules that have more logical argument order,
34e49164
C
514 * and returns the remaining args.
515 *)
ae4735db 516val parse_options :
34e49164
C
517 cmdline_options -> Arg.usage_msg -> string array -> string list
518
519(* Another wrapper that does Arg.align automatically *)
520val usage : Arg.usage_msg -> cmdline_options -> unit
521
522
523
524(* Work with the options_with_title type way to organize a long
525 * list of command line switches.
526 *)
ae4735db 527val short_usage :
34e49164 528 Arg.usage_msg -> short_opt:cmdline_options -> unit
ae4735db
C
529val long_usage :
530 Arg.usage_msg -> short_opt:cmdline_options -> long_opt:cmdline_sections ->
34e49164
C
531 unit
532
533(* With the options_with_title way, we don't want the default -help and --help
534 * so need adapter of Arg module, not just wrapper.
535 *)
536val arg_align2 : cmdline_options -> cmdline_options
ae4735db
C
537val arg_parse2 :
538 cmdline_options -> Arg.usage_msg -> (unit -> unit) (* short_usage func *) ->
34e49164
C
539 string list
540
541
542
543
544
545(* The action lib. Useful to debug supart of your system. cf some of
546 * my main.ml for example of use. *)
547type flag_spec = Arg.key * Arg.spec * Arg.doc
ae4735db 548type action_spec = Arg.key * Arg.doc * action_func
34e49164
C
549 and action_func = (string list -> unit)
550
551type cmdline_actions = action_spec list
552exception WrongNumberOfArguments
553
554val mk_action_0_arg : (unit -> unit) -> action_func
555val mk_action_1_arg : (string -> unit) -> action_func
556val mk_action_2_arg : (string -> string -> unit) -> action_func
557val mk_action_3_arg : (string -> string -> string -> unit) -> action_func
558
559val mk_action_n_arg : (string list -> unit) -> action_func
560
ae4735db 561val options_of_actions:
34e49164 562 string ref (* the action ref *) -> cmdline_actions -> cmdline_options
ae4735db 563val action_list:
34e49164 564 cmdline_actions -> Arg.key list
ae4735db 565val do_action:
34e49164
C
566 Arg.key -> string list (* args *) -> cmdline_actions -> unit
567
568(*****************************************************************************)
569(* Equality *)
570(*****************************************************************************)
571
572(* Using the generic (=) is tempting, but it backfires, so better avoid it *)
573
574(* To infer all the code that use an equal, and that should be
575 * transformed, is not that easy, because (=) is used by many
576 * functions, such as List.find, List.mem, and so on. The strategy to find
577 * them is to turn what you were previously using into a function, because
578 * (=) return an exception when applied to a function, then you simply
579 * use ocamldebug to detect where the code has to be transformed by
580 * finding where the exception was launched from.
581 *)
582
583val (=|=) : int -> int -> bool
584val (=<=) : char -> char -> bool
585val (=$=) : string -> string -> bool
586val (=:=) : bool -> bool -> bool
587
588val (=*=): 'a -> 'a -> bool
589
590(* if want to restrict the use of '=', uncomment this:
591 *
b1b2de81 592 * val (=): unit -> unit -> bool
ae4735db 593 *
34e49164
C
594 * But it will not forbid you to use caml functions like List.find, List.mem
595 * which internaly use this convenient but evolution-unfriendly (=)
596*)
597
598
599
34e49164
C
600(*###########################################################################*)
601(* And now basic types *)
602(*###########################################################################*)
603
604(*****************************************************************************)
605(* Bool *)
606(*****************************************************************************)
607
608val ( ||| ) : 'a -> 'a -> 'a
609val ( ==> ) : bool -> bool -> bool
610val xor : 'a -> 'a -> bool
611
612
0708f913 613
34e49164
C
614(*****************************************************************************)
615(* Char *)
616(*****************************************************************************)
617
618val string_of_char : char -> string
619val string_of_chars : char list -> string
620
621val is_single : char -> bool
622val is_symbol : char -> bool
623val is_space : char -> bool
624val is_upper : char -> bool
625val is_lower : char -> bool
626val is_alpha : char -> bool
627val is_digit : char -> bool
628
629val cbetween : char -> char -> char -> bool
630
631(*****************************************************************************)
632(* Num *)
633(*****************************************************************************)
634
635val ( /! ) : int -> int -> int
636
637val do_n : int -> (unit -> unit) -> unit
638val foldn : ('a -> int -> 'a) -> 'a -> int -> 'a
639
34e49164
C
640val pi : float
641val pi2 : float
642val pi4 : float
643
644val deg_to_rad : float -> float
645
646val clampf : float -> float
647
648val square : float -> float
649val power : int -> int -> int
650
651val between : 'a -> 'a -> 'a -> bool
652val between_strict : int -> int -> int -> bool
653val bitrange : int -> int -> bool
654
655val prime1 : int -> int option
656val prime : int -> int option
657
658val sum : int list -> int
659val product : int list -> int
660
661val decompose : int -> int list
662
663val mysquare : int -> int
664val sqr : float -> float
665
666type compare = Equal | Inf | Sup
667val ( <=> ) : 'a -> 'a -> compare
668val ( <==> ) : 'a -> 'a -> int
669
670type uint = int
671
672val int_of_stringchar : string -> int
673val int_of_base : string -> int -> int
674val int_of_stringbits : string -> int
675val int_of_octal : string -> int
676val int_of_all : string -> int
677
678(* useful but sometimes when want grep for all places where do modif,
679 * easier to have just code using ':=' and '<-' to do some modifications.
680 * In the same way avoid using {contents = xxx} to build some ref.
681 *)
682val ( += ) : int ref -> int -> unit
683val ( -= ) : int ref -> int -> unit
684
ae4735db 685val pourcent: int -> int -> int
34e49164
C
686val pourcent_float: int -> int -> float
687val pourcent_float_of_floats: float -> float -> float
688
91eba41f
C
689val pourcent_good_bad: int -> int -> int
690val pourcent_good_bad_float: int -> int -> float
691
692type 'a max_with_elem = int ref * 'a ref
ae4735db 693val update_max_with_elem:
91eba41f 694 'a max_with_elem -> is_better:(int -> int ref -> bool) -> int * 'a -> unit
34e49164
C
695(*****************************************************************************)
696(* Numeric/overloading *)
697(*****************************************************************************)
698
699type 'a numdict =
700 NumDict of
701 (('a -> 'a -> 'a) * ('a -> 'a -> 'a) * ('a -> 'a -> 'a) * ('a -> 'a))
702val add : 'a numdict -> 'a -> 'a -> 'a
703val mul : 'a numdict -> 'a -> 'a -> 'a
704val div : 'a numdict -> 'a -> 'a -> 'a
705val neg : 'a numdict -> 'a -> 'a
706
707val numd_int : int numdict
708val numd_float : float numdict
709
710val testd : 'a numdict -> 'a -> 'a
711
712
ae4735db 713module ArithFloatInfix : sig
34e49164
C
714 val (+) : float -> float -> float
715 val (-) : float -> float -> float
716 val (/) : float -> float -> float
717 val ( * ) : float -> float -> float
718
719
720 val (+..) : int -> int -> int
721 val (-..) : int -> int -> int
722 val (/..) : int -> int -> int
723 val ( *..) : int -> int -> int
724
725 val (+=) : float ref -> float -> unit
726end
727
728(*****************************************************************************)
729(* Random *)
730(*****************************************************************************)
731
732val _init_random : unit
733val random_list : 'a list -> 'a
734val randomize_list : 'a list -> 'a list
735val random_subset_of_list : int -> 'a list -> 'a list
736
737
738(*****************************************************************************)
739(* Tuples *)
740(*****************************************************************************)
741
742type 'a pair = 'a * 'a
743type 'a triple = 'a * 'a * 'a
744
745val fst3 : 'a * 'b * 'c -> 'a
746val snd3 : 'a * 'b * 'c -> 'b
747val thd3 : 'a * 'b * 'c -> 'c
748
749val sndthd : 'a * 'b * 'c -> 'b * 'c
750
751val map_fst : ('a -> 'b) -> 'a * 'c -> 'b * 'c
752val map_snd : ('a -> 'b) -> 'c * 'a -> 'c * 'b
753
754val pair : ('a -> 'b) -> 'a * 'a -> 'b * 'b
755
756val snd : 'a * 'b -> 'b (* alias *)
757val fst : 'a * 'b -> 'a (* alias *)
758
759val double : 'a -> 'a * 'a
760val swap : 'a * 'b -> 'b * 'a
761
762(* maybe a sign of bad programming if use those functions :) *)
763val tuple_of_list1 : 'a list -> 'a
764val tuple_of_list2 : 'a list -> 'a * 'a
765val tuple_of_list3 : 'a list -> 'a * 'a * 'a
766val tuple_of_list4 : 'a list -> 'a * 'a * 'a * 'a
767val tuple_of_list5 : 'a list -> 'a * 'a * 'a * 'a * 'a
768val tuple_of_list6 : 'a list -> 'a * 'a * 'a * 'a * 'a * 'a
769
770(*****************************************************************************)
771(* Maybe *)
772(*****************************************************************************)
773
774type ('a, 'b) either = Left of 'a | Right of 'b
775type ('a, 'b, 'c) either3 = Left3 of 'a | Middle3 of 'b | Right3 of 'c
776
777val just : 'a option -> 'a
778val some : 'a option -> 'a (* alias *)
779
780val fmap : ('a -> 'b) -> 'a option -> 'b option
781val map_option : ('a -> 'b) -> 'a option -> 'b option (* alias *)
782
783val do_option : ('a -> unit) -> 'a option -> unit
784
785val optionise : (unit -> 'a) -> 'a option
786
787val some_or : 'a option -> 'a -> 'a
788
789val partition_either :
790 ('a -> ('b, 'c) either) -> 'a list -> 'b list * 'c list
978fd7e5
C
791val partition_either3 :
792 ('a -> ('b, 'c, 'd) either3) -> 'a list -> 'b list * 'c list * 'd list
34e49164
C
793
794val filter_some : 'a option list -> 'a list
795val map_filter : ('a -> 'b option) -> 'a list -> 'b list
c491d8ee 796val tail_map_filter : ('a -> 'b option) -> 'a list -> 'b list
34e49164
C
797val find_some : ('a -> 'b option) -> 'a list -> 'b
798
0708f913
C
799val list_to_single_or_exn: 'a list -> 'a
800
801(*****************************************************************************)
802(* TriBool *)
803(*****************************************************************************)
804type bool3 = True3 | False3 | TrueFalsePb3 of string
805
806
34e49164
C
807(*****************************************************************************)
808(* Strings *)
809(*****************************************************************************)
810
811val slength : string -> int (* alias *)
812val concat : string -> string list -> string (* alias *)
813
814val i_to_s : int -> string
815val s_to_i : string -> int
816
817(* strings take space in memory. Better when can share the space used by
818 * similar strings.
819 *)
820val _shareds : (string, string) Hashtbl.t
821val shared_string : string -> string
822
823val chop : string -> string
824val chop_dirsymbol : string -> string
825
826val ( <!!> ) : string -> int * int -> string
827val ( <!> ) : string -> int -> char
828
91eba41f
C
829val take_string: int -> string -> string
830val take_string_safe: int -> string -> string
831
34e49164
C
832val split_on_char : char -> string -> string list
833
834val lowercase : string -> string
835
836val quote : string -> string
837
838val null_string : string -> bool
839val is_blank_string : string -> bool
840val is_string_prefix : string -> string -> bool
841
842
843val plural : int -> string -> string
844
845val showCodeHex : int list -> unit
846
847val size_mo_ko : int -> string
848val size_ko : int -> string
849
ae4735db 850val edit_distance: string -> string -> int
34e49164 851
ae4735db 852val md5sum_of_string : string -> string
485bce71 853
34e49164
C
854(*****************************************************************************)
855(* Regexp *)
856(*****************************************************************************)
857
858val regexp_alpha : Str.regexp
485bce71 859val regexp_word : Str.regexp
34e49164
C
860
861val _memo_compiled_regexp : (string, Str.regexp) Hashtbl.t
862val ( =~ ) : string -> string -> bool
863val ( ==~ ) : string -> Str.regexp -> bool
864
865
866
867val regexp_match : string -> string -> string
868
869val matched : int -> string -> string
870
871(* not yet politypic functions in ocaml *)
872val matched1 : string -> string
873val matched2 : string -> string * string
874val matched3 : string -> string * string * string
875val matched4 : string -> string * string * string * string
876val matched5 : string -> string * string * string * string * string
877val matched6 : string -> string * string * string * string * string * string
878val matched7 : string -> string * string * string * string * string * string * string
879
880val string_match_substring : Str.regexp -> string -> bool
881
882val split : string (* sep regexp *) -> string -> string list
883val join : string (* sep *) -> string list -> string
884
885val split_list_regexp : string -> string list -> (string * string list) list
886
887val all_match : string (* regexp *) -> string -> string list
ae4735db 888val global_replace_regexp :
485bce71
C
889 string (* regexp *) -> (string -> string) -> string -> string
890
891val regular_words: string -> string list
892val contain_regular_word: string -> bool
34e49164
C
893
894(*****************************************************************************)
895(* Filenames *)
896(*****************************************************************************)
897
898(* now at beginning of this file: type filename = string *)
899val dirname : string -> string
900val basename : string -> string
901
902val filesuffix : filename -> string
903val fileprefix : filename -> string
904
905val adjust_ext_if_needed : filename -> string -> filename
906
907(* db for dir, base *)
908val db_of_filename : filename -> (string * filename)
909val filename_of_db : (string * filename) -> filename
910
911(* dbe for dir, base, ext *)
912val dbe_of_filename : filename -> string * string * string
913val dbe_of_filename_nodot : filename -> string * string * string
914(* Left (d,b,e) | Right (d,b) if file has no extension *)
ae4735db 915val dbe_of_filename_safe :
34e49164
C
916 filename -> (string * string * string, string * string) either
917
918val filename_of_dbe : string * string * string -> filename
919
920(* ex: replace_ext "toto.c" "c" "var" *)
921val replace_ext: filename -> string -> string -> filename
922
923(* remove the ., .. *)
924val normalize_path : filename -> filename
925
926val relative_to_absolute : filename -> filename
927
91eba41f
C
928val is_relative: filename -> bool
929val is_absolute: filename -> bool
930
34e49164
C
931val filename_without_leading_path : string -> filename -> filename
932
933(*****************************************************************************)
934(* i18n *)
935(*****************************************************************************)
ae4735db 936type langage =
34e49164
C
937 | English
938 | Francais
939 | Deutsch
940
941(*****************************************************************************)
942(* Dates *)
943(*****************************************************************************)
944
945(* can also use ocamlcalendar, but heavier, use many modules ... *)
946
ae4735db 947type month =
34e49164
C
948 | Jan | Feb | Mar | Apr | May | Jun
949 | Jul | Aug | Sep | Oct | Nov | Dec
950type year = Year of int
951type day = Day of int
952
953type date_dmy = DMY of day * month * year
954
955type hour = Hour of int
956type minute = Min of int
957type second = Sec of int
958
959type time_hms = HMS of hour * minute * second
960
961type full_date = date_dmy * time_hms
962
963
964(* intervalle *)
965type days = Days of int
966
967type time_dmy = TimeDMY of day * month * year
968
969
970(* from Unix *)
971type float_time = float
972
973
974val mk_date_dmy : int -> int -> int -> date_dmy
975
976
977val check_date_dmy : date_dmy -> unit
978val check_time_dmy : time_dmy -> unit
979val check_time_hms : time_hms -> unit
980
981val int_to_month : int -> string
982val int_of_month : month -> int
983val month_of_string : string -> month
984val month_of_string_long : string -> month
985val string_of_month : month -> string
986
987val string_of_date_dmy : date_dmy -> string
988val string_of_unix_time : ?langage:langage -> Unix.tm -> string
989val short_string_of_unix_time : ?langage:langage -> Unix.tm -> string
990val string_of_floattime: ?langage:langage -> float_time -> string
991val short_string_of_floattime: ?langage:langage -> float_time -> string
992
993val floattime_of_string: string -> float_time
994
995val dmy_to_unixtime: date_dmy -> float_time * Unix.tm
996val unixtime_to_dmy: Unix.tm -> date_dmy
997val unixtime_to_floattime: Unix.tm -> float_time
0708f913 998val floattime_to_unixtime: float_time -> Unix.tm
34e49164
C
999
1000val sec_to_days : int -> string
1001val sec_to_hours : int -> string
1002
1003val today : unit -> float_time
1004val yesterday : unit -> float_time
1005val tomorrow : unit -> float_time
1006
1007val lastweek : unit -> float_time
1008val lastmonth : unit -> float_time
1009
1010val week_before: float_time -> float_time
1011val month_before: float_time -> float_time
1012val week_after: float_time -> float_time
1013
1014val days_in_week_of_day : float_time -> float_time list
1015
1016val first_day_in_week_of_day : float_time -> float_time
1017val last_day_in_week_of_day : float_time -> float_time
1018
1019val day_secs: float_time
1020
1021val rough_days_since_jesus : date_dmy -> days
1022val rough_days_between_dates : date_dmy -> date_dmy -> days
1023
1024val string_of_unix_time_lfs : Unix.tm -> string
1025
485bce71
C
1026val is_more_recent : date_dmy -> date_dmy -> bool
1027val max_dmy : date_dmy -> date_dmy -> date_dmy
1028val min_dmy : date_dmy -> date_dmy -> date_dmy
1029val maximum_dmy : date_dmy list -> date_dmy
1030val minimum_dmy : date_dmy list -> date_dmy
34e49164
C
1031
1032(*****************************************************************************)
1033(* Lines/Words/Strings *)
1034(*****************************************************************************)
1035
1036val list_of_string : string -> char list
1037
1038val lines : string -> string list
1039val unlines : string list -> string
1040
1041val words : string -> string list
1042val unwords : string list -> string
1043
1044val split_space : string -> string list
1045
1046val lines_with_nl : string -> string list
1047
1048val nblines : string -> int
1049
1050(*****************************************************************************)
1051(* Process/Files *)
1052(*****************************************************************************)
1053val cat : filename -> string list
1054val cat_orig : filename -> string list
91eba41f
C
1055val cat_array: filename -> string array
1056
1057val uncat: string list -> filename -> unit
34e49164
C
1058
1059val interpolate : string -> string list
1060
1061val echo : string -> string
1062
1063val usleep : int -> unit
1064
1065val process_output_to_list : string -> string list
1066val cmd_to_list : string -> string list (* alias *)
1067val cmd_to_list_and_status : string -> string list * Unix.process_status
1068
1069val command2 : string -> unit
91eba41f 1070val _batch_mode: bool ref
34e49164 1071val command2_y_or_no : string -> bool
0708f913 1072val command2_y_or_no_exit_if_no : string -> unit
34e49164
C
1073
1074val do_in_fork : (unit -> unit) -> int
1075
1076val mkdir: ?mode:Unix.file_perm -> string -> unit
1077
1078val read_file : filename -> string
1079val write_file : file:filename -> string -> unit
1080
1081val filesize : filename -> int
1082val filemtime : filename -> float
1083
1084val nblines_file : filename -> int
1085
1086val lfile_exists : filename -> bool
1087val is_directory : filename -> bool
1088
1089val capsule_unix : ('a -> unit) -> 'a -> unit
1090
1091val readdir_to_kind_list : string -> Unix.file_kind -> string list
1092val readdir_to_dir_list : string -> string list
1093val readdir_to_file_list : string -> string list
1094val readdir_to_link_list : string -> string list
1095val readdir_to_dir_size_list : string -> (string * int) list
1096
1097val glob : string -> filename list
ae4735db 1098val files_of_dir_or_files :
34e49164
C
1099 string (* ext *) -> string list -> filename list
1100val files_of_dir_or_files_no_vcs :
1101 string (* ext *) -> string list -> filename list
1102(* use a post filter =~ for the ext filtering *)
1103val files_of_dir_or_files_no_vcs_post_filter :
1104 string (* regexp *) -> string list -> filename list
1105
1106
1107val sanity_check_files_and_adjust :
1108 string (* ext *) -> string list -> filename list
1109
1110
1111type rwx = [ `R | `W | `X ] list
1112val file_perm_of : u:rwx -> g:rwx -> o:rwx -> Unix.file_perm
1113
1114val has_env : string -> bool
1115
1116(* scheme spirit. do a finalize so no leak. *)
ae4735db 1117val with_open_outfile :
34e49164 1118 filename -> ((string -> unit) * out_channel -> 'a) -> 'a
ae4735db 1119val with_open_infile :
34e49164 1120 filename -> (in_channel -> 'a) -> 'a
ae4735db 1121val with_open_outfile_append :
34e49164
C
1122 filename -> ((string -> unit) * out_channel -> 'a) -> 'a
1123
ae4735db 1124val with_open_stringbuf :
34e49164
C
1125 (((string -> unit) * Buffer.t) -> unit) -> string
1126
1127exception Timeout
1128
ae4735db 1129(* subtil: have to make sure that Timeout is not intercepted before here. So
34e49164 1130 * avoid exn handler such as try (...) with _ -> cos Timeout will not bubble up
ae4735db
C
1131 * enough. In such case, add a case before such as
1132 * with Timeout -> raise Timeout | _ -> ...
1133 *
34e49164
C
1134 * The same is true for UnixExit (see below).
1135 *)
1136val timeout_function : int -> (unit -> 'a) -> 'a
1137
1138val timeout_function_opt : int option -> (unit -> 'a) -> 'a
1139
1140
ae4735db
C
1141(* creation of /tmp files, a la gcc
1142 * ex: new_temp_file "cocci" ".c" will give "/tmp/cocci-3252-434465.c"
34e49164
C
1143 *)
1144val _temp_files_created : string list ref
1145(* see flag: val save_tmp_files : bool ref *)
1146val new_temp_file : string (* prefix *) -> string (* suffix *) -> filename
1147val erase_temp_files : unit -> unit
978fd7e5 1148val erase_this_temp_file : filename -> unit
34e49164
C
1149
1150(* If the user use some exit 0 in his code, then no one can intercept this
1151 * exit and do something before exiting. There is exn handler for exit 0
1152 * so better never use exit 0 but instead use an exception and just at
1153 * the very toplevel transform this exn in a unix exit code.
ae4735db 1154 *
34e49164
C
1155 * subtil: same problem than with Timeout. Do not intercept such exception
1156 * with some blind try (...) with _ -> ...
1157 *)
ae4735db 1158exception UnixExit of int
34e49164
C
1159val exn_to_real_unixexit : (unit -> 'a) -> 'a
1160
1161
1162
1163
1164
1165
1166
1167
1168(*###########################################################################*)
1169(* And now collection-like types. See also ocollection.mli *)
1170(*###########################################################################*)
1171
1172(*****************************************************************************)
1173(* List *)
1174(*****************************************************************************)
1175
485bce71 1176
34e49164
C
1177(* tail recursive efficient map (but that also reverse the element!) *)
1178val map_eff_rev : ('a -> 'b) -> 'a list -> 'b list
1179(* tail recursive efficient map, use accumulator *)
1180val acc_map : ('a -> 'b) -> 'a list -> 'b list
1181
1182
1183val zip : 'a list -> 'b list -> ('a * 'b) list
1184val zip_safe : 'a list -> 'b list -> ('a * 'b) list
1185val unzip : ('a * 'b) list -> 'a list * 'b list
1186
1187val take : int -> 'a list -> 'a list
1188val take_safe : int -> 'a list -> 'a list
1189val take_until : ('a -> bool) -> 'a list -> 'a list
1190val take_while : ('a -> bool) -> 'a list -> 'a list
1191
1192val drop : int -> 'a list -> 'a list
1193val drop_while : ('a -> bool) -> 'a list -> 'a list
1194val drop_until : ('a -> bool) -> 'a list -> 'a list
1195
1196val span : ('a -> bool) -> 'a list -> 'a list * 'a list
1197
1198val skip_until : ('a list -> bool) -> 'a list -> 'a list
b1b2de81 1199val skipfirst : (* Eq a *) 'a -> 'a list -> 'a list
34e49164
C
1200
1201(* cf also List.partition *)
1202val fpartition : ('a -> 'b option) -> 'a list -> 'b list * 'a list
1203
1204val groupBy : ('a -> 'a -> bool) -> 'a list -> 'a list list
1205val exclude_but_keep_attached: ('a -> bool) -> 'a list -> ('a * 'a list) list
b1b2de81
C
1206val group_by_post: ('a -> bool) -> 'a list -> ('a list * 'a) list * 'a list
1207val group_by_pre: ('a -> bool) -> 'a list -> 'a list * ('a * 'a list) list
0708f913 1208val group_by_mapped_key: ('a -> 'b) -> 'a list -> ('b * 'a list) list
34e49164 1209
91eba41f
C
1210(* Use hash internally to not be in O(n2). If you want to use it on a
1211 * simple list, then first do a List.map to generate a key, for instance the
1212 * first char of the element, and then use this function.
1213 *)
34e49164
C
1214val group_assoc_bykey_eff : ('a * 'b) list -> ('a * 'b list) list
1215
1216val splitAt : int -> 'a list -> 'a list * 'a list
1217
1218val split_when: ('a -> bool) -> 'a list -> 'a list * 'a * 'a list
1219val split_gen_when: ('a list -> 'a list option) -> 'a list -> 'a list list
1220
1221val pack : int -> 'a list -> 'a list list
1222
1223
1224val enum : int -> int -> int list
1225val repeat : 'a -> int -> 'a list
1226val generate : int -> 'a -> 'a list
1227
1228
1229
1230val index_list : 'a list -> ('a * int) list
1231val index_list_1 : 'a list -> ('a * int) list
1232val index_list_and_total : 'a list -> ('a * int * int) list
1233
1234val iter_index : ('a -> int -> 'b) -> 'a list -> unit
1235val map_index : ('a -> int -> 'b) -> 'a list -> 'b list
1236val filter_index : (int -> 'a -> bool) -> 'a list -> 'a list
1237val fold_left_with_index : ('a -> 'b -> int -> 'a) -> 'a -> 'b list -> 'a
1238
1239val nth : 'a list -> int -> 'a
b1b2de81 1240val rang : (* Eq a *) 'a -> 'a list -> int
34e49164
C
1241
1242val last_n : int -> 'a list -> 'a list
1243
1244
1245
1246val snoc : 'a -> 'a list -> 'a list
1247val cons : 'a -> 'a list -> 'a list
1248val uncons : 'a list -> 'a * 'a list
1249val safe_tl : 'a list -> 'a list
1250val head_middle_tail : 'a list -> 'a * 'a list * 'a
1251val last : 'a list -> 'a
1252val list_init : 'a list -> 'a list
1253val list_last : 'a list -> 'a
1254val removelast : 'a list -> 'a list
1255
1256val inits : 'a list -> 'a list list
1257val tails : 'a list -> 'a list list
1258
1259
1260val ( ++ ) : 'a list -> 'a list -> 'a list
1261
1262val foldl1 : ('a -> 'a -> 'a) -> 'a list -> 'a
1263val fold_k : ('a -> 'b -> ('a -> 'a) -> 'a) -> ('a -> 'a) -> 'a -> 'b list -> 'a
1264val fold_right1 : ('a -> 'a -> 'a) -> 'a list -> 'a
1265val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
1266
1267val rev_map : ('a -> 'b) -> 'a list -> 'b list
1268
1269val join_gen : 'a -> 'a list -> 'a list
1270
1271val do_withenv :
1272 (('a -> 'b) -> 'c -> 'd) -> ('e -> 'a -> 'b * 'e) -> 'e -> 'c -> 'd * 'e
1273val map_withenv : ('a -> 'b -> 'c * 'a) -> 'a -> 'b list -> 'c list * 'a
113803cf 1274val map_withkeep: ('a -> 'b) -> 'a list -> ('b * 'a) list
34e49164
C
1275
1276val collect_accu : ('a -> 'b list) -> 'b list -> 'a list -> 'b list
1277val collect : ('a -> 'b list) -> 'a list -> 'b list
1278
1279val remove : 'a -> 'a list -> 'a list
1280
1281val exclude : ('a -> bool) -> 'a list -> 'a list
1282
1283(* Not like unix uniq command line tool that only delete contiguous repeated
1284 * line. Here we delete any repeated line (here list element).
1285 *)
1286val uniq : 'a list -> 'a list
ae4735db 1287val uniq_eff: 'a list -> 'a list
91eba41f 1288
113803cf
C
1289val has_no_duplicate: 'a list -> bool
1290val is_set_as_list: 'a list -> bool
1291val get_duplicates: 'a list -> 'a list
1292
34e49164
C
1293val doublon : 'a list -> bool
1294
1295val reverse : 'a list -> 'a list (* alias *)
1296val rev : 'a list -> 'a list (* alias *)
1297val rotate : 'a list -> 'a list
1298
1299val map_flatten : ('a -> 'b list) -> 'a list -> 'b list
1300
1301val map2 : ('a -> 'b) -> 'a list -> 'b list
1302val map3 : ('a -> 'b) -> 'a list -> 'b list
1303
1304
1305val maximum : 'a list -> 'a
1306val minimum : 'a list -> 'a
1307
1308val min_with : ('a -> 'b) -> 'a list -> 'a
1309val two_mins_with : ('a -> 'b) -> 'a list -> 'a * 'a
1310
b1b2de81 1311val all_assoc : (* Eq a *) 'a -> ('a * 'b) list -> 'b list
34e49164
C
1312val prepare_want_all_assoc : ('a * 'b) list -> ('a * 'b list) list
1313
1314val or_list : bool list -> bool
1315val and_list : bool list -> bool
1316
485bce71
C
1317val sum_float : float list -> float
1318val sum_int : int list -> int
ae4735db 1319val avg_list: int list -> float
485bce71 1320
34e49164
C
1321val return_when : ('a -> 'b option) -> 'a list -> 'b
1322
1323
1324val grep_with_previous : ('a -> 'a -> bool) -> 'a list -> 'a list
1325val iter_with_previous : ('a -> 'a -> 'b) -> 'a list -> unit
1326
ae4735db 1327val iter_with_before_after :
34e49164
C
1328 ('a list -> 'a -> 'a list -> unit) -> 'a list -> unit
1329
1330val get_pair : 'a list -> ('a * 'a) list
1331
1332val permutation : 'a list -> 'a list list
1333
1334val remove_elem_pos : int -> 'a list -> 'a list
1335val insert_elem_pos : ('a * int) -> 'a list -> 'a list
1336val uncons_permut : 'a list -> (('a * int) * 'a list) list
1337val uncons_permut_lazy : 'a list -> (('a * int) * 'a list Lazy.t) list
1338
1339
1340val pack_sorted : ('a -> 'a -> bool) -> 'a list -> 'a list list
1341
1342val keep_best : ('a * 'a -> 'a option) -> 'a list -> 'a list
1343val sorted_keep_best : ('a -> 'a -> 'a option) -> 'a list -> 'a list
1344
91eba41f 1345
34e49164
C
1346val cartesian_product : 'a list -> 'b list -> ('a * 'b) list
1347
1348(* old stuff *)
1349val surEnsemble : 'a list -> 'a list list -> 'a list list
1350val realCombinaison : 'a list -> 'a list list
1351val combinaison : 'a list -> ('a * 'a) list
1352val insere : 'a -> 'a list list -> 'a list list
1353val insereListeContenant : 'a list -> 'a -> 'a list list -> 'a list list
1354val fusionneListeContenant : 'a * 'a -> 'a list list -> 'a list list
1355
1356(*****************************************************************************)
1357(* Arrays *)
1358(*****************************************************************************)
1359
b1b2de81
C
1360val array_find_index : (int -> bool) -> 'a array -> int
1361val array_find_index_via_elem : ('a -> bool) -> 'a array -> int
1362
1363(* for better type checking, as sometimes when have an 'int array', can
1364 * easily mess up the index from the value.
1365 *)
ae4735db 1366type idx = Idx of int
b1b2de81
C
1367val next_idx: idx -> idx
1368val int_of_idx: idx -> int
1369
1370val array_find_index_typed : (idx -> bool) -> 'a array -> idx
34e49164 1371
91eba41f
C
1372(*****************************************************************************)
1373(* Matrix *)
1374(*****************************************************************************)
1375
34e49164
C
1376type 'a matrix = 'a array array
1377
1378val map_matrix : ('a -> 'b) -> 'a matrix -> 'b matrix
1379
ae4735db 1380val make_matrix_init:
91eba41f
C
1381 nrow:int -> ncolumn:int -> (int -> int -> 'a) -> 'a matrix
1382
ae4735db 1383val iter_matrix:
91eba41f
C
1384 (int -> int -> 'a -> unit) -> 'a matrix -> unit
1385
ae4735db 1386val nb_rows_matrix: 'a matrix -> int
91eba41f
C
1387val nb_columns_matrix: 'a matrix -> int
1388
1389val rows_of_matrix: 'a matrix -> 'a list list
1390val columns_of_matrix: 'a matrix -> 'a list list
1391
1392val all_elems_matrix_by_row: 'a matrix -> 'a list
1393
34e49164
C
1394(*****************************************************************************)
1395(* Fast array *)
1396(*****************************************************************************)
1397
1398(* ?? *)
1399
1400(*****************************************************************************)
1401(* Set. But have a look too at set*.mli; it's better. Or use Hashtbl. *)
1402(*****************************************************************************)
1403
1404type 'a set = 'a list
1405
1406val empty_set : 'a set
1407
1408val insert_set : 'a -> 'a set -> 'a set
1409val single_set : 'a -> 'a set
1410val set : 'a list -> 'a set
1411
113803cf
C
1412val is_set: 'a list -> bool
1413
34e49164
C
1414val exists_set : ('a -> bool) -> 'a set -> bool
1415val forall_set : ('a -> bool) -> 'a set -> bool
1416
1417val filter_set : ('a -> bool) -> 'a set -> 'a set
1418val fold_set : ('a -> 'b -> 'a) -> 'a -> 'b set -> 'a
1419val map_set : ('a -> 'b) -> 'a set -> 'b set
1420
1421val member_set : 'a -> 'a set -> bool
1422val find_set : ('a -> bool) -> 'a list -> 'a
1423
1424val sort_set : ('a -> 'a -> int) -> 'a list -> 'a list
1425
1426val iter_set : ('a -> unit) -> 'a list -> unit
1427
1428val top_set : 'a set -> 'a
1429
1430val inter_set : 'a set -> 'a set -> 'a set
1431val union_set : 'a set -> 'a set -> 'a set
1432val minus_set : 'a set -> 'a set -> 'a set
1433
1434val union_all : ('a set) list -> 'a set
1435
1436val big_union_set : ('a -> 'b set) -> 'a set -> 'b set
1437val card_set : 'a set -> int
1438
1439val include_set : 'a set -> 'a set -> bool
1440val equal_set : 'a set -> 'a set -> bool
1441val include_set_strict : 'a set -> 'a set -> bool
1442
1443(* could put them in Common.Infix *)
1444val ( $*$ ) : 'a set -> 'a set -> 'a set
1445val ( $+$ ) : 'a set -> 'a set -> 'a set
1446val ( $-$ ) : 'a set -> 'a set -> 'a set
1447
1448val ( $?$ ) : 'a -> 'a set -> bool
1449val ( $<$ ) : 'a set -> 'a set -> bool
1450val ( $<=$ ) : 'a set -> 'a set -> bool
1451val ( $=$ ) : 'a set -> 'a set -> bool
1452
1453val ( $@$ ) : 'a list -> 'a list -> 'a list
1454
1455val nub : 'a list -> 'a list
1456
ae4735db
C
1457(* use internally a hash and return
1458 * - the common part,
1459 * - part only in a,
34e49164
C
1460 * - part only in b
1461 *)
ae4735db 1462val diff_two_say_set_eff : 'a list -> 'a list ->
34e49164
C
1463 'a list * 'a list * 'a list
1464
1465(*****************************************************************************)
1466(* Set as normal list *)
1467(*****************************************************************************)
1468
ae4735db 1469(* cf above *)
34e49164
C
1470
1471(*****************************************************************************)
1472(* Set as sorted list *)
1473(*****************************************************************************)
1474
1475
1476(*****************************************************************************)
1477(* Sets specialized *)
1478(*****************************************************************************)
1479
ae4735db 1480(*
34e49164
C
1481module StringSet = Set.Make(struct type t = string let compare = compare end)
1482*)
ae4735db 1483
34e49164
C
1484
1485(*****************************************************************************)
1486(* Assoc. But have a look too at Mapb.mli; it's better. Or use Hashtbl. *)
1487(*****************************************************************************)
1488
1489type ('a, 'b) assoc = ('a * 'b) list
1490
b1b2de81 1491val assoc_to_function : (* Eq a *) ('a, 'b) assoc -> ('a -> 'b)
34e49164
C
1492
1493val empty_assoc : ('a, 'b) assoc
1494val fold_assoc : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
1495val insert_assoc : 'a -> 'a list -> 'a list
1496val map_assoc : ('a -> 'b) -> 'a list -> 'b list
1497val filter_assoc : ('a -> bool) -> 'a list -> 'a list
1498
1499val assoc : 'a -> ('a * 'b) list -> 'b
1500
1501val keys : ('a * 'b) list -> 'a list
1502val lookup : 'a -> ('a * 'b) list -> 'b
1503
1504val del_assoc : 'a -> ('a * 'b) list -> ('a * 'b) list
1505val replace_assoc : 'a * 'b -> ('a * 'b) list -> ('a * 'b) list
1506val apply_assoc : 'a -> ('b -> 'b) -> ('a * 'b) list -> ('a * 'b) list
1507
1508val big_union_assoc : ('a -> 'b set) -> 'a list -> 'b set
1509
1510val assoc_reverse : ('a * 'b) list -> ('b * 'a) list
1511val assoc_map : ('a * 'b) list -> ('a * 'b) list -> ('a * 'a) list
1512
1513val lookup_list : 'a -> ('a, 'b) assoc list -> 'b
1514val lookup_list2 : 'a -> ('a, 'b) assoc list -> 'b * int
1515
1516val assoc_option : 'a -> ('a, 'b) assoc -> 'b option
485bce71 1517val assoc_with_err_msg : 'a -> ('a, 'b) assoc -> 'b
34e49164 1518
113803cf
C
1519val sort_by_val_lowfirst: ('a,'b) assoc -> ('a * 'b) list
1520val sort_by_val_highfirst: ('a,'b) assoc -> ('a * 'b) list
1521
1522val sort_by_key_lowfirst: (int,'b) assoc -> (int * 'b) list
1523val sort_by_key_highfirst: (int,'b) assoc -> (int * 'b) list
91eba41f 1524
0708f913
C
1525val sortgen_by_key_lowfirst: ('a,'b) assoc -> ('a * 'b) list
1526val sortgen_by_key_highfirst: ('a,'b) assoc -> ('a * 'b) list
1527
34e49164
C
1528(*****************************************************************************)
1529(* Assoc, specialized. *)
1530(*****************************************************************************)
1531
1532module IntMap :
1533 sig
1534 type key = int
1535 type +'a t
1536 val empty : 'a t
1537 val is_empty : 'a t -> bool
1538 val add : key -> 'a -> 'a t -> 'a t
1539 val find : key -> 'a t -> 'a
1540 val remove : key -> 'a t -> 'a t
1541 val mem : key -> 'a t -> bool
1542 val iter : (key -> 'a -> unit) -> 'a t -> unit
1543 val map : ('a -> 'b) -> 'a t -> 'b t
1544 val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t
1545 val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
1546 val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
1547 val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
1548 end
1549val intmap_to_list : 'a IntMap.t -> (IntMap.key * 'a) list
1550val intmap_string_of_t : 'a -> 'b -> string
1551
1552module IntIntMap :
1553 sig
1554 type key = int * int
1555 type +'a t
1556 val empty : 'a t
1557 val is_empty : 'a t -> bool
1558 val add : key -> 'a -> 'a t -> 'a t
1559 val find : key -> 'a t -> 'a
1560 val remove : key -> 'a t -> 'a t
1561 val mem : key -> 'a t -> bool
1562 val iter : (key -> 'a -> unit) -> 'a t -> unit
1563 val map : ('a -> 'b) -> 'a t -> 'b t
1564 val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t
1565 val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
1566 val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
1567 val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
1568 end
1569val intintmap_to_list : 'a IntIntMap.t -> (IntIntMap.key * 'a) list
1570val intintmap_string_of_t : 'a -> 'b -> string
1571
1572
1573(*****************************************************************************)
1574(* Hash *)
1575(*****************************************************************************)
1576
1577(* Note that Hashtbl keep old binding to a key so if want a hash
1578 * of a list, then can use the Hashtbl as is. Use Hashtbl.find_all then
1579 * to get the list of bindings
ae4735db
C
1580 *
1581 * Note that Hashtbl module use different convention :( the object is
34e49164
C
1582 * the first argument, not last as for List or Map.
1583 *)
1584
1585(* obsolete: can use directly the Hashtbl module *)
1586val hcreate : unit -> ('a, 'b) Hashtbl.t
1587val hadd : 'a * 'b -> ('a, 'b) Hashtbl.t -> unit
1588val hmem : 'a -> ('a, 'b) Hashtbl.t -> bool
1589val hfind : 'a -> ('a, 'b) Hashtbl.t -> 'b
1590val hreplace : 'a * 'b -> ('a, 'b) Hashtbl.t -> unit
1591val hiter : ('a -> 'b -> unit) -> ('a, 'b) Hashtbl.t -> unit
1592val hfold : ('a -> 'b -> 'c -> 'c) -> ('a, 'b) Hashtbl.t -> 'c -> 'c
1593val hremove : 'a -> ('a, 'b) Hashtbl.t -> unit
1594
1595
1596val hfind_default : 'a -> (unit -> 'b) -> ('a, 'b) Hashtbl.t -> 'b
1597val hfind_option : 'a -> ('a, 'b) Hashtbl.t -> 'b option
ae4735db 1598val hupdate_default :
34e49164
C
1599 'a -> ('b -> 'b) -> (unit -> 'b) -> ('a, 'b) Hashtbl.t -> unit
1600
1601val hash_to_list : ('a, 'b) Hashtbl.t -> ('a * 'b) list
1602val hash_to_list_unsorted : ('a, 'b) Hashtbl.t -> ('a * 'b) list
1603val hash_of_list : ('a * 'b) list -> ('a, 'b) Hashtbl.t
1604
1605
ae4735db 1606val hkeys : ('a, 'b) Hashtbl.t -> 'a list
34e49164
C
1607
1608(*****************************************************************************)
1609(* Hash sets *)
1610(*****************************************************************************)
1611
ae4735db 1612type 'a hashset = ('a, bool) Hashtbl.t
34e49164
C
1613
1614
1615(* common use of hashset, in a hash of hash *)
1616val hash_hashset_add : 'a -> 'b -> ('a, 'b hashset) Hashtbl.t -> unit
1617
ae4735db 1618val hashset_to_set :
34e49164
C
1619 < fromlist : ('a ) list -> 'c; .. > -> ('a, 'b) Hashtbl.t -> 'c
1620
1621val hashset_to_list : 'a hashset -> 'a list
1622val hashset_of_list : 'a list -> 'a hashset
1623
1624
1625(*****************************************************************************)
1626(* Stack *)
1627(*****************************************************************************)
1628
1629type 'a stack = 'a list
1630val empty_stack : 'a stack
1631val push : 'a -> 'a stack -> 'a stack
1632val top : 'a stack -> 'a
1633val pop : 'a stack -> 'a stack
1634
91eba41f
C
1635val top_option: 'a stack -> 'a option
1636
34e49164
C
1637val push2 : 'a -> 'a stack ref -> unit
1638val pop2: 'a stack ref -> 'a
1639
91eba41f
C
1640(*****************************************************************************)
1641(* Stack with undo/redo support *)
1642(*****************************************************************************)
1643
1644type 'a undo_stack = 'a list * 'a list
1645val empty_undo_stack : 'a undo_stack
1646val push_undo : 'a -> 'a undo_stack -> 'a undo_stack
1647val top_undo : 'a undo_stack -> 'a
1648val pop_undo : 'a undo_stack -> 'a undo_stack
1649val redo_undo: 'a undo_stack -> 'a undo_stack
1650val undo_pop: 'a undo_stack -> 'a undo_stack
1651
1652val top_undo_option: 'a undo_stack -> 'a option
1653
34e49164
C
1654
1655(*****************************************************************************)
1656(* Binary tree *)
1657(*****************************************************************************)
1658type 'a bintree = Leaf of 'a | Branch of ('a bintree * 'a bintree)
1659
1660(*****************************************************************************)
1661(* N-ary tree *)
1662(*****************************************************************************)
1663
1664(* no empty tree, must have one root at least *)
1665type 'a tree = Tree of 'a * ('a tree) list
1666
1667val tree_iter : ('a -> unit) -> 'a tree -> unit
1668
1669
1670(*****************************************************************************)
1671(* N-ary tree with updatable childrens *)
1672(*****************************************************************************)
1673
b1b2de81 1674(* no empty tree, must have one root at least *)
ae4735db
C
1675type 'a treeref =
1676 | NodeRef of 'a * 'a treeref list ref
34e49164 1677
ae4735db 1678val treeref_node_iter:
b1b2de81 1679 (('a * 'a treeref list ref) -> unit) -> 'a treeref -> unit
ae4735db
C
1680val treeref_node_iter_with_parents:
1681 (('a * 'a treeref list ref) -> ('a list) -> unit) ->
b1b2de81 1682 'a treeref -> unit
34e49164 1683
ae4735db
C
1684val find_treeref:
1685 (('a * 'a treeref list ref) -> bool) ->
b1b2de81
C
1686 'a treeref -> 'a treeref
1687
ae4735db
C
1688val treeref_children_ref:
1689 'a treeref -> 'a treeref list ref
b1b2de81
C
1690
1691val find_treeref_with_parents_some:
1692 ('a * 'a treeref list ref -> 'a list -> 'c option) ->
1693 'a treeref -> 'c
1694
1695val find_multi_treeref_with_parents_some:
1696 ('a * 'a treeref list ref -> 'a list -> 'c option) ->
1697 'a treeref -> 'c list
1698
1699
ae4735db 1700(* Leaf can seem redundant, but sometimes want to directly see if
b1b2de81
C
1701 * a children is a leaf without looking if the list is empty.
1702 *)
ae4735db
C
1703type ('a, 'b) treeref2 =
1704 | NodeRef2 of 'a * ('a, 'b) treeref2 list ref
b1b2de81
C
1705 | LeafRef2 of 'b
1706
1707
ae4735db
C
1708val find_treeref2:
1709 (('a * ('a, 'b) treeref2 list ref) -> bool) ->
b1b2de81
C
1710 ('a, 'b) treeref2 -> ('a, 'b) treeref2
1711
ae4735db
C
1712val treeref_node_iter_with_parents2:
1713 (('a * ('a, 'b) treeref2 list ref) -> ('a list) -> unit) ->
b1b2de81
C
1714 ('a, 'b) treeref2 -> unit
1715
ae4735db 1716val treeref_node_iter2:
b1b2de81
C
1717 (('a * ('a, 'b) treeref2 list ref) -> unit) -> ('a, 'b) treeref2 -> unit
1718
1719(*
1720
34e49164 1721
ae4735db 1722val treeref_children_ref: ('a, 'b) treeref -> ('a, 'b) treeref list ref
34e49164 1723
91eba41f
C
1724val find_treeref_with_parents_some:
1725 ('a * ('a, 'b) treeref list ref -> 'a list -> 'c option) ->
1726 ('a, 'b) treeref -> 'c
34e49164 1727
91eba41f
C
1728val find_multi_treeref_with_parents_some:
1729 ('a * ('a, 'b) treeref list ref -> 'a list -> 'c option) ->
1730 ('a, 'b) treeref -> 'c list
b1b2de81 1731*)
34e49164
C
1732
1733(*****************************************************************************)
1734(* Graph. But have a look too at Ograph_*.mli; it's better *)
1735(*****************************************************************************)
1736
1737type 'a graph = 'a set * ('a * 'a) set
1738
1739val add_node : 'a -> 'a graph -> 'a graph
1740val del_node : 'a -> 'a graph -> 'a graph
1741
1742val add_arc : 'a * 'a -> 'a graph -> 'a graph
1743val del_arc : 'a * 'a -> 'a graph -> 'a graph
1744
1745val successors : 'a -> 'a graph -> 'a set
1746val predecessors : 'a -> 'a graph -> 'a set
1747
1748val nodes : 'a graph -> 'a set
1749
1750val fold_upward : ('a -> 'b -> 'a) -> 'b set -> 'a -> 'b graph -> 'a
1751
1752val empty_graph : 'a list * 'b list
1753
1754
1755(*****************************************************************************)
1756(* Generic op *)
1757(*****************************************************************************)
1758
1759(* mostly alias to functions in List *)
1760
1761val map : ('a -> 'b) -> 'a list -> 'b list
c491d8ee 1762val tail_map : ('a -> 'b) -> 'a list -> 'b list
34e49164
C
1763val filter : ('a -> bool) -> 'a list -> 'a list
1764val fold : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
1765
1766val member : 'a -> 'a list -> bool
1767
1768val iter : ('a -> unit) -> 'a list -> unit
1769
1770val find : ('a -> bool) -> 'a list -> 'a
1771
1772val exists : ('a -> bool) -> 'a list -> bool
1773val forall : ('a -> bool) -> 'a list -> bool
1774
1775val big_union : ('a -> 'b set) -> 'a list -> 'b set
1776
1777(* same than [] but easier to search for, because [] can also be a pattern *)
1778val empty_list : 'a list
1779
1780val sort : ('a -> 'a -> int) -> 'a list -> 'a list
1781
1782val length : 'a list -> int
1783
1784val null : 'a list -> bool
1785
1786val head : 'a list -> 'a
1787val tail : 'a list -> 'a list
1788
1789val is_singleton : 'a list -> bool
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799(*###########################################################################*)
1800(* And now misc functions *)
1801(*###########################################################################*)
1802
1803(*****************************************************************************)
1804(* DB (LFS) *)
1805(*****************************************************************************)
1806
1807(* cf oassocbdb.ml or oassocdbm.ml *)
1808
1809(*****************************************************************************)
1810(* GUI (LFS, CComment, otimetracker) *)
1811(*****************************************************************************)
1812
1813(* cf ocamlgtk and my gui.ml *)
1814
1815
1816(*****************************************************************************)
1817(* Graphics (otimetracker) *)
1818(*****************************************************************************)
1819
1820(* cf ocamlgl and my opengl.ml *)
1821
1822
1823
1824(*****************************************************************************)
1825(* Geometry (ICFP raytracer) *)
1826(*****************************************************************************)
1827
1828type vector = float * float * float
1829
1830type point = vector
1831type color = vector
1832
1833val dotproduct : vector * vector -> float
1834
1835val vector_length : vector -> float
1836
1837val minus_point : point * point -> vector
1838
1839val distance : point * point -> float
1840
1841val normalise : vector -> vector
1842
1843val mult_coeff : vector -> float -> vector
1844
1845val add_vector : vector -> vector -> vector
1846val mult_vector : vector -> vector -> vector
1847val sum_vector : vector list -> vector
1848
1849
1850(*****************************************************************************)
1851(* Pics (ICFP raytracer) *)
1852(*****************************************************************************)
1853type pixel = int * int * int
1854val write_ppm : int -> int -> pixel list -> filename -> unit
1855val test_ppm1 : unit -> unit
1856
1857(*****************************************************************************)
1858(* Diff (LFS) *)
1859(*****************************************************************************)
1860
1861type diff = Match | BnotinA | AnotinB
1862val diff : (int -> int -> diff -> unit) -> string list * string list -> unit
1863val diff2 : (int -> int -> diff -> unit) -> string * string -> unit
1864
1865(*****************************************************************************)
1866(* Parsers (aop-colcombet) *)
1867(*****************************************************************************)
1868
1869val parserCommon : Lexing.lexbuf -> ('a -> Lexing.lexbuf -> 'b) -> 'a -> 'b
1870val getDoubleParser :
1871 ('a -> Lexing.lexbuf -> 'b) -> 'a -> (string -> 'b) * (string -> 'b)
1872
1873(*****************************************************************************)
1874(* Parsers (cocci) *)
1875(*****************************************************************************)
1876
1877
1878(* Currently lexing.ml does not handle the line number position.
ae4735db 1879 * Even if there is some fields in the lexing structure, they are not
34e49164 1880 * maintained by the lexing engine :( So the following code does not work:
ae4735db
C
1881 *
1882 * let pos = Lexing.lexeme_end_p lexbuf in
1883 * sprintf "at file %s, line %d, char %d" pos.pos_fname pos.pos_lnum
1884 * (pos.pos_cnum - pos.pos_bol) in
1885 *
34e49164
C
1886 * Hence those functions to overcome the previous limitation.
1887 *)
1888
1889type parse_info = {
1890 str: string;
1891 charpos: int;
1892
1893 line: int;
1894 column: int;
1895 file: filename;
ae4735db 1896 }
34e49164
C
1897val fake_parse_info : parse_info
1898val string_of_parse_info : parse_info -> string
485bce71 1899val string_of_parse_info_bis : parse_info -> string
34e49164
C
1900
1901(* array[i] will contain the (line x col) of the i char position *)
1902val full_charpos_to_pos : filename -> (int * int) array
1903
1904(* fill in the line and column field of parse_info that were not set
1905 * during lexing because of limitations of ocamllex. *)
ae4735db 1906val complete_parse_info :
34e49164
C
1907 filename -> (int * int) array -> parse_info -> parse_info
1908
ae4735db 1909val full_charpos_to_pos_large:
708f4980
C
1910 filename -> (int -> (int * int))
1911
ae4735db 1912val complete_parse_info_large :
708f4980
C
1913 filename -> (int -> (int * int)) -> parse_info -> parse_info
1914
34e49164
C
1915(* return line x col x str_line from a charpos. This function is quite
1916 * expensive so don't use it to get the line x col from every token in
1917 * a file. Instead use full_charpos_to_pos.
1918 *)
1919val info_from_charpos : int -> filename -> (int * int * string)
1920
1921val error_message : filename -> (string * int) -> string
1922val error_message_short : filename -> (string * int) -> string
1923
ae4735db 1924(* add a 'decalage/shift' argument to handle stuff such as cpp which includes
34e49164
C
1925 * files and who can make shift.
1926 *)
1927val error_messagebis : filename -> (string * int) -> int -> string
1928
1929(*****************************************************************************)
1930(* Scope managment (cocci) *)
1931(*****************************************************************************)
1932
1933(* for example of use, see the code used in coccinelle *)
1934type ('a, 'b) scoped_env = ('a, 'b) assoc list
1935
b1b2de81 1936val lookup_env : (* Eq a *) 'a -> ('a, 'b) scoped_env -> 'b
34e49164
C
1937val member_env_key : 'a -> ('a, 'b) scoped_env -> bool
1938
1939val new_scope : ('a, 'b) scoped_env ref -> unit
1940val del_scope : ('a, 'b) scoped_env ref -> unit
1941
1942val do_in_new_scope : ('a, 'b) scoped_env ref -> (unit -> unit) -> unit
ae4735db 1943
34e49164
C
1944val add_in_scope : ('a, 'b) scoped_env ref -> 'a * 'b -> unit
1945
1946
1947
1948
1949(* for example of use, see the code used in coccinelle *)
1950type ('a, 'b) scoped_h_env = {
1951 scoped_h : ('a, 'b) Hashtbl.t;
1952 scoped_list : ('a, 'b) assoc list;
1953}
1954val empty_scoped_h_env : unit -> ('a, 'b) scoped_h_env
1955val clone_scoped_h_env : ('a, 'b) scoped_h_env -> ('a, 'b) scoped_h_env
1956
1957val lookup_h_env : 'a -> ('a, 'b) scoped_h_env -> 'b
1958val member_h_env_key : 'a -> ('a, 'b) scoped_h_env -> bool
1959
1960val new_scope_h : ('a, 'b) scoped_h_env ref -> unit
1961val del_scope_h : ('a, 'b) scoped_h_env ref -> unit
1962
1963val do_in_new_scope_h : ('a, 'b) scoped_h_env ref -> (unit -> unit) -> unit
1964
1965val add_in_scope_h : ('a, 'b) scoped_h_env ref -> 'a * 'b -> unit
1966
1967(*****************************************************************************)
1968(* Terminal (LFS) *)
1969(*****************************************************************************)
1970
91eba41f
C
1971(* don't forget to call Common_extra.set_link () *)
1972
34e49164 1973val _execute_and_show_progress_func :
ae4735db
C
1974 (int (* length *) -> ((unit -> unit) -> unit) -> unit) ref
1975val execute_and_show_progress :
34e49164
C
1976 int (* length *) -> ((unit -> unit) -> unit) -> unit
1977
1978(*****************************************************************************)
1979(* Flags and actions *)
1980(*****************************************************************************)
1981
1982val cmdline_flags_devel : unit -> cmdline_options
1983val cmdline_flags_verbose : unit -> cmdline_options
1984val cmdline_flags_other : unit -> cmdline_options
1985
1986(*****************************************************************************)
1987(* Misc/test *)
1988(*****************************************************************************)
1989
1990val generic_print : 'a -> string -> string
1991
1992class ['a] olist :
1993 'a list ->
1994 object
1995 val xs : 'a list
1996 method fold : ('b -> 'a -> 'b) -> 'b -> 'b
1997 method view : 'a list
1998 end
1999
2000val typing_sux_test : unit -> unit
2001