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 pr2
: string -> unit
134 val pr2_no_nl
: string -> unit
135 val pr2_xxxxxxxxxxxxxxxxx
: unit -> unit
137 (* use Dumper.dump *)
138 val pr2_gen
: 'a
-> unit
139 val dump
: 'a
-> string
141 (* see flag: val disable_pr2_once : bool ref *)
142 val _already_printed
: (string, bool) Hashtbl.t
143 val pr2_once
: string -> unit
145 val mk_pr2_wrappers
: bool ref -> (string -> unit) * (string -> unit)
148 val redirect_stdout_stderr
: filename
-> (unit -> unit) -> unit
149 val redirect_stdin
: filename
-> (unit -> unit) -> unit
150 val redirect_stdin_opt
: filename
option -> (unit -> unit) -> unit
152 val with_pr2_to_string
: (unit -> unit) -> string list
154 val fprintf
: out_channel
-> ('a
, out_channel
, unit) format
-> 'a
155 val printf
: ('a
, out_channel
, unit) format
-> 'a
156 val eprintf
: ('a
, out_channel
, unit) format
-> 'a
157 val sprintf
: ('a
, unit, string) format
-> 'a
160 val spf
: ('a
, unit, string) format
-> 'a
162 (* default = stderr *)
163 val _chan
: out_channel
ref
164 (* generate & use a /tmp/debugml-xxx file *)
165 val start_log_file
: unit -> unit
167 (* see flag: val verbose_level : int ref *)
168 val log
: string -> unit
169 val log2
: string -> unit
170 val log3
: string -> unit
171 val log4
: string -> unit
173 val if_log
: (unit -> unit) -> unit
174 val if_log2
: (unit -> unit) -> unit
175 val if_log3
: (unit -> unit) -> unit
176 val if_log4
: (unit -> unit) -> unit
178 val pause
: unit -> unit
180 (* was used by fix_caml *)
181 val _trace_var
: int ref
182 val add_var
: unit -> unit
183 val dec_var
: unit -> unit
184 val get_var
: unit -> int
186 val print_n
: int -> string -> unit
187 val printerr_n
: int -> string -> unit
189 val _debug
: bool ref
190 val debugon
: unit -> unit
191 val debugoff
: unit -> unit
192 val debug
: (unit -> unit) -> unit
194 (* see flag: val debugger : bool ref *)
197 (*****************************************************************************)
198 (* Profiling (cpu/mem) *)
199 (*****************************************************************************)
201 val get_mem
: unit -> unit
202 val memory_stat
: unit -> string
204 val timenow
: unit -> string
206 val _count1
: int ref
207 val _count2
: int ref
208 val _count3
: int ref
209 val _count4
: int ref
210 val _count5
: int ref
212 val count1
: unit -> unit
213 val count2
: unit -> unit
214 val count3
: unit -> unit
215 val count4
: unit -> unit
216 val count5
: unit -> unit
217 val profile_diagnostic_basic
: unit -> string
219 val time_func
: (unit -> 'a
) -> 'a
223 (* see flag: type prof = PALL | PNONE | PSOME of string list *)
224 (* see flag: val profile : prof ref *)
226 val _profile_table
: (string, (float ref * int ref)) Hashtbl.t
ref
227 val profile_code
: string -> (unit -> 'a
) -> 'a
228 val profile_diagnostic
: unit -> string
230 val profile_code_exclusif
: string -> (unit -> 'a
) -> 'a
231 val profile_code_inside_exclusif_ok
: string -> (unit -> 'a
) -> 'a
233 val report_if_take_time
: int -> string -> (unit -> 'a
) -> 'a
235 (* similar to profile_code but print some information during execution too *)
236 val profile_code2
: string -> (unit -> 'a
) -> 'a
238 (*****************************************************************************)
240 (*****************************************************************************)
242 val example
: bool -> unit
243 (* generate failwith <string> when pb *)
244 val example2
: string -> bool -> unit
245 (* use Dumper to report when pb *)
246 val assert_equal
: 'a
-> 'a
-> unit
248 val _list_bool
: (string * bool) list
ref
249 val example3
: string -> bool -> unit
250 val test_all
: unit -> unit
253 (* regression testing *)
254 type score_result
= Ok
| Pb
of string
255 type score
= (string (* usually a filename *), score_result
) Hashtbl.t
256 type score_list
= (string (* usually a filename *) * score_result
) list
257 val empty_score
: unit -> score
258 val regression_testing
:
259 score
-> filename
(* old score file on disk (usually in /tmp) *) -> unit
260 val regression_testing_vs
: score
-> score
-> score
261 val total_scores
: score
-> int (* good *) * int (* total *)
262 val print_score
: score
-> unit
263 val print_total_score
: score
-> unit
266 (* quickcheck spirit *)
267 type 'a gen
= unit -> 'a
269 (* quickcheck random generators *)
271 val lg
: 'a gen
-> 'a list gen
272 val pg
: 'a gen
-> 'b gen
-> ('a
* 'b
) gen
276 val oneofl
: 'a list
-> 'a gen
277 val oneof
: 'a gen list
-> 'a gen
278 val always
: 'a
-> 'a gen
279 val frequency
: (int * 'a gen
) list
-> 'a gen
280 val frequencyl
: (int * 'a
) list
-> 'a gen
282 val laws
: string -> ('a
-> bool) -> 'a gen
-> 'a
option
285 * let b = laws "unit" (fun x -> reverse [x] = [x]) ig
288 val statistic_number
: 'a list
-> (int * 'a
) list
289 val statistic
: 'a list
-> (int * 'a
) list
292 string -> ('a
-> bool * '
b) -> 'a gen
-> 'a
option * (int * '
b) list
294 (*****************************************************************************)
296 (*****************************************************************************)
298 (* just wrappers around Marshal *)
299 val get_value
: filename
-> 'a
300 val read_value
: filename
-> 'a
(* alias *)
301 val write_value
: 'a
-> filename
-> unit
302 val write_back
: ('a
-> '
b) -> filename
-> unit
304 (* wrappers that also use profile_code *)
305 val marshal__to_string
: 'a
-> Marshal.extern_flags list
-> string
306 val marshal__from_string
: string -> int -> 'a
308 (*****************************************************************************)
310 (*****************************************************************************)
311 val _counter
: int ref
312 val _counter2
: int ref
313 val _counter3
: int ref
315 val counter
: unit -> int
316 val counter2
: unit -> int
317 val counter3
: unit -> int
321 (*****************************************************************************)
322 (* String_of and (pretty) printing *)
323 (*****************************************************************************)
325 val string_of_string
: (string -> string) -> string
326 val string_of_list
: ('a
-> string) -> 'a list
-> string
327 val string_of_unit
: unit -> string
328 val string_of_array
: ('a
-> string) -> 'a array
-> string
329 val string_of_option
: ('a
-> string) -> 'a
option -> string
331 val print_bool
: bool -> unit
332 val print_option
: ('a
-> '
b) -> 'a
option -> unit
333 val print_list
: ('a
-> '
b) -> 'a list
-> unit
334 val print_between
: (unit -> unit) -> ('a
-> unit) -> 'a list
-> unit
336 (* use Format internally *)
337 val pp_do_in_box
: (unit -> unit) -> unit
338 val pp_f_in_box
: (unit -> 'a
) -> 'a
339 val pp_do_in_zero_box
: (unit -> unit) -> unit
340 val pp
: string -> unit
342 (* convert something printed using Format to print into a string *)
343 val format_to_string
: (unit -> unit) (* printer *) -> string
345 (* works with _tab_level_print enabling to mix some calls to pp, pr2
346 * and indent_do to sometimes use advanced indentation pretty printing
347 * (with the pp* functions) and sometimes explicit and simple indendation
348 * printing (with pr* and indent_do) *)
349 val adjust_pp_with_indent
: (unit -> unit) -> unit
350 val adjust_pp_with_indent_and_header
: string -> (unit -> unit) -> unit
353 val mk_str_func_of_assoc_conv
:
354 ('a
* string) list
-> (string -> 'a
) * ('a
-> string)
356 (*****************************************************************************)
358 (*****************************************************************************)
360 (* was working with my macro.ml4 *)
361 val macro_expand
: string -> unit
363 (*****************************************************************************)
364 (* Composition/Control *)
365 (*****************************************************************************)
367 val ( +> ) : 'a
-> ('a
-> '
b) -> '
b
368 val ( +!> ) : 'a
ref -> ('a
-> 'a
) -> unit
369 val ( $
) : ('a
-> '
b) -> ('
b -> 'c
) -> 'a
-> 'c
371 val compose
: ('a
-> '
b) -> ('c
-> 'a
) -> 'c
-> '
b
372 val flip
: ('a
-> '
b -> 'c
) -> '
b -> 'a
-> 'c
374 val curry
: ('a
* '
b -> 'c
) -> 'a
-> '
b -> 'c
375 val uncurry
: ('a
-> '
b -> 'c
) -> 'a
* '
b -> 'c
378 val do_nothing
: unit -> unit
380 val forever
: (unit -> unit) -> unit
382 val applyn
: int -> ('a
-> 'a
) -> 'a
-> 'a
384 class ['a
] shared_variable_hook
:
387 val mutable data
: 'a
388 val mutable registered
: (unit -> unit) list
390 method modify
: ('a
-> 'a
) -> unit
391 method register
: (unit -> unit) -> unit
392 method set
: 'a
-> unit
395 val fixpoint
: ('a
-> 'a
) -> 'a
-> 'a
396 val fixpoint_for_object
: ((< equal
: 'a
-> bool; .. > as 'a
) -> 'a
) -> 'a
-> 'a
398 val add_hook
: ('a
-> ('a
-> '
b) -> '
b) ref -> ('a
-> ('a
-> '
b) -> '
b) -> unit
399 val add_hook_action
: ('a
-> unit) -> ('a
-> unit) list
ref -> unit
400 val run_hooks_action
: 'a
-> ('a
-> unit) list
ref -> unit
402 type 'a mylazy
= (unit -> 'a
)
405 val save_excursion
: 'a
ref -> (unit -> '
b) -> '
b
406 val save_excursion_and_disable
: bool ref -> (unit -> '
b) -> '
b
407 val save_excursion_and_enable
: bool ref -> (unit -> '
b) -> '
b
410 val unwind_protect
: (unit -> 'a
) -> (exn
-> '
b) -> 'a
413 val finalize
: (unit -> 'a
) -> (unit -> '
b) -> 'a
415 val memoized
: ('a
, '
b) Hashtbl.t
-> 'a
-> (unit -> '
b) -> '
b
417 val cache_in_ref
: 'a
option ref -> (unit -> 'a
) -> 'a
420 (* take file from which computation is done, an extension, and the function
421 * and will compute the function only once and then save result in
424 val cache_computation
:
425 ?verbose
:bool -> ?use_cache
:bool -> filename
-> string (* extension *) ->
428 (* a more robust version where the client describes the dependencies of the
429 * computation so it will relaunch the computation in 'f' if needed.
431 val cache_computation_robust
:
433 string (* extension for marshalled object *) ->
434 (filename list
* 'x
) ->
435 string (* extension for marshalled dependencies *) ->
441 val once
: ('a
-> unit) -> ('a
-> unit)
443 val before_leaving
: ('a
-> unit) -> 'a
-> 'a
445 (* do some finalize, signal handling, unix exit conversion, etc *)
446 val main_boilerplate
: (unit -> unit) -> unit
449 (* cf also the timeout function below that are control related too *)
452 (*****************************************************************************)
454 (*****************************************************************************)
456 (* how ensure really atomic file creation ? hehe :) *)
457 exception FileAlreadyLocked
458 val acquire_file_lock
: filename
-> unit
459 val release_file_lock
: filename
-> unit
461 (*****************************************************************************)
462 (* Error managment *)
463 (*****************************************************************************)
469 exception Multi_found
471 exception WrongFormat
of string
474 val internal_error
: string -> 'a
475 val myassert
: bool -> unit
476 val warning
: string -> 'a
-> 'a
477 val error_cant_have
: 'a
-> '
b
479 val exn_to_s
: exn
-> string
481 val string_of_exn
: exn
-> string
483 type error
= Error
of string
488 (*****************************************************************************)
490 (*****************************************************************************)
492 val check_stack_size
: int -> unit
493 val check_stack_nbfiles
: int -> unit
495 (* internally common.ml set Gc. parameters *)
496 val _init_gc_stack
: unit
498 (*****************************************************************************)
499 (* Arguments and command line *)
500 (*****************************************************************************)
502 type arg_spec_full
= Arg.key
* Arg.spec
* Arg.doc
503 type cmdline_options
= arg_spec_full list
506 type options_with_title
= string * string * arg_spec_full list
507 type cmdline_sections
= options_with_title list
510 (* A wrapper around Arg modules that have more logical argument order,
511 * and returns the remaining args.
514 cmdline_options
-> Arg.usage_msg
-> string array
-> string list
516 (* Another wrapper that does Arg.align automatically *)
517 val usage
: Arg.usage_msg
-> cmdline_options
-> unit
521 (* Work with the options_with_title type way to organize a long
522 * list of command line switches.
525 Arg.usage_msg
-> short_opt
:cmdline_options
-> unit
527 Arg.usage_msg
-> short_opt
:cmdline_options
-> long_opt
:cmdline_sections
->
530 (* With the options_with_title way, we don't want the default -help and --help
531 * so need adapter of Arg module, not just wrapper.
533 val arg_align2
: cmdline_options
-> cmdline_options
535 cmdline_options
-> Arg.usage_msg
-> (unit -> unit) (* short_usage func *) ->
542 (* The action lib. Useful to debug supart of your system. cf some of
543 * my main.ml for example of use. *)
544 type flag_spec
= Arg.key
* Arg.spec
* Arg.doc
545 type action_spec
= Arg.key
* Arg.doc
* action_func
546 and action_func
= (string list
-> unit)
548 type cmdline_actions
= action_spec list
549 exception WrongNumberOfArguments
551 val mk_action_0_arg
: (unit -> unit) -> action_func
552 val mk_action_1_arg
: (string -> unit) -> action_func
553 val mk_action_2_arg
: (string -> string -> unit) -> action_func
554 val mk_action_3_arg
: (string -> string -> string -> unit) -> action_func
556 val mk_action_n_arg
: (string list
-> unit) -> action_func
558 val options_of_actions
:
559 string ref (* the action ref *) -> cmdline_actions
-> cmdline_options
561 cmdline_actions
-> Arg.key list
563 Arg.key
-> string list
(* args *) -> cmdline_actions
-> unit
565 (*****************************************************************************)
567 (*****************************************************************************)
569 (* Using the generic (=) is tempting, but it backfires, so better avoid it *)
571 (* To infer all the code that use an equal, and that should be
572 * transformed, is not that easy, because (=) is used by many
573 * functions, such as List.find, List.mem, and so on. The strategy to find
574 * them is to turn what you were previously using into a function, because
575 * (=) return an exception when applied to a function, then you simply
576 * use ocamldebug to detect where the code has to be transformed by
577 * finding where the exception was launched from.
580 val (=|=) : int -> int -> bool
581 val (=<=) : char
-> char
-> bool
582 val (=$
=) : string -> string -> bool
583 val (=:=) : bool -> bool -> bool
585 val (=*=): 'a
-> 'a
-> bool
587 (* if want to restrict the use of '=', uncomment this:
589 * val (=): unit -> unit -> bool
591 * But it will not forbid you to use caml functions like List.find, List.mem
592 * which internaly use this convenient but evolution-unfriendly (=)
597 (*###########################################################################*)
598 (* And now basic types *)
599 (*###########################################################################*)
601 (*****************************************************************************)
603 (*****************************************************************************)
605 val ( ||| ) : 'a
-> 'a
-> 'a
606 val ( ==> ) : bool -> bool -> bool
607 val xor
: 'a
-> 'a
-> bool
611 (*****************************************************************************)
613 (*****************************************************************************)
615 val string_of_char
: char
-> string
616 val string_of_chars
: char list
-> string
618 val is_single
: char
-> bool
619 val is_symbol
: char
-> bool
620 val is_space
: char
-> bool
621 val is_upper
: char
-> bool
622 val is_lower
: char
-> bool
623 val is_alpha
: char
-> bool
624 val is_digit
: char
-> bool
626 val cbetween
: char
-> char
-> char
-> bool
628 (*****************************************************************************)
630 (*****************************************************************************)
632 val ( /! ) : int -> int -> int
634 val do_n
: int -> (unit -> unit) -> unit
635 val foldn
: ('a
-> int -> 'a
) -> 'a
-> int -> 'a
641 val deg_to_rad
: float -> float
643 val clampf
: float -> float
645 val square
: float -> float
646 val power
: int -> int -> int
648 val between
: 'a
-> 'a
-> 'a
-> bool
649 val between_strict
: int -> int -> int -> bool
650 val bitrange
: int -> int -> bool
652 val prime1
: int -> int option
653 val prime
: int -> int option
655 val sum
: int list
-> int
656 val product
: int list
-> int
658 val decompose
: int -> int list
660 val mysquare
: int -> int
661 val sqr
: float -> float
663 type compare
= Equal
| Inf
| Sup
664 val ( <=> ) : 'a
-> 'a
-> compare
665 val ( <==> ) : 'a
-> 'a
-> int
669 val int_of_stringchar
: string -> int
670 val int_of_base
: string -> int -> int
671 val int_of_stringbits
: string -> int
672 val int_of_octal
: string -> int
673 val int_of_all
: string -> int
675 (* useful but sometimes when want grep for all places where do modif,
676 * easier to have just code using ':=' and '<-' to do some modifications.
677 * In the same way avoid using {contents = xxx} to build some ref.
679 val ( += ) : int ref -> int -> unit
680 val ( -= ) : int ref -> int -> unit
682 val pourcent
: int -> int -> int
683 val pourcent_float
: int -> int -> float
684 val pourcent_float_of_floats
: float -> float -> float
686 val pourcent_good_bad
: int -> int -> int
687 val pourcent_good_bad_float
: int -> int -> float
689 type 'a max_with_elem
= int ref * 'a
ref
690 val update_max_with_elem
:
691 'a max_with_elem
-> is_better
:(int -> int ref -> bool) -> int * 'a
-> unit
692 (*****************************************************************************)
693 (* Numeric/overloading *)
694 (*****************************************************************************)
698 (('a
-> 'a
-> 'a
) * ('a
-> 'a
-> 'a
) * ('a
-> 'a
-> 'a
) * ('a
-> 'a
))
699 val add
: 'a numdict
-> 'a
-> 'a
-> 'a
700 val mul
: 'a numdict
-> 'a
-> 'a
-> 'a
701 val div
: 'a numdict
-> 'a
-> 'a
-> 'a
702 val neg
: 'a numdict
-> 'a
-> 'a
704 val numd_int
: int numdict
705 val numd_float
: float numdict
707 val testd
: 'a numdict
-> 'a
-> 'a
710 module ArithFloatInfix
: sig
711 val (+) : float -> float -> float
712 val (-) : float -> float -> float
713 val (/) : float -> float -> float
714 val ( * ) : float -> float -> float
717 val (+..) : int -> int -> int
718 val (-..) : int -> int -> int
719 val (/..) : int -> int -> int
720 val ( *..) : int -> int -> int
722 val (+=) : float ref -> float -> unit
725 (*****************************************************************************)
727 (*****************************************************************************)
729 val _init_random
: unit
730 val random_list
: 'a list
-> 'a
731 val randomize_list
: 'a list
-> 'a list
732 val random_subset_of_list
: int -> 'a list
-> 'a list
735 (*****************************************************************************)
737 (*****************************************************************************)
739 type 'a pair
= 'a
* 'a
740 type 'a triple
= 'a
* 'a
* 'a
742 val fst3
: 'a
* '
b * 'c
-> 'a
743 val snd3
: 'a
* '
b * 'c
-> '
b
744 val thd3
: 'a
* '
b * 'c
-> 'c
746 val sndthd
: 'a
* '
b * 'c
-> '
b * 'c
748 val map_fst
: ('a
-> '
b) -> 'a
* 'c
-> '
b * 'c
749 val map_snd
: ('a
-> '
b) -> 'c
* 'a
-> 'c
* '
b
751 val pair
: ('a
-> '
b) -> 'a
* 'a
-> '
b * '
b
753 val snd
: 'a
* '
b -> '
b (* alias *)
754 val fst
: 'a
* '
b -> 'a
(* alias *)
756 val double
: 'a
-> 'a
* 'a
757 val swap
: 'a
* '
b -> '
b * 'a
759 (* maybe a sign of bad programming if use those functions :) *)
760 val tuple_of_list1
: 'a list
-> 'a
761 val tuple_of_list2
: 'a list
-> 'a
* 'a
762 val tuple_of_list3
: 'a list
-> 'a
* 'a
* 'a
763 val tuple_of_list4
: 'a list
-> 'a
* 'a
* 'a
* 'a
764 val tuple_of_list5
: 'a list
-> 'a
* 'a
* 'a
* 'a
* 'a
765 val tuple_of_list6
: 'a list
-> 'a
* 'a
* 'a
* 'a
* 'a
* 'a
767 (*****************************************************************************)
769 (*****************************************************************************)
771 type ('a
, '
b) either
= Left
of 'a
| Right
of '
b
772 type ('a
, '
b, 'c
) either3
= Left3
of 'a
| Middle3
of '
b | Right3
of 'c
774 val just
: 'a
option -> 'a
775 val some
: 'a
option -> 'a
(* alias *)
777 val fmap
: ('a
-> '
b) -> 'a
option -> '
b option
778 val map_option
: ('a
-> '
b) -> 'a
option -> '
b option (* alias *)
780 val do_option
: ('a
-> unit) -> 'a
option -> unit
782 val optionise
: (unit -> 'a
) -> 'a
option
784 val some_or
: 'a
option -> 'a
-> 'a
786 val partition_either
:
787 ('a
-> ('
b, 'c
) either
) -> 'a list
-> '
b list
* 'c list
789 val filter_some
: 'a
option list
-> 'a list
790 val map_filter
: ('a
-> '
b option) -> 'a list
-> '
b list
791 val find_some
: ('a
-> '
b option) -> 'a list
-> '
b
793 val list_to_single_or_exn
: 'a list
-> 'a
795 (*****************************************************************************)
797 (*****************************************************************************)
798 type bool3
= True3
| False3
| TrueFalsePb3
of string
801 (*****************************************************************************)
803 (*****************************************************************************)
805 val slength
: string -> int (* alias *)
806 val concat
: string -> string list
-> string (* alias *)
808 val i_to_s
: int -> string
809 val s_to_i
: string -> int
811 (* strings take space in memory. Better when can share the space used by
814 val _shareds
: (string, string) Hashtbl.t
815 val shared_string
: string -> string
817 val chop
: string -> string
818 val chop_dirsymbol
: string -> string
820 val ( <!!> ) : string -> int * int -> string
821 val ( <!> ) : string -> int -> char
823 val take_string
: int -> string -> string
824 val take_string_safe
: int -> string -> string
826 val split_on_char
: char
-> string -> string list
828 val lowercase
: string -> string
830 val quote
: string -> string
832 val null_string
: string -> bool
833 val is_blank_string
: string -> bool
834 val is_string_prefix
: string -> string -> bool
837 val plural
: int -> string -> string
839 val showCodeHex
: int list
-> unit
841 val size_mo_ko
: int -> string
842 val size_ko
: int -> string
844 val edit_distance
: string -> string -> int
846 val md5sum_of_string
: string -> string
848 (*****************************************************************************)
850 (*****************************************************************************)
852 val regexp_alpha
: Str.regexp
853 val regexp_word
: Str.regexp
855 val _memo_compiled_regexp
: (string, Str.regexp
) Hashtbl.t
856 val ( =~
) : string -> string -> bool
857 val ( ==~
) : string -> Str.regexp
-> bool
861 val regexp_match
: string -> string -> string
863 val matched
: int -> string -> string
865 (* not yet politypic functions in ocaml *)
866 val matched1
: string -> string
867 val matched2
: string -> string * string
868 val matched3
: string -> string * string * string
869 val matched4
: string -> string * string * string * string
870 val matched5
: string -> string * string * string * string * string
871 val matched6
: string -> string * string * string * string * string * string
872 val matched7
: string -> string * string * string * string * string * string * string
874 val string_match_substring
: Str.regexp
-> string -> bool
876 val split
: string (* sep regexp *) -> string -> string list
877 val join
: string (* sep *) -> string list
-> string
879 val split_list_regexp
: string -> string list
-> (string * string list
) list
881 val all_match
: string (* regexp *) -> string -> string list
882 val global_replace_regexp
:
883 string (* regexp *) -> (string -> string) -> string -> string
885 val regular_words
: string -> string list
886 val contain_regular_word
: string -> bool
888 (*****************************************************************************)
890 (*****************************************************************************)
892 (* now at beginning of this file: type filename = string *)
893 val dirname
: string -> string
894 val basename
: string -> string
896 val filesuffix
: filename
-> string
897 val fileprefix
: filename
-> string
899 val adjust_ext_if_needed
: filename
-> string -> filename
901 (* db for dir, base *)
902 val db_of_filename
: filename
-> (string * filename
)
903 val filename_of_db
: (string * filename
) -> filename
905 (* dbe for dir, base, ext *)
906 val dbe_of_filename
: filename
-> string * string * string
907 val dbe_of_filename_nodot
: filename
-> string * string * string
908 (* Left (d,b,e) | Right (d,b) if file has no extension *)
909 val dbe_of_filename_safe
:
910 filename
-> (string * string * string, string * string) either
912 val filename_of_dbe
: string * string * string -> filename
914 (* ex: replace_ext "toto.c" "c" "var" *)
915 val replace_ext
: filename
-> string -> string -> filename
917 (* remove the ., .. *)
918 val normalize_path
: filename
-> filename
920 val relative_to_absolute
: filename
-> filename
922 val is_relative
: filename
-> bool
923 val is_absolute
: filename
-> bool
925 val filename_without_leading_path
: string -> filename
-> filename
927 (*****************************************************************************)
929 (*****************************************************************************)
935 (*****************************************************************************)
937 (*****************************************************************************)
939 (* can also use ocamlcalendar, but heavier, use many modules ... *)
942 | Jan
| Feb
| Mar
| Apr
| May
| Jun
943 | Jul
| Aug
| Sep
| Oct
| Nov
| Dec
944 type year
= Year
of int
945 type day
= Day
of int
947 type date_dmy
= DMY
of day
* month
* year
949 type hour
= Hour
of int
950 type minute
= Min
of int
951 type second
= Sec
of int
953 type time_hms
= HMS
of hour
* minute
* second
955 type full_date
= date_dmy
* time_hms
959 type days
= Days
of int
961 type time_dmy
= TimeDMY
of day
* month
* year
965 type float_time
= float
968 val mk_date_dmy
: int -> int -> int -> date_dmy
971 val check_date_dmy
: date_dmy
-> unit
972 val check_time_dmy
: time_dmy
-> unit
973 val check_time_hms
: time_hms
-> unit
975 val int_to_month
: int -> string
976 val int_of_month
: month
-> int
977 val month_of_string
: string -> month
978 val month_of_string_long
: string -> month
979 val string_of_month
: month
-> string
981 val string_of_date_dmy
: date_dmy
-> string
982 val string_of_unix_time
: ?langage
:langage
-> Unix.tm
-> string
983 val short_string_of_unix_time
: ?langage
:langage
-> Unix.tm
-> string
984 val string_of_floattime
: ?langage
:langage
-> float_time
-> string
985 val short_string_of_floattime
: ?langage
:langage
-> float_time
-> string
987 val floattime_of_string
: string -> float_time
989 val dmy_to_unixtime
: date_dmy
-> float_time
* Unix.tm
990 val unixtime_to_dmy
: Unix.tm
-> date_dmy
991 val unixtime_to_floattime
: Unix.tm
-> float_time
992 val floattime_to_unixtime
: float_time
-> Unix.tm
994 val sec_to_days
: int -> string
995 val sec_to_hours
: int -> string
997 val today
: unit -> float_time
998 val yesterday
: unit -> float_time
999 val tomorrow
: unit -> float_time
1001 val lastweek
: unit -> float_time
1002 val lastmonth
: unit -> float_time
1004 val week_before
: float_time
-> float_time
1005 val month_before
: float_time
-> float_time
1006 val week_after
: float_time
-> float_time
1008 val days_in_week_of_day
: float_time
-> float_time list
1010 val first_day_in_week_of_day
: float_time
-> float_time
1011 val last_day_in_week_of_day
: float_time
-> float_time
1013 val day_secs
: float_time
1015 val rough_days_since_jesus
: date_dmy
-> days
1016 val rough_days_between_dates
: date_dmy
-> date_dmy
-> days
1018 val string_of_unix_time_lfs
: Unix.tm
-> string
1020 val is_more_recent
: date_dmy
-> date_dmy
-> bool
1021 val max_dmy
: date_dmy
-> date_dmy
-> date_dmy
1022 val min_dmy
: date_dmy
-> date_dmy
-> date_dmy
1023 val maximum_dmy
: date_dmy list
-> date_dmy
1024 val minimum_dmy
: date_dmy list
-> date_dmy
1026 (*****************************************************************************)
1027 (* Lines/Words/Strings *)
1028 (*****************************************************************************)
1030 val list_of_string
: string -> char list
1032 val lines
: string -> string list
1033 val unlines
: string list
-> string
1035 val words
: string -> string list
1036 val unwords
: string list
-> string
1038 val split_space
: string -> string list
1040 val lines_with_nl
: string -> string list
1042 val nblines
: string -> int
1044 (*****************************************************************************)
1046 (*****************************************************************************)
1047 val cat
: filename
-> string list
1048 val cat_orig
: filename
-> string list
1049 val cat_array
: filename
-> string array
1051 val uncat
: string list
-> filename
-> unit
1053 val interpolate
: string -> string list
1055 val echo
: string -> string
1057 val usleep
: int -> unit
1059 val process_output_to_list
: string -> string list
1060 val cmd_to_list
: string -> string list
(* alias *)
1061 val cmd_to_list_and_status
: string -> string list
* Unix.process_status
1063 val command2
: string -> unit
1064 val _batch_mode
: bool ref
1065 val command2_y_or_no
: string -> bool
1066 val command2_y_or_no_exit_if_no
: string -> unit
1068 val do_in_fork
: (unit -> unit) -> int
1070 val mkdir
: ?mode
:Unix.file_perm
-> string -> unit
1072 val read_file
: filename
-> string
1073 val write_file
: file
:filename
-> string -> unit
1075 val filesize
: filename
-> int
1076 val filemtime
: filename
-> float
1078 val nblines_file
: filename
-> int
1080 val lfile_exists
: filename
-> bool
1081 val is_directory
: filename
-> bool
1083 val capsule_unix
: ('a
-> unit) -> 'a
-> unit
1085 val readdir_to_kind_list
: string -> Unix.file_kind
-> string list
1086 val readdir_to_dir_list
: string -> string list
1087 val readdir_to_file_list
: string -> string list
1088 val readdir_to_link_list
: string -> string list
1089 val readdir_to_dir_size_list
: string -> (string * int) list
1091 val glob
: string -> filename list
1092 val files_of_dir_or_files
:
1093 string (* ext *) -> string list
-> filename list
1094 val files_of_dir_or_files_no_vcs
:
1095 string (* ext *) -> string list
-> filename list
1096 (* use a post filter =~ for the ext filtering *)
1097 val files_of_dir_or_files_no_vcs_post_filter
:
1098 string (* regexp *) -> string list
-> filename list
1101 val sanity_check_files_and_adjust
:
1102 string (* ext *) -> string list
-> filename list
1105 type rwx
= [ `R
| `W
| `X
] list
1106 val file_perm_of
: u
:rwx
-> g
:rwx
-> o
:rwx
-> Unix.file_perm
1108 val has_env
: string -> bool
1110 (* scheme spirit. do a finalize so no leak. *)
1111 val with_open_outfile
:
1112 filename
-> ((string -> unit) * out_channel
-> 'a
) -> 'a
1113 val with_open_infile
:
1114 filename
-> (in_channel
-> 'a
) -> 'a
1115 val with_open_outfile_append
:
1116 filename
-> ((string -> unit) * out_channel
-> 'a
) -> 'a
1118 val with_open_stringbuf
:
1119 (((string -> unit) * Buffer.t
) -> unit) -> string
1123 (* subtil: have to make sure that Timeout is not intercepted before here. So
1124 * avoid exn handler such as try (...) with _ -> cos Timeout will not bubble up
1125 * enough. In such case, add a case before such as
1126 * with Timeout -> raise Timeout | _ -> ...
1128 * The same is true for UnixExit (see below).
1130 val timeout_function
: int -> (unit -> 'a
) -> 'a
1132 val timeout_function_opt
: int option -> (unit -> 'a
) -> 'a
1135 (* creation of /tmp files, a la gcc
1136 * ex: new_temp_file "cocci" ".c" will give "/tmp/cocci-3252-434465.c"
1138 val _temp_files_created
: string list
ref
1139 (* see flag: val save_tmp_files : bool ref *)
1140 val new_temp_file
: string (* prefix *) -> string (* suffix *) -> filename
1141 val erase_temp_files
: unit -> unit
1143 (* If the user use some exit 0 in his code, then no one can intercept this
1144 * exit and do something before exiting. There is exn handler for exit 0
1145 * so better never use exit 0 but instead use an exception and just at
1146 * the very toplevel transform this exn in a unix exit code.
1148 * subtil: same problem than with Timeout. Do not intercept such exception
1149 * with some blind try (...) with _ -> ...
1151 exception UnixExit
of int
1152 val exn_to_real_unixexit
: (unit -> 'a
) -> 'a
1161 (*###########################################################################*)
1162 (* And now collection-like types. See also ocollection.mli *)
1163 (*###########################################################################*)
1165 (*****************************************************************************)
1167 (*****************************************************************************)
1170 (* tail recursive efficient map (but that also reverse the element!) *)
1171 val map_eff_rev
: ('a
-> '
b) -> 'a list
-> '
b list
1172 (* tail recursive efficient map, use accumulator *)
1173 val acc_map
: ('a
-> '
b) -> 'a list
-> '
b list
1176 val zip
: 'a list
-> '
b list
-> ('a
* '
b) list
1177 val zip_safe
: 'a list
-> '
b list
-> ('a
* '
b) list
1178 val unzip
: ('a
* '
b) list
-> 'a list
* '
b list
1180 val take
: int -> 'a list
-> 'a list
1181 val take_safe
: int -> 'a list
-> 'a list
1182 val take_until
: ('a
-> bool) -> 'a list
-> 'a list
1183 val take_while
: ('a
-> bool) -> 'a list
-> 'a list
1185 val drop
: int -> 'a list
-> 'a list
1186 val drop_while
: ('a
-> bool) -> 'a list
-> 'a list
1187 val drop_until
: ('a
-> bool) -> 'a list
-> 'a list
1189 val span
: ('a
-> bool) -> 'a list
-> 'a list
* 'a list
1191 val skip_until
: ('a list
-> bool) -> 'a list
-> 'a list
1192 val skipfirst
: (* Eq a *) 'a
-> 'a list
-> 'a list
1194 (* cf also List.partition *)
1195 val fpartition
: ('a
-> '
b option) -> 'a list
-> '
b list
* 'a list
1197 val groupBy
: ('a
-> 'a
-> bool) -> 'a list
-> 'a list list
1198 val exclude_but_keep_attached
: ('a
-> bool) -> 'a list
-> ('a
* 'a list
) list
1199 val group_by_post
: ('a
-> bool) -> 'a list
-> ('a list
* 'a
) list
* 'a list
1200 val group_by_pre
: ('a
-> bool) -> 'a list
-> 'a list
* ('a
* 'a list
) list
1201 val group_by_mapped_key
: ('a
-> '
b) -> 'a list
-> ('
b * 'a list
) list
1203 (* Use hash internally to not be in O(n2). If you want to use it on a
1204 * simple list, then first do a List.map to generate a key, for instance the
1205 * first char of the element, and then use this function.
1207 val group_assoc_bykey_eff
: ('a
* '
b) list
-> ('a
* '
b list
) list
1209 val splitAt
: int -> 'a list
-> 'a list
* 'a list
1211 val split_when
: ('a
-> bool) -> 'a list
-> 'a list
* 'a
* 'a list
1212 val split_gen_when
: ('a list
-> 'a list
option) -> 'a list
-> 'a list list
1214 val pack
: int -> 'a list
-> 'a list list
1217 val enum
: int -> int -> int list
1218 val repeat
: 'a
-> int -> 'a list
1219 val generate
: int -> 'a
-> 'a list
1223 val index_list
: 'a list
-> ('a
* int) list
1224 val index_list_1
: 'a list
-> ('a
* int) list
1225 val index_list_and_total
: 'a list
-> ('a
* int * int) list
1227 val iter_index
: ('a
-> int -> '
b) -> 'a list
-> unit
1228 val map_index
: ('a
-> int -> '
b) -> 'a list
-> '
b list
1229 val filter_index
: (int -> 'a
-> bool) -> 'a list
-> 'a list
1230 val fold_left_with_index
: ('a
-> '
b -> int -> 'a
) -> 'a
-> '
b list
-> 'a
1232 val nth
: 'a list
-> int -> 'a
1233 val rang
: (* Eq a *) 'a
-> 'a list
-> int
1235 val last_n
: int -> 'a list
-> 'a list
1239 val snoc
: 'a
-> 'a list
-> 'a list
1240 val cons
: 'a
-> 'a list
-> 'a list
1241 val uncons
: 'a list
-> 'a
* 'a list
1242 val safe_tl
: 'a list
-> 'a list
1243 val head_middle_tail
: 'a list
-> 'a
* 'a list
* 'a
1244 val last
: 'a list
-> 'a
1245 val list_init
: 'a list
-> 'a list
1246 val list_last
: 'a list
-> 'a
1247 val removelast
: 'a list
-> 'a list
1249 val inits
: 'a list
-> 'a list list
1250 val tails
: 'a list
-> 'a list list
1253 val ( ++ ) : 'a list
-> 'a list
-> 'a list
1255 val foldl1
: ('a
-> 'a
-> 'a
) -> 'a list
-> 'a
1256 val fold_k
: ('a
-> '
b -> ('a
-> 'a
) -> 'a
) -> ('a
-> 'a
) -> 'a
-> '
b list
-> 'a
1257 val fold_right1
: ('a
-> 'a
-> 'a
) -> 'a list
-> 'a
1258 val fold_left
: ('a
-> '
b -> 'a
) -> 'a
-> '
b list
-> 'a
1260 val rev_map
: ('a
-> '
b) -> 'a list
-> '
b list
1262 val join_gen
: 'a
-> 'a list
-> 'a list
1265 (('a
-> '
b) -> 'c
-> 'd
) -> ('e
-> 'a
-> '
b * 'e
) -> 'e
-> 'c
-> 'd
* 'e
1266 val map_withenv
: ('a
-> '
b -> 'c
* 'a
) -> 'a
-> '
b list
-> 'c list
* 'a
1267 val map_withkeep
: ('a
-> '
b) -> 'a list
-> ('
b * 'a
) list
1269 val collect_accu
: ('a
-> '
b list
) -> '
b list
-> 'a list
-> '
b list
1270 val collect
: ('a
-> '
b list
) -> 'a list
-> '
b list
1272 val remove
: 'a
-> 'a list
-> 'a list
1274 val exclude
: ('a
-> bool) -> 'a list
-> 'a list
1276 (* Not like unix uniq command line tool that only delete contiguous repeated
1277 * line. Here we delete any repeated line (here list element).
1279 val uniq
: 'a list
-> 'a list
1280 val uniq_eff
: 'a list
-> 'a list
1282 val has_no_duplicate
: 'a list
-> bool
1283 val is_set_as_list
: 'a list
-> bool
1284 val get_duplicates
: 'a list
-> 'a list
1286 val doublon
: 'a list
-> bool
1288 val reverse
: 'a list
-> 'a list
(* alias *)
1289 val rev
: 'a list
-> 'a list
(* alias *)
1290 val rotate
: 'a list
-> 'a list
1292 val map_flatten
: ('a
-> '
b list
) -> 'a list
-> '
b list
1294 val map2
: ('a
-> '
b) -> 'a list
-> '
b list
1295 val map3
: ('a
-> '
b) -> 'a list
-> '
b list
1298 val maximum
: 'a list
-> 'a
1299 val minimum
: 'a list
-> 'a
1301 val min_with
: ('a
-> '
b) -> 'a list
-> 'a
1302 val two_mins_with
: ('a
-> '
b) -> 'a list
-> 'a
* 'a
1304 val all_assoc
: (* Eq a *) 'a
-> ('a
* '
b) list
-> '
b list
1305 val prepare_want_all_assoc
: ('a
* '
b) list
-> ('a
* '
b list
) list
1307 val or_list
: bool list
-> bool
1308 val and_list
: bool list
-> bool
1310 val sum_float
: float list
-> float
1311 val sum_int
: int list
-> int
1312 val avg_list
: int list
-> float
1314 val return_when
: ('a
-> '
b option) -> 'a list
-> '
b
1317 val grep_with_previous
: ('a
-> 'a
-> bool) -> 'a list
-> 'a list
1318 val iter_with_previous
: ('a
-> 'a
-> '
b) -> 'a list
-> unit
1320 val iter_with_before_after
:
1321 ('a list
-> 'a
-> 'a list
-> unit) -> 'a list
-> unit
1323 val get_pair
: 'a list
-> ('a
* 'a
) list
1325 val permutation
: 'a list
-> 'a list list
1327 val remove_elem_pos
: int -> 'a list
-> 'a list
1328 val insert_elem_pos
: ('a
* int) -> 'a list
-> 'a list
1329 val uncons_permut
: 'a list
-> (('a
* int) * 'a list
) list
1330 val uncons_permut_lazy
: 'a list
-> (('a
* int) * 'a list
Lazy.t
) list
1333 val pack_sorted
: ('a
-> 'a
-> bool) -> 'a list
-> 'a list list
1335 val keep_best
: ('a
* 'a
-> 'a
option) -> 'a list
-> 'a list
1336 val sorted_keep_best
: ('a
-> 'a
-> 'a
option) -> 'a list
-> 'a list
1339 val cartesian_product
: 'a list
-> '
b list
-> ('a
* '
b) list
1342 val surEnsemble
: 'a list
-> 'a list list
-> 'a list list
1343 val realCombinaison
: 'a list
-> 'a list list
1344 val combinaison
: 'a list
-> ('a
* 'a
) list
1345 val insere
: 'a
-> 'a list list
-> 'a list list
1346 val insereListeContenant
: 'a list
-> 'a
-> 'a list list
-> 'a list list
1347 val fusionneListeContenant
: 'a
* 'a
-> 'a list list
-> 'a list list
1349 (*****************************************************************************)
1351 (*****************************************************************************)
1353 val array_find_index
: (int -> bool) -> 'a array
-> int
1354 val array_find_index_via_elem
: ('a
-> bool) -> 'a array
-> int
1356 (* for better type checking, as sometimes when have an 'int array', can
1357 * easily mess up the index from the value.
1359 type idx
= Idx
of int
1360 val next_idx
: idx
-> idx
1361 val int_of_idx
: idx
-> int
1363 val array_find_index_typed
: (idx
-> bool) -> 'a array
-> idx
1365 (*****************************************************************************)
1367 (*****************************************************************************)
1369 type 'a matrix
= 'a array array
1371 val map_matrix
: ('a
-> '
b) -> 'a matrix
-> '
b matrix
1373 val make_matrix_init
:
1374 nrow
:int -> ncolumn
:int -> (int -> int -> 'a
) -> 'a matrix
1377 (int -> int -> 'a
-> unit) -> 'a matrix
-> unit
1379 val nb_rows_matrix
: 'a matrix
-> int
1380 val nb_columns_matrix
: 'a matrix
-> int
1382 val rows_of_matrix
: 'a matrix
-> 'a list list
1383 val columns_of_matrix
: 'a matrix
-> 'a list list
1385 val all_elems_matrix_by_row
: 'a matrix
-> 'a list
1387 (*****************************************************************************)
1389 (*****************************************************************************)
1393 (*****************************************************************************)
1394 (* Set. But have a look too at set*.mli; it's better. Or use Hashtbl. *)
1395 (*****************************************************************************)
1397 type 'a set
= 'a list
1399 val empty_set
: 'a set
1401 val insert_set
: 'a
-> 'a set
-> 'a set
1402 val single_set
: 'a
-> 'a set
1403 val set
: 'a list
-> 'a set
1405 val is_set
: 'a list
-> bool
1407 val exists_set
: ('a
-> bool) -> 'a set
-> bool
1408 val forall_set
: ('a
-> bool) -> 'a set
-> bool
1410 val filter_set
: ('a
-> bool) -> 'a set
-> 'a set
1411 val fold_set
: ('a
-> '
b -> 'a
) -> 'a
-> '
b set
-> 'a
1412 val map_set
: ('a
-> '
b) -> 'a set
-> '
b set
1414 val member_set
: 'a
-> 'a set
-> bool
1415 val find_set
: ('a
-> bool) -> 'a list
-> 'a
1417 val sort_set
: ('a
-> 'a
-> int) -> 'a list
-> 'a list
1419 val iter_set
: ('a
-> unit) -> 'a list
-> unit
1421 val top_set
: 'a set
-> 'a
1423 val inter_set
: 'a set
-> 'a set
-> 'a set
1424 val union_set
: 'a set
-> 'a set
-> 'a set
1425 val minus_set
: 'a set
-> 'a set
-> 'a set
1427 val union_all
: ('a set
) list
-> 'a set
1429 val big_union_set
: ('a
-> '
b set
) -> 'a set
-> '
b set
1430 val card_set
: 'a set
-> int
1432 val include_set
: 'a set
-> 'a set
-> bool
1433 val equal_set
: 'a set
-> 'a set
-> bool
1434 val include_set_strict
: 'a set
-> 'a set
-> bool
1436 (* could put them in Common.Infix *)
1437 val ( $
*$
) : 'a set
-> 'a set
-> 'a set
1438 val ( $
+$
) : 'a set
-> 'a set
-> 'a set
1439 val ( $
-$
) : 'a set
-> 'a set
-> 'a set
1441 val ( $?$
) : 'a
-> 'a set
-> bool
1442 val ( $
<$
) : 'a set
-> 'a set
-> bool
1443 val ( $
<=$
) : 'a set
-> 'a set
-> bool
1444 val ( $
=$
) : 'a set
-> 'a set
-> bool
1446 val ( $
@$
) : 'a list
-> 'a list
-> 'a list
1448 val nub
: 'a list
-> 'a list
1450 (* use internally a hash and return
1451 * - the common part,
1455 val diff_two_say_set_eff
: 'a list
-> 'a list
->
1456 'a list
* 'a list
* 'a list
1458 (*****************************************************************************)
1459 (* Set as normal list *)
1460 (*****************************************************************************)
1464 (*****************************************************************************)
1465 (* Set as sorted list *)
1466 (*****************************************************************************)
1469 (*****************************************************************************)
1470 (* Sets specialized *)
1471 (*****************************************************************************)
1474 module StringSet = Set.Make(struct type t = string let compare = compare end)
1478 (*****************************************************************************)
1479 (* Assoc. But have a look too at Mapb.mli; it's better. Or use Hashtbl. *)
1480 (*****************************************************************************)
1482 type ('a
, '
b) assoc
= ('a
* '
b) list
1484 val assoc_to_function
: (* Eq a *) ('a
, '
b) assoc
-> ('a
-> '
b)
1486 val empty_assoc
: ('a
, '
b) assoc
1487 val fold_assoc
: ('a
-> '
b -> 'a
) -> 'a
-> '
b list
-> 'a
1488 val insert_assoc
: 'a
-> 'a list
-> 'a list
1489 val map_assoc
: ('a
-> '
b) -> 'a list
-> '
b list
1490 val filter_assoc
: ('a
-> bool) -> 'a list
-> 'a list
1492 val assoc
: 'a
-> ('a
* '
b) list
-> '
b
1494 val keys
: ('a
* '
b) list
-> 'a list
1495 val lookup
: 'a
-> ('a
* '
b) list
-> '
b
1497 val del_assoc
: 'a
-> ('a
* '
b) list
-> ('a
* '
b) list
1498 val replace_assoc
: 'a
* '
b -> ('a
* '
b) list
-> ('a
* '
b) list
1499 val apply_assoc
: 'a
-> ('
b -> '
b) -> ('a
* '
b) list
-> ('a
* '
b) list
1501 val big_union_assoc
: ('a
-> '
b set
) -> 'a list
-> '
b set
1503 val assoc_reverse
: ('a
* '
b) list
-> ('
b * 'a
) list
1504 val assoc_map
: ('a
* '
b) list
-> ('a
* '
b) list
-> ('a
* 'a
) list
1506 val lookup_list
: 'a
-> ('a
, '
b) assoc list
-> '
b
1507 val lookup_list2
: 'a
-> ('a
, '
b) assoc list
-> '
b * int
1509 val assoc_option
: 'a
-> ('a
, '
b) assoc
-> '
b option
1510 val assoc_with_err_msg
: 'a
-> ('a
, '
b) assoc
-> '
b
1512 val sort_by_val_lowfirst
: ('a
,'
b) assoc
-> ('a
* '
b) list
1513 val sort_by_val_highfirst
: ('a
,'
b) assoc
-> ('a
* '
b) list
1515 val sort_by_key_lowfirst
: (int,'
b) assoc
-> (int * '
b) list
1516 val sort_by_key_highfirst
: (int,'
b) assoc
-> (int * '
b) list
1518 val sortgen_by_key_lowfirst
: ('a
,'
b) assoc
-> ('a
* '
b) list
1519 val sortgen_by_key_highfirst
: ('a
,'
b) assoc
-> ('a
* '
b) list
1521 (*****************************************************************************)
1522 (* Assoc, specialized. *)
1523 (*****************************************************************************)
1530 val is_empty
: 'a t
-> bool
1531 val add
: key
-> 'a
-> 'a t
-> 'a t
1532 val find
: key
-> 'a t
-> 'a
1533 val remove
: key
-> 'a t
-> 'a t
1534 val mem
: key
-> 'a t
-> bool
1535 val iter
: (key
-> 'a
-> unit) -> 'a t
-> unit
1536 val map
: ('a
-> '
b) -> 'a t
-> '
b t
1537 val mapi
: (key
-> 'a
-> '
b) -> 'a t
-> '
b t
1538 val fold
: (key
-> 'a
-> '
b -> '
b) -> 'a t
-> '
b -> '
b
1539 val compare : ('a
-> 'a
-> int) -> 'a t
-> 'a t
-> int
1540 val equal
: ('a
-> 'a
-> bool) -> 'a t
-> 'a t
-> bool
1542 val intmap_to_list
: 'a
IntMap.t
-> (IntMap.key
* 'a
) list
1543 val intmap_string_of_t
: 'a
-> '
b -> string
1547 type key
= int * int
1550 val is_empty
: 'a t
-> bool
1551 val add
: key
-> 'a
-> 'a t
-> 'a t
1552 val find
: key
-> 'a t
-> 'a
1553 val remove
: key
-> 'a t
-> 'a t
1554 val mem
: key
-> 'a t
-> bool
1555 val iter
: (key
-> 'a
-> unit) -> 'a t
-> unit
1556 val map
: ('a
-> '
b) -> 'a t
-> '
b t
1557 val mapi
: (key
-> 'a
-> '
b) -> 'a t
-> '
b t
1558 val fold
: (key
-> 'a
-> '
b -> '
b) -> 'a t
-> '
b -> '
b
1559 val compare : ('a
-> 'a
-> int) -> 'a t
-> 'a t
-> int
1560 val equal
: ('a
-> 'a
-> bool) -> 'a t
-> 'a t
-> bool
1562 val intintmap_to_list
: 'a
IntIntMap.t
-> (IntIntMap.key
* 'a
) list
1563 val intintmap_string_of_t
: 'a
-> '
b -> string
1566 (*****************************************************************************)
1568 (*****************************************************************************)
1570 (* Note that Hashtbl keep old binding to a key so if want a hash
1571 * of a list, then can use the Hashtbl as is. Use Hashtbl.find_all then
1572 * to get the list of bindings
1574 * Note that Hashtbl module use different convention :( the object is
1575 * the first argument, not last as for List or Map.
1578 (* obsolete: can use directly the Hashtbl module *)
1579 val hcreate
: unit -> ('a
, '
b) Hashtbl.t
1580 val hadd
: 'a
* '
b -> ('a
, '
b) Hashtbl.t
-> unit
1581 val hmem
: 'a
-> ('a
, '
b) Hashtbl.t
-> bool
1582 val hfind
: 'a
-> ('a
, '
b) Hashtbl.t
-> '
b
1583 val hreplace
: 'a
* '
b -> ('a
, '
b) Hashtbl.t
-> unit
1584 val hiter
: ('a
-> '
b -> unit) -> ('a
, '
b) Hashtbl.t
-> unit
1585 val hfold
: ('a
-> '
b -> 'c
-> 'c
) -> ('a
, '
b) Hashtbl.t
-> 'c
-> 'c
1586 val hremove
: 'a
-> ('a
, '
b) Hashtbl.t
-> unit
1589 val hfind_default
: 'a
-> (unit -> '
b) -> ('a
, '
b) Hashtbl.t
-> '
b
1590 val hfind_option
: 'a
-> ('a
, '
b) Hashtbl.t
-> '
b option
1591 val hupdate_default
:
1592 'a
-> ('
b -> '
b) -> (unit -> '
b) -> ('a
, '
b) Hashtbl.t
-> unit
1594 val hash_to_list
: ('a
, '
b) Hashtbl.t
-> ('a
* '
b) list
1595 val hash_to_list_unsorted
: ('a
, '
b) Hashtbl.t
-> ('a
* '
b) list
1596 val hash_of_list
: ('a
* '
b) list
-> ('a
, '
b) Hashtbl.t
1599 val hkeys
: ('a
, '
b) Hashtbl.t
-> 'a list
1601 (*****************************************************************************)
1603 (*****************************************************************************)
1605 type 'a hashset
= ('a
, bool) Hashtbl.t
1608 (* common use of hashset, in a hash of hash *)
1609 val hash_hashset_add
: 'a
-> '
b -> ('a
, '
b hashset
) Hashtbl.t
-> unit
1611 val hashset_to_set
:
1612 < fromlist
: ('a
) list
-> 'c
; .. > -> ('a
, '
b) Hashtbl.t
-> 'c
1614 val hashset_to_list
: 'a hashset
-> 'a list
1615 val hashset_of_list
: 'a list
-> 'a hashset
1618 (*****************************************************************************)
1620 (*****************************************************************************)
1622 type 'a stack
= 'a list
1623 val empty_stack
: 'a stack
1624 val push
: 'a
-> 'a stack
-> 'a stack
1625 val top
: 'a stack
-> 'a
1626 val pop
: 'a stack
-> 'a stack
1628 val top_option
: 'a stack
-> 'a
option
1630 val push2
: 'a
-> 'a stack
ref -> unit
1631 val pop2
: 'a stack
ref -> 'a
1633 (*****************************************************************************)
1634 (* Stack with undo/redo support *)
1635 (*****************************************************************************)
1637 type 'a undo_stack
= 'a list
* 'a list
1638 val empty_undo_stack
: 'a undo_stack
1639 val push_undo
: 'a
-> 'a undo_stack
-> 'a undo_stack
1640 val top_undo
: 'a undo_stack
-> 'a
1641 val pop_undo
: 'a undo_stack
-> 'a undo_stack
1642 val redo_undo
: 'a undo_stack
-> 'a undo_stack
1643 val undo_pop
: 'a undo_stack
-> 'a undo_stack
1645 val top_undo_option
: 'a undo_stack
-> 'a
option
1648 (*****************************************************************************)
1650 (*****************************************************************************)
1651 type 'a bintree
= Leaf
of 'a
| Branch
of ('a bintree
* 'a bintree
)
1653 (*****************************************************************************)
1655 (*****************************************************************************)
1657 (* no empty tree, must have one root at least *)
1658 type 'a tree
= Tree
of 'a
* ('a tree
) list
1660 val tree_iter
: ('a
-> unit) -> 'a tree
-> unit
1663 (*****************************************************************************)
1664 (* N-ary tree with updatable childrens *)
1665 (*****************************************************************************)
1667 (* no empty tree, must have one root at least *)
1669 | NodeRef
of 'a
* 'a treeref list
ref
1671 val treeref_node_iter
:
1672 (('a
* 'a treeref list
ref) -> unit) -> 'a treeref
-> unit
1673 val treeref_node_iter_with_parents
:
1674 (('a
* 'a treeref list
ref) -> ('a list
) -> unit) ->
1678 (('a
* 'a treeref list
ref) -> bool) ->
1679 'a treeref
-> 'a treeref
1681 val treeref_children_ref
:
1682 'a treeref
-> 'a treeref list
ref
1684 val find_treeref_with_parents_some
:
1685 ('a
* 'a treeref list
ref -> 'a list
-> 'c
option) ->
1688 val find_multi_treeref_with_parents_some
:
1689 ('a
* 'a treeref list
ref -> 'a list
-> 'c
option) ->
1690 'a treeref
-> 'c list
1693 (* Leaf can seem redundant, but sometimes want to directly see if
1694 * a children is a leaf without looking if the list is empty.
1696 type ('a
, '
b) treeref2
=
1697 | NodeRef2
of 'a
* ('a
, '
b) treeref2 list
ref
1702 (('a
* ('a
, '
b) treeref2 list
ref) -> bool) ->
1703 ('a
, '
b) treeref2
-> ('a
, '
b) treeref2
1705 val treeref_node_iter_with_parents2
:
1706 (('a
* ('a
, '
b) treeref2 list
ref) -> ('a list
) -> unit) ->
1707 ('a
, '
b) treeref2
-> unit
1709 val treeref_node_iter2
:
1710 (('a
* ('a
, '
b) treeref2 list
ref) -> unit) -> ('a
, '
b) treeref2
-> unit
1715 val treeref_children_ref: ('a, 'b) treeref -> ('a, 'b) treeref list ref
1717 val find_treeref_with_parents_some:
1718 ('a * ('a, 'b) treeref list ref -> 'a list -> 'c option) ->
1719 ('a, 'b) treeref -> 'c
1721 val find_multi_treeref_with_parents_some:
1722 ('a * ('a, 'b) treeref list ref -> 'a list -> 'c option) ->
1723 ('a, 'b) treeref -> 'c list
1726 (*****************************************************************************)
1727 (* Graph. But have a look too at Ograph_*.mli; it's better *)
1728 (*****************************************************************************)
1730 type 'a graph
= 'a set
* ('a
* 'a
) set
1732 val add_node
: 'a
-> 'a graph
-> 'a graph
1733 val del_node
: 'a
-> 'a graph
-> 'a graph
1735 val add_arc
: 'a
* 'a
-> 'a graph
-> 'a graph
1736 val del_arc
: 'a
* 'a
-> 'a graph
-> 'a graph
1738 val successors
: 'a
-> 'a graph
-> 'a set
1739 val predecessors
: 'a
-> 'a graph
-> 'a set
1741 val nodes
: 'a graph
-> 'a set
1743 val fold_upward
: ('a
-> '
b -> 'a
) -> '
b set
-> 'a
-> '
b graph
-> 'a
1745 val empty_graph
: 'a list
* '
b list
1748 (*****************************************************************************)
1750 (*****************************************************************************)
1752 (* mostly alias to functions in List *)
1754 val map
: ('a
-> '
b) -> 'a list
-> '
b list
1755 val filter
: ('a
-> bool) -> 'a list
-> 'a list
1756 val fold
: ('a
-> '
b -> 'a
) -> 'a
-> '
b list
-> 'a
1758 val member
: 'a
-> 'a list
-> bool
1760 val iter
: ('a
-> unit) -> 'a list
-> unit
1762 val find
: ('a
-> bool) -> 'a list
-> 'a
1764 val exists
: ('a
-> bool) -> 'a list
-> bool
1765 val forall
: ('a
-> bool) -> 'a list
-> bool
1767 val big_union
: ('a
-> '
b set
) -> 'a list
-> '
b set
1769 (* same than [] but easier to search for, because [] can also be a pattern *)
1770 val empty_list
: 'a list
1772 val sort
: ('a
-> 'a
-> int) -> 'a list
-> 'a list
1774 val length
: 'a list
-> int
1776 val null
: 'a list
-> bool
1778 val head
: 'a list
-> 'a
1779 val tail
: 'a list
-> 'a list
1781 val is_singleton
: 'a list
-> bool
1791 (*###########################################################################*)
1792 (* And now misc functions *)
1793 (*###########################################################################*)
1795 (*****************************************************************************)
1797 (*****************************************************************************)
1799 (* cf oassocbdb.ml or oassocdbm.ml *)
1801 (*****************************************************************************)
1802 (* GUI (LFS, CComment, otimetracker) *)
1803 (*****************************************************************************)
1805 (* cf ocamlgtk and my gui.ml *)
1808 (*****************************************************************************)
1809 (* Graphics (otimetracker) *)
1810 (*****************************************************************************)
1812 (* cf ocamlgl and my opengl.ml *)
1816 (*****************************************************************************)
1817 (* Geometry (ICFP raytracer) *)
1818 (*****************************************************************************)
1820 type vector
= float * float * float
1825 val dotproduct
: vector
* vector
-> float
1827 val vector_length
: vector
-> float
1829 val minus_point
: point
* point
-> vector
1831 val distance
: point
* point
-> float
1833 val normalise
: vector
-> vector
1835 val mult_coeff
: vector
-> float -> vector
1837 val add_vector
: vector
-> vector
-> vector
1838 val mult_vector
: vector
-> vector
-> vector
1839 val sum_vector
: vector list
-> vector
1842 (*****************************************************************************)
1843 (* Pics (ICFP raytracer) *)
1844 (*****************************************************************************)
1845 type pixel
= int * int * int
1846 val write_ppm
: int -> int -> pixel list
-> filename
-> unit
1847 val test_ppm1
: unit -> unit
1849 (*****************************************************************************)
1851 (*****************************************************************************)
1853 type diff
= Match
| BnotinA
| AnotinB
1854 val diff
: (int -> int -> diff
-> unit) -> string list
* string list
-> unit
1855 val diff2
: (int -> int -> diff
-> unit) -> string * string -> unit
1857 (*****************************************************************************)
1858 (* Parsers (aop-colcombet) *)
1859 (*****************************************************************************)
1861 val parserCommon
: Lexing.lexbuf
-> ('a
-> Lexing.lexbuf
-> '
b) -> 'a
-> '
b
1862 val getDoubleParser
:
1863 ('a
-> Lexing.lexbuf
-> '
b) -> 'a
-> (string -> '
b) * (string -> '
b)
1865 (*****************************************************************************)
1866 (* Parsers (cocci) *)
1867 (*****************************************************************************)
1870 (* Currently lexing.ml does not handle the line number position.
1871 * Even if there is some fields in the lexing structure, they are not
1872 * maintained by the lexing engine :( So the following code does not work:
1874 * let pos = Lexing.lexeme_end_p lexbuf in
1875 * sprintf "at file %s, line %d, char %d" pos.pos_fname pos.pos_lnum
1876 * (pos.pos_cnum - pos.pos_bol) in
1878 * Hence those functions to overcome the previous limitation.
1889 val fake_parse_info
: parse_info
1890 val string_of_parse_info
: parse_info
-> string
1891 val string_of_parse_info_bis
: parse_info
-> string
1893 (* array[i] will contain the (line x col) of the i char position *)
1894 val full_charpos_to_pos
: filename
-> (int * int) array
1896 (* fill in the line and column field of parse_info that were not set
1897 * during lexing because of limitations of ocamllex. *)
1898 val complete_parse_info
:
1899 filename
-> (int * int) array
-> parse_info
-> parse_info
1901 val full_charpos_to_pos_large
:
1902 filename
-> (int -> (int * int))
1904 val complete_parse_info_large
:
1905 filename
-> (int -> (int * int)) -> parse_info
-> parse_info
1907 (* return line x col x str_line from a charpos. This function is quite
1908 * expensive so don't use it to get the line x col from every token in
1909 * a file. Instead use full_charpos_to_pos.
1911 val info_from_charpos
: int -> filename
-> (int * int * string)
1913 val error_message
: filename
-> (string * int) -> string
1914 val error_message_short
: filename
-> (string * int) -> string
1916 (* add a 'decalage/shift' argument to handle stuff such as cpp which includes
1917 * files and who can make shift.
1919 val error_messagebis
: filename
-> (string * int) -> int -> string
1921 (*****************************************************************************)
1922 (* Scope managment (cocci) *)
1923 (*****************************************************************************)
1925 (* for example of use, see the code used in coccinelle *)
1926 type ('a
, '
b) scoped_env
= ('a
, '
b) assoc list
1928 val lookup_env
: (* Eq a *) 'a
-> ('a
, '
b) scoped_env
-> '
b
1929 val member_env_key
: 'a
-> ('a
, '
b) scoped_env
-> bool
1931 val new_scope
: ('a
, '
b) scoped_env
ref -> unit
1932 val del_scope
: ('a
, '
b) scoped_env
ref -> unit
1934 val do_in_new_scope
: ('a
, '
b) scoped_env
ref -> (unit -> unit) -> unit
1936 val add_in_scope
: ('a
, '
b) scoped_env
ref -> 'a
* '
b -> unit
1941 (* for example of use, see the code used in coccinelle *)
1942 type ('a
, '
b) scoped_h_env
= {
1943 scoped_h
: ('a
, '
b) Hashtbl.t
;
1944 scoped_list
: ('a
, '
b) assoc list
;
1946 val empty_scoped_h_env
: unit -> ('a
, '
b) scoped_h_env
1947 val clone_scoped_h_env
: ('a
, '
b) scoped_h_env
-> ('a
, '
b) scoped_h_env
1949 val lookup_h_env
: 'a
-> ('a
, '
b) scoped_h_env
-> '
b
1950 val member_h_env_key
: 'a
-> ('a
, '
b) scoped_h_env
-> bool
1952 val new_scope_h
: ('a
, '
b) scoped_h_env
ref -> unit
1953 val del_scope_h
: ('a
, '
b) scoped_h_env
ref -> unit
1955 val do_in_new_scope_h
: ('a
, '
b) scoped_h_env
ref -> (unit -> unit) -> unit
1957 val add_in_scope_h
: ('a
, '
b) scoped_h_env
ref -> 'a
* '
b -> unit
1959 (*****************************************************************************)
1960 (* Terminal (LFS) *)
1961 (*****************************************************************************)
1963 (* don't forget to call Common_extra.set_link () *)
1965 val _execute_and_show_progress_func
:
1966 (int (* length *) -> ((unit -> unit) -> unit) -> unit) ref
1967 val execute_and_show_progress
:
1968 int (* length *) -> ((unit -> unit) -> unit) -> unit
1970 (*****************************************************************************)
1971 (* Flags and actions *)
1972 (*****************************************************************************)
1974 val cmdline_flags_devel
: unit -> cmdline_options
1975 val cmdline_flags_verbose
: unit -> cmdline_options
1976 val cmdline_flags_other
: unit -> cmdline_options
1978 (*****************************************************************************)
1980 (*****************************************************************************)
1982 val generic_print
: 'a
-> string -> string
1988 method fold
: ('
b -> 'a
-> '
b) -> '
b -> '
b
1989 method view
: 'a list
1992 val typing_sux_test
: unit -> unit