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
121 * The use of 2 in pr2 is because 2 is under UNIX the second descriptor
122 * which corresponds to stderr.
124 val _prefix_pr
: string ref
125 val pr
: string -> unit
126 val pr2
: string -> unit
127 val pr_no_nl
: string -> unit
128 val pr2_no_nl
: string -> unit
129 val pr_xxxxxxxxxxxxxxxxx
: unit -> unit
130 val pr2_xxxxxxxxxxxxxxxxx
: unit -> unit
132 (* use Dumper.dump *)
133 val pr2_gen
: 'a
-> unit
134 val dump
: 'a
-> string
136 (* see flag: val disable_pr2_once : bool ref *)
137 val _already_printed
: (string, bool) Hashtbl.t
138 val pr2_once
: string -> unit
140 val redirect_stdout_stderr
: filename
-> (unit -> unit) -> unit
141 val redirect_stdin
: filename
-> (unit -> unit) -> unit
142 val redirect_stdin_opt
: filename
option -> (unit -> unit) -> unit
144 val fprintf
: out_channel
-> ('a
, out_channel
, unit) format
-> 'a
145 val printf
: ('a
, out_channel
, unit) format
-> 'a
146 val eprintf
: ('a
, out_channel
, unit) format
-> 'a
147 val sprintf
: ('a
, unit, string) format
-> 'a
150 val spf
: ('a
, unit, string) format
-> 'a
152 (* default = stderr *)
153 val _chan
: out_channel
ref
154 (* generate & use a /tmp/debugml-xxx file *)
155 val start_log_file
: unit -> unit
157 (* see flag: val verbose_level : int ref *)
158 val log
: string -> unit
159 val log2
: string -> unit
160 val log3
: string -> unit
161 val log4
: string -> unit
163 val if_log
: (unit -> unit) -> unit
164 val if_log2
: (unit -> unit) -> unit
165 val if_log3
: (unit -> unit) -> unit
166 val if_log4
: (unit -> unit) -> unit
168 val pause
: unit -> unit
170 (* was used by fix_caml *)
171 val _trace_var
: int ref
172 val add_var
: unit -> unit
173 val dec_var
: unit -> unit
174 val get_var
: unit -> int
176 val print_n
: int -> string -> unit
177 val printerr_n
: int -> string -> unit
179 val _debug
: bool ref
180 val debugon
: unit -> unit
181 val debugoff
: unit -> unit
182 val debug
: (unit -> unit) -> unit
184 (* see flag: val debugger : bool ref *)
187 (*****************************************************************************)
188 (* Profiling (cpu/mem) *)
189 (*****************************************************************************)
191 val get_mem
: unit -> unit
192 val memory_stat
: unit -> string
194 val timenow
: unit -> string
196 val _count1
: int ref
197 val _count2
: int ref
198 val _count3
: int ref
199 val _count4
: int ref
200 val _count5
: int ref
202 val count1
: unit -> unit
203 val count2
: unit -> unit
204 val count3
: unit -> unit
205 val count4
: unit -> unit
206 val count5
: unit -> unit
207 val profile_diagnostic_basic
: unit -> string
209 val time_func
: (unit -> 'a
) -> 'a
213 (* see flag: type prof = PALL | PNONE | PSOME of string list *)
214 (* see flag: val profile : prof ref *)
216 val _profile_table
: (string, (float ref * int ref)) Hashtbl.t
ref
217 val profile_code
: string -> (unit -> 'a
) -> 'a
218 val profile_diagnostic
: unit -> string
220 val profile_code_exclusif
: string -> (unit -> 'a
) -> 'a
221 val profile_code_inside_exclusif_ok
: string -> (unit -> 'a
) -> 'a
223 val report_if_take_time
: int -> string -> (unit -> 'a
) -> 'a
225 (* similar to profile_code but print some information during execution too *)
226 val profile_code2
: string -> (unit -> 'a
) -> 'a
228 (*****************************************************************************)
230 (*****************************************************************************)
232 val example
: bool -> unit
233 (* generate failwith <string> when pb *)
234 val example2
: string -> bool -> unit
235 (* use Dumper to report when pb *)
236 val assert_equal
: 'a
-> 'a
-> unit
238 val _list_bool
: (string * bool) list
ref
239 val example3
: string -> bool -> unit
240 val test_all
: unit -> unit
242 (* regression testing *)
243 type score_result
= Ok
| Pb
of string
244 type score
= (string (* usually a filename *), score_result
) Hashtbl.t
245 val empty_score
: unit -> score
246 val regression_testing
:
247 score
-> filename
(* old score file on disk (usually in /tmp) *) -> unit
248 val print_score
: score
-> unit
251 (* quickcheck spirit *)
252 type 'a gen
= unit -> 'a
254 (* quickcheck random generators *)
256 val lg
: 'a gen
-> 'a list gen
257 val pg
: 'a gen
-> 'b gen
-> ('a
* 'b
) gen
261 val oneofl
: 'a list
-> 'a gen
262 val oneof
: 'a gen list
-> 'a gen
263 val always
: 'a
-> 'a gen
264 val frequency
: (int * 'a gen
) list
-> 'a gen
265 val frequencyl
: (int * 'a
) list
-> 'a gen
267 val laws
: string -> ('a
-> bool) -> 'a gen
-> 'a
option
270 * let b = laws "unit" (fun x -> reverse [x] = [x]) ig
273 val statistic_number
: 'a list
-> (int * 'a
) list
274 val statistic
: 'a list
-> (int * 'a
) list
277 string -> ('a
-> bool * '
b) -> 'a gen
-> 'a
option * (int * '
b) list
279 (*****************************************************************************)
281 (*****************************************************************************)
283 (* just wrappers around Marshall *)
284 val get_value
: filename
-> 'a
285 val read_value
: filename
-> 'a
(* alias *)
286 val write_value
: 'a
-> filename
-> unit
287 val write_back
: ('a
-> '
b) -> filename
-> unit
289 (*****************************************************************************)
291 (*****************************************************************************)
292 val _counter
: int ref
293 val _counter2
: int ref
294 val _counter3
: int ref
296 val counter
: unit -> int
297 val counter2
: unit -> int
298 val counter3
: unit -> int
302 (*****************************************************************************)
303 (* String_of and (pretty) printing *)
304 (*****************************************************************************)
306 val string_of_string
: (string -> string) -> string
307 val string_of_list
: ('a
-> string) -> 'a list
-> string
308 val string_of_unit
: unit -> string
309 val string_of_array
: ('a
-> string) -> 'a array
-> string
310 val string_of_option
: ('a
-> string) -> 'a
option -> string
312 val print_bool
: bool -> unit
313 val print_option
: ('a
-> '
b) -> 'a
option -> unit
314 val print_list
: ('a
-> '
b) -> 'a list
-> unit
315 val print_between
: (unit -> unit) -> ('a
-> unit) -> 'a list
-> unit
317 (* use Format internally *)
318 val pp_do_in_box
: (unit -> unit) -> unit
319 val pp_f_in_box
: (unit -> 'a
) -> 'a
320 val pp_do_in_zero_box
: (unit -> unit) -> unit
321 val pp
: string -> unit
323 (* convert something printed using Format to print into a string *)
324 val format_to_string
: (unit -> unit) (* printer *) -> string
326 (* works with _tab_level_print enabling to mix some calls to pp, pr2
327 * and indent_do to sometimes use advanced indentation pretty printing
328 * (with the pp* functions) and sometimes explicit and simple indendation
329 * printing (with pr* and indent_do) *)
330 val adjust_pp_with_indent
: (unit -> unit) -> unit
331 val adjust_pp_with_indent_and_header
: string -> (unit -> unit) -> unit
333 (*****************************************************************************)
335 (*****************************************************************************)
337 (* was working with my macro.ml4 *)
338 val macro_expand
: string -> unit
340 (*****************************************************************************)
341 (* Composition/Control *)
342 (*****************************************************************************)
344 val ( +> ) : 'a
-> ('a
-> '
b) -> '
b
345 val ( +!> ) : 'a
ref -> ('a
-> 'a
) -> unit
346 val ( $
) : ('a
-> '
b) -> ('
b -> 'c
) -> 'a
-> 'c
348 val compose
: ('a
-> '
b) -> ('c
-> 'a
) -> 'c
-> '
b
349 val flip
: ('a
-> '
b -> 'c
) -> '
b -> 'a
-> 'c
351 val curry
: ('a
* '
b -> 'c
) -> 'a
-> '
b -> 'c
352 val uncurry
: ('a
-> '
b -> 'c
) -> 'a
* '
b -> 'c
355 val do_nothing
: unit -> unit
357 val forever
: (unit -> unit) -> unit
359 val applyn
: int -> ('a
-> 'a
) -> 'a
-> 'a
361 class ['a
] shared_variable_hook
:
364 val mutable data
: 'a
365 val mutable registered
: (unit -> unit) list
367 method modify
: ('a
-> 'a
) -> unit
368 method register
: (unit -> unit) -> unit
369 method set
: 'a
-> unit
372 val fixpoint
: ('a
-> 'a
) -> 'a
-> 'a
373 val fixpoint_for_object
: ((< equal
: 'a
-> bool; .. > as 'a
) -> 'a
) -> 'a
-> 'a
375 val add_hook
: ('a
-> ('a
-> '
b) -> '
b) ref -> ('a
-> ('a
-> '
b) -> '
b) -> unit
376 val add_hook_action
: ('a
-> unit) -> ('a
-> unit) list
ref -> unit
377 val run_hooks_action
: 'a
-> ('a
-> unit) list
ref -> unit
379 type 'a mylazy
= (unit -> 'a
)
382 val save_excursion
: 'a
ref -> (unit -> '
b) -> '
b
385 val unwind_protect
: (unit -> 'a
) -> (exn
-> '
b) -> 'a
388 val finalize
: (unit -> 'a
) -> (unit -> '
b) -> 'a
390 val memoized
: ('a
, '
b) Hashtbl.t
-> 'a
-> (unit -> '
b) -> '
b
393 (* take file from which computation is done, an extension, and the function
394 * and will compute the function only once and then save result in
397 val cache_computation
:
398 ?verbose
:bool -> ?use_cache
:bool -> filename
-> string (* extension *) ->
401 (* a more robust version where the client describes the dependencies of the
402 * computation so it will relaunch the computation in 'f' if needed.
404 val cache_computation_robust
:
406 string (* extension for marshalled object *) ->
407 (filename list
* 'x
) ->
408 string (* extension for marshalled dependencies *) ->
414 val once
: ('a
-> unit) -> ('a
-> unit)
416 val before_leaving
: ('a
-> unit) -> 'a
-> 'a
418 (* do some finalize, signal handling, unix exit conversion, etc *)
419 val main_boilerplate
: (unit -> unit) -> unit
422 (* cf also the timeout function below that are control related too *)
425 (*****************************************************************************)
427 (*****************************************************************************)
429 (* how ensure really atomic file creation ? hehe :) *)
430 exception FileAlreadyLocked
431 val acquire_file_lock
: filename
-> unit
432 val release_file_lock
: filename
-> unit
434 (*****************************************************************************)
435 (* Error managment *)
436 (*****************************************************************************)
442 exception WrongFormat
of string
445 val internal_error
: string -> 'a
446 val myassert
: bool -> unit
447 val warning
: string -> 'a
-> 'a
448 val error_cant_have
: 'a
-> '
b
450 val exn_to_s
: exn
-> string
452 (*****************************************************************************)
454 (*****************************************************************************)
456 val check_stack_size
: int -> unit
457 val check_stack_nbfiles
: int -> unit
459 (* internally common.ml set Gc. parameters *)
460 val _init_gc_stack
: unit
462 (*****************************************************************************)
463 (* Arguments and command line *)
464 (*****************************************************************************)
466 type arg_spec_full
= Arg.key
* Arg.spec
* Arg.doc
467 type cmdline_options
= arg_spec_full list
470 type options_with_title
= string * string * arg_spec_full list
471 type cmdline_sections
= options_with_title list
474 (* A wrapper around Arg modules that have more logical argument order,
475 * and returns the remaining args.
478 cmdline_options
-> Arg.usage_msg
-> string array
-> string list
480 (* Another wrapper that does Arg.align automatically *)
481 val usage
: Arg.usage_msg
-> cmdline_options
-> unit
485 (* Work with the options_with_title type way to organize a long
486 * list of command line switches.
489 Arg.usage_msg
-> short_opt
:cmdline_options
-> unit
491 Arg.usage_msg
-> short_opt
:cmdline_options
-> long_opt
:cmdline_sections
->
494 (* With the options_with_title way, we don't want the default -help and --help
495 * so need adapter of Arg module, not just wrapper.
497 val arg_align2
: cmdline_options
-> cmdline_options
499 cmdline_options
-> Arg.usage_msg
-> (unit -> unit) (* short_usage func *) ->
506 (* The action lib. Useful to debug supart of your system. cf some of
507 * my main.ml for example of use. *)
508 type flag_spec
= Arg.key
* Arg.spec
* Arg.doc
509 type action_spec
= Arg.key
* Arg.doc
* action_func
510 and action_func
= (string list
-> unit)
512 type cmdline_actions
= action_spec list
513 exception WrongNumberOfArguments
515 val mk_action_0_arg
: (unit -> unit) -> action_func
516 val mk_action_1_arg
: (string -> unit) -> action_func
517 val mk_action_2_arg
: (string -> string -> unit) -> action_func
518 val mk_action_3_arg
: (string -> string -> string -> unit) -> action_func
520 val mk_action_n_arg
: (string list
-> unit) -> action_func
522 val options_of_actions
:
523 string ref (* the action ref *) -> cmdline_actions
-> cmdline_options
525 cmdline_actions
-> Arg.key list
527 Arg.key
-> string list
(* args *) -> cmdline_actions
-> unit
529 (*****************************************************************************)
531 (*****************************************************************************)
533 (* Using the generic (=) is tempting, but it backfires, so better avoid it *)
535 (* To infer all the code that use an equal, and that should be
536 * transformed, is not that easy, because (=) is used by many
537 * functions, such as List.find, List.mem, and so on. The strategy to find
538 * them is to turn what you were previously using into a function, because
539 * (=) return an exception when applied to a function, then you simply
540 * use ocamldebug to detect where the code has to be transformed by
541 * finding where the exception was launched from.
544 val (=|=) : int -> int -> bool
545 val (=<=) : char
-> char
-> bool
546 val (=$
=) : string -> string -> bool
547 val (=:=) : bool -> bool -> bool
549 val (=*=): 'a
-> 'a
-> bool
551 (* if want to restrict the use of '=', uncomment this:
553 * val (=): int -> int -> bool
555 * But it will not forbid you to use caml functions like List.find, List.mem
556 * which internaly use this convenient but evolution-unfriendly (=)
562 (*###########################################################################*)
563 (* And now basic types *)
564 (*###########################################################################*)
566 (*****************************************************************************)
568 (*****************************************************************************)
570 val ( ||| ) : 'a
-> 'a
-> 'a
571 val ( ==> ) : bool -> bool -> bool
572 val xor
: 'a
-> 'a
-> bool
575 (*****************************************************************************)
577 (*****************************************************************************)
579 val string_of_char
: char
-> string
580 val string_of_chars
: char list
-> string
582 val is_single
: char
-> bool
583 val is_symbol
: char
-> bool
584 val is_space
: char
-> bool
585 val is_upper
: char
-> bool
586 val is_lower
: char
-> bool
587 val is_alpha
: char
-> bool
588 val is_digit
: char
-> bool
590 val cbetween
: char
-> char
-> char
-> bool
592 (*****************************************************************************)
594 (*****************************************************************************)
596 val ( /! ) : int -> int -> int
598 val do_n
: int -> (unit -> unit) -> unit
599 val foldn
: ('a
-> int -> 'a
) -> 'a
-> int -> 'a
605 val deg_to_rad
: float -> float
607 val clampf
: float -> float
609 val square
: float -> float
610 val power
: int -> int -> int
612 val between
: 'a
-> 'a
-> 'a
-> bool
613 val between_strict
: int -> int -> int -> bool
614 val bitrange
: int -> int -> bool
616 val prime1
: int -> int option
617 val prime
: int -> int option
619 val sum
: int list
-> int
620 val product
: int list
-> int
622 val decompose
: int -> int list
624 val mysquare
: int -> int
625 val sqr
: float -> float
627 type compare
= Equal
| Inf
| Sup
628 val ( <=> ) : 'a
-> 'a
-> compare
629 val ( <==> ) : 'a
-> 'a
-> int
633 val int_of_stringchar
: string -> int
634 val int_of_base
: string -> int -> int
635 val int_of_stringbits
: string -> int
636 val int_of_octal
: string -> int
637 val int_of_all
: string -> int
639 (* useful but sometimes when want grep for all places where do modif,
640 * easier to have just code using ':=' and '<-' to do some modifications.
641 * In the same way avoid using {contents = xxx} to build some ref.
643 val ( += ) : int ref -> int -> unit
644 val ( -= ) : int ref -> int -> unit
646 val pourcent
: int -> int -> int
647 val pourcent_float
: int -> int -> float
648 val pourcent_float_of_floats
: float -> float -> float
650 (*****************************************************************************)
651 (* Numeric/overloading *)
652 (*****************************************************************************)
656 (('a
-> 'a
-> 'a
) * ('a
-> 'a
-> 'a
) * ('a
-> 'a
-> 'a
) * ('a
-> 'a
))
657 val add
: 'a numdict
-> 'a
-> 'a
-> 'a
658 val mul
: 'a numdict
-> 'a
-> 'a
-> 'a
659 val div
: 'a numdict
-> 'a
-> 'a
-> 'a
660 val neg
: 'a numdict
-> 'a
-> 'a
662 val numd_int
: int numdict
663 val numd_float
: float numdict
665 val testd
: 'a numdict
-> 'a
-> 'a
668 module ArithFloatInfix
: sig
669 val (+) : float -> float -> float
670 val (-) : float -> float -> float
671 val (/) : float -> float -> float
672 val ( * ) : float -> float -> float
675 val (+..) : int -> int -> int
676 val (-..) : int -> int -> int
677 val (/..) : int -> int -> int
678 val ( *..) : int -> int -> int
680 val (+=) : float ref -> float -> unit
683 (*****************************************************************************)
685 (*****************************************************************************)
687 val _init_random
: unit
688 val random_list
: 'a list
-> 'a
689 val randomize_list
: 'a list
-> 'a list
690 val random_subset_of_list
: int -> 'a list
-> 'a list
693 (*****************************************************************************)
695 (*****************************************************************************)
697 type 'a pair
= 'a
* 'a
698 type 'a triple
= 'a
* 'a
* 'a
700 val fst3
: 'a
* '
b * 'c
-> 'a
701 val snd3
: 'a
* '
b * 'c
-> '
b
702 val thd3
: 'a
* '
b * 'c
-> 'c
704 val sndthd
: 'a
* '
b * 'c
-> '
b * 'c
706 val map_fst
: ('a
-> '
b) -> 'a
* 'c
-> '
b * 'c
707 val map_snd
: ('a
-> '
b) -> 'c
* 'a
-> 'c
* '
b
709 val pair
: ('a
-> '
b) -> 'a
* 'a
-> '
b * '
b
711 val snd
: 'a
* '
b -> '
b (* alias *)
712 val fst
: 'a
* '
b -> 'a
(* alias *)
714 val double
: 'a
-> 'a
* 'a
715 val swap
: 'a
* '
b -> '
b * 'a
717 (* maybe a sign of bad programming if use those functions :) *)
718 val tuple_of_list1
: 'a list
-> 'a
719 val tuple_of_list2
: 'a list
-> 'a
* 'a
720 val tuple_of_list3
: 'a list
-> 'a
* 'a
* 'a
721 val tuple_of_list4
: 'a list
-> 'a
* 'a
* 'a
* 'a
722 val tuple_of_list5
: 'a list
-> 'a
* 'a
* 'a
* 'a
* 'a
723 val tuple_of_list6
: 'a list
-> 'a
* 'a
* 'a
* 'a
* 'a
* 'a
725 (*****************************************************************************)
727 (*****************************************************************************)
729 type ('a
, '
b) either
= Left
of 'a
| Right
of '
b
730 type ('a
, '
b, 'c
) either3
= Left3
of 'a
| Middle3
of '
b | Right3
of 'c
732 val just
: 'a
option -> 'a
733 val some
: 'a
option -> 'a
(* alias *)
735 val fmap
: ('a
-> '
b) -> 'a
option -> '
b option
736 val map_option
: ('a
-> '
b) -> 'a
option -> '
b option (* alias *)
738 val do_option
: ('a
-> unit) -> 'a
option -> unit
740 val optionise
: (unit -> 'a
) -> 'a
option
742 val some_or
: 'a
option -> 'a
-> 'a
744 val partition_either
:
745 ('a
-> ('
b, 'c
) either
) -> 'a list
-> '
b list
* 'c list
747 val filter_some
: 'a
option list
-> 'a list
748 val map_filter
: ('a
-> '
b option) -> 'a list
-> '
b list
749 val find_some
: ('a
-> '
b option) -> 'a list
-> '
b
751 (*****************************************************************************)
753 (*****************************************************************************)
755 val slength
: string -> int (* alias *)
756 val concat
: string -> string list
-> string (* alias *)
758 val i_to_s
: int -> string
759 val s_to_i
: string -> int
761 (* strings take space in memory. Better when can share the space used by
764 val _shareds
: (string, string) Hashtbl.t
765 val shared_string
: string -> string
767 val chop
: string -> string
768 val chop_dirsymbol
: string -> string
770 val ( <!!> ) : string -> int * int -> string
771 val ( <!> ) : string -> int -> char
773 val split_on_char
: char
-> string -> string list
775 val lowercase
: string -> string
777 val quote
: string -> string
779 val null_string
: string -> bool
780 val is_blank_string
: string -> bool
781 val is_string_prefix
: string -> string -> bool
784 val plural
: int -> string -> string
786 val showCodeHex
: int list
-> unit
788 val size_mo_ko
: int -> string
789 val size_ko
: int -> string
791 val edit_distance
: string -> string -> int
793 val md5sum_of_string
: string -> string
795 (*****************************************************************************)
797 (*****************************************************************************)
799 val regexp_alpha
: Str.regexp
800 val regexp_word
: Str.regexp
802 val _memo_compiled_regexp
: (string, Str.regexp
) Hashtbl.t
803 val ( =~
) : string -> string -> bool
804 val ( ==~
) : string -> Str.regexp
-> bool
808 val regexp_match
: string -> string -> string
810 val matched
: int -> string -> string
812 (* not yet politypic functions in ocaml *)
813 val matched1
: string -> string
814 val matched2
: string -> string * string
815 val matched3
: string -> string * string * string
816 val matched4
: string -> string * string * string * string
817 val matched5
: string -> string * string * string * string * string
818 val matched6
: string -> string * string * string * string * string * string
819 val matched7
: string -> string * string * string * string * string * string * string
821 val string_match_substring
: Str.regexp
-> string -> bool
823 val split
: string (* sep regexp *) -> string -> string list
824 val join
: string (* sep *) -> string list
-> string
826 val split_list_regexp
: string -> string list
-> (string * string list
) list
828 val all_match
: string (* regexp *) -> string -> string list
829 val global_replace_regexp
:
830 string (* regexp *) -> (string -> string) -> string -> string
832 val regular_words
: string -> string list
833 val contain_regular_word
: string -> bool
835 (*****************************************************************************)
837 (*****************************************************************************)
839 (* now at beginning of this file: type filename = string *)
840 val dirname
: string -> string
841 val basename
: string -> string
843 val filesuffix
: filename
-> string
844 val fileprefix
: filename
-> string
846 val adjust_ext_if_needed
: filename
-> string -> filename
848 (* db for dir, base *)
849 val db_of_filename
: filename
-> (string * filename
)
850 val filename_of_db
: (string * filename
) -> filename
852 (* dbe for dir, base, ext *)
853 val dbe_of_filename
: filename
-> string * string * string
854 val dbe_of_filename_nodot
: filename
-> string * string * string
855 (* Left (d,b,e) | Right (d,b) if file has no extension *)
856 val dbe_of_filename_safe
:
857 filename
-> (string * string * string, string * string) either
859 val filename_of_dbe
: string * string * string -> filename
861 (* ex: replace_ext "toto.c" "c" "var" *)
862 val replace_ext
: filename
-> string -> string -> filename
864 (* remove the ., .. *)
865 val normalize_path
: filename
-> filename
867 val relative_to_absolute
: filename
-> filename
869 val filename_without_leading_path
: string -> filename
-> filename
871 (*****************************************************************************)
873 (*****************************************************************************)
879 (*****************************************************************************)
881 (*****************************************************************************)
883 (* can also use ocamlcalendar, but heavier, use many modules ... *)
886 | Jan
| Feb
| Mar
| Apr
| May
| Jun
887 | Jul
| Aug
| Sep
| Oct
| Nov
| Dec
888 type year
= Year
of int
889 type day
= Day
of int
891 type date_dmy
= DMY
of day
* month
* year
893 type hour
= Hour
of int
894 type minute
= Min
of int
895 type second
= Sec
of int
897 type time_hms
= HMS
of hour
* minute
* second
899 type full_date
= date_dmy
* time_hms
903 type days
= Days
of int
905 type time_dmy
= TimeDMY
of day
* month
* year
909 type float_time
= float
912 val mk_date_dmy
: int -> int -> int -> date_dmy
915 val check_date_dmy
: date_dmy
-> unit
916 val check_time_dmy
: time_dmy
-> unit
917 val check_time_hms
: time_hms
-> unit
919 val int_to_month
: int -> string
920 val int_of_month
: month
-> int
921 val month_of_string
: string -> month
922 val month_of_string_long
: string -> month
923 val string_of_month
: month
-> string
925 val string_of_date_dmy
: date_dmy
-> string
926 val string_of_unix_time
: ?langage
:langage
-> Unix.tm
-> string
927 val short_string_of_unix_time
: ?langage
:langage
-> Unix.tm
-> string
928 val string_of_floattime
: ?langage
:langage
-> float_time
-> string
929 val short_string_of_floattime
: ?langage
:langage
-> float_time
-> string
931 val floattime_of_string
: string -> float_time
933 val dmy_to_unixtime
: date_dmy
-> float_time
* Unix.tm
934 val unixtime_to_dmy
: Unix.tm
-> date_dmy
935 val unixtime_to_floattime
: Unix.tm
-> float_time
937 val sec_to_days
: int -> string
938 val sec_to_hours
: int -> string
940 val today
: unit -> float_time
941 val yesterday
: unit -> float_time
942 val tomorrow
: unit -> float_time
944 val lastweek
: unit -> float_time
945 val lastmonth
: unit -> float_time
947 val week_before
: float_time
-> float_time
948 val month_before
: float_time
-> float_time
949 val week_after
: float_time
-> float_time
951 val days_in_week_of_day
: float_time
-> float_time list
953 val first_day_in_week_of_day
: float_time
-> float_time
954 val last_day_in_week_of_day
: float_time
-> float_time
956 val day_secs
: float_time
958 val rough_days_since_jesus
: date_dmy
-> days
959 val rough_days_between_dates
: date_dmy
-> date_dmy
-> days
961 val string_of_unix_time_lfs
: Unix.tm
-> string
963 val is_more_recent
: date_dmy
-> date_dmy
-> bool
964 val max_dmy
: date_dmy
-> date_dmy
-> date_dmy
965 val min_dmy
: date_dmy
-> date_dmy
-> date_dmy
966 val maximum_dmy
: date_dmy list
-> date_dmy
967 val minimum_dmy
: date_dmy list
-> date_dmy
969 (*****************************************************************************)
970 (* Lines/Words/Strings *)
971 (*****************************************************************************)
973 val list_of_string
: string -> char list
975 val lines
: string -> string list
976 val unlines
: string list
-> string
978 val words
: string -> string list
979 val unwords
: string list
-> string
981 val split_space
: string -> string list
983 val lines_with_nl
: string -> string list
985 val nblines
: string -> int
987 (*****************************************************************************)
989 (*****************************************************************************)
990 val cat
: filename
-> string list
991 val cat_orig
: filename
-> string list
993 val interpolate
: string -> string list
995 val echo
: string -> string
997 val usleep
: int -> unit
999 val process_output_to_list
: string -> string list
1000 val cmd_to_list
: string -> string list
(* alias *)
1001 val cmd_to_list_and_status
: string -> string list
* Unix.process_status
1003 val command2
: string -> unit
1004 val command2_y_or_no
: string -> bool
1006 val do_in_fork
: (unit -> unit) -> int
1008 val mkdir
: ?mode
:Unix.file_perm
-> string -> unit
1010 val read_file
: filename
-> string
1011 val write_file
: file
:filename
-> string -> unit
1013 val filesize
: filename
-> int
1014 val filemtime
: filename
-> float
1016 val nblines_file
: filename
-> int
1018 val lfile_exists
: filename
-> bool
1019 val is_directory
: filename
-> bool
1021 val capsule_unix
: ('a
-> unit) -> 'a
-> unit
1023 val readdir_to_kind_list
: string -> Unix.file_kind
-> string list
1024 val readdir_to_dir_list
: string -> string list
1025 val readdir_to_file_list
: string -> string list
1026 val readdir_to_link_list
: string -> string list
1027 val readdir_to_dir_size_list
: string -> (string * int) list
1029 val glob
: string -> filename list
1030 val files_of_dir_or_files
:
1031 string (* ext *) -> string list
-> filename list
1032 val files_of_dir_or_files_no_vcs
:
1033 string (* ext *) -> string list
-> filename list
1034 (* use a post filter =~ for the ext filtering *)
1035 val files_of_dir_or_files_no_vcs_post_filter
:
1036 string (* regexp *) -> string list
-> filename list
1039 val sanity_check_files_and_adjust
:
1040 string (* ext *) -> string list
-> filename list
1043 type rwx
= [ `R
| `W
| `X
] list
1044 val file_perm_of
: u
:rwx
-> g
:rwx
-> o
:rwx
-> Unix.file_perm
1046 val has_env
: string -> bool
1048 (* scheme spirit. do a finalize so no leak. *)
1049 val with_open_outfile
:
1050 filename
-> ((string -> unit) * out_channel
-> 'a
) -> 'a
1051 val with_open_infile
:
1052 filename
-> (in_channel
-> 'a
) -> 'a
1053 val with_open_outfile_append
:
1054 filename
-> ((string -> unit) * out_channel
-> 'a
) -> 'a
1056 val with_open_stringbuf
:
1057 (((string -> unit) * Buffer.t
) -> unit) -> string
1061 (* subtil: have to make sure that Timeout is not intercepted before here. So
1062 * avoid exn handler such as try (...) with _ -> cos Timeout will not bubble up
1063 * enough. In such case, add a case before such as
1064 * with Timeout -> raise Timeout | _ -> ...
1066 * The same is true for UnixExit (see below).
1068 val timeout_function
: int -> (unit -> 'a
) -> 'a
1070 val timeout_function_opt
: int option -> (unit -> 'a
) -> 'a
1073 (* creation of /tmp files, a la gcc
1074 * ex: new_temp_file "cocci" ".c" will give "/tmp/cocci-3252-434465.c"
1076 val _temp_files_created
: string list
ref
1077 (* see flag: val save_tmp_files : bool ref *)
1078 val new_temp_file
: string (* prefix *) -> string (* suffix *) -> filename
1079 val erase_temp_files
: unit -> unit
1081 (* If the user use some exit 0 in his code, then no one can intercept this
1082 * exit and do something before exiting. There is exn handler for exit 0
1083 * so better never use exit 0 but instead use an exception and just at
1084 * the very toplevel transform this exn in a unix exit code.
1086 * subtil: same problem than with Timeout. Do not intercept such exception
1087 * with some blind try (...) with _ -> ...
1089 exception UnixExit
of int
1090 val exn_to_real_unixexit
: (unit -> 'a
) -> 'a
1099 (*###########################################################################*)
1100 (* And now collection-like types. See also ocollection.mli *)
1101 (*###########################################################################*)
1103 (*****************************************************************************)
1105 (*****************************************************************************)
1108 (* tail recursive efficient map (but that also reverse the element!) *)
1109 val map_eff_rev
: ('a
-> '
b) -> 'a list
-> '
b list
1110 (* tail recursive efficient map, use accumulator *)
1111 val acc_map
: ('a
-> '
b) -> 'a list
-> '
b list
1114 val zip
: 'a list
-> '
b list
-> ('a
* '
b) list
1115 val zip_safe
: 'a list
-> '
b list
-> ('a
* '
b) list
1116 val unzip
: ('a
* '
b) list
-> 'a list
* '
b list
1118 val take
: int -> 'a list
-> 'a list
1119 val take_safe
: int -> 'a list
-> 'a list
1120 val take_until
: ('a
-> bool) -> 'a list
-> 'a list
1121 val take_while
: ('a
-> bool) -> 'a list
-> 'a list
1123 val drop
: int -> 'a list
-> 'a list
1124 val drop_while
: ('a
-> bool) -> 'a list
-> 'a list
1125 val drop_until
: ('a
-> bool) -> 'a list
-> 'a list
1127 val span
: ('a
-> bool) -> 'a list
-> 'a list
* 'a list
1129 val skip_until
: ('a list
-> bool) -> 'a list
-> 'a list
1130 val skipfirst
: 'a
-> 'a list
-> 'a list
1132 (* cf also List.partition *)
1133 val fpartition
: ('a
-> '
b option) -> 'a list
-> '
b list
* 'a list
1135 val groupBy
: ('a
-> 'a
-> bool) -> 'a list
-> 'a list list
1136 val exclude_but_keep_attached
: ('a
-> bool) -> 'a list
-> ('a
* 'a list
) list
1137 val group_by_post
: ('a
-> bool) -> 'a list
-> ('a list
* 'a
) list
* 'a list
1139 (* use hash internally to not be in O(n2) *)
1140 val group_assoc_bykey_eff
: ('a
* '
b) list
-> ('a
* '
b list
) list
1142 val splitAt
: int -> 'a list
-> 'a list
* 'a list
1144 val split_when
: ('a
-> bool) -> 'a list
-> 'a list
* 'a
* 'a list
1145 val split_gen_when
: ('a list
-> 'a list
option) -> 'a list
-> 'a list list
1147 val pack
: int -> 'a list
-> 'a list list
1150 val enum
: int -> int -> int list
1151 val repeat
: 'a
-> int -> 'a list
1152 val generate
: int -> 'a
-> 'a list
1156 val index_list
: 'a list
-> ('a
* int) list
1157 val index_list_1
: 'a list
-> ('a
* int) list
1158 val index_list_and_total
: 'a list
-> ('a
* int * int) list
1160 val iter_index
: ('a
-> int -> '
b) -> 'a list
-> unit
1161 val map_index
: ('a
-> int -> '
b) -> 'a list
-> '
b list
1162 val filter_index
: (int -> 'a
-> bool) -> 'a list
-> 'a list
1163 val fold_left_with_index
: ('a
-> '
b -> int -> 'a
) -> 'a
-> '
b list
-> 'a
1165 val nth
: 'a list
-> int -> 'a
1166 val rang
: 'a
-> 'a list
-> int
1168 val last_n
: int -> 'a list
-> 'a list
1172 val snoc
: 'a
-> 'a list
-> 'a list
1173 val cons
: 'a
-> 'a list
-> 'a list
1174 val uncons
: 'a list
-> 'a
* 'a list
1175 val safe_tl
: 'a list
-> 'a list
1176 val head_middle_tail
: 'a list
-> 'a
* 'a list
* 'a
1177 val last
: 'a list
-> 'a
1178 val list_init
: 'a list
-> 'a list
1179 val list_last
: 'a list
-> 'a
1180 val removelast
: 'a list
-> 'a list
1182 val inits
: 'a list
-> 'a list list
1183 val tails
: 'a list
-> 'a list list
1186 val ( ++ ) : 'a list
-> 'a list
-> 'a list
1188 val foldl1
: ('a
-> 'a
-> 'a
) -> 'a list
-> 'a
1189 val fold_k
: ('a
-> '
b -> ('a
-> 'a
) -> 'a
) -> ('a
-> 'a
) -> 'a
-> '
b list
-> 'a
1190 val fold_right1
: ('a
-> 'a
-> 'a
) -> 'a list
-> 'a
1191 val fold_left
: ('a
-> '
b -> 'a
) -> 'a
-> '
b list
-> 'a
1193 val rev_map
: ('a
-> '
b) -> 'a list
-> '
b list
1195 val join_gen
: 'a
-> 'a list
-> 'a list
1198 (('a
-> '
b) -> 'c
-> 'd
) -> ('e
-> 'a
-> '
b * 'e
) -> 'e
-> 'c
-> 'd
* 'e
1199 val map_withenv
: ('a
-> '
b -> 'c
* 'a
) -> 'a
-> '
b list
-> 'c list
* 'a
1201 val collect_accu
: ('a
-> '
b list
) -> '
b list
-> 'a list
-> '
b list
1202 val collect
: ('a
-> '
b list
) -> 'a list
-> '
b list
1204 val remove
: 'a
-> 'a list
-> 'a list
1206 val exclude
: ('a
-> bool) -> 'a list
-> 'a list
1208 (* Not like unix uniq command line tool that only delete contiguous repeated
1209 * line. Here we delete any repeated line (here list element).
1211 val uniq
: 'a list
-> 'a list
1212 val doublon
: 'a list
-> bool
1214 val reverse
: 'a list
-> 'a list
(* alias *)
1215 val rev
: 'a list
-> 'a list
(* alias *)
1216 val rotate
: 'a list
-> 'a list
1218 val map_flatten
: ('a
-> '
b list
) -> 'a list
-> '
b list
1220 val map2
: ('a
-> '
b) -> 'a list
-> '
b list
1221 val map3
: ('a
-> '
b) -> 'a list
-> '
b list
1224 val maximum
: 'a list
-> 'a
1225 val minimum
: 'a list
-> 'a
1227 val min_with
: ('a
-> '
b) -> 'a list
-> 'a
1228 val two_mins_with
: ('a
-> '
b) -> 'a list
-> 'a
* 'a
1230 val all_assoc
: 'a
-> ('a
* '
b) list
-> '
b list
1231 val prepare_want_all_assoc
: ('a
* '
b) list
-> ('a
* '
b list
) list
1233 val or_list
: bool list
-> bool
1234 val and_list
: bool list
-> bool
1236 val sum_float
: float list
-> float
1237 val sum_int
: int list
-> int
1238 val avg_list
: int list
-> float
1240 val return_when
: ('a
-> '
b option) -> 'a list
-> '
b
1243 val grep_with_previous
: ('a
-> 'a
-> bool) -> 'a list
-> 'a list
1244 val iter_with_previous
: ('a
-> 'a
-> '
b) -> 'a list
-> unit
1246 val iter_with_before_after
:
1247 ('a list
-> 'a
-> 'a list
-> unit) -> 'a list
-> unit
1249 val get_pair
: 'a list
-> ('a
* 'a
) list
1251 val permutation
: 'a list
-> 'a list list
1253 val remove_elem_pos
: int -> 'a list
-> 'a list
1254 val insert_elem_pos
: ('a
* int) -> 'a list
-> 'a list
1255 val uncons_permut
: 'a list
-> (('a
* int) * 'a list
) list
1256 val uncons_permut_lazy
: 'a list
-> (('a
* int) * 'a list
Lazy.t
) list
1259 val pack_sorted
: ('a
-> 'a
-> bool) -> 'a list
-> 'a list list
1261 val keep_best
: ('a
* 'a
-> 'a
option) -> 'a list
-> 'a list
1262 val sorted_keep_best
: ('a
-> 'a
-> 'a
option) -> 'a list
-> 'a list
1264 val cartesian_product
: 'a list
-> '
b list
-> ('a
* '
b) list
1267 val surEnsemble
: 'a list
-> 'a list list
-> 'a list list
1268 val realCombinaison
: 'a list
-> 'a list list
1269 val combinaison
: 'a list
-> ('a
* 'a
) list
1270 val insere
: 'a
-> 'a list list
-> 'a list list
1271 val insereListeContenant
: 'a list
-> 'a
-> 'a list list
-> 'a list list
1272 val fusionneListeContenant
: 'a
* 'a
-> 'a list list
-> 'a list list
1274 (*****************************************************************************)
1276 (*****************************************************************************)
1278 val array_find_index
: ('a
-> bool) -> 'a array
-> int
1280 type 'a matrix
= 'a array array
1282 val map_matrix
: ('a
-> '
b) -> 'a matrix
-> '
b matrix
1284 (*****************************************************************************)
1286 (*****************************************************************************)
1290 (*****************************************************************************)
1291 (* Set. But have a look too at set*.mli; it's better. Or use Hashtbl. *)
1292 (*****************************************************************************)
1294 type 'a set
= 'a list
1296 val empty_set
: 'a set
1298 val insert_set
: 'a
-> 'a set
-> 'a set
1299 val single_set
: 'a
-> 'a set
1300 val set
: 'a list
-> 'a set
1302 val exists_set
: ('a
-> bool) -> 'a set
-> bool
1303 val forall_set
: ('a
-> bool) -> 'a set
-> bool
1305 val filter_set
: ('a
-> bool) -> 'a set
-> 'a set
1306 val fold_set
: ('a
-> '
b -> 'a
) -> 'a
-> '
b set
-> 'a
1307 val map_set
: ('a
-> '
b) -> 'a set
-> '
b set
1309 val member_set
: 'a
-> 'a set
-> bool
1310 val find_set
: ('a
-> bool) -> 'a list
-> 'a
1312 val sort_set
: ('a
-> 'a
-> int) -> 'a list
-> 'a list
1314 val iter_set
: ('a
-> unit) -> 'a list
-> unit
1316 val top_set
: 'a set
-> 'a
1318 val inter_set
: 'a set
-> 'a set
-> 'a set
1319 val union_set
: 'a set
-> 'a set
-> 'a set
1320 val minus_set
: 'a set
-> 'a set
-> 'a set
1322 val union_all
: ('a set
) list
-> 'a set
1324 val big_union_set
: ('a
-> '
b set
) -> 'a set
-> '
b set
1325 val card_set
: 'a set
-> int
1327 val include_set
: 'a set
-> 'a set
-> bool
1328 val equal_set
: 'a set
-> 'a set
-> bool
1329 val include_set_strict
: 'a set
-> 'a set
-> bool
1331 (* could put them in Common.Infix *)
1332 val ( $
*$
) : 'a set
-> 'a set
-> 'a set
1333 val ( $
+$
) : 'a set
-> 'a set
-> 'a set
1334 val ( $
-$
) : 'a set
-> 'a set
-> 'a set
1336 val ( $?$
) : 'a
-> 'a set
-> bool
1337 val ( $
<$
) : 'a set
-> 'a set
-> bool
1338 val ( $
<=$
) : 'a set
-> 'a set
-> bool
1339 val ( $
=$
) : 'a set
-> 'a set
-> bool
1341 val ( $
@$
) : 'a list
-> 'a list
-> 'a list
1343 val nub
: 'a list
-> 'a list
1345 (* use internally a hash and return
1346 * - the common part,
1350 val diff_two_say_set_eff
: 'a list
-> 'a list
->
1351 'a list
* 'a list
* 'a list
1353 (*****************************************************************************)
1354 (* Set as normal list *)
1355 (*****************************************************************************)
1359 (*****************************************************************************)
1360 (* Set as sorted list *)
1361 (*****************************************************************************)
1364 (*****************************************************************************)
1365 (* Sets specialized *)
1366 (*****************************************************************************)
1369 module StringSet = Set.Make(struct type t = string let compare = compare end)
1373 (*****************************************************************************)
1374 (* Assoc. But have a look too at Mapb.mli; it's better. Or use Hashtbl. *)
1375 (*****************************************************************************)
1377 type ('a
, '
b) assoc
= ('a
* '
b) list
1379 val assoc_to_function
: ('a
, '
b) assoc
-> ('a
-> '
b)
1381 val empty_assoc
: ('a
, '
b) assoc
1382 val fold_assoc
: ('a
-> '
b -> 'a
) -> 'a
-> '
b list
-> 'a
1383 val insert_assoc
: 'a
-> 'a list
-> 'a list
1384 val map_assoc
: ('a
-> '
b) -> 'a list
-> '
b list
1385 val filter_assoc
: ('a
-> bool) -> 'a list
-> 'a list
1387 val assoc
: 'a
-> ('a
* '
b) list
-> '
b
1389 val keys
: ('a
* '
b) list
-> 'a list
1390 val lookup
: 'a
-> ('a
* '
b) list
-> '
b
1392 val del_assoc
: 'a
-> ('a
* '
b) list
-> ('a
* '
b) list
1393 val replace_assoc
: 'a
* '
b -> ('a
* '
b) list
-> ('a
* '
b) list
1394 val apply_assoc
: 'a
-> ('
b -> '
b) -> ('a
* '
b) list
-> ('a
* '
b) list
1396 val big_union_assoc
: ('a
-> '
b set
) -> 'a list
-> '
b set
1398 val assoc_reverse
: ('a
* '
b) list
-> ('
b * 'a
) list
1399 val assoc_map
: ('a
* '
b) list
-> ('a
* '
b) list
-> ('a
* 'a
) list
1401 val lookup_list
: 'a
-> ('a
, '
b) assoc list
-> '
b
1402 val lookup_list2
: 'a
-> ('a
, '
b) assoc list
-> '
b * int
1404 val assoc_option
: 'a
-> ('a
, '
b) assoc
-> '
b option
1405 val assoc_with_err_msg
: 'a
-> ('a
, '
b) assoc
-> '
b
1407 (*****************************************************************************)
1408 (* Assoc, specialized. *)
1409 (*****************************************************************************)
1416 val is_empty
: 'a t
-> bool
1417 val add
: key
-> 'a
-> 'a t
-> 'a t
1418 val find
: key
-> 'a t
-> 'a
1419 val remove
: key
-> 'a t
-> 'a t
1420 val mem
: key
-> 'a t
-> bool
1421 val iter
: (key
-> 'a
-> unit) -> 'a t
-> unit
1422 val map
: ('a
-> '
b) -> 'a t
-> '
b t
1423 val mapi
: (key
-> 'a
-> '
b) -> 'a t
-> '
b t
1424 val fold
: (key
-> 'a
-> '
b -> '
b) -> 'a t
-> '
b -> '
b
1425 val compare : ('a
-> 'a
-> int) -> 'a t
-> 'a t
-> int
1426 val equal
: ('a
-> 'a
-> bool) -> 'a t
-> 'a t
-> bool
1428 val intmap_to_list
: 'a
IntMap.t
-> (IntMap.key
* 'a
) list
1429 val intmap_string_of_t
: 'a
-> '
b -> string
1433 type key
= int * int
1436 val is_empty
: 'a t
-> bool
1437 val add
: key
-> 'a
-> 'a t
-> 'a t
1438 val find
: key
-> 'a t
-> 'a
1439 val remove
: key
-> 'a t
-> 'a t
1440 val mem
: key
-> 'a t
-> bool
1441 val iter
: (key
-> 'a
-> unit) -> 'a t
-> unit
1442 val map
: ('a
-> '
b) -> 'a t
-> '
b t
1443 val mapi
: (key
-> 'a
-> '
b) -> 'a t
-> '
b t
1444 val fold
: (key
-> 'a
-> '
b -> '
b) -> 'a t
-> '
b -> '
b
1445 val compare : ('a
-> 'a
-> int) -> 'a t
-> 'a t
-> int
1446 val equal
: ('a
-> 'a
-> bool) -> 'a t
-> 'a t
-> bool
1448 val intintmap_to_list
: 'a
IntIntMap.t
-> (IntIntMap.key
* 'a
) list
1449 val intintmap_string_of_t
: 'a
-> '
b -> string
1452 (*****************************************************************************)
1454 (*****************************************************************************)
1456 (* Note that Hashtbl keep old binding to a key so if want a hash
1457 * of a list, then can use the Hashtbl as is. Use Hashtbl.find_all then
1458 * to get the list of bindings
1460 * Note that Hashtbl module use different convention :( the object is
1461 * the first argument, not last as for List or Map.
1464 (* obsolete: can use directly the Hashtbl module *)
1465 val hcreate
: unit -> ('a
, '
b) Hashtbl.t
1466 val hadd
: 'a
* '
b -> ('a
, '
b) Hashtbl.t
-> unit
1467 val hmem
: 'a
-> ('a
, '
b) Hashtbl.t
-> bool
1468 val hfind
: 'a
-> ('a
, '
b) Hashtbl.t
-> '
b
1469 val hreplace
: 'a
* '
b -> ('a
, '
b) Hashtbl.t
-> unit
1470 val hiter
: ('a
-> '
b -> unit) -> ('a
, '
b) Hashtbl.t
-> unit
1471 val hfold
: ('a
-> '
b -> 'c
-> 'c
) -> ('a
, '
b) Hashtbl.t
-> 'c
-> 'c
1472 val hremove
: 'a
-> ('a
, '
b) Hashtbl.t
-> unit
1475 val hfind_default
: 'a
-> (unit -> '
b) -> ('a
, '
b) Hashtbl.t
-> '
b
1476 val hfind_option
: 'a
-> ('a
, '
b) Hashtbl.t
-> '
b option
1477 val hupdate_default
:
1478 'a
-> ('
b -> '
b) -> (unit -> '
b) -> ('a
, '
b) Hashtbl.t
-> unit
1480 val hash_to_list
: ('a
, '
b) Hashtbl.t
-> ('a
* '
b) list
1481 val hash_to_list_unsorted
: ('a
, '
b) Hashtbl.t
-> ('a
* '
b) list
1482 val hash_of_list
: ('a
* '
b) list
-> ('a
, '
b) Hashtbl.t
1485 val hkeys
: ('a
, '
b) Hashtbl.t
-> 'a list
1487 (*****************************************************************************)
1489 (*****************************************************************************)
1491 type 'a hashset
= ('a
, bool) Hashtbl.t
1494 (* common use of hashset, in a hash of hash *)
1495 val hash_hashset_add
: 'a
-> '
b -> ('a
, '
b hashset
) Hashtbl.t
-> unit
1497 val hashset_to_set
:
1498 < fromlist
: ('a
) list
-> 'c
; .. > -> ('a
, '
b) Hashtbl.t
-> 'c
1500 val hashset_to_list
: 'a hashset
-> 'a list
1501 val hashset_of_list
: 'a list
-> 'a hashset
1504 (*****************************************************************************)
1506 (*****************************************************************************)
1508 type 'a stack
= 'a list
1509 val empty_stack
: 'a stack
1510 val push
: 'a
-> 'a stack
-> 'a stack
1511 val top
: 'a stack
-> 'a
1512 val pop
: 'a stack
-> 'a stack
1514 val push2
: 'a
-> 'a stack
ref -> unit
1515 val pop2
: 'a stack
ref -> 'a
1518 (*****************************************************************************)
1520 (*****************************************************************************)
1521 type 'a bintree
= Leaf
of 'a
| Branch
of ('a bintree
* 'a bintree
)
1523 (*****************************************************************************)
1525 (*****************************************************************************)
1527 (* no empty tree, must have one root at least *)
1528 type 'a tree
= Tree
of 'a
* ('a tree
) list
1530 val tree_iter
: ('a
-> unit) -> 'a tree
-> unit
1533 (*****************************************************************************)
1534 (* N-ary tree with updatable childrens *)
1535 (*****************************************************************************)
1537 (* Leaf can seem redundant, but sometimes want to directly see if
1538 * a children is a leaf without looking if the list is empty.
1540 type ('a
, '
b) treeref
=
1541 | NodeRef
of 'a
* ('a
, '
b) treeref list
ref
1544 val treeref_node_iter
:
1545 (('a
* ('a
, '
b) treeref list
ref) -> unit) -> ('a
, '
b) treeref
-> unit
1546 val treeref_node_iter_with_parents
:
1547 (('a
* ('a
, '
b) treeref list
ref) -> ('a list
) -> unit) ->
1548 ('a
, '
b) treeref
-> unit
1551 (('a
* ('a
, '
b) treeref list
ref) -> bool) ->
1552 ('a
, '
b) treeref
-> ('a
, '
b) treeref
1558 (*****************************************************************************)
1559 (* Graph. But have a look too at Ograph_*.mli; it's better *)
1560 (*****************************************************************************)
1562 type 'a graph
= 'a set
* ('a
* 'a
) set
1564 val add_node
: 'a
-> 'a graph
-> 'a graph
1565 val del_node
: 'a
-> 'a graph
-> 'a graph
1567 val add_arc
: 'a
* 'a
-> 'a graph
-> 'a graph
1568 val del_arc
: 'a
* 'a
-> 'a graph
-> 'a graph
1570 val successors
: 'a
-> 'a graph
-> 'a set
1571 val predecessors
: 'a
-> 'a graph
-> 'a set
1573 val nodes
: 'a graph
-> 'a set
1575 val fold_upward
: ('a
-> '
b -> 'a
) -> '
b set
-> 'a
-> '
b graph
-> 'a
1577 val empty_graph
: 'a list
* '
b list
1580 (*****************************************************************************)
1582 (*****************************************************************************)
1584 (* mostly alias to functions in List *)
1586 val map
: ('a
-> '
b) -> 'a list
-> '
b list
1587 val filter
: ('a
-> bool) -> 'a list
-> 'a list
1588 val fold
: ('a
-> '
b -> 'a
) -> 'a
-> '
b list
-> 'a
1590 val member
: 'a
-> 'a list
-> bool
1592 val iter
: ('a
-> unit) -> 'a list
-> unit
1594 val find
: ('a
-> bool) -> 'a list
-> 'a
1596 val exists
: ('a
-> bool) -> 'a list
-> bool
1597 val forall
: ('a
-> bool) -> 'a list
-> bool
1599 val big_union
: ('a
-> '
b set
) -> 'a list
-> '
b set
1601 (* same than [] but easier to search for, because [] can also be a pattern *)
1602 val empty_list
: 'a list
1604 val sort
: ('a
-> 'a
-> int) -> 'a list
-> 'a list
1606 val length
: 'a list
-> int
1608 val null
: 'a list
-> bool
1610 val head
: 'a list
-> 'a
1611 val tail
: 'a list
-> 'a list
1613 val is_singleton
: 'a list
-> bool
1623 (*###########################################################################*)
1624 (* And now misc functions *)
1625 (*###########################################################################*)
1627 (*****************************************************************************)
1629 (*****************************************************************************)
1631 (* cf oassocbdb.ml or oassocdbm.ml *)
1633 (*****************************************************************************)
1634 (* GUI (LFS, CComment, otimetracker) *)
1635 (*****************************************************************************)
1637 (* cf ocamlgtk and my gui.ml *)
1640 (*****************************************************************************)
1641 (* Graphics (otimetracker) *)
1642 (*****************************************************************************)
1644 (* cf ocamlgl and my opengl.ml *)
1648 (*****************************************************************************)
1649 (* Geometry (ICFP raytracer) *)
1650 (*****************************************************************************)
1652 type vector
= float * float * float
1657 val dotproduct
: vector
* vector
-> float
1659 val vector_length
: vector
-> float
1661 val minus_point
: point
* point
-> vector
1663 val distance
: point
* point
-> float
1665 val normalise
: vector
-> vector
1667 val mult_coeff
: vector
-> float -> vector
1669 val add_vector
: vector
-> vector
-> vector
1670 val mult_vector
: vector
-> vector
-> vector
1671 val sum_vector
: vector list
-> vector
1674 (*****************************************************************************)
1675 (* Pics (ICFP raytracer) *)
1676 (*****************************************************************************)
1677 type pixel
= int * int * int
1678 val write_ppm
: int -> int -> pixel list
-> filename
-> unit
1679 val test_ppm1
: unit -> unit
1681 (*****************************************************************************)
1683 (*****************************************************************************)
1685 type diff
= Match
| BnotinA
| AnotinB
1686 val diff
: (int -> int -> diff
-> unit) -> string list
* string list
-> unit
1687 val diff2
: (int -> int -> diff
-> unit) -> string * string -> unit
1689 (*****************************************************************************)
1690 (* Parsers (aop-colcombet) *)
1691 (*****************************************************************************)
1693 val parserCommon
: Lexing.lexbuf
-> ('a
-> Lexing.lexbuf
-> '
b) -> 'a
-> '
b
1694 val getDoubleParser
:
1695 ('a
-> Lexing.lexbuf
-> '
b) -> 'a
-> (string -> '
b) * (string -> '
b)
1697 (*****************************************************************************)
1698 (* Parsers (cocci) *)
1699 (*****************************************************************************)
1702 (* Currently lexing.ml does not handle the line number position.
1703 * Even if there is some fields in the lexing structure, they are not
1704 * maintained by the lexing engine :( So the following code does not work:
1706 * let pos = Lexing.lexeme_end_p lexbuf in
1707 * sprintf "at file %s, line %d, char %d" pos.pos_fname pos.pos_lnum
1708 * (pos.pos_cnum - pos.pos_bol) in
1710 * Hence those functions to overcome the previous limitation.
1721 val fake_parse_info
: parse_info
1722 val string_of_parse_info
: parse_info
-> string
1723 val string_of_parse_info_bis
: parse_info
-> string
1725 (* array[i] will contain the (line x col) of the i char position *)
1726 val full_charpos_to_pos
: filename
-> (int * int) array
1728 (* fill in the line and column field of parse_info that were not set
1729 * during lexing because of limitations of ocamllex. *)
1730 val complete_parse_info
:
1731 filename
-> (int * int) array
-> parse_info
-> parse_info
1733 (* return line x col x str_line from a charpos. This function is quite
1734 * expensive so don't use it to get the line x col from every token in
1735 * a file. Instead use full_charpos_to_pos.
1737 val info_from_charpos
: int -> filename
-> (int * int * string)
1739 val error_message
: filename
-> (string * int) -> string
1740 val error_message_short
: filename
-> (string * int) -> string
1742 (* add a 'decalage/shift' argument to handle stuff such as cpp which includes
1743 * files and who can make shift.
1745 val error_messagebis
: filename
-> (string * int) -> int -> string
1747 (*****************************************************************************)
1748 (* Scope managment (cocci) *)
1749 (*****************************************************************************)
1751 (* for example of use, see the code used in coccinelle *)
1752 type ('a
, '
b) scoped_env
= ('a
, '
b) assoc list
1754 val lookup_env
: 'a
-> ('a
, '
b) scoped_env
-> '
b
1755 val member_env_key
: 'a
-> ('a
, '
b) scoped_env
-> bool
1757 val new_scope
: ('a
, '
b) scoped_env
ref -> unit
1758 val del_scope
: ('a
, '
b) scoped_env
ref -> unit
1760 val do_in_new_scope
: ('a
, '
b) scoped_env
ref -> (unit -> unit) -> unit
1762 val add_in_scope
: ('a
, '
b) scoped_env
ref -> 'a
* '
b -> unit
1767 (* for example of use, see the code used in coccinelle *)
1768 type ('a
, '
b) scoped_h_env
= {
1769 scoped_h
: ('a
, '
b) Hashtbl.t
;
1770 scoped_list
: ('a
, '
b) assoc list
;
1772 val empty_scoped_h_env
: unit -> ('a
, '
b) scoped_h_env
1773 val clone_scoped_h_env
: ('a
, '
b) scoped_h_env
-> ('a
, '
b) scoped_h_env
1775 val lookup_h_env
: 'a
-> ('a
, '
b) scoped_h_env
-> '
b
1776 val member_h_env_key
: 'a
-> ('a
, '
b) scoped_h_env
-> bool
1778 val new_scope_h
: ('a
, '
b) scoped_h_env
ref -> unit
1779 val del_scope_h
: ('a
, '
b) scoped_h_env
ref -> unit
1781 val do_in_new_scope_h
: ('a
, '
b) scoped_h_env
ref -> (unit -> unit) -> unit
1783 val add_in_scope_h
: ('a
, '
b) scoped_h_env
ref -> 'a
* '
b -> unit
1785 (*****************************************************************************)
1786 (* Terminal (LFS) *)
1787 (*****************************************************************************)
1789 val _execute_and_show_progress_func
:
1790 (int (* length *) -> ((unit -> unit) -> unit) -> unit) ref
1791 val execute_and_show_progress
:
1792 int (* length *) -> ((unit -> unit) -> unit) -> unit
1794 (*****************************************************************************)
1795 (* Flags and actions *)
1796 (*****************************************************************************)
1798 val cmdline_flags_devel
: unit -> cmdline_options
1799 val cmdline_flags_verbose
: unit -> cmdline_options
1800 val cmdline_flags_other
: unit -> cmdline_options
1802 (*****************************************************************************)
1804 (*****************************************************************************)
1806 val generic_print
: 'a
-> string -> string
1812 method fold
: ('
b -> 'a
-> '
b) -> '
b -> '
b
1813 method view
: 'a list
1816 val typing_sux_test
: unit -> unit