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