(* The following functions first indent _tab_level_print spaces.
* They also add the _prefix_pr, for instance used in MPI to show which
* worker is talking.
+ * update: for pr2, it can also print into a log file.
*
* The use of 2 in pr2 is because 2 is under UNIX the second descriptor
* which corresponds to stderr.
*)
val _prefix_pr : string ref
+
val pr : string -> unit
-val pr2 : string -> unit
val pr_no_nl : string -> unit
-val pr2_no_nl : string -> unit
val pr_xxxxxxxxxxxxxxxxx : unit -> unit
+
+(* pr2 print on stderr, but can also in addition print into a file *)
+val _chan_pr2: out_channel option ref
+val pr2 : string -> unit
+val pr2_no_nl : string -> unit
val pr2_xxxxxxxxxxxxxxxxx : unit -> unit
(* use Dumper.dump *)
val _already_printed : (string, bool) Hashtbl.t
val pr2_once : string -> unit
+val mk_pr2_wrappers: bool ref -> (string -> unit) * (string -> unit)
+
+
val redirect_stdout_stderr : filename -> (unit -> unit) -> unit
val redirect_stdin : filename -> (unit -> unit) -> unit
val redirect_stdin_opt : filename option -> (unit -> unit) -> unit
+val with_pr2_to_string: (unit -> unit) -> string list
+
val fprintf : out_channel -> ('a, out_channel, unit) format -> 'a
val printf : ('a, out_channel, unit) format -> 'a
val eprintf : ('a, out_channel, unit) format -> 'a
val example3 : string -> bool -> unit
val test_all : unit -> unit
+
(* regression testing *)
type score_result = Ok | Pb of string
-type score = (string (* usually a filename *), score_result) Hashtbl.t
+type score = (string (* usually a filename *), score_result) Hashtbl.t
+type score_list = (string (* usually a filename *) * score_result) list
val empty_score : unit -> score
val regression_testing :
score -> filename (* old score file on disk (usually in /tmp) *) -> unit
+val regression_testing_vs: score -> score -> score
+val total_scores : score -> int (* good *) * int (* total *)
val print_score : score -> unit
+val print_total_score: score -> unit
(* quickcheck spirit *)
(* Persistence *)
(*****************************************************************************)
-(* just wrappers around Marshall *)
+(* just wrappers around Marshal *)
val get_value : filename -> 'a
val read_value : filename -> 'a (* alias *)
val write_value : 'a -> filename -> unit
val write_back : ('a -> 'b) -> filename -> unit
+(* wrappers that also use profile_code *)
+val marshal__to_string: 'a -> Marshal.extern_flags list -> string
+val marshal__from_string: string -> int -> 'a
+
(*****************************************************************************)
(* Counter *)
(*****************************************************************************)
val adjust_pp_with_indent : (unit -> unit) -> unit
val adjust_pp_with_indent_and_header : string -> (unit -> unit) -> unit
+
+val mk_str_func_of_assoc_conv:
+ ('a * string) list -> (string -> 'a) * ('a -> string)
+
(*****************************************************************************)
(* Macro *)
(*****************************************************************************)
(* emacs spirit *)
val save_excursion : 'a ref -> (unit -> 'b) -> 'b
+val save_excursion_and_disable : bool ref -> (unit -> 'b) -> 'b
+val save_excursion_and_enable : bool ref -> (unit -> 'b) -> 'b
(* emacs spirit *)
val unwind_protect : (unit -> 'a) -> (exn -> 'b) -> 'a
exception Here
exception ReturnExn
-exception MultiFound
+exception Multi_found
exception WrongFormat of string
(* alias *)
val string_of_exn : exn -> string
+type error = Error of string
+
+type evotype = unit
+val evoval : evotype
+
(*****************************************************************************)
(* Environment *)
(*****************************************************************************)
(* if want to restrict the use of '=', uncomment this:
*
- * val (=): int -> int -> bool
+ * val (=): unit -> unit -> bool
*
* But it will not forbid you to use caml functions like List.find, List.mem
* which internaly use this convenient but evolution-unfriendly (=)
-
(*###########################################################################*)
(* And now basic types *)
(*###########################################################################*)
val xor : 'a -> 'a -> bool
+
(*****************************************************************************)
(* Char *)
(*****************************************************************************)
val map_filter : ('a -> 'b option) -> 'a list -> 'b list
val find_some : ('a -> 'b option) -> 'a list -> 'b
+val list_to_single_or_exn: 'a list -> 'a
+
+(*****************************************************************************)
+(* TriBool *)
+(*****************************************************************************)
+type bool3 = True3 | False3 | TrueFalsePb3 of string
+
+
(*****************************************************************************)
(* Strings *)
(*****************************************************************************)
val dmy_to_unixtime: date_dmy -> float_time * Unix.tm
val unixtime_to_dmy: Unix.tm -> date_dmy
val unixtime_to_floattime: Unix.tm -> float_time
+val floattime_to_unixtime: float_time -> Unix.tm
val sec_to_days : int -> string
val sec_to_hours : int -> string
val command2 : string -> unit
val _batch_mode: bool ref
val command2_y_or_no : string -> bool
+val command2_y_or_no_exit_if_no : string -> unit
val do_in_fork : (unit -> unit) -> int
val span : ('a -> bool) -> 'a list -> 'a list * 'a list
val skip_until : ('a list -> bool) -> 'a list -> 'a list
-val skipfirst : 'a -> 'a list -> 'a list
+val skipfirst : (* Eq a *) 'a -> 'a list -> 'a list
(* cf also List.partition *)
val fpartition : ('a -> 'b option) -> 'a list -> 'b list * 'a list
val groupBy : ('a -> 'a -> bool) -> 'a list -> 'a list list
val exclude_but_keep_attached: ('a -> bool) -> 'a list -> ('a * 'a list) list
-val group_by_post: ('a -> bool) -> 'a list -> ('a list * 'a) list * 'a list
+val group_by_post: ('a -> bool) -> 'a list -> ('a list * 'a) list * 'a list
+val group_by_pre: ('a -> bool) -> 'a list -> 'a list * ('a * 'a list) list
+val group_by_mapped_key: ('a -> 'b) -> 'a list -> ('b * 'a list) list
(* Use hash internally to not be in O(n2). If you want to use it on a
* simple list, then first do a List.map to generate a key, for instance the
val fold_left_with_index : ('a -> 'b -> int -> 'a) -> 'a -> 'b list -> 'a
val nth : 'a list -> int -> 'a
-val rang : 'a -> 'a list -> int
+val rang : (* Eq a *) 'a -> 'a list -> int
val last_n : int -> 'a list -> 'a list
val min_with : ('a -> 'b) -> 'a list -> 'a
val two_mins_with : ('a -> 'b) -> 'a list -> 'a * 'a
-val all_assoc : 'a -> ('a * 'b) list -> 'b list
+val all_assoc : (* Eq a *) 'a -> ('a * 'b) list -> 'b list
val prepare_want_all_assoc : ('a * 'b) list -> ('a * 'b list) list
val or_list : bool list -> bool
(* Arrays *)
(*****************************************************************************)
-val array_find_index : ('a -> bool) -> 'a array -> int
+val array_find_index : (int -> bool) -> 'a array -> int
+val array_find_index_via_elem : ('a -> bool) -> 'a array -> int
+
+(* for better type checking, as sometimes when have an 'int array', can
+ * easily mess up the index from the value.
+ *)
+type idx = Idx of int
+val next_idx: idx -> idx
+val int_of_idx: idx -> int
+
+val array_find_index_typed : (idx -> bool) -> 'a array -> idx
(*****************************************************************************)
(* Matrix *)
type ('a, 'b) assoc = ('a * 'b) list
-val assoc_to_function : ('a, 'b) assoc -> ('a -> 'b)
+val assoc_to_function : (* Eq a *) ('a, 'b) assoc -> ('a -> 'b)
val empty_assoc : ('a, 'b) assoc
val fold_assoc : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
val sort_by_key_lowfirst: (int,'b) assoc -> (int * 'b) list
val sort_by_key_highfirst: (int,'b) assoc -> (int * 'b) list
+val sortgen_by_key_lowfirst: ('a,'b) assoc -> ('a * 'b) list
+val sortgen_by_key_highfirst: ('a,'b) assoc -> ('a * 'b) list
+
(*****************************************************************************)
(* Assoc, specialized. *)
(*****************************************************************************)
(* N-ary tree with updatable childrens *)
(*****************************************************************************)
-(* Leaf can seem redundant, but sometimes want to directly see if
- * a children is a leaf without looking if the list is empty.
- *)
-type ('a, 'b) treeref =
- | NodeRef of 'a * ('a, 'b) treeref list ref
- | LeafRef of 'b
+(* no empty tree, must have one root at least *)
+type 'a treeref =
+ | NodeRef of 'a * 'a treeref list ref
val treeref_node_iter:
- (('a * ('a, 'b) treeref list ref) -> unit) -> ('a, 'b) treeref -> unit
+ (('a * 'a treeref list ref) -> unit) -> 'a treeref -> unit
val treeref_node_iter_with_parents:
- (('a * ('a, 'b) treeref list ref) -> ('a list) -> unit) ->
- ('a, 'b) treeref -> unit
+ (('a * 'a treeref list ref) -> ('a list) -> unit) ->
+ 'a treeref -> unit
val find_treeref:
- (('a * ('a, 'b) treeref list ref) -> bool) ->
- ('a, 'b) treeref -> ('a, 'b) treeref
+ (('a * 'a treeref list ref) -> bool) ->
+ 'a treeref -> 'a treeref
+
+val treeref_children_ref:
+ 'a treeref -> 'a treeref list ref
+
+val find_treeref_with_parents_some:
+ ('a * 'a treeref list ref -> 'a list -> 'c option) ->
+ 'a treeref -> 'c
+
+val find_multi_treeref_with_parents_some:
+ ('a * 'a treeref list ref -> 'a list -> 'c option) ->
+ 'a treeref -> 'c list
+
+
+(* Leaf can seem redundant, but sometimes want to directly see if
+ * a children is a leaf without looking if the list is empty.
+ *)
+type ('a, 'b) treeref2 =
+ | NodeRef2 of 'a * ('a, 'b) treeref2 list ref
+ | LeafRef2 of 'b
+
+
+val find_treeref2:
+ (('a * ('a, 'b) treeref2 list ref) -> bool) ->
+ ('a, 'b) treeref2 -> ('a, 'b) treeref2
+
+val treeref_node_iter_with_parents2:
+ (('a * ('a, 'b) treeref2 list ref) -> ('a list) -> unit) ->
+ ('a, 'b) treeref2 -> unit
+
+val treeref_node_iter2:
+ (('a * ('a, 'b) treeref2 list ref) -> unit) -> ('a, 'b) treeref2 -> unit
+
+(*
+
val treeref_children_ref: ('a, 'b) treeref -> ('a, 'b) treeref list ref
val find_multi_treeref_with_parents_some:
('a * ('a, 'b) treeref list ref -> 'a list -> 'c option) ->
('a, 'b) treeref -> 'c list
-
+*)
(*****************************************************************************)
(* Graph. But have a look too at Ograph_*.mli; it's better *)
val complete_parse_info :
filename -> (int * int) array -> parse_info -> parse_info
+val full_charpos_to_pos_large:
+ filename -> (int -> (int * int))
+
+val complete_parse_info_large :
+ filename -> (int -> (int * int)) -> parse_info -> parse_info
+
(* return line x col x str_line from a charpos. This function is quite
* expensive so don't use it to get the line x col from every token in
* a file. Instead use full_charpos_to_pos.
(* for example of use, see the code used in coccinelle *)
type ('a, 'b) scoped_env = ('a, 'b) assoc list
-val lookup_env : 'a -> ('a, 'b) scoped_env -> 'b
+val lookup_env : (* Eq a *) 'a -> ('a, 'b) scoped_env -> 'b
val member_env_key : 'a -> ('a, 'b) scoped_env -> bool
val new_scope : ('a, 'b) scoped_env ref -> unit