1 (*###########################################################################*)
3 (*###########################################################################*)
7 * When I have some _xxx variables before some functions, it's
8 * because I want to show that those functions internally use a global
9 * variable. That does not mean I want people to modify this global.
10 * In fact they are kind of private, but I still want to show them.
11 * Maybe one day OCaml will have an effect type system so I don't need this.
13 * The variables that are called _init_xxx show the internal init
14 * side effect of the module (like static var trick used in C/C++)
16 * Why not split the functionnalities of this file in different files ?
17 * Because when I write ocaml script I want simply to load one
18 * file, common.ml, and that's it. Cf common_extra.ml for more on this.
22 (*****************************************************************************)
24 (*****************************************************************************)
25 (* see the corresponding section for the use of those flags. See also
26 * the "Flags and actions" section at the end of this file.
29 (* if set then will not do certain finalize so faster to go back in replay *)
30 val debugger
: bool ref
32 type prof
= PALL
| PNONE
| PSOME
of string list
33 val profile
: prof
ref
34 val show_trace_profile
: bool ref
37 val verbose_level
: int ref
39 (* forbid pr2_once to do the once "optimisation" *)
40 val disable_pr2_once
: bool ref
44 (* works with new_temp_file *)
45 val save_tmp_files
: bool ref
49 (*****************************************************************************)
50 (* Module side effect *)
51 (*****************************************************************************)
53 * I define a few unit tests via some let _ = example (... = ...).
54 * I also initialize the random seed, cf _init_random .
55 * I also set Gc.stack_size, cf _init_gc_stack .
58 (*****************************************************************************)
60 (*****************************************************************************)
61 (* cf the _xxx variables in this file *)
63 (*###########################################################################*)
65 (*###########################################################################*)
67 type filename
= string
70 (* Trick in case you dont want to do an 'open Common' while still wanting
71 * more pervasive types than the one in Pervasives. Just do the selective
72 * open Common.BasicType.
74 module BasicType
: sig
75 type filename
= string
78 (* Same spirit. Trick found in Jane Street core lib, but originated somewhere
79 * else I think: the ability to open nested modules. *)
81 val ( +> ) : 'a
-> ('a
-> 'b
) -> 'b
82 val ( =~
) : string -> string -> bool
83 val ( ==~
) : string -> Str.regexp
-> bool
88 * Another related trick, found via Jon Harrop to have an extended standard
89 * lib is to do something like
91 * module List = struct
96 * And then can put this "module extension" somewhere to open it.
101 (* This module defines the Timeout and UnixExit exceptions.
102 * You have to make sure that those exn are not intercepted. So
103 * avoid exn handler such as try (...) with _ -> cos Timeout will not bubble up
104 * enough. In such case, add a case before such as
105 * with Timeout -> raise Timeout | _ -> ...
106 * The same is true for UnixExit (see below).
109 (*****************************************************************************)
110 (* Debugging/logging *)
111 (*****************************************************************************)
113 val _tab_level_print
: int ref
114 val indent_do
: (unit -> 'a
) -> 'a
115 val reset_pr_indent
: unit -> unit
117 (* The following functions first indent _tab_level_print spaces.
118 * They also add the _prefix_pr, for instance used in MPI to show which
120 * update: for pr2, it can also print into a log file.
122 * The use of 2 in pr2 is because 2 is under UNIX the second descriptor
123 * which corresponds to stderr.
125 val _prefix_pr
: string ref
127 val pr
: string -> unit
128 val pr_no_nl
: string -> unit
129 val pr_xxxxxxxxxxxxxxxxx
: unit -> unit
131 (* pr2 print on stderr, but can also in addition print into a file *)
132 val _chan_pr2
: out_channel
option ref
133 val print_to_stderr
: bool ref
134 val pr2
: string -> unit
135 val pr2_no_nl
: string -> unit
136 val pr2_xxxxxxxxxxxxxxxxx
: unit -> unit
138 (* use Dumper.dump *)
139 val pr2_gen
: 'a
-> unit
140 val dump
: 'a
-> string
142 (* see flag: val disable_pr2_once : bool ref *)
143 val _already_printed
: (string, bool) Hashtbl.t
144 val pr2_once
: string -> unit
146 val mk_pr2_wrappers
: bool ref -> (string -> unit) * (string -> unit)
149 val redirect_stdout_opt
: filename
option -> (unit -> 'a
) -> 'a
150 val redirect_stdout_stderr
: filename
-> (unit -> unit) -> unit
151 val redirect_stdin
: filename
-> (unit -> unit) -> unit
152 val redirect_stdin_opt
: filename
option -> (unit -> unit) -> unit
154 val with_pr2_to_string
: (unit -> unit) -> string list
156 val fprintf
: out_channel
-> ('a
, out_channel
, unit) format
-> 'a
157 val printf
: ('a
, out_channel
, unit) format
-> 'a
158 val eprintf
: ('a
, out_channel
, unit) format
-> 'a
159 val sprintf
: ('a
, unit, string) format
-> 'a
162 val spf
: ('a
, unit, string) format
-> 'a
164 (* default = stderr *)
165 val _chan
: out_channel
ref
166 (* generate & use a /tmp/debugml-xxx file *)
167 val start_log_file
: unit -> unit
169 (* see flag: val verbose_level : int ref *)
170 val log
: string -> unit
171 val log2
: string -> unit
172 val log3
: string -> unit
173 val log4
: string -> unit
175 val if_log
: (unit -> unit) -> unit
176 val if_log2
: (unit -> unit) -> unit
177 val if_log3
: (unit -> unit) -> unit
178 val if_log4
: (unit -> unit) -> unit
180 val pause
: unit -> unit
182 (* was used by fix_caml *)
183 val _trace_var
: int ref
184 val add_var
: unit -> unit
185 val dec_var
: unit -> unit
186 val get_var
: unit -> int
188 val print_n
: int -> string -> unit
189 val printerr_n
: int -> string -> unit
191 val _debug
: bool ref
192 val debugon
: unit -> unit
193 val debugoff
: unit -> unit
194 val debug
: (unit -> unit) -> unit
196 (* see flag: val debugger : bool ref *)
199 (*****************************************************************************)
200 (* Profiling (cpu/mem) *)
201 (*****************************************************************************)
203 val get_mem
: unit -> unit
204 val memory_stat
: unit -> string
206 val timenow
: unit -> string
208 val _count1
: int ref
209 val _count2
: int ref
210 val _count3
: int ref
211 val _count4
: int ref
212 val _count5
: int ref
214 val count1
: unit -> unit
215 val count2
: unit -> unit
216 val count3
: unit -> unit
217 val count4
: unit -> unit
218 val count5
: unit -> unit
219 val profile_diagnostic_basic
: unit -> string
221 val time_func
: (unit -> 'a
) -> 'a
225 (* see flag: type prof = PALL | PNONE | PSOME of string list *)
226 (* see flag: val profile : prof ref *)
228 val _profile_table
: (string, (float ref * int ref)) Hashtbl.t
ref
229 val profile_code
: string -> (unit -> 'a
) -> 'a
230 val profile_diagnostic
: unit -> string
232 val profile_code_exclusif
: string -> (unit -> 'a
) -> 'a
233 val profile_code_inside_exclusif_ok
: string -> (unit -> 'a
) -> 'a
235 val report_if_take_time
: int -> string -> (unit -> 'a
) -> 'a
237 (* similar to profile_code but print some information during execution too *)
238 val profile_code2
: string -> (unit -> 'a
) -> 'a
240 (*****************************************************************************)
242 (*****************************************************************************)
244 val example
: bool -> unit
245 (* generate failwith <string> when pb *)
246 val example2
: string -> bool -> unit
247 (* use Dumper to report when pb *)
248 val assert_equal
: 'a
-> 'a
-> unit
250 val _list_bool
: (string * bool) list
ref
251 val example3
: string -> bool -> unit
252 val test_all
: unit -> unit
255 (* regression testing *)
256 type score_result
= Ok
| Pb
of string
257 type score
= (string (* usually a filename *), score_result
) Hashtbl.t
258 type score_list
= (string (* usually a filename *) * score_result
) list
259 val empty_score
: unit -> score
260 val regression_testing
:
261 score
-> filename
(* old score file on disk (usually in /tmp) *) -> unit
262 val regression_testing_vs
: score
-> score
-> score
263 val total_scores
: score
-> int (* good *) * int (* total *)
264 val print_score
: score
-> unit
265 val print_total_score
: score
-> unit
268 (* quickcheck spirit *)
269 type 'a gen
= unit -> 'a
271 (* quickcheck random generators *)
273 val lg
: 'a gen
-> 'a list gen
274 val pg
: 'a gen
-> 'b gen
-> ('a
* 'b
) gen
278 val oneofl
: 'a list
-> 'a gen
279 val oneof
: 'a gen list
-> 'a gen
280 val always
: 'a
-> 'a gen
281 val frequency
: (int * 'a gen
) list
-> 'a gen
282 val frequencyl
: (int * 'a
) list
-> 'a gen
284 val laws
: string -> ('a
-> bool) -> 'a gen
-> 'a
option
287 * let b = laws "unit" (fun x -> reverse [x] = [x]) ig
290 val statistic_number
: 'a list
-> (int * 'a
) list
291 val statistic
: 'a list
-> (int * 'a
) list
294 string -> ('a
-> bool * '
b) -> 'a gen
-> 'a
option * (int * '
b) list
296 (*****************************************************************************)
298 (*****************************************************************************)
300 (* just wrappers around Marshal *)
301 val get_value
: filename
-> 'a
302 val read_value
: filename
-> 'a
(* alias *)
303 val write_value
: 'a
-> filename
-> unit
304 val write_back
: ('a
-> '
b) -> filename
-> unit
306 (* wrappers that also use profile_code *)
307 val marshal__to_string
: 'a
-> Marshal.extern_flags list
-> string
308 val marshal__from_string
: string -> int -> 'a
310 (*****************************************************************************)
312 (*****************************************************************************)
313 val _counter
: int ref
314 val _counter2
: int ref
315 val _counter3
: int ref
317 val counter
: unit -> int
318 val counter2
: unit -> int
319 val counter3
: unit -> int
323 (*****************************************************************************)
324 (* String_of and (pretty) printing *)
325 (*****************************************************************************)
327 val string_of_string
: (string -> string) -> string
328 val string_of_list
: ('a
-> string) -> 'a list
-> string
329 val string_of_unit
: unit -> string
330 val string_of_array
: ('a
-> string) -> 'a array
-> string
331 val string_of_option
: ('a
-> string) -> 'a
option -> string
333 val print_bool
: bool -> unit
334 val print_option
: ('a
-> '
b) -> 'a
option -> unit
335 val print_list
: ('a
-> '
b) -> 'a list
-> unit
336 val print_between
: (unit -> unit) -> ('a
-> unit) -> 'a list
-> unit
338 (* use Format internally *)
339 val pp_do_in_box
: (unit -> unit) -> unit
340 val pp_f_in_box
: (unit -> 'a
) -> 'a
341 val pp_do_in_zero_box
: (unit -> unit) -> unit
342 val pp
: string -> unit
344 (* convert something printed using Format to print into a string *)
345 val format_to_string
: (unit -> unit) (* printer *) -> string
347 (* works with _tab_level_print enabling to mix some calls to pp, pr2
348 * and indent_do to sometimes use advanced indentation pretty printing
349 * (with the pp* functions) and sometimes explicit and simple indendation
350 * printing (with pr* and indent_do) *)
351 val adjust_pp_with_indent
: (unit -> unit) -> unit
352 val adjust_pp_with_indent_and_header
: string -> (unit -> unit) -> unit
355 val mk_str_func_of_assoc_conv
:
356 ('a
* string) list
-> (string -> 'a
) * ('a
-> string)
358 (*****************************************************************************)
360 (*****************************************************************************)
362 (* was working with my macro.ml4 *)
363 val macro_expand
: string -> unit
365 (*****************************************************************************)
366 (* Composition/Control *)
367 (*****************************************************************************)
369 val ( +> ) : 'a
-> ('a
-> '
b) -> '
b
370 val ( +!> ) : 'a
ref -> ('a
-> 'a
) -> unit
371 val ( $
) : ('a
-> '
b) -> ('
b -> 'c
) -> 'a
-> 'c
373 val compose
: ('a
-> '
b) -> ('c
-> 'a
) -> 'c
-> '
b
374 val flip
: ('a
-> '
b -> 'c
) -> '
b -> 'a
-> 'c
376 val curry
: ('a
* '
b -> 'c
) -> 'a
-> '
b -> 'c
377 val uncurry
: ('a
-> '
b -> 'c
) -> 'a
* '
b -> 'c
380 val do_nothing
: unit -> unit
382 val forever
: (unit -> unit) -> unit
384 val applyn
: int -> ('a
-> 'a
) -> 'a
-> 'a
386 class ['a
] shared_variable_hook
:
389 val mutable data
: 'a
390 val mutable registered
: (unit -> unit) list
392 method modify
: ('a
-> 'a
) -> unit
393 method register
: (unit -> unit) -> unit
394 method set
: 'a
-> unit
397 val fixpoint
: ('a
-> 'a
) -> 'a
-> 'a
398 val fixpoint_for_object
: ((< equal
: 'a
-> bool; .. > as 'a
) -> 'a
) -> 'a
-> 'a
400 val add_hook
: ('a
-> ('a
-> '
b) -> '
b) ref -> ('a
-> ('a
-> '
b) -> '
b) -> unit
401 val add_hook_action
: ('a
-> unit) -> ('a
-> unit) list
ref -> unit
402 val run_hooks_action
: 'a
-> ('a
-> unit) list
ref -> unit
404 type 'a mylazy
= (unit -> 'a
)
407 val save_excursion
: 'a
ref -> (unit -> '
b) -> '
b
408 val save_excursion_and_disable
: bool ref -> (unit -> '
b) -> '
b
409 val save_excursion_and_enable
: bool ref -> (unit -> '
b) -> '
b
412 val unwind_protect
: (unit -> 'a
) -> (exn
-> '
b) -> 'a
415 val finalize
: (unit -> 'a
) -> (unit -> '
b) -> 'a
417 val memoized
: ('a
, '
b) Hashtbl.t
-> 'a
-> (unit -> '
b) -> '
b
419 val cache_in_ref
: 'a
option ref -> (unit -> 'a
) -> 'a
422 (* take file from which computation is done, an extension, and the function
423 * and will compute the function only once and then save result in
426 val cache_computation
:
427 ?verbose
:bool -> ?use_cache
:bool -> filename
-> string (* extension *) ->
430 (* a more robust version where the client describes the dependencies of the
431 * computation so it will relaunch the computation in 'f' if needed.
433 val cache_computation_robust
:
435 string (* extension for marshalled object *) ->
436 (filename list
* 'x
) ->
437 string (* extension for marshalled dependencies *) ->
443 val once
: ('a
-> unit) -> ('a
-> unit)
445 val before_leaving
: ('a
-> unit) -> 'a
-> 'a
447 (* do some finalize, signal handling, unix exit conversion, etc *)
448 val main_boilerplate
: (unit -> unit) -> unit
451 (* cf also the timeout function below that are control related too *)
454 (*****************************************************************************)
456 (*****************************************************************************)
458 (* how ensure really atomic file creation ? hehe :) *)
459 exception FileAlreadyLocked
460 val acquire_file_lock
: filename
-> unit
461 val release_file_lock
: filename
-> unit
463 (*****************************************************************************)
464 (* Error managment *)
465 (*****************************************************************************)
471 exception Multi_found
473 exception WrongFormat
of string
476 val internal_error
: string -> 'a
477 val myassert
: bool -> unit
478 val warning
: string -> 'a
-> 'a
479 val error_cant_have
: 'a
-> '
b
481 val exn_to_s
: exn
-> string
483 val string_of_exn
: exn
-> string
485 type error
= Error
of string
490 (*****************************************************************************)
492 (*****************************************************************************)
494 val check_stack_size
: int -> unit
495 val check_stack_nbfiles
: int -> unit
497 (* internally common.ml set Gc. parameters *)
498 val _init_gc_stack
: unit
500 (*****************************************************************************)
501 (* Arguments and command line *)
502 (*****************************************************************************)
504 type arg_spec_full
= Arg.key
* Arg.spec
* Arg.doc
505 type cmdline_options
= arg_spec_full list
508 type options_with_title
= string * string * arg_spec_full list
509 type cmdline_sections
= options_with_title list
512 (* A wrapper around Arg modules that have more logical argument order,
513 * and returns the remaining args.
516 cmdline_options
-> Arg.usage_msg
-> string array
-> string list
518 (* Another wrapper that does Arg.align automatically *)
519 val usage
: Arg.usage_msg
-> cmdline_options
-> unit
523 (* Work with the options_with_title type way to organize a long
524 * list of command line switches.
527 Arg.usage_msg
-> short_opt
:cmdline_options
-> unit
529 Arg.usage_msg
-> short_opt
:cmdline_options
-> long_opt
:cmdline_sections
->
532 (* With the options_with_title way, we don't want the default -help and --help
533 * so need adapter of Arg module, not just wrapper.
535 val arg_align2
: cmdline_options
-> cmdline_options
537 cmdline_options
-> Arg.usage_msg
-> (unit -> unit) (* short_usage func *) ->
544 (* The action lib. Useful to debug supart of your system. cf some of
545 * my main.ml for example of use. *)
546 type flag_spec
= Arg.key
* Arg.spec
* Arg.doc
547 type action_spec
= Arg.key
* Arg.doc
* action_func
548 and action_func
= (string list
-> unit)
550 type cmdline_actions
= action_spec list
551 exception WrongNumberOfArguments
553 val mk_action_0_arg
: (unit -> unit) -> action_func
554 val mk_action_1_arg
: (string -> unit) -> action_func
555 val mk_action_2_arg
: (string -> string -> unit) -> action_func
556 val mk_action_3_arg
: (string -> string -> string -> unit) -> action_func
558 val mk_action_n_arg
: (string list
-> unit) -> action_func
560 val options_of_actions
:
561 string ref (* the action ref *) -> cmdline_actions
-> cmdline_options
563 cmdline_actions
-> Arg.key list
565 Arg.key
-> string list
(* args *) -> cmdline_actions
-> unit
567 (*****************************************************************************)
569 (*****************************************************************************)
571 (* Using the generic (=) is tempting, but it backfires, so better avoid it *)
573 (* To infer all the code that use an equal, and that should be
574 * transformed, is not that easy, because (=) is used by many
575 * functions, such as List.find, List.mem, and so on. The strategy to find
576 * them is to turn what you were previously using into a function, because
577 * (=) return an exception when applied to a function, then you simply
578 * use ocamldebug to detect where the code has to be transformed by
579 * finding where the exception was launched from.
582 val (=|=) : int -> int -> bool
583 val (=<=) : char
-> char
-> bool
584 val (=$
=) : string -> string -> bool
585 val (=:=) : bool -> bool -> bool
587 val (=*=): 'a
-> 'a
-> bool
589 (* if want to restrict the use of '=', uncomment this:
591 * val (=): unit -> unit -> bool
593 * But it will not forbid you to use caml functions like List.find, List.mem
594 * which internaly use this convenient but evolution-unfriendly (=)
599 (*###########################################################################*)
600 (* And now basic types *)
601 (*###########################################################################*)
603 (*****************************************************************************)
605 (*****************************************************************************)
607 val ( ||| ) : 'a
-> 'a
-> 'a
608 val ( ==> ) : bool -> bool -> bool
609 val xor
: 'a
-> 'a
-> bool
613 (*****************************************************************************)
615 (*****************************************************************************)
617 val string_of_char
: char
-> string
618 val string_of_chars
: char list
-> string
620 val is_single
: char
-> bool
621 val is_symbol
: char
-> bool
622 val is_space
: char
-> bool
623 val is_upper
: char
-> bool
624 val is_lower
: char
-> bool
625 val is_alpha
: char
-> bool
626 val is_digit
: char
-> bool
628 val cbetween
: char
-> char
-> char
-> bool
630 (*****************************************************************************)
632 (*****************************************************************************)
634 val ( /! ) : int -> int -> int
636 val do_n
: int -> (unit -> unit) -> unit
637 val foldn
: ('a
-> int -> 'a
) -> 'a
-> int -> 'a
643 val deg_to_rad
: float -> float
645 val clampf
: float -> float
647 val square
: float -> float
648 val power
: int -> int -> int
650 val between
: 'a
-> 'a
-> 'a
-> bool
651 val between_strict
: int -> int -> int -> bool
652 val bitrange
: int -> int -> bool
654 val prime1
: int -> int option
655 val prime
: int -> int option
657 val sum
: int list
-> int
658 val product
: int list
-> int
660 val decompose
: int -> int list
662 val mysquare
: int -> int
663 val sqr
: float -> float
665 type compare
= Equal
| Inf
| Sup
666 val ( <=> ) : 'a
-> 'a
-> compare
667 val ( <==> ) : 'a
-> 'a
-> int
671 val int_of_stringchar
: string -> int
672 val int_of_base
: string -> int -> int
673 val int_of_stringbits
: string -> int
674 val int_of_octal
: string -> int
675 val int_of_all
: string -> int
677 (* useful but sometimes when want grep for all places where do modif,
678 * easier to have just code using ':=' and '<-' to do some modifications.
679 * In the same way avoid using {contents = xxx} to build some ref.
681 val ( += ) : int ref -> int -> unit
682 val ( -= ) : int ref -> int -> unit
684 val pourcent
: int -> int -> int
685 val pourcent_float
: int -> int -> float
686 val pourcent_float_of_floats
: float -> float -> float
688 val pourcent_good_bad
: int -> int -> int
689 val pourcent_good_bad_float
: int -> int -> float
691 type 'a max_with_elem
= int ref * 'a
ref
692 val update_max_with_elem
:
693 'a max_with_elem
-> is_better
:(int -> int ref -> bool) -> int * 'a
-> unit
694 (*****************************************************************************)
695 (* Numeric/overloading *)
696 (*****************************************************************************)
700 (('a
-> 'a
-> 'a
) * ('a
-> 'a
-> 'a
) * ('a
-> 'a
-> 'a
) * ('a
-> 'a
))
701 val add
: 'a numdict
-> 'a
-> 'a
-> 'a
702 val mul
: 'a numdict
-> 'a
-> 'a
-> 'a
703 val div
: 'a numdict
-> 'a
-> 'a
-> 'a
704 val neg
: 'a numdict
-> 'a
-> 'a
706 val numd_int
: int numdict
707 val numd_float
: float numdict
709 val testd
: 'a numdict
-> 'a
-> 'a
712 module ArithFloatInfix
: sig
713 val (+) : float -> float -> float
714 val (-) : float -> float -> float
715 val (/) : float -> float -> float
716 val ( * ) : float -> float -> float
719 val (+..) : int -> int -> int
720 val (-..) : int -> int -> int
721 val (/..) : int -> int -> int
722 val ( *..) : int -> int -> int
724 val (+=) : float ref -> float -> unit
727 (*****************************************************************************)
729 (*****************************************************************************)
731 val _init_random
: unit
732 val random_list
: 'a list
-> 'a
733 val randomize_list
: 'a list
-> 'a list
734 val random_subset_of_list
: int -> 'a list
-> 'a list
737 (*****************************************************************************)
739 (*****************************************************************************)
741 type 'a pair
= 'a
* 'a
742 type 'a triple
= 'a
* 'a
* 'a
744 val fst3
: 'a
* '
b * 'c
-> 'a
745 val snd3
: 'a
* '
b * 'c
-> '
b
746 val thd3
: 'a
* '
b * 'c
-> 'c
748 val sndthd
: 'a
* '
b * 'c
-> '
b * 'c
750 val map_fst
: ('a
-> '
b) -> 'a
* 'c
-> '
b * 'c
751 val map_snd
: ('a
-> '
b) -> 'c
* 'a
-> 'c
* '
b
753 val pair
: ('a
-> '
b) -> 'a
* 'a
-> '
b * '
b
755 val snd
: 'a
* '
b -> '
b (* alias *)
756 val fst
: 'a
* '
b -> 'a
(* alias *)
758 val double
: 'a
-> 'a
* 'a
759 val swap
: 'a
* '
b -> '
b * 'a
761 (* maybe a sign of bad programming if use those functions :) *)
762 val tuple_of_list1
: 'a list
-> 'a
763 val tuple_of_list2
: 'a list
-> 'a
* 'a
764 val tuple_of_list3
: 'a list
-> 'a
* 'a
* 'a
765 val tuple_of_list4
: 'a list
-> 'a
* 'a
* 'a
* 'a
766 val tuple_of_list5
: 'a list
-> 'a
* 'a
* 'a
* 'a
* 'a
767 val tuple_of_list6
: 'a list
-> 'a
* 'a
* 'a
* 'a
* 'a
* 'a
769 (*****************************************************************************)
771 (*****************************************************************************)
773 type ('a
, '
b) either
= Left
of 'a
| Right
of '
b
774 type ('a
, '
b, 'c
) either3
= Left3
of 'a
| Middle3
of '
b | Right3
of 'c
776 val just
: 'a
option -> 'a
777 val some
: 'a
option -> 'a
(* alias *)
779 val fmap
: ('a
-> '
b) -> 'a
option -> '
b option
780 val map_option
: ('a
-> '
b) -> 'a
option -> '
b option (* alias *)
782 val do_option
: ('a
-> unit) -> 'a
option -> unit
784 val optionise
: (unit -> 'a
) -> 'a
option
786 val some_or
: 'a
option -> 'a
-> 'a
788 val partition_either
:
789 ('a
-> ('
b, 'c
) either
) -> 'a list
-> '
b list
* 'c list
790 val partition_either3
:
791 ('a
-> ('
b, 'c
, 'd
) either3
) -> 'a list
-> '
b list
* 'c list
* 'd list
793 val filter_some
: 'a
option list
-> 'a list
794 val map_filter
: ('a
-> '
b option) -> 'a list
-> '
b list
795 val find_some
: ('a
-> '
b option) -> 'a list
-> '
b
797 val list_to_single_or_exn
: 'a list
-> 'a
799 (*****************************************************************************)
801 (*****************************************************************************)
802 type bool3
= True3
| False3
| TrueFalsePb3
of string
805 (*****************************************************************************)
807 (*****************************************************************************)
809 val slength
: string -> int (* alias *)
810 val concat
: string -> string list
-> string (* alias *)
812 val i_to_s
: int -> string
813 val s_to_i
: string -> int
815 (* strings take space in memory. Better when can share the space used by
818 val _shareds
: (string, string) Hashtbl.t
819 val shared_string
: string -> string
821 val chop
: string -> string
822 val chop_dirsymbol
: string -> string
824 val ( <!!> ) : string -> int * int -> string
825 val ( <!> ) : string -> int -> char
827 val take_string
: int -> string -> string
828 val take_string_safe
: int -> string -> string
830 val split_on_char
: char
-> string -> string list
832 val lowercase
: string -> string
834 val quote
: string -> string
836 val null_string
: string -> bool
837 val is_blank_string
: string -> bool
838 val is_string_prefix
: string -> string -> bool
841 val plural
: int -> string -> string
843 val showCodeHex
: int list
-> unit
845 val size_mo_ko
: int -> string
846 val size_ko
: int -> string
848 val edit_distance
: string -> string -> int
850 val md5sum_of_string
: string -> string
852 (*****************************************************************************)
854 (*****************************************************************************)
856 val regexp_alpha
: Str.regexp
857 val regexp_word
: Str.regexp
859 val _memo_compiled_regexp
: (string, Str.regexp
) Hashtbl.t
860 val ( =~
) : string -> string -> bool
861 val ( ==~
) : string -> Str.regexp
-> bool
865 val regexp_match
: string -> string -> string
867 val matched
: int -> string -> string
869 (* not yet politypic functions in ocaml *)
870 val matched1
: string -> string
871 val matched2
: string -> string * string
872 val matched3
: string -> string * string * string
873 val matched4
: string -> string * string * string * string
874 val matched5
: string -> string * string * string * string * string
875 val matched6
: string -> string * string * string * string * string * string
876 val matched7
: string -> string * string * string * string * string * string * string
878 val string_match_substring
: Str.regexp
-> string -> bool
880 val split
: string (* sep regexp *) -> string -> string list
881 val join
: string (* sep *) -> string list
-> string
883 val split_list_regexp
: string -> string list
-> (string * string list
) list
885 val all_match
: string (* regexp *) -> string -> string list
886 val global_replace_regexp
:
887 string (* regexp *) -> (string -> string) -> string -> string
889 val regular_words
: string -> string list
890 val contain_regular_word
: string -> bool
892 (*****************************************************************************)
894 (*****************************************************************************)
896 (* now at beginning of this file: type filename = string *)
897 val dirname
: string -> string
898 val basename
: string -> string
900 val filesuffix
: filename
-> string
901 val fileprefix
: filename
-> string
903 val adjust_ext_if_needed
: filename
-> string -> filename
905 (* db for dir, base *)
906 val db_of_filename
: filename
-> (string * filename
)
907 val filename_of_db
: (string * filename
) -> filename
909 (* dbe for dir, base, ext *)
910 val dbe_of_filename
: filename
-> string * string * string
911 val dbe_of_filename_nodot
: filename
-> string * string * string
912 (* Left (d,b,e) | Right (d,b) if file has no extension *)
913 val dbe_of_filename_safe
:
914 filename
-> (string * string * string, string * string) either
916 val filename_of_dbe
: string * string * string -> filename
918 (* ex: replace_ext "toto.c" "c" "var" *)
919 val replace_ext
: filename
-> string -> string -> filename
921 (* remove the ., .. *)
922 val normalize_path
: filename
-> filename
924 val relative_to_absolute
: filename
-> filename
926 val is_relative
: filename
-> bool
927 val is_absolute
: filename
-> bool
929 val filename_without_leading_path
: string -> filename
-> filename
931 (*****************************************************************************)
933 (*****************************************************************************)
939 (*****************************************************************************)
941 (*****************************************************************************)
943 (* can also use ocamlcalendar, but heavier, use many modules ... *)
946 | Jan
| Feb
| Mar
| Apr
| May
| Jun
947 | Jul
| Aug
| Sep
| Oct
| Nov
| Dec
948 type year
= Year
of int
949 type day
= Day
of int
951 type date_dmy
= DMY
of day
* month
* year
953 type hour
= Hour
of int
954 type minute
= Min
of int
955 type second
= Sec
of int
957 type time_hms
= HMS
of hour
* minute
* second
959 type full_date
= date_dmy
* time_hms
963 type days
= Days
of int
965 type time_dmy
= TimeDMY
of day
* month
* year
969 type float_time
= float
972 val mk_date_dmy
: int -> int -> int -> date_dmy
975 val check_date_dmy
: date_dmy
-> unit
976 val check_time_dmy
: time_dmy
-> unit
977 val check_time_hms
: time_hms
-> unit
979 val int_to_month
: int -> string
980 val int_of_month
: month
-> int
981 val month_of_string
: string -> month
982 val month_of_string_long
: string -> month
983 val string_of_month
: month
-> string
985 val string_of_date_dmy
: date_dmy
-> string
986 val string_of_unix_time
: ?langage
:langage
-> Unix.tm
-> string
987 val short_string_of_unix_time
: ?langage
:langage
-> Unix.tm
-> string
988 val string_of_floattime
: ?langage
:langage
-> float_time
-> string
989 val short_string_of_floattime
: ?langage
:langage
-> float_time
-> string
991 val floattime_of_string
: string -> float_time
993 val dmy_to_unixtime
: date_dmy
-> float_time
* Unix.tm
994 val unixtime_to_dmy
: Unix.tm
-> date_dmy
995 val unixtime_to_floattime
: Unix.tm
-> float_time
996 val floattime_to_unixtime
: float_time
-> Unix.tm
998 val sec_to_days
: int -> string
999 val sec_to_hours
: int -> string
1001 val today
: unit -> float_time
1002 val yesterday
: unit -> float_time
1003 val tomorrow
: unit -> float_time
1005 val lastweek
: unit -> float_time
1006 val lastmonth
: unit -> float_time
1008 val week_before
: float_time
-> float_time
1009 val month_before
: float_time
-> float_time
1010 val week_after
: float_time
-> float_time
1012 val days_in_week_of_day
: float_time
-> float_time list
1014 val first_day_in_week_of_day
: float_time
-> float_time
1015 val last_day_in_week_of_day
: float_time
-> float_time
1017 val day_secs
: float_time
1019 val rough_days_since_jesus
: date_dmy
-> days
1020 val rough_days_between_dates
: date_dmy
-> date_dmy
-> days
1022 val string_of_unix_time_lfs
: Unix.tm
-> string
1024 val is_more_recent
: date_dmy
-> date_dmy
-> bool
1025 val max_dmy
: date_dmy
-> date_dmy
-> date_dmy
1026 val min_dmy
: date_dmy
-> date_dmy
-> date_dmy
1027 val maximum_dmy
: date_dmy list
-> date_dmy
1028 val minimum_dmy
: date_dmy list
-> date_dmy
1030 (*****************************************************************************)
1031 (* Lines/Words/Strings *)
1032 (*****************************************************************************)
1034 val list_of_string
: string -> char list
1036 val lines
: string -> string list
1037 val unlines
: string list
-> string
1039 val words
: string -> string list
1040 val unwords
: string list
-> string
1042 val split_space
: string -> string list
1044 val lines_with_nl
: string -> string list
1046 val nblines
: string -> int
1048 (*****************************************************************************)
1050 (*****************************************************************************)
1051 val cat
: filename
-> string list
1052 val cat_orig
: filename
-> string list
1053 val cat_array
: filename
-> string array
1055 val uncat
: string list
-> filename
-> unit
1057 val interpolate
: string -> string list
1059 val echo
: string -> string
1061 val usleep
: int -> unit
1063 val process_output_to_list
: string -> string list
1064 val cmd_to_list
: string -> string list
(* alias *)
1065 val cmd_to_list_and_status
: string -> string list
* Unix.process_status
1067 val command2
: string -> unit
1068 val _batch_mode
: bool ref
1069 val command2_y_or_no
: string -> bool
1070 val command2_y_or_no_exit_if_no
: string -> unit
1072 val do_in_fork
: (unit -> unit) -> int
1074 val mkdir
: ?mode
:Unix.file_perm
-> string -> unit
1076 val read_file
: filename
-> string
1077 val write_file
: file
:filename
-> string -> unit
1079 val filesize
: filename
-> int
1080 val filemtime
: filename
-> float
1082 val nblines_file
: filename
-> int
1084 val lfile_exists
: filename
-> bool
1085 val is_directory
: filename
-> bool
1087 val capsule_unix
: ('a
-> unit) -> 'a
-> unit
1089 val readdir_to_kind_list
: string -> Unix.file_kind
-> string list
1090 val readdir_to_dir_list
: string -> string list
1091 val readdir_to_file_list
: string -> string list
1092 val readdir_to_link_list
: string -> string list
1093 val readdir_to_dir_size_list
: string -> (string * int) list
1095 val glob
: string -> filename list
1096 val files_of_dir_or_files
:
1097 string (* ext *) -> string list
-> filename list
1098 val files_of_dir_or_files_no_vcs
:
1099 string (* ext *) -> string list
-> filename list
1100 (* use a post filter =~ for the ext filtering *)
1101 val files_of_dir_or_files_no_vcs_post_filter
:
1102 string (* regexp *) -> string list
-> filename list
1105 val sanity_check_files_and_adjust
:
1106 string (* ext *) -> string list
-> filename list
1109 type rwx
= [ `R
| `W
| `X
] list
1110 val file_perm_of
: u
:rwx
-> g
:rwx
-> o
:rwx
-> Unix.file_perm
1112 val has_env
: string -> bool
1114 (* scheme spirit. do a finalize so no leak. *)
1115 val with_open_outfile
:
1116 filename
-> ((string -> unit) * out_channel
-> 'a
) -> 'a
1117 val with_open_infile
:
1118 filename
-> (in_channel
-> 'a
) -> 'a
1119 val with_open_outfile_append
:
1120 filename
-> ((string -> unit) * out_channel
-> 'a
) -> 'a
1122 val with_open_stringbuf
:
1123 (((string -> unit) * Buffer.t
) -> unit) -> string
1127 (* subtil: have to make sure that Timeout is not intercepted before here. So
1128 * avoid exn handler such as try (...) with _ -> cos Timeout will not bubble up
1129 * enough. In such case, add a case before such as
1130 * with Timeout -> raise Timeout | _ -> ...
1132 * The same is true for UnixExit (see below).
1134 val timeout_function
: int -> (unit -> 'a
) -> 'a
1136 val timeout_function_opt
: int option -> (unit -> 'a
) -> 'a
1139 (* creation of /tmp files, a la gcc
1140 * ex: new_temp_file "cocci" ".c" will give "/tmp/cocci-3252-434465.c"
1142 val _temp_files_created
: string list
ref
1143 (* see flag: val save_tmp_files : bool ref *)
1144 val new_temp_file
: string (* prefix *) -> string (* suffix *) -> filename
1145 val erase_temp_files
: unit -> unit
1146 val erase_this_temp_file
: filename
-> unit
1148 (* If the user use some exit 0 in his code, then no one can intercept this
1149 * exit and do something before exiting. There is exn handler for exit 0
1150 * so better never use exit 0 but instead use an exception and just at
1151 * the very toplevel transform this exn in a unix exit code.
1153 * subtil: same problem than with Timeout. Do not intercept such exception
1154 * with some blind try (...) with _ -> ...
1156 exception UnixExit
of int
1157 val exn_to_real_unixexit
: (unit -> 'a
) -> 'a
1166 (*###########################################################################*)
1167 (* And now collection-like types. See also ocollection.mli *)
1168 (*###########################################################################*)
1170 (*****************************************************************************)
1172 (*****************************************************************************)
1175 (* tail recursive efficient map (but that also reverse the element!) *)
1176 val map_eff_rev
: ('a
-> '
b) -> 'a list
-> '
b list
1177 (* tail recursive efficient map, use accumulator *)
1178 val acc_map
: ('a
-> '
b) -> 'a list
-> '
b list
1181 val zip
: 'a list
-> '
b list
-> ('a
* '
b) list
1182 val zip_safe
: 'a list
-> '
b list
-> ('a
* '
b) list
1183 val unzip
: ('a
* '
b) list
-> 'a list
* '
b list
1185 val take
: int -> 'a list
-> 'a list
1186 val take_safe
: int -> 'a list
-> 'a list
1187 val take_until
: ('a
-> bool) -> 'a list
-> 'a list
1188 val take_while
: ('a
-> bool) -> 'a list
-> 'a list
1190 val drop
: int -> 'a list
-> 'a list
1191 val drop_while
: ('a
-> bool) -> 'a list
-> 'a list
1192 val drop_until
: ('a
-> bool) -> 'a list
-> 'a list
1194 val span
: ('a
-> bool) -> 'a list
-> 'a list
* 'a list
1196 val skip_until
: ('a list
-> bool) -> 'a list
-> 'a list
1197 val skipfirst
: (* Eq a *) 'a
-> 'a list
-> 'a list
1199 (* cf also List.partition *)
1200 val fpartition
: ('a
-> '
b option) -> 'a list
-> '
b list
* 'a list
1202 val groupBy
: ('a
-> 'a
-> bool) -> 'a list
-> 'a list list
1203 val exclude_but_keep_attached
: ('a
-> bool) -> 'a list
-> ('a
* 'a list
) list
1204 val group_by_post
: ('a
-> bool) -> 'a list
-> ('a list
* 'a
) list
* 'a list
1205 val group_by_pre
: ('a
-> bool) -> 'a list
-> 'a list
* ('a
* 'a list
) list
1206 val group_by_mapped_key
: ('a
-> '
b) -> 'a list
-> ('
b * 'a list
) list
1208 (* Use hash internally to not be in O(n2). If you want to use it on a
1209 * simple list, then first do a List.map to generate a key, for instance the
1210 * first char of the element, and then use this function.
1212 val group_assoc_bykey_eff
: ('a
* '
b) list
-> ('a
* '
b list
) list
1214 val splitAt
: int -> 'a list
-> 'a list
* 'a list
1216 val split_when
: ('a
-> bool) -> 'a list
-> 'a list
* 'a
* 'a list
1217 val split_gen_when
: ('a list
-> 'a list
option) -> 'a list
-> 'a list list
1219 val pack
: int -> 'a list
-> 'a list list
1222 val enum
: int -> int -> int list
1223 val repeat
: 'a
-> int -> 'a list
1224 val generate
: int -> 'a
-> 'a list
1228 val index_list
: 'a list
-> ('a
* int) list
1229 val index_list_1
: 'a list
-> ('a
* int) list
1230 val index_list_and_total
: 'a list
-> ('a
* int * int) list
1232 val iter_index
: ('a
-> int -> '
b) -> 'a list
-> unit
1233 val map_index
: ('a
-> int -> '
b) -> 'a list
-> '
b list
1234 val filter_index
: (int -> 'a
-> bool) -> 'a list
-> 'a list
1235 val fold_left_with_index
: ('a
-> '
b -> int -> 'a
) -> 'a
-> '
b list
-> 'a
1237 val nth
: 'a list
-> int -> 'a
1238 val rang
: (* Eq a *) 'a
-> 'a list
-> int
1240 val last_n
: int -> 'a list
-> 'a list
1244 val snoc
: 'a
-> 'a list
-> 'a list
1245 val cons
: 'a
-> 'a list
-> 'a list
1246 val uncons
: 'a list
-> 'a
* 'a list
1247 val safe_tl
: 'a list
-> 'a list
1248 val head_middle_tail
: 'a list
-> 'a
* 'a list
* 'a
1249 val last
: 'a list
-> 'a
1250 val list_init
: 'a list
-> 'a list
1251 val list_last
: 'a list
-> 'a
1252 val removelast
: 'a list
-> 'a list
1254 val inits
: 'a list
-> 'a list list
1255 val tails
: 'a list
-> 'a list list
1258 val ( ++ ) : 'a list
-> 'a list
-> 'a list
1260 val foldl1
: ('a
-> 'a
-> 'a
) -> 'a list
-> 'a
1261 val fold_k
: ('a
-> '
b -> ('a
-> 'a
) -> 'a
) -> ('a
-> 'a
) -> 'a
-> '
b list
-> 'a
1262 val fold_right1
: ('a
-> 'a
-> 'a
) -> 'a list
-> 'a
1263 val fold_left
: ('a
-> '
b -> 'a
) -> 'a
-> '
b list
-> 'a
1265 val rev_map
: ('a
-> '
b) -> 'a list
-> '
b list
1267 val join_gen
: 'a
-> 'a list
-> 'a list
1270 (('a
-> '
b) -> 'c
-> 'd
) -> ('e
-> 'a
-> '
b * 'e
) -> 'e
-> 'c
-> 'd
* 'e
1271 val map_withenv
: ('a
-> '
b -> 'c
* 'a
) -> 'a
-> '
b list
-> 'c list
* 'a
1272 val map_withkeep
: ('a
-> '
b) -> 'a list
-> ('
b * 'a
) list
1274 val collect_accu
: ('a
-> '
b list
) -> '
b list
-> 'a list
-> '
b list
1275 val collect
: ('a
-> '
b list
) -> 'a list
-> '
b list
1277 val remove
: 'a
-> 'a list
-> 'a list
1279 val exclude
: ('a
-> bool) -> 'a list
-> 'a list
1281 (* Not like unix uniq command line tool that only delete contiguous repeated
1282 * line. Here we delete any repeated line (here list element).
1284 val uniq
: 'a list
-> 'a list
1285 val uniq_eff
: 'a list
-> 'a list
1287 val has_no_duplicate
: 'a list
-> bool
1288 val is_set_as_list
: 'a list
-> bool
1289 val get_duplicates
: 'a list
-> 'a list
1291 val doublon
: 'a list
-> bool
1293 val reverse
: 'a list
-> 'a list
(* alias *)
1294 val rev
: 'a list
-> 'a list
(* alias *)
1295 val rotate
: 'a list
-> 'a list
1297 val map_flatten
: ('a
-> '
b list
) -> 'a list
-> '
b list
1299 val map2
: ('a
-> '
b) -> 'a list
-> '
b list
1300 val map3
: ('a
-> '
b) -> 'a list
-> '
b list
1303 val maximum
: 'a list
-> 'a
1304 val minimum
: 'a list
-> 'a
1306 val min_with
: ('a
-> '
b) -> 'a list
-> 'a
1307 val two_mins_with
: ('a
-> '
b) -> 'a list
-> 'a
* 'a
1309 val all_assoc
: (* Eq a *) 'a
-> ('a
* '
b) list
-> '
b list
1310 val prepare_want_all_assoc
: ('a
* '
b) list
-> ('a
* '
b list
) list
1312 val or_list
: bool list
-> bool
1313 val and_list
: bool list
-> bool
1315 val sum_float
: float list
-> float
1316 val sum_int
: int list
-> int
1317 val avg_list
: int list
-> float
1319 val return_when
: ('a
-> '
b option) -> 'a list
-> '
b
1322 val grep_with_previous
: ('a
-> 'a
-> bool) -> 'a list
-> 'a list
1323 val iter_with_previous
: ('a
-> 'a
-> '
b) -> 'a list
-> unit
1325 val iter_with_before_after
:
1326 ('a list
-> 'a
-> 'a list
-> unit) -> 'a list
-> unit
1328 val get_pair
: 'a list
-> ('a
* 'a
) list
1330 val permutation
: 'a list
-> 'a list list
1332 val remove_elem_pos
: int -> 'a list
-> 'a list
1333 val insert_elem_pos
: ('a
* int) -> 'a list
-> 'a list
1334 val uncons_permut
: 'a list
-> (('a
* int) * 'a list
) list
1335 val uncons_permut_lazy
: 'a list
-> (('a
* int) * 'a list
Lazy.t
) list
1338 val pack_sorted
: ('a
-> 'a
-> bool) -> 'a list
-> 'a list list
1340 val keep_best
: ('a
* 'a
-> 'a
option) -> 'a list
-> 'a list
1341 val sorted_keep_best
: ('a
-> 'a
-> 'a
option) -> 'a list
-> 'a list
1344 val cartesian_product
: 'a list
-> '
b list
-> ('a
* '
b) list
1347 val surEnsemble
: 'a list
-> 'a list list
-> 'a list list
1348 val realCombinaison
: 'a list
-> 'a list list
1349 val combinaison
: 'a list
-> ('a
* 'a
) list
1350 val insere
: 'a
-> 'a list list
-> 'a list list
1351 val insereListeContenant
: 'a list
-> 'a
-> 'a list list
-> 'a list list
1352 val fusionneListeContenant
: 'a
* 'a
-> 'a list list
-> 'a list list
1354 (*****************************************************************************)
1356 (*****************************************************************************)
1358 val array_find_index
: (int -> bool) -> 'a array
-> int
1359 val array_find_index_via_elem
: ('a
-> bool) -> 'a array
-> int
1361 (* for better type checking, as sometimes when have an 'int array', can
1362 * easily mess up the index from the value.
1364 type idx
= Idx
of int
1365 val next_idx
: idx
-> idx
1366 val int_of_idx
: idx
-> int
1368 val array_find_index_typed
: (idx
-> bool) -> 'a array
-> idx
1370 (*****************************************************************************)
1372 (*****************************************************************************)
1374 type 'a matrix
= 'a array array
1376 val map_matrix
: ('a
-> '
b) -> 'a matrix
-> '
b matrix
1378 val make_matrix_init
:
1379 nrow
:int -> ncolumn
:int -> (int -> int -> 'a
) -> 'a matrix
1382 (int -> int -> 'a
-> unit) -> 'a matrix
-> unit
1384 val nb_rows_matrix
: 'a matrix
-> int
1385 val nb_columns_matrix
: 'a matrix
-> int
1387 val rows_of_matrix
: 'a matrix
-> 'a list list
1388 val columns_of_matrix
: 'a matrix
-> 'a list list
1390 val all_elems_matrix_by_row
: 'a matrix
-> 'a list
1392 (*****************************************************************************)
1394 (*****************************************************************************)
1398 (*****************************************************************************)
1399 (* Set. But have a look too at set*.mli; it's better. Or use Hashtbl. *)
1400 (*****************************************************************************)
1402 type 'a set
= 'a list
1404 val empty_set
: 'a set
1406 val insert_set
: 'a
-> 'a set
-> 'a set
1407 val single_set
: 'a
-> 'a set
1408 val set
: 'a list
-> 'a set
1410 val is_set
: 'a list
-> bool
1412 val exists_set
: ('a
-> bool) -> 'a set
-> bool
1413 val forall_set
: ('a
-> bool) -> 'a set
-> bool
1415 val filter_set
: ('a
-> bool) -> 'a set
-> 'a set
1416 val fold_set
: ('a
-> '
b -> 'a
) -> 'a
-> '
b set
-> 'a
1417 val map_set
: ('a
-> '
b) -> 'a set
-> '
b set
1419 val member_set
: 'a
-> 'a set
-> bool
1420 val find_set
: ('a
-> bool) -> 'a list
-> 'a
1422 val sort_set
: ('a
-> 'a
-> int) -> 'a list
-> 'a list
1424 val iter_set
: ('a
-> unit) -> 'a list
-> unit
1426 val top_set
: 'a set
-> 'a
1428 val inter_set
: 'a set
-> 'a set
-> 'a set
1429 val union_set
: 'a set
-> 'a set
-> 'a set
1430 val minus_set
: 'a set
-> 'a set
-> 'a set
1432 val union_all
: ('a set
) list
-> 'a set
1434 val big_union_set
: ('a
-> '
b set
) -> 'a set
-> '
b set
1435 val card_set
: 'a set
-> int
1437 val include_set
: 'a set
-> 'a set
-> bool
1438 val equal_set
: 'a set
-> 'a set
-> bool
1439 val include_set_strict
: 'a set
-> 'a set
-> bool
1441 (* could put them in Common.Infix *)
1442 val ( $
*$
) : 'a set
-> 'a set
-> 'a set
1443 val ( $
+$
) : 'a set
-> 'a set
-> 'a set
1444 val ( $
-$
) : 'a set
-> 'a set
-> 'a set
1446 val ( $?$
) : 'a
-> 'a set
-> bool
1447 val ( $
<$
) : 'a set
-> 'a set
-> bool
1448 val ( $
<=$
) : 'a set
-> 'a set
-> bool
1449 val ( $
=$
) : 'a set
-> 'a set
-> bool
1451 val ( $
@$
) : 'a list
-> 'a list
-> 'a list
1453 val nub
: 'a list
-> 'a list
1455 (* use internally a hash and return
1456 * - the common part,
1460 val diff_two_say_set_eff
: 'a list
-> 'a list
->
1461 'a list
* 'a list
* 'a list
1463 (*****************************************************************************)
1464 (* Set as normal list *)
1465 (*****************************************************************************)
1469 (*****************************************************************************)
1470 (* Set as sorted list *)
1471 (*****************************************************************************)
1474 (*****************************************************************************)
1475 (* Sets specialized *)
1476 (*****************************************************************************)
1479 module StringSet = Set.Make(struct type t = string let compare = compare end)
1483 (*****************************************************************************)
1484 (* Assoc. But have a look too at Mapb.mli; it's better. Or use Hashtbl. *)
1485 (*****************************************************************************)
1487 type ('a
, '
b) assoc
= ('a
* '
b) list
1489 val assoc_to_function
: (* Eq a *) ('a
, '
b) assoc
-> ('a
-> '
b)
1491 val empty_assoc
: ('a
, '
b) assoc
1492 val fold_assoc
: ('a
-> '
b -> 'a
) -> 'a
-> '
b list
-> 'a
1493 val insert_assoc
: 'a
-> 'a list
-> 'a list
1494 val map_assoc
: ('a
-> '
b) -> 'a list
-> '
b list
1495 val filter_assoc
: ('a
-> bool) -> 'a list
-> 'a list
1497 val assoc
: 'a
-> ('a
* '
b) list
-> '
b
1499 val keys
: ('a
* '
b) list
-> 'a list
1500 val lookup
: 'a
-> ('a
* '
b) list
-> '
b
1502 val del_assoc
: 'a
-> ('a
* '
b) list
-> ('a
* '
b) list
1503 val replace_assoc
: 'a
* '
b -> ('a
* '
b) list
-> ('a
* '
b) list
1504 val apply_assoc
: 'a
-> ('
b -> '
b) -> ('a
* '
b) list
-> ('a
* '
b) list
1506 val big_union_assoc
: ('a
-> '
b set
) -> 'a list
-> '
b set
1508 val assoc_reverse
: ('a
* '
b) list
-> ('
b * 'a
) list
1509 val assoc_map
: ('a
* '
b) list
-> ('a
* '
b) list
-> ('a
* 'a
) list
1511 val lookup_list
: 'a
-> ('a
, '
b) assoc list
-> '
b
1512 val lookup_list2
: 'a
-> ('a
, '
b) assoc list
-> '
b * int
1514 val assoc_option
: 'a
-> ('a
, '
b) assoc
-> '
b option
1515 val assoc_with_err_msg
: 'a
-> ('a
, '
b) assoc
-> '
b
1517 val sort_by_val_lowfirst
: ('a
,'
b) assoc
-> ('a
* '
b) list
1518 val sort_by_val_highfirst
: ('a
,'
b) assoc
-> ('a
* '
b) list
1520 val sort_by_key_lowfirst
: (int,'
b) assoc
-> (int * '
b) list
1521 val sort_by_key_highfirst
: (int,'
b) assoc
-> (int * '
b) list
1523 val sortgen_by_key_lowfirst
: ('a
,'
b) assoc
-> ('a
* '
b) list
1524 val sortgen_by_key_highfirst
: ('a
,'
b) assoc
-> ('a
* '
b) list
1526 (*****************************************************************************)
1527 (* Assoc, specialized. *)
1528 (*****************************************************************************)
1535 val is_empty
: 'a t
-> bool
1536 val add
: key
-> 'a
-> 'a t
-> 'a t
1537 val find
: key
-> 'a t
-> 'a
1538 val remove
: key
-> 'a t
-> 'a t
1539 val mem
: key
-> 'a t
-> bool
1540 val iter
: (key
-> 'a
-> unit) -> 'a t
-> unit
1541 val map
: ('a
-> '
b) -> 'a t
-> '
b t
1542 val mapi
: (key
-> 'a
-> '
b) -> 'a t
-> '
b t
1543 val fold
: (key
-> 'a
-> '
b -> '
b) -> 'a t
-> '
b -> '
b
1544 val compare : ('a
-> 'a
-> int) -> 'a t
-> 'a t
-> int
1545 val equal
: ('a
-> 'a
-> bool) -> 'a t
-> 'a t
-> bool
1547 val intmap_to_list
: 'a
IntMap.t
-> (IntMap.key
* 'a
) list
1548 val intmap_string_of_t
: 'a
-> '
b -> string
1552 type key
= int * int
1555 val is_empty
: 'a t
-> bool
1556 val add
: key
-> 'a
-> 'a t
-> 'a t
1557 val find
: key
-> 'a t
-> 'a
1558 val remove
: key
-> 'a t
-> 'a t
1559 val mem
: key
-> 'a t
-> bool
1560 val iter
: (key
-> 'a
-> unit) -> 'a t
-> unit
1561 val map
: ('a
-> '
b) -> 'a t
-> '
b t
1562 val mapi
: (key
-> 'a
-> '
b) -> 'a t
-> '
b t
1563 val fold
: (key
-> 'a
-> '
b -> '
b) -> 'a t
-> '
b -> '
b
1564 val compare : ('a
-> 'a
-> int) -> 'a t
-> 'a t
-> int
1565 val equal
: ('a
-> 'a
-> bool) -> 'a t
-> 'a t
-> bool
1567 val intintmap_to_list
: 'a
IntIntMap.t
-> (IntIntMap.key
* 'a
) list
1568 val intintmap_string_of_t
: 'a
-> '
b -> string
1571 (*****************************************************************************)
1573 (*****************************************************************************)
1575 (* Note that Hashtbl keep old binding to a key so if want a hash
1576 * of a list, then can use the Hashtbl as is. Use Hashtbl.find_all then
1577 * to get the list of bindings
1579 * Note that Hashtbl module use different convention :( the object is
1580 * the first argument, not last as for List or Map.
1583 (* obsolete: can use directly the Hashtbl module *)
1584 val hcreate
: unit -> ('a
, '
b) Hashtbl.t
1585 val hadd
: 'a
* '
b -> ('a
, '
b) Hashtbl.t
-> unit
1586 val hmem
: 'a
-> ('a
, '
b) Hashtbl.t
-> bool
1587 val hfind
: 'a
-> ('a
, '
b) Hashtbl.t
-> '
b
1588 val hreplace
: 'a
* '
b -> ('a
, '
b) Hashtbl.t
-> unit
1589 val hiter
: ('a
-> '
b -> unit) -> ('a
, '
b) Hashtbl.t
-> unit
1590 val hfold
: ('a
-> '
b -> 'c
-> 'c
) -> ('a
, '
b) Hashtbl.t
-> 'c
-> 'c
1591 val hremove
: 'a
-> ('a
, '
b) Hashtbl.t
-> unit
1594 val hfind_default
: 'a
-> (unit -> '
b) -> ('a
, '
b) Hashtbl.t
-> '
b
1595 val hfind_option
: 'a
-> ('a
, '
b) Hashtbl.t
-> '
b option
1596 val hupdate_default
:
1597 'a
-> ('
b -> '
b) -> (unit -> '
b) -> ('a
, '
b) Hashtbl.t
-> unit
1599 val hash_to_list
: ('a
, '
b) Hashtbl.t
-> ('a
* '
b) list
1600 val hash_to_list_unsorted
: ('a
, '
b) Hashtbl.t
-> ('a
* '
b) list
1601 val hash_of_list
: ('a
* '
b) list
-> ('a
, '
b) Hashtbl.t
1604 val hkeys
: ('a
, '
b) Hashtbl.t
-> 'a list
1606 (*****************************************************************************)
1608 (*****************************************************************************)
1610 type 'a hashset
= ('a
, bool) Hashtbl.t
1613 (* common use of hashset, in a hash of hash *)
1614 val hash_hashset_add
: 'a
-> '
b -> ('a
, '
b hashset
) Hashtbl.t
-> unit
1616 val hashset_to_set
:
1617 < fromlist
: ('a
) list
-> 'c
; .. > -> ('a
, '
b) Hashtbl.t
-> 'c
1619 val hashset_to_list
: 'a hashset
-> 'a list
1620 val hashset_of_list
: 'a list
-> 'a hashset
1623 (*****************************************************************************)
1625 (*****************************************************************************)
1627 type 'a stack
= 'a list
1628 val empty_stack
: 'a stack
1629 val push
: 'a
-> 'a stack
-> 'a stack
1630 val top
: 'a stack
-> 'a
1631 val pop
: 'a stack
-> 'a stack
1633 val top_option
: 'a stack
-> 'a
option
1635 val push2
: 'a
-> 'a stack
ref -> unit
1636 val pop2
: 'a stack
ref -> 'a
1638 (*****************************************************************************)
1639 (* Stack with undo/redo support *)
1640 (*****************************************************************************)
1642 type 'a undo_stack
= 'a list
* 'a list
1643 val empty_undo_stack
: 'a undo_stack
1644 val push_undo
: 'a
-> 'a undo_stack
-> 'a undo_stack
1645 val top_undo
: 'a undo_stack
-> 'a
1646 val pop_undo
: 'a undo_stack
-> 'a undo_stack
1647 val redo_undo
: 'a undo_stack
-> 'a undo_stack
1648 val undo_pop
: 'a undo_stack
-> 'a undo_stack
1650 val top_undo_option
: 'a undo_stack
-> 'a
option
1653 (*****************************************************************************)
1655 (*****************************************************************************)
1656 type 'a bintree
= Leaf
of 'a
| Branch
of ('a bintree
* 'a bintree
)
1658 (*****************************************************************************)
1660 (*****************************************************************************)
1662 (* no empty tree, must have one root at least *)
1663 type 'a tree
= Tree
of 'a
* ('a tree
) list
1665 val tree_iter
: ('a
-> unit) -> 'a tree
-> unit
1668 (*****************************************************************************)
1669 (* N-ary tree with updatable childrens *)
1670 (*****************************************************************************)
1672 (* no empty tree, must have one root at least *)
1674 | NodeRef
of 'a
* 'a treeref list
ref
1676 val treeref_node_iter
:
1677 (('a
* 'a treeref list
ref) -> unit) -> 'a treeref
-> unit
1678 val treeref_node_iter_with_parents
:
1679 (('a
* 'a treeref list
ref) -> ('a list
) -> unit) ->
1683 (('a
* 'a treeref list
ref) -> bool) ->
1684 'a treeref
-> 'a treeref
1686 val treeref_children_ref
:
1687 'a treeref
-> 'a treeref list
ref
1689 val find_treeref_with_parents_some
:
1690 ('a
* 'a treeref list
ref -> 'a list
-> 'c
option) ->
1693 val find_multi_treeref_with_parents_some
:
1694 ('a
* 'a treeref list
ref -> 'a list
-> 'c
option) ->
1695 'a treeref
-> 'c list
1698 (* Leaf can seem redundant, but sometimes want to directly see if
1699 * a children is a leaf without looking if the list is empty.
1701 type ('a
, '
b) treeref2
=
1702 | NodeRef2
of 'a
* ('a
, '
b) treeref2 list
ref
1707 (('a
* ('a
, '
b) treeref2 list
ref) -> bool) ->
1708 ('a
, '
b) treeref2
-> ('a
, '
b) treeref2
1710 val treeref_node_iter_with_parents2
:
1711 (('a
* ('a
, '
b) treeref2 list
ref) -> ('a list
) -> unit) ->
1712 ('a
, '
b) treeref2
-> unit
1714 val treeref_node_iter2
:
1715 (('a
* ('a
, '
b) treeref2 list
ref) -> unit) -> ('a
, '
b) treeref2
-> unit
1720 val treeref_children_ref: ('a, 'b) treeref -> ('a, 'b) treeref list ref
1722 val find_treeref_with_parents_some:
1723 ('a * ('a, 'b) treeref list ref -> 'a list -> 'c option) ->
1724 ('a, 'b) treeref -> 'c
1726 val find_multi_treeref_with_parents_some:
1727 ('a * ('a, 'b) treeref list ref -> 'a list -> 'c option) ->
1728 ('a, 'b) treeref -> 'c list
1731 (*****************************************************************************)
1732 (* Graph. But have a look too at Ograph_*.mli; it's better *)
1733 (*****************************************************************************)
1735 type 'a graph
= 'a set
* ('a
* 'a
) set
1737 val add_node
: 'a
-> 'a graph
-> 'a graph
1738 val del_node
: 'a
-> 'a graph
-> 'a graph
1740 val add_arc
: 'a
* 'a
-> 'a graph
-> 'a graph
1741 val del_arc
: 'a
* 'a
-> 'a graph
-> 'a graph
1743 val successors
: 'a
-> 'a graph
-> 'a set
1744 val predecessors
: 'a
-> 'a graph
-> 'a set
1746 val nodes
: 'a graph
-> 'a set
1748 val fold_upward
: ('a
-> '
b -> 'a
) -> '
b set
-> 'a
-> '
b graph
-> 'a
1750 val empty_graph
: 'a list
* '
b list
1753 (*****************************************************************************)
1755 (*****************************************************************************)
1757 (* mostly alias to functions in List *)
1759 val map
: ('a
-> '
b) -> 'a list
-> '
b list
1760 val filter
: ('a
-> bool) -> 'a list
-> 'a list
1761 val fold
: ('a
-> '
b -> 'a
) -> 'a
-> '
b list
-> 'a
1763 val member
: 'a
-> 'a list
-> bool
1765 val iter
: ('a
-> unit) -> 'a list
-> unit
1767 val find
: ('a
-> bool) -> 'a list
-> 'a
1769 val exists
: ('a
-> bool) -> 'a list
-> bool
1770 val forall
: ('a
-> bool) -> 'a list
-> bool
1772 val big_union
: ('a
-> '
b set
) -> 'a list
-> '
b set
1774 (* same than [] but easier to search for, because [] can also be a pattern *)
1775 val empty_list
: 'a list
1777 val sort
: ('a
-> 'a
-> int) -> 'a list
-> 'a list
1779 val length
: 'a list
-> int
1781 val null
: 'a list
-> bool
1783 val head
: 'a list
-> 'a
1784 val tail
: 'a list
-> 'a list
1786 val is_singleton
: 'a list
-> bool
1796 (*###########################################################################*)
1797 (* And now misc functions *)
1798 (*###########################################################################*)
1800 (*****************************************************************************)
1802 (*****************************************************************************)
1804 (* cf oassocbdb.ml or oassocdbm.ml *)
1806 (*****************************************************************************)
1807 (* GUI (LFS, CComment, otimetracker) *)
1808 (*****************************************************************************)
1810 (* cf ocamlgtk and my gui.ml *)
1813 (*****************************************************************************)
1814 (* Graphics (otimetracker) *)
1815 (*****************************************************************************)
1817 (* cf ocamlgl and my opengl.ml *)
1821 (*****************************************************************************)
1822 (* Geometry (ICFP raytracer) *)
1823 (*****************************************************************************)
1825 type vector
= float * float * float
1830 val dotproduct
: vector
* vector
-> float
1832 val vector_length
: vector
-> float
1834 val minus_point
: point
* point
-> vector
1836 val distance
: point
* point
-> float
1838 val normalise
: vector
-> vector
1840 val mult_coeff
: vector
-> float -> vector
1842 val add_vector
: vector
-> vector
-> vector
1843 val mult_vector
: vector
-> vector
-> vector
1844 val sum_vector
: vector list
-> vector
1847 (*****************************************************************************)
1848 (* Pics (ICFP raytracer) *)
1849 (*****************************************************************************)
1850 type pixel
= int * int * int
1851 val write_ppm
: int -> int -> pixel list
-> filename
-> unit
1852 val test_ppm1
: unit -> unit
1854 (*****************************************************************************)
1856 (*****************************************************************************)
1858 type diff
= Match
| BnotinA
| AnotinB
1859 val diff
: (int -> int -> diff
-> unit) -> string list
* string list
-> unit
1860 val diff2
: (int -> int -> diff
-> unit) -> string * string -> unit
1862 (*****************************************************************************)
1863 (* Parsers (aop-colcombet) *)
1864 (*****************************************************************************)
1866 val parserCommon
: Lexing.lexbuf
-> ('a
-> Lexing.lexbuf
-> '
b) -> 'a
-> '
b
1867 val getDoubleParser
:
1868 ('a
-> Lexing.lexbuf
-> '
b) -> 'a
-> (string -> '
b) * (string -> '
b)
1870 (*****************************************************************************)
1871 (* Parsers (cocci) *)
1872 (*****************************************************************************)
1875 (* Currently lexing.ml does not handle the line number position.
1876 * Even if there is some fields in the lexing structure, they are not
1877 * maintained by the lexing engine :( So the following code does not work:
1879 * let pos = Lexing.lexeme_end_p lexbuf in
1880 * sprintf "at file %s, line %d, char %d" pos.pos_fname pos.pos_lnum
1881 * (pos.pos_cnum - pos.pos_bol) in
1883 * Hence those functions to overcome the previous limitation.
1894 val fake_parse_info
: parse_info
1895 val string_of_parse_info
: parse_info
-> string
1896 val string_of_parse_info_bis
: parse_info
-> string
1898 (* array[i] will contain the (line x col) of the i char position *)
1899 val full_charpos_to_pos
: filename
-> (int * int) array
1901 (* fill in the line and column field of parse_info that were not set
1902 * during lexing because of limitations of ocamllex. *)
1903 val complete_parse_info
:
1904 filename
-> (int * int) array
-> parse_info
-> parse_info
1906 val full_charpos_to_pos_large
:
1907 filename
-> (int -> (int * int))
1909 val complete_parse_info_large
:
1910 filename
-> (int -> (int * int)) -> parse_info
-> parse_info
1912 (* return line x col x str_line from a charpos. This function is quite
1913 * expensive so don't use it to get the line x col from every token in
1914 * a file. Instead use full_charpos_to_pos.
1916 val info_from_charpos
: int -> filename
-> (int * int * string)
1918 val error_message
: filename
-> (string * int) -> string
1919 val error_message_short
: filename
-> (string * int) -> string
1921 (* add a 'decalage/shift' argument to handle stuff such as cpp which includes
1922 * files and who can make shift.
1924 val error_messagebis
: filename
-> (string * int) -> int -> string
1926 (*****************************************************************************)
1927 (* Scope managment (cocci) *)
1928 (*****************************************************************************)
1930 (* for example of use, see the code used in coccinelle *)
1931 type ('a
, '
b) scoped_env
= ('a
, '
b) assoc list
1933 val lookup_env
: (* Eq a *) 'a
-> ('a
, '
b) scoped_env
-> '
b
1934 val member_env_key
: 'a
-> ('a
, '
b) scoped_env
-> bool
1936 val new_scope
: ('a
, '
b) scoped_env
ref -> unit
1937 val del_scope
: ('a
, '
b) scoped_env
ref -> unit
1939 val do_in_new_scope
: ('a
, '
b) scoped_env
ref -> (unit -> unit) -> unit
1941 val add_in_scope
: ('a
, '
b) scoped_env
ref -> 'a
* '
b -> unit
1946 (* for example of use, see the code used in coccinelle *)
1947 type ('a
, '
b) scoped_h_env
= {
1948 scoped_h
: ('a
, '
b) Hashtbl.t
;
1949 scoped_list
: ('a
, '
b) assoc list
;
1951 val empty_scoped_h_env
: unit -> ('a
, '
b) scoped_h_env
1952 val clone_scoped_h_env
: ('a
, '
b) scoped_h_env
-> ('a
, '
b) scoped_h_env
1954 val lookup_h_env
: 'a
-> ('a
, '
b) scoped_h_env
-> '
b
1955 val member_h_env_key
: 'a
-> ('a
, '
b) scoped_h_env
-> bool
1957 val new_scope_h
: ('a
, '
b) scoped_h_env
ref -> unit
1958 val del_scope_h
: ('a
, '
b) scoped_h_env
ref -> unit
1960 val do_in_new_scope_h
: ('a
, '
b) scoped_h_env
ref -> (unit -> unit) -> unit
1962 val add_in_scope_h
: ('a
, '
b) scoped_h_env
ref -> 'a
* '
b -> unit
1964 (*****************************************************************************)
1965 (* Terminal (LFS) *)
1966 (*****************************************************************************)
1968 (* don't forget to call Common_extra.set_link () *)
1970 val _execute_and_show_progress_func
:
1971 (int (* length *) -> ((unit -> unit) -> unit) -> unit) ref
1972 val execute_and_show_progress
:
1973 int (* length *) -> ((unit -> unit) -> unit) -> unit
1975 (*****************************************************************************)
1976 (* Flags and actions *)
1977 (*****************************************************************************)
1979 val cmdline_flags_devel
: unit -> cmdline_options
1980 val cmdline_flags_verbose
: unit -> cmdline_options
1981 val cmdline_flags_other
: unit -> cmdline_options
1983 (*****************************************************************************)
1985 (*****************************************************************************)
1987 val generic_print
: 'a
-> string -> string
1993 method fold
: ('
b -> 'a
-> '
b) -> '
b -> '
b
1994 method view
: 'a list
1997 val typing_sux_test
: unit -> unit