1 (*###########################################################################*)
3 (*###########################################################################*)
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
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.
13 * The variables that are called _init_xxx show the internal init
14 * side effect of the module (like static var trick used in C/C++)
16 * Why not split the functionnalities of this file in different files ?
17 * Because when I write ocaml script I want simply to load one
18 * file, common.ml, and that's it. Cf common_extra.ml for more on this.
22 (*****************************************************************************)
24 (*****************************************************************************)
25 (* see the corresponding section for the use of those flags. See also
26 * the "Flags and actions" section at the end of this file.
29 (* if set then will not do certain finalize so faster to go back in replay *)
30 val debugger
: bool ref
32 type prof
= PALL
| PNONE
| PSOME
of string list
33 val profile
: prof
ref
34 val show_trace_profile
: bool ref
37 val verbose_level
: int ref
39 (* forbid pr2_once to do the once "optimisation" *)
40 val disable_pr2_once
: bool ref
44 (* works with new_temp_file *)
45 val save_tmp_files
: bool ref
49 (*****************************************************************************)
50 (* Module side effect *)
51 (*****************************************************************************)
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 .
58 (*****************************************************************************)
60 (*****************************************************************************)
61 (* cf the _xxx variables in this file *)
63 (*###########################################################################*)
65 (*###########################################################################*)
67 type filename
= string
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.
74 module BasicType
: sig
75 type filename
= string
78 (* Same spirit. Trick found in Jane Street core lib, but originated somewhere
79 * else I think: the ability to open nested modules. *)
81 val ( +> ) : 'a
-> ('a
-> 'b
) -> 'b
82 val ( =~
) : string -> string -> bool
83 val ( ==~
) : string -> Str.regexp
-> bool
88 * Another related trick, found via Jon Harrop to have an extended standard
89 * lib is to do something like
91 * module List = struct
96 * And then can put this "module extension" somewhere to open it.
101 (* This module defines the Timeout and UnixExit exceptions.
102 * You have to make sure that those exn are not intercepted. So
103 * avoid exn handler such as try (...) with _ -> cos Timeout will not bubble up
104 * enough. In such case, add a case before such as
105 * with Timeout -> raise Timeout | _ -> ...
106 * The same is true for UnixExit (see below).
109 (*****************************************************************************)
110 (* Debugging/logging *)
111 (*****************************************************************************)
113 val _tab_level_print
: int ref
114 val indent_do
: (unit -> 'a
) -> 'a
115 val reset_pr_indent
: unit -> unit
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
120 * update: for pr2, it can also print into a log file.
122 * The use of 2 in pr2 is because 2 is under UNIX the second descriptor
123 * which corresponds to stderr.
125 val _prefix_pr
: string ref
127 val pr
: string -> unit
128 val pr_no_nl
: string -> unit
129 val pr_xxxxxxxxxxxxxxxxx
: unit -> unit
131 (* pr2 print on stderr, but can also in addition print into a file *)
132 val _chan_pr2
: out_channel
option ref
133 val print_to_stderr
: bool ref
134 val pr2
: string -> unit
135 val pr2_no_nl
: string -> unit
136 val pr2_xxxxxxxxxxxxxxxxx
: unit -> unit
138 (* use Dumper.dump *)
139 val pr2_gen
: 'a
-> unit
140 val dump
: 'a
-> string
142 (* see flag: val disable_pr2_once : bool ref *)
143 val _already_printed
: (string, bool) Hashtbl.t
144 val pr2_once
: string -> unit
145 val clear_pr2_once
: unit -> unit
147 val mk_pr2_wrappers
: bool ref -> (string -> unit) * (string -> unit)
150 val redirect_stdout_opt
: filename
option -> (unit -> 'a
) -> 'a
151 val redirect_stdout_stderr
: filename
-> (unit -> unit) -> unit
152 val redirect_stdin
: filename
-> (unit -> 'a
) -> 'a
153 val redirect_stdin_opt
: filename
option -> (unit -> 'a
) -> 'a
155 val with_pr2_to_string
: (unit -> unit) -> string list
157 val fprintf
: out_channel
-> ('a
, out_channel
, unit) format
-> 'a
158 val printf
: ('a
, out_channel
, unit) format
-> 'a
159 val eprintf
: ('a
, out_channel
, unit) format
-> 'a
160 val sprintf
: ('a
, unit, string) format
-> 'a
163 val spf
: ('a
, unit, string) format
-> 'a
165 (* default = stderr *)
166 val _chan
: out_channel
ref
167 (* generate & use a /tmp/debugml-xxx file *)
168 val start_log_file
: unit -> unit
170 (* see flag: val verbose_level : int ref *)
171 val log
: string -> unit
172 val log2
: string -> unit
173 val log3
: string -> unit
174 val log4
: string -> unit
176 val if_log
: (unit -> unit) -> unit
177 val if_log2
: (unit -> unit) -> unit
178 val if_log3
: (unit -> unit) -> unit
179 val if_log4
: (unit -> unit) -> unit
181 val pause
: unit -> unit
183 (* was used by fix_caml *)
184 val _trace_var
: int ref
185 val add_var
: unit -> unit
186 val dec_var
: unit -> unit
187 val get_var
: unit -> int
189 val print_n
: int -> string -> unit
190 val printerr_n
: int -> string -> unit
192 val _debug
: bool ref
193 val debugon
: unit -> unit
194 val debugoff
: unit -> unit
195 val debug
: (unit -> unit) -> unit
197 (* see flag: val debugger : bool ref *)
200 (*****************************************************************************)
201 (* Profiling (cpu/mem) *)
202 (*****************************************************************************)
204 val get_mem
: unit -> unit
205 val memory_stat
: unit -> string
207 val timenow
: unit -> string
209 val _count1
: int ref
210 val _count2
: int ref
211 val _count3
: int ref
212 val _count4
: int ref
213 val _count5
: int ref
215 val count1
: unit -> unit
216 val count2
: unit -> unit
217 val count3
: unit -> unit
218 val count4
: unit -> unit
219 val count5
: unit -> unit
220 val profile_diagnostic_basic
: unit -> string
222 val time_func
: (unit -> 'a
) -> 'a
226 (* see flag: type prof = PALL | PNONE | PSOME of string list *)
227 (* see flag: val profile : prof ref *)
229 val _profile_table
: (string, (float ref * int ref)) Hashtbl.t
ref
230 val profile_code
: string -> (unit -> 'a
) -> 'a
231 val profile_diagnostic
: unit -> string
233 val profile_code_exclusif
: string -> (unit -> 'a
) -> 'a
234 val profile_code_inside_exclusif_ok
: string -> (unit -> 'a
) -> 'a
236 val report_if_take_time
: int -> string -> (unit -> 'a
) -> 'a
238 (* similar to profile_code but print some information during execution too *)
239 val profile_code2
: string -> (unit -> 'a
) -> 'a
241 (*****************************************************************************)
243 (*****************************************************************************)
245 val example
: bool -> unit
246 (* generate failwith <string> when pb *)
247 val example2
: string -> bool -> unit
248 (* use Dumper to report when pb *)
249 val assert_equal
: 'a
-> 'a
-> unit
251 val _list_bool
: (string * bool) list
ref
252 val example3
: string -> bool -> unit
253 val test_all
: unit -> unit
256 (* regression testing *)
257 type score_result
= Ok
| Pb
of string
258 type score
= (string (* usually a filename *), score_result
) Hashtbl.t
259 type score_list
= (string (* usually a filename *) * score_result
) list
260 val empty_score
: unit -> score
261 val regression_testing
:
262 score
-> filename
(* old score file on disk (usually in /tmp) *) -> unit
263 val regression_testing_vs
: score
-> score
-> score
264 val total_scores
: score
-> int (* good *) * int (* total *)
265 val print_score
: score
-> unit
266 val print_total_score
: score
-> unit
269 (* quickcheck spirit *)
270 type 'a gen
= unit -> 'a
272 (* quickcheck random generators *)
274 val lg
: 'a gen
-> 'a list gen
275 val pg
: 'a gen
-> 'b gen
-> ('a
* 'b
) gen
279 val oneofl
: 'a list
-> 'a gen
280 val oneof
: 'a gen list
-> 'a gen
281 val always
: 'a
-> 'a gen
282 val frequency
: (int * 'a gen
) list
-> 'a gen
283 val frequencyl
: (int * 'a
) list
-> 'a gen
285 val laws
: string -> ('a
-> bool) -> 'a gen
-> 'a
option
288 * let b = laws "unit" (fun x -> reverse [x] = [x]) ig
291 val statistic_number
: 'a list
-> (int * 'a
) list
292 val statistic
: 'a list
-> (int * 'a
) list
295 string -> ('a
-> bool * '
b) -> 'a gen
-> 'a
option * (int * '
b) list
297 (*****************************************************************************)
299 (*****************************************************************************)
301 (* just wrappers around Marshal *)
302 val get_value
: filename
-> 'a
303 val read_value
: filename
-> 'a
(* alias *)
304 val write_value
: 'a
-> filename
-> unit
305 val write_back
: ('a
-> '
b) -> filename
-> unit
307 (* wrappers that also use profile_code *)
308 val marshal__to_string
: 'a
-> Marshal.extern_flags list
-> string
309 val marshal__from_string
: string -> int -> 'a
311 (*****************************************************************************)
313 (*****************************************************************************)
314 val _counter
: int ref
315 val _counter2
: int ref
316 val _counter3
: int ref
318 val counter
: unit -> int
319 val counter2
: unit -> int
320 val counter3
: unit -> int
324 (*****************************************************************************)
325 (* String_of and (pretty) printing *)
326 (*****************************************************************************)
328 val string_of_string
: (string -> string) -> string
329 val string_of_list
: ('a
-> string) -> 'a list
-> string
330 val string_of_unit
: unit -> string
331 val string_of_array
: ('a
-> string) -> 'a array
-> string
332 val string_of_option
: ('a
-> string) -> 'a
option -> string
334 val print_bool
: bool -> unit
335 val print_option
: ('a
-> '
b) -> 'a
option -> unit
336 val print_list
: ('a
-> '
b) -> 'a list
-> unit
337 val print_between
: (unit -> unit) -> ('a
-> unit) -> 'a list
-> unit
339 (* use Format internally *)
340 val pp_do_in_box
: (unit -> unit) -> unit
341 val pp_f_in_box
: (unit -> 'a
) -> 'a
342 val pp_do_in_zero_box
: (unit -> unit) -> unit
343 val pp
: string -> unit
345 (* convert something printed using Format to print into a string *)
346 val format_to_string
: (unit -> unit) (* printer *) -> string
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) *)
352 val adjust_pp_with_indent
: (unit -> unit) -> unit
353 val adjust_pp_with_indent_and_header
: string -> (unit -> unit) -> unit
356 val mk_str_func_of_assoc_conv
:
357 ('a
* string) list
-> (string -> 'a
) * ('a
-> string)
359 (*****************************************************************************)
361 (*****************************************************************************)
363 (* was working with my macro.ml4 *)
364 val macro_expand
: string -> unit
366 (*****************************************************************************)
367 (* Composition/Control *)
368 (*****************************************************************************)
370 val ( +> ) : 'a
-> ('a
-> '
b) -> '
b
371 val ( +!> ) : 'a
ref -> ('a
-> 'a
) -> unit
372 val ( $
) : ('a
-> '
b) -> ('
b -> 'c
) -> 'a
-> 'c
374 val compose
: ('a
-> '
b) -> ('c
-> 'a
) -> 'c
-> '
b
375 val flip
: ('a
-> '
b -> 'c
) -> '
b -> 'a
-> 'c
377 val curry
: ('a
* '
b -> 'c
) -> 'a
-> '
b -> 'c
378 val uncurry
: ('a
-> '
b -> 'c
) -> 'a
* '
b -> 'c
381 val do_nothing
: unit -> unit
383 val forever
: (unit -> unit) -> unit
385 val applyn
: int -> ('a
-> 'a
) -> 'a
-> 'a
387 class ['a
] shared_variable_hook
:
390 val mutable data
: 'a
391 val mutable registered
: (unit -> unit) list
393 method modify
: ('a
-> 'a
) -> unit
394 method register
: (unit -> unit) -> unit
395 method set
: 'a
-> unit
398 val fixpoint
: ('a
-> 'a
) -> 'a
-> 'a
399 val fixpoint_for_object
: ((< equal
: 'a
-> bool; .. > as 'a
) -> 'a
) -> 'a
-> 'a
401 val add_hook
: ('a
-> ('a
-> '
b) -> '
b) ref -> ('a
-> ('a
-> '
b) -> '
b) -> unit
402 val add_hook_action
: ('a
-> unit) -> ('a
-> unit) list
ref -> unit
403 val run_hooks_action
: 'a
-> ('a
-> unit) list
ref -> unit
405 type 'a mylazy
= (unit -> 'a
)
408 val save_excursion
: 'a
ref -> (unit -> '
b) -> '
b
409 val save_excursion_and_disable
: bool ref -> (unit -> '
b) -> '
b
410 val save_excursion_and_enable
: bool ref -> (unit -> '
b) -> '
b
413 val unwind_protect
: (unit -> 'a
) -> (exn
-> '
b) -> 'a
416 val finalize
: (unit -> 'a
) -> (unit -> '
b) -> 'a
418 val memoized
: ('a
, '
b) Hashtbl.t
-> 'a
-> (unit -> '
b) -> '
b
420 val cache_in_ref
: 'a
option ref -> (unit -> 'a
) -> 'a
423 (* take file from which computation is done, an extension, and the function
424 * and will compute the function only once and then save result in
427 val cache_computation
:
428 ?verbose
:bool -> ?use_cache
:bool -> filename
-> string (* extension *) ->
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.
434 val cache_computation_robust
:
436 string (* extension for marshalled object *) ->
437 (filename list
* 'x
) ->
438 string (* extension for marshalled dependencies *) ->
444 val once
: ('a
-> unit) -> ('a
-> unit)
446 val before_leaving
: ('a
-> unit) -> 'a
-> 'a
448 (* do some finalize, signal handling, unix exit conversion, etc *)
449 val main_boilerplate
: (unit -> unit) -> unit
452 (* cf also the timeout function below that are control related too *)
455 (*****************************************************************************)
457 (*****************************************************************************)
459 (* how ensure really atomic file creation ? hehe :) *)
460 exception FileAlreadyLocked
461 val acquire_file_lock
: filename
-> unit
462 val release_file_lock
: filename
-> unit
464 (*****************************************************************************)
465 (* Error managment *)
466 (*****************************************************************************)
472 exception Multi_found
474 exception WrongFormat
of string
477 val internal_error
: string -> 'a
478 val myassert
: bool -> unit
479 val warning
: string -> 'a
-> 'a
480 val error_cant_have
: 'a
-> '
b
482 val exn_to_s
: exn
-> string
484 val string_of_exn
: exn
-> string
486 type error
= Error
of string
491 (*****************************************************************************)
493 (*****************************************************************************)
495 val check_stack_size
: int -> unit
496 val check_stack_nbfiles
: int -> unit
498 (* internally common.ml set Gc. parameters *)
499 val _init_gc_stack
: unit
501 (*****************************************************************************)
502 (* Arguments and command line *)
503 (*****************************************************************************)
505 type arg_spec_full
= Arg.key
* Arg.spec
* Arg.doc
506 type cmdline_options
= arg_spec_full list
509 type options_with_title
= string * string * arg_spec_full list
510 type cmdline_sections
= options_with_title list
513 (* A wrapper around Arg modules that have more logical argument order,
514 * and returns the remaining args.
517 cmdline_options
-> Arg.usage_msg
-> string array
-> string list
519 (* Another wrapper that does Arg.align automatically *)
520 val usage
: Arg.usage_msg
-> cmdline_options
-> unit
524 (* Work with the options_with_title type way to organize a long
525 * list of command line switches.
528 Arg.usage_msg
-> short_opt
:cmdline_options
-> unit
530 Arg.usage_msg
-> short_opt
:cmdline_options
-> long_opt
:cmdline_sections
->
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.
536 val arg_align2
: cmdline_options
-> cmdline_options
538 cmdline_options
-> Arg.usage_msg
-> (unit -> unit) (* short_usage func *) ->
545 (* The action lib. Useful to debug supart of your system. cf some of
546 * my main.ml for example of use. *)
547 type flag_spec
= Arg.key
* Arg.spec
* Arg.doc
548 type action_spec
= Arg.key
* Arg.doc
* action_func
549 and action_func
= (string list
-> unit)
551 type cmdline_actions
= action_spec list
552 exception WrongNumberOfArguments
554 val mk_action_0_arg
: (unit -> unit) -> action_func
555 val mk_action_1_arg
: (string -> unit) -> action_func
556 val mk_action_2_arg
: (string -> string -> unit) -> action_func
557 val mk_action_3_arg
: (string -> string -> string -> unit) -> action_func
559 val mk_action_n_arg
: (string list
-> unit) -> action_func
561 val options_of_actions
:
562 string ref (* the action ref *) -> cmdline_actions
-> cmdline_options
564 cmdline_actions
-> Arg.key list
566 Arg.key
-> string list
(* args *) -> cmdline_actions
-> unit
568 (*****************************************************************************)
570 (*****************************************************************************)
572 (* Using the generic (=) is tempting, but it backfires, so better avoid it *)
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.
583 val (=|=) : int -> int -> bool
584 val (=<=) : char
-> char
-> bool
585 val (=$
=) : string -> string -> bool
586 val (=:=) : bool -> bool -> bool
588 val (=*=): 'a
-> 'a
-> bool
590 (* if want to restrict the use of '=', uncomment this:
592 * val (=): unit -> unit -> bool
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 (=)
600 (*###########################################################################*)
601 (* And now basic types *)
602 (*###########################################################################*)
604 (*****************************************************************************)
606 (*****************************************************************************)
608 val ( ||| ) : 'a
-> 'a
-> 'a
609 val ( ==> ) : bool -> bool -> bool
610 val xor
: 'a
-> 'a
-> bool
614 (*****************************************************************************)
616 (*****************************************************************************)
618 val string_of_char
: char
-> string
619 val string_of_chars
: char list
-> string
621 val is_single
: char
-> bool
622 val is_symbol
: char
-> bool
623 val is_space
: char
-> bool
624 val is_upper
: char
-> bool
625 val is_lower
: char
-> bool
626 val is_alpha
: char
-> bool
627 val is_digit
: char
-> bool
629 val cbetween
: char
-> char
-> char
-> bool
631 (*****************************************************************************)
633 (*****************************************************************************)
635 val ( /! ) : int -> int -> int
637 val do_n
: int -> (unit -> unit) -> unit
638 val foldn
: ('a
-> int -> 'a
) -> 'a
-> int -> 'a
644 val deg_to_rad
: float -> float
646 val clampf
: float -> float
648 val square
: float -> float
649 val power
: int -> int -> int
651 val between
: 'a
-> 'a
-> 'a
-> bool
652 val between_strict
: int -> int -> int -> bool
653 val bitrange
: int -> int -> bool
655 val prime1
: int -> int option
656 val prime
: int -> int option
658 val sum
: int list
-> int
659 val product
: int list
-> int
661 val decompose
: int -> int list
663 val mysquare
: int -> int
664 val sqr
: float -> float
666 type compare
= Equal
| Inf
| Sup
667 val ( <=> ) : 'a
-> 'a
-> compare
668 val ( <==> ) : 'a
-> 'a
-> int
672 val int_of_stringchar
: string -> int
673 val int_of_base
: string -> int -> int
674 val int_of_stringbits
: string -> int
675 val int_of_octal
: string -> int
676 val int_of_all
: string -> int
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.
682 val ( += ) : int ref -> int -> unit
683 val ( -= ) : int ref -> int -> unit
685 val pourcent
: int -> int -> int
686 val pourcent_float
: int -> int -> float
687 val pourcent_float_of_floats
: float -> float -> float
689 val pourcent_good_bad
: int -> int -> int
690 val pourcent_good_bad_float
: int -> int -> float
692 type 'a max_with_elem
= int ref * 'a
ref
693 val update_max_with_elem
:
694 'a max_with_elem
-> is_better
:(int -> int ref -> bool) -> int * 'a
-> unit
695 (*****************************************************************************)
696 (* Numeric/overloading *)
697 (*****************************************************************************)
701 (('a
-> 'a
-> 'a
) * ('a
-> 'a
-> 'a
) * ('a
-> 'a
-> 'a
) * ('a
-> 'a
))
702 val add
: 'a numdict
-> 'a
-> 'a
-> 'a
703 val mul
: 'a numdict
-> 'a
-> 'a
-> 'a
704 val div
: 'a numdict
-> 'a
-> 'a
-> 'a
705 val neg
: 'a numdict
-> 'a
-> 'a
707 val numd_int
: int numdict
708 val numd_float
: float numdict
710 val testd
: 'a numdict
-> 'a
-> 'a
713 module ArithFloatInfix
: sig
714 val (+) : float -> float -> float
715 val (-) : float -> float -> float
716 val (/) : float -> float -> float
717 val ( * ) : float -> float -> float
720 val (+..) : int -> int -> int
721 val (-..) : int -> int -> int
722 val (/..) : int -> int -> int
723 val ( *..) : int -> int -> int
725 val (+=) : float ref -> float -> unit
728 (*****************************************************************************)
730 (*****************************************************************************)
732 val _init_random
: unit
733 val random_list
: 'a list
-> 'a
734 val randomize_list
: 'a list
-> 'a list
735 val random_subset_of_list
: int -> 'a list
-> 'a list
738 (*****************************************************************************)
740 (*****************************************************************************)
742 type 'a pair
= 'a
* 'a
743 type 'a triple
= 'a
* 'a
* 'a
745 val fst3
: 'a
* '
b * 'c
-> 'a
746 val snd3
: 'a
* '
b * 'c
-> '
b
747 val thd3
: 'a
* '
b * 'c
-> 'c
749 val sndthd
: 'a
* '
b * 'c
-> '
b * 'c
751 val map_fst
: ('a
-> '
b) -> 'a
* 'c
-> '
b * 'c
752 val map_snd
: ('a
-> '
b) -> 'c
* 'a
-> 'c
* '
b
754 val pair
: ('a
-> '
b) -> 'a
* 'a
-> '
b * '
b
756 val snd
: 'a
* '
b -> '
b (* alias *)
757 val fst
: 'a
* '
b -> 'a
(* alias *)
759 val double
: 'a
-> 'a
* 'a
760 val swap
: 'a
* '
b -> '
b * 'a
762 (* maybe a sign of bad programming if use those functions :) *)
763 val tuple_of_list1
: 'a list
-> 'a
764 val tuple_of_list2
: 'a list
-> 'a
* 'a
765 val tuple_of_list3
: 'a list
-> 'a
* 'a
* 'a
766 val tuple_of_list4
: 'a list
-> 'a
* 'a
* 'a
* 'a
767 val tuple_of_list5
: 'a list
-> 'a
* 'a
* 'a
* 'a
* 'a
768 val tuple_of_list6
: 'a list
-> 'a
* 'a
* 'a
* 'a
* 'a
* 'a
770 (*****************************************************************************)
772 (*****************************************************************************)
774 type ('a
, '
b) either
= Left
of 'a
| Right
of '
b
775 type ('a
, '
b, 'c
) either3
= Left3
of 'a
| Middle3
of '
b | Right3
of 'c
777 val just
: 'a
option -> 'a
778 val some
: 'a
option -> 'a
(* alias *)
780 val fmap
: ('a
-> '
b) -> 'a
option -> '
b option
781 val map_option
: ('a
-> '
b) -> 'a
option -> '
b option (* alias *)
783 val do_option
: ('a
-> unit) -> 'a
option -> unit
785 val optionise
: (unit -> 'a
) -> 'a
option
787 val some_or
: 'a
option -> 'a
-> 'a
789 val partition_either
:
790 ('a
-> ('
b, 'c
) either
) -> 'a list
-> '
b list
* 'c list
791 val partition_either3
:
792 ('a
-> ('
b, 'c
, 'd
) either3
) -> 'a list
-> '
b list
* 'c list
* 'd list
794 val filter_some
: 'a
option list
-> 'a list
795 val map_filter
: ('a
-> '
b option) -> 'a list
-> '
b list
796 val tail_map_filter
: ('a
-> '
b option) -> 'a list
-> '
b list
797 val find_some
: ('a
-> '
b option) -> 'a list
-> '
b
799 val list_to_single_or_exn
: 'a list
-> 'a
801 (*****************************************************************************)
803 (*****************************************************************************)
804 type bool3
= True3
| False3
| TrueFalsePb3
of string
807 (*****************************************************************************)
809 (*****************************************************************************)
811 val slength
: string -> int (* alias *)
812 val concat
: string -> string list
-> string (* alias *)
814 val i_to_s
: int -> string
815 val s_to_i
: string -> int
817 (* strings take space in memory. Better when can share the space used by
820 val _shareds
: (string, string) Hashtbl.t
821 val shared_string
: string -> string
823 val chop
: string -> string
824 val chop_dirsymbol
: string -> string
826 val ( <!!> ) : string -> int * int -> string
827 val ( <!> ) : string -> int -> char
829 val take_string
: int -> string -> string
830 val take_string_safe
: int -> string -> string
832 val split_on_char
: char
-> string -> string list
834 val lowercase
: string -> string
836 val quote
: string -> string
838 val null_string
: string -> bool
839 val is_blank_string
: string -> bool
840 val is_string_prefix
: string -> string -> bool
843 val plural
: int -> string -> string
845 val showCodeHex
: int list
-> unit
847 val size_mo_ko
: int -> string
848 val size_ko
: int -> string
850 val edit_distance
: string -> string -> int
852 val md5sum_of_string
: string -> string
854 (*****************************************************************************)
856 (*****************************************************************************)
858 val regexp_alpha
: Str.regexp
859 val regexp_word
: Str.regexp
861 val _memo_compiled_regexp
: (string, Str.regexp
) Hashtbl.t
862 val ( =~
) : string -> string -> bool
863 val ( ==~
) : string -> Str.regexp
-> bool
867 val regexp_match
: string -> string -> string
869 val matched
: int -> string -> string
871 (* not yet politypic functions in ocaml *)
872 val matched1
: string -> string
873 val matched2
: string -> string * string
874 val matched3
: string -> string * string * string
875 val matched4
: string -> string * string * string * string
876 val matched5
: string -> string * string * string * string * string
877 val matched6
: string -> string * string * string * string * string * string
878 val matched7
: string -> string * string * string * string * string * string * string
880 val string_match_substring
: Str.regexp
-> string -> bool
882 val split
: string (* sep regexp *) -> string -> string list
883 val join
: string (* sep *) -> string list
-> string
885 val split_list_regexp
: string -> string list
-> (string * string list
) list
887 val all_match
: string (* regexp *) -> string -> string list
888 val global_replace_regexp
:
889 string (* regexp *) -> (string -> string) -> string -> string
891 val regular_words
: string -> string list
892 val contain_regular_word
: string -> bool
894 (*****************************************************************************)
896 (*****************************************************************************)
898 (* now at beginning of this file: type filename = string *)
899 val dirname
: string -> string
900 val basename
: string -> string
902 val filesuffix
: filename
-> string
903 val fileprefix
: filename
-> string
905 val adjust_ext_if_needed
: filename
-> string -> filename
907 (* db for dir, base *)
908 val db_of_filename
: filename
-> (string * filename
)
909 val filename_of_db
: (string * filename
) -> filename
911 (* dbe for dir, base, ext *)
912 val dbe_of_filename
: filename
-> string * string * string
913 val dbe_of_filename_nodot
: filename
-> string * string * string
914 (* Left (d,b,e) | Right (d,b) if file has no extension *)
915 val dbe_of_filename_safe
:
916 filename
-> (string * string * string, string * string) either
918 val filename_of_dbe
: string * string * string -> filename
920 (* ex: replace_ext "toto.c" "c" "var" *)
921 val replace_ext
: filename
-> string -> string -> filename
923 (* remove the ., .. *)
924 val normalize_path
: filename
-> filename
926 val relative_to_absolute
: filename
-> filename
928 val is_relative
: filename
-> bool
929 val is_absolute
: filename
-> bool
931 val filename_without_leading_path
: string -> filename
-> filename
933 (*****************************************************************************)
935 (*****************************************************************************)
941 (*****************************************************************************)
943 (*****************************************************************************)
945 (* can also use ocamlcalendar, but heavier, use many modules ... *)
948 | Jan
| Feb
| Mar
| Apr
| May
| Jun
949 | Jul
| Aug
| Sep
| Oct
| Nov
| Dec
950 type year
= Year
of int
951 type day
= Day
of int
953 type date_dmy
= DMY
of day
* month
* year
955 type hour
= Hour
of int
956 type minute
= Min
of int
957 type second
= Sec
of int
959 type time_hms
= HMS
of hour
* minute
* second
961 type full_date
= date_dmy
* time_hms
965 type days
= Days
of int
967 type time_dmy
= TimeDMY
of day
* month
* year
971 type float_time
= float
974 val mk_date_dmy
: int -> int -> int -> date_dmy
977 val check_date_dmy
: date_dmy
-> unit
978 val check_time_dmy
: time_dmy
-> unit
979 val check_time_hms
: time_hms
-> unit
981 val int_to_month
: int -> string
982 val int_of_month
: month
-> int
983 val month_of_string
: string -> month
984 val month_of_string_long
: string -> month
985 val string_of_month
: month
-> string
987 val string_of_date_dmy
: date_dmy
-> string
988 val string_of_unix_time
: ?langage
:langage
-> Unix.tm
-> string
989 val short_string_of_unix_time
: ?langage
:langage
-> Unix.tm
-> string
990 val string_of_floattime
: ?langage
:langage
-> float_time
-> string
991 val short_string_of_floattime
: ?langage
:langage
-> float_time
-> string
993 val floattime_of_string
: string -> float_time
995 val dmy_to_unixtime
: date_dmy
-> float_time
* Unix.tm
996 val unixtime_to_dmy
: Unix.tm
-> date_dmy
997 val unixtime_to_floattime
: Unix.tm
-> float_time
998 val floattime_to_unixtime
: float_time
-> Unix.tm
1000 val sec_to_days
: int -> string
1001 val sec_to_hours
: int -> string
1003 val today
: unit -> float_time
1004 val yesterday
: unit -> float_time
1005 val tomorrow
: unit -> float_time
1007 val lastweek
: unit -> float_time
1008 val lastmonth
: unit -> float_time
1010 val week_before
: float_time
-> float_time
1011 val month_before
: float_time
-> float_time
1012 val week_after
: float_time
-> float_time
1014 val days_in_week_of_day
: float_time
-> float_time list
1016 val first_day_in_week_of_day
: float_time
-> float_time
1017 val last_day_in_week_of_day
: float_time
-> float_time
1019 val day_secs
: float_time
1021 val rough_days_since_jesus
: date_dmy
-> days
1022 val rough_days_between_dates
: date_dmy
-> date_dmy
-> days
1024 val string_of_unix_time_lfs
: Unix.tm
-> string
1026 val is_more_recent
: date_dmy
-> date_dmy
-> bool
1027 val max_dmy
: date_dmy
-> date_dmy
-> date_dmy
1028 val min_dmy
: date_dmy
-> date_dmy
-> date_dmy
1029 val maximum_dmy
: date_dmy list
-> date_dmy
1030 val minimum_dmy
: date_dmy list
-> date_dmy
1032 (*****************************************************************************)
1033 (* Lines/Words/Strings *)
1034 (*****************************************************************************)
1036 val list_of_string
: string -> char list
1038 val lines
: string -> string list
1039 val unlines
: string list
-> string
1041 val words
: string -> string list
1042 val unwords
: string list
-> string
1044 val split_space
: string -> string list
1046 val lines_with_nl
: string -> string list
1048 val nblines
: string -> int
1050 (*****************************************************************************)
1052 (*****************************************************************************)
1053 val cat
: filename
-> string list
1054 val cat_orig
: filename
-> string list
1055 val cat_array
: filename
-> string array
1057 val uncat
: string list
-> filename
-> unit
1059 val interpolate
: string -> string list
1061 val echo
: string -> string
1063 val usleep
: int -> unit
1065 val process_output_to_list
: string -> string list
1066 val cmd_to_list
: string -> string list
(* alias *)
1067 val cmd_to_list_and_status
: string -> string list
* Unix.process_status
1069 val command2
: string -> unit
1070 val _batch_mode
: bool ref
1071 val command2_y_or_no
: string -> bool
1072 val command2_y_or_no_exit_if_no
: string -> unit
1074 val do_in_fork
: (unit -> unit) -> int
1076 val mkdir
: ?mode
:Unix.file_perm
-> string -> unit
1078 val read_file
: filename
-> string
1079 val write_file
: file
:filename
-> string -> unit
1081 val filesize
: filename
-> int
1082 val filemtime
: filename
-> float
1084 val nblines_file
: filename
-> int
1086 val lfile_exists
: filename
-> bool
1087 val is_directory
: filename
-> bool
1089 val capsule_unix
: ('a
-> unit) -> 'a
-> unit
1091 val readdir_to_kind_list
: string -> Unix.file_kind
-> string list
1092 val readdir_to_dir_list
: string -> string list
1093 val readdir_to_file_list
: string -> string list
1094 val readdir_to_link_list
: string -> string list
1095 val readdir_to_dir_size_list
: string -> (string * int) list
1097 val glob
: string -> filename list
1098 val files_of_dir_or_files
:
1099 string (* ext *) -> string list
-> filename list
1100 val files_of_dir_or_files_no_vcs
:
1101 string (* ext *) -> string list
-> filename list
1102 (* use a post filter =~ for the ext filtering *)
1103 val files_of_dir_or_files_no_vcs_post_filter
:
1104 string (* regexp *) -> string list
-> filename list
1107 val sanity_check_files_and_adjust
:
1108 string (* ext *) -> string list
-> filename list
1111 type rwx
= [ `R
| `W
| `X
] list
1112 val file_perm_of
: u
:rwx
-> g
:rwx
-> o
:rwx
-> Unix.file_perm
1114 val has_env
: string -> bool
1116 (* scheme spirit. do a finalize so no leak. *)
1117 val with_open_outfile
:
1118 filename
-> ((string -> unit) * out_channel
-> 'a
) -> 'a
1119 val with_open_infile
:
1120 filename
-> (in_channel
-> 'a
) -> 'a
1121 val with_open_outfile_append
:
1122 filename
-> ((string -> unit) * out_channel
-> 'a
) -> 'a
1124 val with_open_stringbuf
:
1125 (((string -> unit) * Buffer.t
) -> unit) -> string
1129 (* subtil: have to make sure that Timeout is not intercepted before here. So
1130 * avoid exn handler such as try (...) with _ -> cos Timeout will not bubble up
1131 * enough. In such case, add a case before such as
1132 * with Timeout -> raise Timeout | _ -> ...
1134 * The same is true for UnixExit (see below).
1136 val timeout_function
: int -> (unit -> 'a
) -> 'a
1138 val timeout_function_opt
: int option -> (unit -> 'a
) -> 'a
1141 (* creation of /tmp files, a la gcc
1142 * ex: new_temp_file "cocci" ".c" will give "/tmp/cocci-3252-434465.c"
1144 val _temp_files_created
: string list
ref
1145 (* see flag: val save_tmp_files : bool ref *)
1146 val new_temp_file
: string (* prefix *) -> string (* suffix *) -> filename
1147 val erase_temp_files
: unit -> unit
1148 val erase_this_temp_file
: filename
-> unit
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.
1155 * subtil: same problem than with Timeout. Do not intercept such exception
1156 * with some blind try (...) with _ -> ...
1158 exception UnixExit
of int
1159 val exn_to_real_unixexit
: (unit -> 'a
) -> 'a
1168 (*###########################################################################*)
1169 (* And now collection-like types. See also ocollection.mli *)
1170 (*###########################################################################*)
1172 (*****************************************************************************)
1174 (*****************************************************************************)
1177 (* tail recursive efficient map (but that also reverse the element!) *)
1178 val map_eff_rev
: ('a
-> '
b) -> 'a list
-> '
b list
1179 (* tail recursive efficient map, use accumulator *)
1180 val acc_map
: ('a
-> '
b) -> 'a list
-> '
b list
1183 val zip
: 'a list
-> '
b list
-> ('a
* '
b) list
1184 val zip_safe
: 'a list
-> '
b list
-> ('a
* '
b) list
1185 val unzip
: ('a
* '
b) list
-> 'a list
* '
b list
1187 val take
: int -> 'a list
-> 'a list
1188 val take_safe
: int -> 'a list
-> 'a list
1189 val take_until
: ('a
-> bool) -> 'a list
-> 'a list
1190 val take_while
: ('a
-> bool) -> 'a list
-> 'a list
1192 val drop
: int -> 'a list
-> 'a list
1193 val drop_while
: ('a
-> bool) -> 'a list
-> 'a list
1194 val drop_until
: ('a
-> bool) -> 'a list
-> 'a list
1196 val span
: ('a
-> bool) -> 'a list
-> 'a list
* 'a list
1198 val skip_until
: ('a list
-> bool) -> 'a list
-> 'a list
1199 val skipfirst
: (* Eq a *) 'a
-> 'a list
-> 'a list
1201 (* cf also List.partition *)
1202 val fpartition
: ('a
-> '
b option) -> 'a list
-> '
b list
* 'a list
1204 val groupBy
: ('a
-> 'a
-> bool) -> 'a list
-> 'a list list
1205 val exclude_but_keep_attached
: ('a
-> bool) -> 'a list
-> ('a
* 'a list
) list
1206 val group_by_post
: ('a
-> bool) -> 'a list
-> ('a list
* 'a
) list
* 'a list
1207 val group_by_pre
: ('a
-> bool) -> 'a list
-> 'a list
* ('a
* 'a list
) list
1208 val group_by_mapped_key
: ('a
-> '
b) -> 'a list
-> ('
b * 'a list
) list
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.
1214 val group_assoc_bykey_eff
: ('a
* '
b) list
-> ('a
* '
b list
) list
1216 val splitAt
: int -> 'a list
-> 'a list
* 'a list
1218 val split_when
: ('a
-> bool) -> 'a list
-> 'a list
* 'a
* 'a list
1219 val split_gen_when
: ('a list
-> 'a list
option) -> 'a list
-> 'a list list
1221 val pack
: int -> 'a list
-> 'a list list
1224 val enum
: int -> int -> int list
1225 val repeat
: 'a
-> int -> 'a list
1226 val generate
: int -> 'a
-> 'a list
1230 val index_list
: 'a list
-> ('a
* int) list
1231 val index_list_1
: 'a list
-> ('a
* int) list
1232 val index_list_and_total
: 'a list
-> ('a
* int * int) list
1234 val iter_index
: ('a
-> int -> '
b) -> 'a list
-> unit
1235 val map_index
: ('a
-> int -> '
b) -> 'a list
-> '
b list
1236 val filter_index
: (int -> 'a
-> bool) -> 'a list
-> 'a list
1237 val fold_left_with_index
: ('a
-> '
b -> int -> 'a
) -> 'a
-> '
b list
-> 'a
1239 val nth
: 'a list
-> int -> 'a
1240 val rang
: (* Eq a *) 'a
-> 'a list
-> int
1242 val last_n
: int -> 'a list
-> 'a list
1246 val snoc
: 'a
-> 'a list
-> 'a list
1247 val cons
: 'a
-> 'a list
-> 'a list
1248 val uncons
: 'a list
-> 'a
* 'a list
1249 val safe_tl
: 'a list
-> 'a list
1250 val head_middle_tail
: 'a list
-> 'a
* 'a list
* 'a
1251 val last
: 'a list
-> 'a
1252 val list_init
: 'a list
-> 'a list
1253 val list_last
: 'a list
-> 'a
1254 val removelast
: 'a list
-> 'a list
1256 val inits
: 'a list
-> 'a list list
1257 val tails
: 'a list
-> 'a list list
1260 val ( ++ ) : 'a list
-> 'a list
-> 'a list
1262 val foldl1
: ('a
-> 'a
-> 'a
) -> 'a list
-> 'a
1263 val fold_k
: ('a
-> '
b -> ('a
-> 'a
) -> 'a
) -> ('a
-> 'a
) -> 'a
-> '
b list
-> 'a
1264 val fold_right1
: ('a
-> 'a
-> 'a
) -> 'a list
-> 'a
1265 val fold_left
: ('a
-> '
b -> 'a
) -> 'a
-> '
b list
-> 'a
1267 val rev_map
: ('a
-> '
b) -> 'a list
-> '
b list
1269 val join_gen
: 'a
-> 'a list
-> 'a list
1272 (('a
-> '
b) -> 'c
-> 'd
) -> ('e
-> 'a
-> '
b * 'e
) -> 'e
-> 'c
-> 'd
* 'e
1273 val map_withenv
: ('a
-> '
b -> 'c
* 'a
) -> 'a
-> '
b list
-> 'c list
* 'a
1274 val map_withkeep
: ('a
-> '
b) -> 'a list
-> ('
b * 'a
) list
1276 val collect_accu
: ('a
-> '
b list
) -> '
b list
-> 'a list
-> '
b list
1277 val collect
: ('a
-> '
b list
) -> 'a list
-> '
b list
1279 val remove
: 'a
-> 'a list
-> 'a list
1281 val exclude
: ('a
-> bool) -> 'a list
-> 'a list
1283 (* Not like unix uniq command line tool that only delete contiguous repeated
1284 * line. Here we delete any repeated line (here list element).
1286 val uniq
: 'a list
-> 'a list
1287 val uniq_eff
: 'a list
-> 'a list
1289 val has_no_duplicate
: 'a list
-> bool
1290 val is_set_as_list
: 'a list
-> bool
1291 val get_duplicates
: 'a list
-> 'a list
1293 val doublon
: 'a list
-> bool
1295 val reverse
: 'a list
-> 'a list
(* alias *)
1296 val rev
: 'a list
-> 'a list
(* alias *)
1297 val rotate
: 'a list
-> 'a list
1299 val map_flatten
: ('a
-> '
b list
) -> 'a list
-> '
b list
1301 val map2
: ('a
-> '
b) -> 'a list
-> '
b list
1302 val map3
: ('a
-> '
b) -> 'a list
-> '
b list
1305 val maximum
: 'a list
-> 'a
1306 val minimum
: 'a list
-> 'a
1308 val min_with
: ('a
-> '
b) -> 'a list
-> 'a
1309 val two_mins_with
: ('a
-> '
b) -> 'a list
-> 'a
* 'a
1311 val all_assoc
: (* Eq a *) 'a
-> ('a
* '
b) list
-> '
b list
1312 val prepare_want_all_assoc
: ('a
* '
b) list
-> ('a
* '
b list
) list
1314 val or_list
: bool list
-> bool
1315 val and_list
: bool list
-> bool
1317 val sum_float
: float list
-> float
1318 val sum_int
: int list
-> int
1319 val avg_list
: int list
-> float
1321 val return_when
: ('a
-> '
b option) -> 'a list
-> '
b
1324 val grep_with_previous
: ('a
-> 'a
-> bool) -> 'a list
-> 'a list
1325 val iter_with_previous
: ('a
-> 'a
-> '
b) -> 'a list
-> unit
1327 val iter_with_before_after
:
1328 ('a list
-> 'a
-> 'a list
-> unit) -> 'a list
-> unit
1330 val get_pair
: 'a list
-> ('a
* 'a
) list
1332 val permutation
: 'a list
-> 'a list list
1334 val remove_elem_pos
: int -> 'a list
-> 'a list
1335 val insert_elem_pos
: ('a
* int) -> 'a list
-> 'a list
1336 val uncons_permut
: 'a list
-> (('a
* int) * 'a list
) list
1337 val uncons_permut_lazy
: 'a list
-> (('a
* int) * 'a list
Lazy.t
) list
1340 val pack_sorted
: ('a
-> 'a
-> bool) -> 'a list
-> 'a list list
1342 val keep_best
: ('a
* 'a
-> 'a
option) -> 'a list
-> 'a list
1343 val sorted_keep_best
: ('a
-> 'a
-> 'a
option) -> 'a list
-> 'a list
1346 val cartesian_product
: 'a list
-> '
b list
-> ('a
* '
b) list
1349 val surEnsemble
: 'a list
-> 'a list list
-> 'a list list
1350 val realCombinaison
: 'a list
-> 'a list list
1351 val combinaison
: 'a list
-> ('a
* 'a
) list
1352 val insere
: 'a
-> 'a list list
-> 'a list list
1353 val insereListeContenant
: 'a list
-> 'a
-> 'a list list
-> 'a list list
1354 val fusionneListeContenant
: 'a
* 'a
-> 'a list list
-> 'a list list
1356 (*****************************************************************************)
1358 (*****************************************************************************)
1360 val array_find_index
: (int -> bool) -> 'a array
-> int
1361 val array_find_index_via_elem
: ('a
-> bool) -> 'a array
-> int
1363 (* for better type checking, as sometimes when have an 'int array', can
1364 * easily mess up the index from the value.
1366 type idx
= Idx
of int
1367 val next_idx
: idx
-> idx
1368 val int_of_idx
: idx
-> int
1370 val array_find_index_typed
: (idx
-> bool) -> 'a array
-> idx
1372 (*****************************************************************************)
1374 (*****************************************************************************)
1376 type 'a matrix
= 'a array array
1378 val map_matrix
: ('a
-> '
b) -> 'a matrix
-> '
b matrix
1380 val make_matrix_init
:
1381 nrow
:int -> ncolumn
:int -> (int -> int -> 'a
) -> 'a matrix
1384 (int -> int -> 'a
-> unit) -> 'a matrix
-> unit
1386 val nb_rows_matrix
: 'a matrix
-> int
1387 val nb_columns_matrix
: 'a matrix
-> int
1389 val rows_of_matrix
: 'a matrix
-> 'a list list
1390 val columns_of_matrix
: 'a matrix
-> 'a list list
1392 val all_elems_matrix_by_row
: 'a matrix
-> 'a list
1394 (*****************************************************************************)
1396 (*****************************************************************************)
1400 (*****************************************************************************)
1401 (* Set. But have a look too at set*.mli; it's better. Or use Hashtbl. *)
1402 (*****************************************************************************)
1404 type 'a set
= 'a list
1406 val empty_set
: 'a set
1408 val insert_set
: 'a
-> 'a set
-> 'a set
1409 val single_set
: 'a
-> 'a set
1410 val set
: 'a list
-> 'a set
1412 val is_set
: 'a list
-> bool
1414 val exists_set
: ('a
-> bool) -> 'a set
-> bool
1415 val forall_set
: ('a
-> bool) -> 'a set
-> bool
1417 val filter_set
: ('a
-> bool) -> 'a set
-> 'a set
1418 val fold_set
: ('a
-> '
b -> 'a
) -> 'a
-> '
b set
-> 'a
1419 val map_set
: ('a
-> '
b) -> 'a set
-> '
b set
1421 val member_set
: 'a
-> 'a set
-> bool
1422 val find_set
: ('a
-> bool) -> 'a list
-> 'a
1424 val sort_set
: ('a
-> 'a
-> int) -> 'a list
-> 'a list
1426 val iter_set
: ('a
-> unit) -> 'a list
-> unit
1428 val top_set
: 'a set
-> 'a
1430 val inter_set
: 'a set
-> 'a set
-> 'a set
1431 val union_set
: 'a set
-> 'a set
-> 'a set
1432 val minus_set
: 'a set
-> 'a set
-> 'a set
1434 val union_all
: ('a set
) list
-> 'a set
1436 val big_union_set
: ('a
-> '
b set
) -> 'a set
-> '
b set
1437 val card_set
: 'a set
-> int
1439 val include_set
: 'a set
-> 'a set
-> bool
1440 val equal_set
: 'a set
-> 'a set
-> bool
1441 val include_set_strict
: 'a set
-> 'a set
-> bool
1443 (* could put them in Common.Infix *)
1444 val ( $
*$
) : 'a set
-> 'a set
-> 'a set
1445 val ( $
+$
) : 'a set
-> 'a set
-> 'a set
1446 val ( $
-$
) : 'a set
-> 'a set
-> 'a set
1448 val ( $?$
) : 'a
-> 'a set
-> bool
1449 val ( $
<$
) : 'a set
-> 'a set
-> bool
1450 val ( $
<=$
) : 'a set
-> 'a set
-> bool
1451 val ( $
=$
) : 'a set
-> 'a set
-> bool
1453 val ( $
@$
) : 'a list
-> 'a list
-> 'a list
1455 val nub
: 'a list
-> 'a list
1457 (* use internally a hash and return
1458 * - the common part,
1462 val diff_two_say_set_eff
: 'a list
-> 'a list
->
1463 'a list
* 'a list
* 'a list
1465 (*****************************************************************************)
1466 (* Set as normal list *)
1467 (*****************************************************************************)
1471 (*****************************************************************************)
1472 (* Set as sorted list *)
1473 (*****************************************************************************)
1476 (*****************************************************************************)
1477 (* Sets specialized *)
1478 (*****************************************************************************)
1481 module StringSet = Set.Make(struct type t = string let compare = compare end)
1485 (*****************************************************************************)
1486 (* Assoc. But have a look too at Mapb.mli; it's better. Or use Hashtbl. *)
1487 (*****************************************************************************)
1489 type ('a
, '
b) assoc
= ('a
* '
b) list
1491 val assoc_to_function
: (* Eq a *) ('a
, '
b) assoc
-> ('a
-> '
b)
1493 val empty_assoc
: ('a
, '
b) assoc
1494 val fold_assoc
: ('a
-> '
b -> 'a
) -> 'a
-> '
b list
-> 'a
1495 val insert_assoc
: 'a
-> 'a list
-> 'a list
1496 val map_assoc
: ('a
-> '
b) -> 'a list
-> '
b list
1497 val filter_assoc
: ('a
-> bool) -> 'a list
-> 'a list
1499 val assoc
: 'a
-> ('a
* '
b) list
-> '
b
1501 val keys
: ('a
* '
b) list
-> 'a list
1502 val lookup
: 'a
-> ('a
* '
b) list
-> '
b
1504 val del_assoc
: 'a
-> ('a
* '
b) list
-> ('a
* '
b) list
1505 val replace_assoc
: 'a
* '
b -> ('a
* '
b) list
-> ('a
* '
b) list
1506 val apply_assoc
: 'a
-> ('
b -> '
b) -> ('a
* '
b) list
-> ('a
* '
b) list
1508 val big_union_assoc
: ('a
-> '
b set
) -> 'a list
-> '
b set
1510 val assoc_reverse
: ('a
* '
b) list
-> ('
b * 'a
) list
1511 val assoc_map
: ('a
* '
b) list
-> ('a
* '
b) list
-> ('a
* 'a
) list
1513 val lookup_list
: 'a
-> ('a
, '
b) assoc list
-> '
b
1514 val lookup_list2
: 'a
-> ('a
, '
b) assoc list
-> '
b * int
1516 val assoc_option
: 'a
-> ('a
, '
b) assoc
-> '
b option
1517 val assoc_with_err_msg
: 'a
-> ('a
, '
b) assoc
-> '
b
1519 val sort_by_val_lowfirst
: ('a
,'
b) assoc
-> ('a
* '
b) list
1520 val sort_by_val_highfirst
: ('a
,'
b) assoc
-> ('a
* '
b) list
1522 val sort_by_key_lowfirst
: (int,'
b) assoc
-> (int * '
b) list
1523 val sort_by_key_highfirst
: (int,'
b) assoc
-> (int * '
b) list
1525 val sortgen_by_key_lowfirst
: ('a
,'
b) assoc
-> ('a
* '
b) list
1526 val sortgen_by_key_highfirst
: ('a
,'
b) assoc
-> ('a
* '
b) list
1528 (*****************************************************************************)
1529 (* Assoc, specialized. *)
1530 (*****************************************************************************)
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
1549 val intmap_to_list
: 'a
IntMap.t
-> (IntMap.key
* 'a
) list
1550 val intmap_string_of_t
: 'a
-> '
b -> string
1554 type key
= int * int
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
1569 val intintmap_to_list
: 'a
IntIntMap.t
-> (IntIntMap.key
* 'a
) list
1570 val intintmap_string_of_t
: 'a
-> '
b -> string
1573 (*****************************************************************************)
1575 (*****************************************************************************)
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
1581 * Note that Hashtbl module use different convention :( the object is
1582 * the first argument, not last as for List or Map.
1585 (* obsolete: can use directly the Hashtbl module *)
1586 val hcreate
: unit -> ('a
, '
b) Hashtbl.t
1587 val hadd
: 'a
* '
b -> ('a
, '
b) Hashtbl.t
-> unit
1588 val hmem
: 'a
-> ('a
, '
b) Hashtbl.t
-> bool
1589 val hfind
: 'a
-> ('a
, '
b) Hashtbl.t
-> '
b
1590 val hreplace
: 'a
* '
b -> ('a
, '
b) Hashtbl.t
-> unit
1591 val hiter
: ('a
-> '
b -> unit) -> ('a
, '
b) Hashtbl.t
-> unit
1592 val hfold
: ('a
-> '
b -> 'c
-> 'c
) -> ('a
, '
b) Hashtbl.t
-> 'c
-> 'c
1593 val hremove
: 'a
-> ('a
, '
b) Hashtbl.t
-> unit
1596 val hfind_default
: 'a
-> (unit -> '
b) -> ('a
, '
b) Hashtbl.t
-> '
b
1597 val hfind_option
: 'a
-> ('a
, '
b) Hashtbl.t
-> '
b option
1598 val hupdate_default
:
1599 'a
-> ('
b -> '
b) -> (unit -> '
b) -> ('a
, '
b) Hashtbl.t
-> unit
1601 val hash_to_list
: ('a
, '
b) Hashtbl.t
-> ('a
* '
b) list
1602 val hash_to_list_unsorted
: ('a
, '
b) Hashtbl.t
-> ('a
* '
b) list
1603 val hash_of_list
: ('a
* '
b) list
-> ('a
, '
b) Hashtbl.t
1606 val hkeys
: ('a
, '
b) Hashtbl.t
-> 'a list
1608 (*****************************************************************************)
1610 (*****************************************************************************)
1612 type 'a hashset
= ('a
, bool) Hashtbl.t
1615 (* common use of hashset, in a hash of hash *)
1616 val hash_hashset_add
: 'a
-> '
b -> ('a
, '
b hashset
) Hashtbl.t
-> unit
1618 val hashset_to_set
:
1619 < fromlist
: ('a
) list
-> 'c
; .. > -> ('a
, '
b) Hashtbl.t
-> 'c
1621 val hashset_to_list
: 'a hashset
-> 'a list
1622 val hashset_of_list
: 'a list
-> 'a hashset
1625 (*****************************************************************************)
1627 (*****************************************************************************)
1629 type 'a stack
= 'a list
1630 val empty_stack
: 'a stack
1631 val push
: 'a
-> 'a stack
-> 'a stack
1632 val top
: 'a stack
-> 'a
1633 val pop
: 'a stack
-> 'a stack
1635 val top_option
: 'a stack
-> 'a
option
1637 val push2
: 'a
-> 'a stack
ref -> unit
1638 val pop2
: 'a stack
ref -> 'a
1640 (*****************************************************************************)
1641 (* Stack with undo/redo support *)
1642 (*****************************************************************************)
1644 type 'a undo_stack
= 'a list
* 'a list
1645 val empty_undo_stack
: 'a undo_stack
1646 val push_undo
: 'a
-> 'a undo_stack
-> 'a undo_stack
1647 val top_undo
: 'a undo_stack
-> 'a
1648 val pop_undo
: 'a undo_stack
-> 'a undo_stack
1649 val redo_undo
: 'a undo_stack
-> 'a undo_stack
1650 val undo_pop
: 'a undo_stack
-> 'a undo_stack
1652 val top_undo_option
: 'a undo_stack
-> 'a
option
1655 (*****************************************************************************)
1657 (*****************************************************************************)
1658 type 'a bintree
= Leaf
of 'a
| Branch
of ('a bintree
* 'a bintree
)
1660 (*****************************************************************************)
1662 (*****************************************************************************)
1664 (* no empty tree, must have one root at least *)
1665 type 'a tree
= Tree
of 'a
* ('a tree
) list
1667 val tree_iter
: ('a
-> unit) -> 'a tree
-> unit
1670 (*****************************************************************************)
1671 (* N-ary tree with updatable childrens *)
1672 (*****************************************************************************)
1674 (* no empty tree, must have one root at least *)
1676 | NodeRef
of 'a
* 'a treeref list
ref
1678 val treeref_node_iter
:
1679 (('a
* 'a treeref list
ref) -> unit) -> 'a treeref
-> unit
1680 val treeref_node_iter_with_parents
:
1681 (('a
* 'a treeref list
ref) -> ('a list
) -> unit) ->
1685 (('a
* 'a treeref list
ref) -> bool) ->
1686 'a treeref
-> 'a treeref
1688 val treeref_children_ref
:
1689 'a treeref
-> 'a treeref list
ref
1691 val find_treeref_with_parents_some
:
1692 ('a
* 'a treeref list
ref -> 'a list
-> 'c
option) ->
1695 val find_multi_treeref_with_parents_some
:
1696 ('a
* 'a treeref list
ref -> 'a list
-> 'c
option) ->
1697 'a treeref
-> 'c list
1700 (* Leaf can seem redundant, but sometimes want to directly see if
1701 * a children is a leaf without looking if the list is empty.
1703 type ('a
, '
b) treeref2
=
1704 | NodeRef2
of 'a
* ('a
, '
b) treeref2 list
ref
1709 (('a
* ('a
, '
b) treeref2 list
ref) -> bool) ->
1710 ('a
, '
b) treeref2
-> ('a
, '
b) treeref2
1712 val treeref_node_iter_with_parents2
:
1713 (('a
* ('a
, '
b) treeref2 list
ref) -> ('a list
) -> unit) ->
1714 ('a
, '
b) treeref2
-> unit
1716 val treeref_node_iter2
:
1717 (('a
* ('a
, '
b) treeref2 list
ref) -> unit) -> ('a
, '
b) treeref2
-> unit
1722 val treeref_children_ref: ('a, 'b) treeref -> ('a, 'b) treeref list ref
1724 val find_treeref_with_parents_some:
1725 ('a * ('a, 'b) treeref list ref -> 'a list -> 'c option) ->
1726 ('a, 'b) treeref -> 'c
1728 val find_multi_treeref_with_parents_some:
1729 ('a * ('a, 'b) treeref list ref -> 'a list -> 'c option) ->
1730 ('a, 'b) treeref -> 'c list
1733 (*****************************************************************************)
1734 (* Graph. But have a look too at Ograph_*.mli; it's better *)
1735 (*****************************************************************************)
1737 type 'a graph
= 'a set
* ('a
* 'a
) set
1739 val add_node
: 'a
-> 'a graph
-> 'a graph
1740 val del_node
: 'a
-> 'a graph
-> 'a graph
1742 val add_arc
: 'a
* 'a
-> 'a graph
-> 'a graph
1743 val del_arc
: 'a
* 'a
-> 'a graph
-> 'a graph
1745 val successors
: 'a
-> 'a graph
-> 'a set
1746 val predecessors
: 'a
-> 'a graph
-> 'a set
1748 val nodes
: 'a graph
-> 'a set
1750 val fold_upward
: ('a
-> '
b -> 'a
) -> '
b set
-> 'a
-> '
b graph
-> 'a
1752 val empty_graph
: 'a list
* '
b list
1755 (*****************************************************************************)
1757 (*****************************************************************************)
1759 (* mostly alias to functions in List *)
1761 val map
: ('a
-> '
b) -> 'a list
-> '
b list
1762 val tail_map
: ('a
-> '
b) -> 'a list
-> '
b list
1763 val filter
: ('a
-> bool) -> 'a list
-> 'a list
1764 val fold
: ('a
-> '
b -> 'a
) -> 'a
-> '
b list
-> 'a
1766 val member
: 'a
-> 'a list
-> bool
1768 val iter
: ('a
-> unit) -> 'a list
-> unit
1770 val find
: ('a
-> bool) -> 'a list
-> 'a
1772 val exists
: ('a
-> bool) -> 'a list
-> bool
1773 val forall
: ('a
-> bool) -> 'a list
-> bool
1775 val big_union
: ('a
-> '
b set
) -> 'a list
-> '
b set
1777 (* same than [] but easier to search for, because [] can also be a pattern *)
1778 val empty_list
: 'a list
1780 val sort
: ('a
-> 'a
-> int) -> 'a list
-> 'a list
1782 val length
: 'a list
-> int
1784 val null
: 'a list
-> bool
1786 val head
: 'a list
-> 'a
1787 val tail
: 'a list
-> 'a list
1789 val is_singleton
: 'a list
-> bool
1799 (*###########################################################################*)
1800 (* And now misc functions *)
1801 (*###########################################################################*)
1803 (*****************************************************************************)
1805 (*****************************************************************************)
1807 (* cf oassocbdb.ml or oassocdbm.ml *)
1809 (*****************************************************************************)
1810 (* GUI (LFS, CComment, otimetracker) *)
1811 (*****************************************************************************)
1813 (* cf ocamlgtk and my gui.ml *)
1816 (*****************************************************************************)
1817 (* Graphics (otimetracker) *)
1818 (*****************************************************************************)
1820 (* cf ocamlgl and my opengl.ml *)
1824 (*****************************************************************************)
1825 (* Geometry (ICFP raytracer) *)
1826 (*****************************************************************************)
1828 type vector
= float * float * float
1833 val dotproduct
: vector
* vector
-> float
1835 val vector_length
: vector
-> float
1837 val minus_point
: point
* point
-> vector
1839 val distance
: point
* point
-> float
1841 val normalise
: vector
-> vector
1843 val mult_coeff
: vector
-> float -> vector
1845 val add_vector
: vector
-> vector
-> vector
1846 val mult_vector
: vector
-> vector
-> vector
1847 val sum_vector
: vector list
-> vector
1850 (*****************************************************************************)
1851 (* Pics (ICFP raytracer) *)
1852 (*****************************************************************************)
1853 type pixel
= int * int * int
1854 val write_ppm
: int -> int -> pixel list
-> filename
-> unit
1855 val test_ppm1
: unit -> unit
1857 (*****************************************************************************)
1859 (*****************************************************************************)
1861 type diff
= Match
| BnotinA
| AnotinB
1862 val diff
: (int -> int -> diff
-> unit) -> string list
* string list
-> unit
1863 val diff2
: (int -> int -> diff
-> unit) -> string * string -> unit
1865 (*****************************************************************************)
1866 (* Parsers (aop-colcombet) *)
1867 (*****************************************************************************)
1869 val parserCommon
: Lexing.lexbuf
-> ('a
-> Lexing.lexbuf
-> '
b) -> 'a
-> '
b
1870 val getDoubleParser
:
1871 ('a
-> Lexing.lexbuf
-> '
b) -> 'a
-> (string -> '
b) * (string -> '
b)
1873 (*****************************************************************************)
1874 (* Parsers (cocci) *)
1875 (*****************************************************************************)
1878 (* Currently lexing.ml does not handle the line number position.
1879 * Even if there is some fields in the lexing structure, they are not
1880 * maintained by the lexing engine :( So the following code does not work:
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
1886 * Hence those functions to overcome the previous limitation.
1897 val fake_parse_info
: parse_info
1898 val string_of_parse_info
: parse_info
-> string
1899 val string_of_parse_info_bis
: parse_info
-> string
1901 (* array[i] will contain the (line x col) of the i char position *)
1902 val full_charpos_to_pos
: filename
-> (int * int) array
1904 (* fill in the line and column field of parse_info that were not set
1905 * during lexing because of limitations of ocamllex. *)
1906 val complete_parse_info
:
1907 filename
-> (int * int) array
-> parse_info
-> parse_info
1909 val full_charpos_to_pos_large
:
1910 filename
-> (int -> (int * int))
1912 val complete_parse_info_large
:
1913 filename
-> (int -> (int * int)) -> parse_info
-> parse_info
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.
1919 val info_from_charpos
: int -> filename
-> (int * int * string)
1921 val error_message
: filename
-> (string * int) -> string
1922 val error_message_short
: filename
-> (string * int) -> string
1924 (* add a 'decalage/shift' argument to handle stuff such as cpp which includes
1925 * files and who can make shift.
1927 val error_messagebis
: filename
-> (string * int) -> int -> string
1929 (*****************************************************************************)
1930 (* Scope managment (cocci) *)
1931 (*****************************************************************************)
1933 (* for example of use, see the code used in coccinelle *)
1934 type ('a
, '
b) scoped_env
= ('a
, '
b) assoc list
1936 val lookup_env
: (* Eq a *) 'a
-> ('a
, '
b) scoped_env
-> '
b
1937 val member_env_key
: 'a
-> ('a
, '
b) scoped_env
-> bool
1939 val new_scope
: ('a
, '
b) scoped_env
ref -> unit
1940 val del_scope
: ('a
, '
b) scoped_env
ref -> unit
1942 val do_in_new_scope
: ('a
, '
b) scoped_env
ref -> (unit -> unit) -> unit
1944 val add_in_scope
: ('a
, '
b) scoped_env
ref -> 'a
* '
b -> unit
1949 (* for example of use, see the code used in coccinelle *)
1950 type ('a
, '
b) scoped_h_env
= {
1951 scoped_h
: ('a
, '
b) Hashtbl.t
;
1952 scoped_list
: ('a
, '
b) assoc list
;
1954 val empty_scoped_h_env
: unit -> ('a
, '
b) scoped_h_env
1955 val clone_scoped_h_env
: ('a
, '
b) scoped_h_env
-> ('a
, '
b) scoped_h_env
1957 val lookup_h_env
: 'a
-> ('a
, '
b) scoped_h_env
-> '
b
1958 val member_h_env_key
: 'a
-> ('a
, '
b) scoped_h_env
-> bool
1960 val new_scope_h
: ('a
, '
b) scoped_h_env
ref -> unit
1961 val del_scope_h
: ('a
, '
b) scoped_h_env
ref -> unit
1962 val clean_scope_h
: ('a
, '
b) scoped_h_env
ref -> unit
1964 val do_in_new_scope_h
: ('a
, '
b) scoped_h_env
ref -> (unit -> unit) -> unit
1966 val add_in_scope_h
: ('a
, '
b) scoped_h_env
ref -> 'a
* '
b -> unit
1968 (*****************************************************************************)
1969 (* Terminal (LFS) *)
1970 (*****************************************************************************)
1972 (* don't forget to call Common_extra.set_link () *)
1974 val _execute_and_show_progress_func
:
1975 (int (* length *) -> ((unit -> unit) -> unit) -> unit) ref
1976 val execute_and_show_progress
:
1977 int (* length *) -> ((unit -> unit) -> unit) -> unit
1979 (*****************************************************************************)
1980 (* Flags and actions *)
1981 (*****************************************************************************)
1983 val cmdline_flags_devel
: unit -> cmdline_options
1984 val cmdline_flags_verbose
: unit -> cmdline_options
1985 val cmdline_flags_other
: unit -> cmdline_options
1987 (*****************************************************************************)
1989 (*****************************************************************************)
1991 val generic_print
: 'a
-> string -> string
1997 method fold
: ('
b -> 'a
-> '
b) -> '
b -> '
b
1998 method view
: 'a list
2001 val typing_sux_test
: unit -> unit