Up

module Util

: sig

return a unique identifier based on random numbers

#
val uuid : unit -> string
#
val list_unique : 'a list -> 'a list

return a list of unique elements. This algorithm runs in O(n) but is not stable . elements are returned in reverse order

#
val memo : ('a -> 'b) -> 'a -> 'b

A generic memoization function. To use with care as it allocates an hashtbl storing all results that will be released only on exit

#
val timestamp : unit -> string

Debug, ProgressBars, Timers and Loggers

#
type label = string
#
module type Messages = sig
#
type t

create a new message handle with label t . Printing is disabled per default

#
val create : ?enabled:bool -> label -> t
#
val eprintf : ?raw:bool -> t -> ('a, unit, string, unit) Pervasives.format4 -> 'a

Print the message on stderr if the Util module has been set to verbose using the function make_verbose and either the handle t is enable or all handles were enabled with the function all_enabled

#
val enable : label -> unit

enable l the handle with label l

#
val disable : label -> unit

disable l the handle with label l

#
val all_disabled : unit -> unit

disable all handles in the module

#
val all_enabled : unit -> unit

enable all handles in the module

#
val avalaible : unit -> label list

return the list of all labels known to the module

#
val is_enabled : label -> bool
end
#
module Debug : Messages

Debug, Info and Warning messages are printed immediately on stderr. Info messages are enabled per default. Debug and Warning messages must be enabled explicitely

#
module Warning : Messages
#
module Info : Messages
#
module Notice : Messages

Ex : To use the Message framework, you should declare three functions at the begin of each module as:

let debug fmt = Util.make_debug "MyModuleLabel" fmt let info fmt = Util.make_info "MyModuleLabel" fmt let warning fmt = Util.make_warning "MyModuleLabel" fmt

and then use these function as

debug "this is a message string %s" "a string"

To enable this handle, from the main program use the function

Debug.enable "MyModuleLabel"

#
module Logging : functor (X : sig
#
val label : string
end
) -> sig
#
val it : Info.t
#
val info : ('a, unit, string, unit) Pervasives.format4 -> 'a
#
val nt : Notice.t
#
val notice : ('a, unit, string, unit) Pervasives.format4 -> 'a
#
val wt : Warning.t
#
val warning : ('a, unit, string, unit) Pervasives.format4 -> 'a
#
val dt : Debug.t
#
val debug : ('a, unit, string, unit) Pervasives.format4 -> 'a
#
val fatal : ('a, unit, string, 'b) Pervasives.format4 -> 'a
end
#
module Progress : sig

ProgressBars are printed immediately on stderr. To be used, the **must** be created outside the functions where they are used. They can enabled or disabled (default)

#
type t
#
val create : ?enabled:bool -> ?total:int -> ?unbounded:bool -> label -> t

create "barname" : create new a progress bar labelled "barname". The progress bar is disabled by default

#
val enable : label -> unit

enable "barname" : enable the progress bar with label "barname"

#
val disable : label -> unit

disable "barname" : disable the progress bar with label "barname"

#
val set_total : t -> int -> unit

set_total bar 10 : set the max width of the progress bar to 10 units

#
val progress : ?i:int -> t -> unit

increment the progress bar of i units

#
val reset : t -> unit

reset the progress bar

#
val available : unit -> label list

return the labels of all available progress bar

end
#
module Timer : sig

Timers are printed all at once by the dump function on stderr. They can enabled or disabled (default)

#
type t
#
val create : ?enabled:bool -> string -> t

create s create and register a new logger named s

#
val enable : label -> unit

enable "barname" : enable the progress bar with label "barname"

#
val pp_timer : Format.formatter -> t -> unit
#
val dump : Format.formatter -> unit -> unit

print all timers that are enabled

#
val start : t -> unit
#
val stop : t -> 'a -> 'a
#
val available : unit -> label list

return the labels of all available progress bar

end
#
module IntHashtbl : Hashtbl.S with type key = int
#
module IntPairHashtbl : Hashtbl.S with type key = int * int
#
module StringHashtbl : Hashtbl.S with type key = string
#
module StringPairHashtbl : Hashtbl.S with type key = string * string
#
val range : int -> int -> int list
#
val string_of_list : ('a -> string) -> string -> 'a list -> string
end