• en

Module OpamMisc

module type SET = sig
Collection of abstract values
type elt
type t
val empty : t
val is_empty : t -> bool
val mem : elt -> t -> bool
val add : elt -> t -> t
val singleton : elt -> t
val remove : elt -> t -> t
val union : t -> t -> t
val inter : t -> t -> t
val diff : t -> t -> t
val compare : t -> t -> int
val equal : t -> t -> bool
val subset : t -> t -> bool
val iter : elt -> unit -> t -> unit
val fold : elt -> 'a -> 'a -> t -> 'a -> 'a
val for_all : elt -> bool -> t -> bool
val exists : elt -> bool -> t -> bool
val filter : elt -> bool -> t -> t
val partition : elt -> bool -> t -> (t * t)
val cardinal : t -> int
val elements : t -> elt list
val min_elt : t -> elt
val max_elt : t -> elt
val choose : t -> elt
val split : elt -> t -> (t * bool * t)
val map : elt -> elt -> t -> t
auto-map
val choose_one : t -> elt
Return one element. Fail if the set is not a singleton.
val of_list : elt list -> t
Make a set from a list
val to_string : t -> string
Pretty-print a set
val to_json : t -> OpamJson.t
Return a JSON representation of the given set
val find : elt -> bool -> t -> elt
Find an element in the list
module Op : sig
val (++) : t -> t -> t
Infix set union
val (--) : t -> t -> t
Infix set difference
val (%%) : t -> t -> t
Infix set intersection
end
end
module type MAP = sig
Dictionaries of abstract values
type key
type 'a t
val empty : 'a t
val is_empty : 'a t -> bool
val mem : key -> 'a t -> bool
val add : key -> 'a -> 'a t -> 'a t
val singleton : key -> 'a -> 'a t
val remove : key -> 'a t -> 'a t
val merge : key -> 'a option -> 'b option -> 'c option -> 'a t -> 'b t -> 'c t
val compare : 'a -> 'a -> int -> 'a t -> 'a t -> int
val equal : 'a -> 'a -> bool -> 'a t -> 'a t -> bool
val iter : key -> 'a -> unit -> 'a t -> unit
val fold : key -> 'a -> 'b -> 'b -> 'a t -> 'b -> 'b
val for_all : key -> 'a -> bool -> 'a t -> bool
val exists : key -> 'a -> bool -> 'a t -> bool
val filter : key -> 'a -> bool -> 'a t -> 'a t
val partition : key -> 'a -> bool -> 'a t -> ('a t * 'a t)
val cardinal : 'a t -> int
val bindings : 'a t -> (key * 'a) list
val min_binding : 'a t -> (key * 'a)
val max_binding : 'a t -> (key * 'a)
val choose : 'a t -> (key * 'a)
val split : key -> 'a t -> ('a t * 'a option * 'a t)
val find : key -> 'a t -> 'a
val map : 'a -> 'b -> 'a t -> 'b t
val mapi : key -> 'a -> 'b -> 'a t -> 'b t
val to_string : 'a -> string -> 'a t -> string
Pretty-printing
val to_json : 'a -> OpamJson.t -> 'a t -> OpamJson.t
Return a JSON representation of the given map.
val values : 'a t -> 'a list
Return the values in the map.
val keys : 'a t -> key list
Return the keys in the map.
val union : 'a -> 'a -> 'a -> 'a t -> 'a t -> 'a t
A key will be in the union of m1 and m2 if it is appears either m1 or m2, with the corresponding value. If a key appears in both m1 and m2, then the resulting value is built using the function given as argument.
val of_list : (key * 'a) list -> 'a t
Convert an assoc list to a map
end
module type ABSTRACT = sig
All abstract types should implement this signature
type t
ABSTRACT type
val of_string : string -> t
Create an abstract value from a string
val to_string : t -> string
Convert an abstract value to a string
val to_json : t -> OpamJson.t
Convert an abstract value to a JSON object
module Set : sig
TODO: functor:opam-lib.42/opam-lib/OpamMisc.Set.Make
end
module Map : sig
TODO: functor:opam-lib.42/opam-lib/OpamMisc.Map.Make
end
end
module type OrderedType = sig
Extended sets and maps
type t
val compare : t -> t -> int
val to_string : t -> string
val to_json : t -> OpamJson.t
end
module Set : sig
Set constructor
TODO: functor:opam-lib.42/opam-lib/OpamMisc.Set.Make
end
module Map : sig
Map constructor
TODO: functor:opam-lib.42/opam-lib/OpamMisc.Map.Make
end
module Base : sig
Base module, useful to abstract strings
type t = string
val of_string : string -> t
val to_string : t -> string
val to_json : t -> OpamJson.t
module Map : sig
type key = string
type 'a t
val empty : 'a t
val is_empty : 'a t -> bool
val mem : key -> 'a t -> bool
val add : key -> 'a -> 'a t -> 'a t
val singleton : key -> 'a -> 'a t
val remove : key -> 'a t -> 'a t
val merge : key -> 'a option -> 'b option -> 'c option -> 'a t -> 'b t -> 'c t
val compare : 'a -> 'a -> int -> 'a t -> 'a t -> int
val equal : 'a -> 'a -> bool -> 'a t -> 'a t -> bool
val iter : key -> 'a -> unit -> 'a t -> unit
val fold : key -> 'a -> 'b -> 'b -> 'a t -> 'b -> 'b
val for_all : key -> 'a -> bool -> 'a t -> bool
val exists : key -> 'a -> bool -> 'a t -> bool
val filter : key -> 'a -> bool -> 'a t -> 'a t
val partition : key -> 'a -> bool -> 'a t -> ('a t * 'a t)
val cardinal : 'a t -> int
val bindings : 'a t -> (key * 'a) list
val min_binding : 'a t -> (key * 'a)
val max_binding : 'a t -> (key * 'a)
val choose : 'a t -> (key * 'a)
val split : key -> 'a t -> ('a t * 'a option * 'a t)
val find : key -> 'a t -> 'a
val map : 'a -> 'b -> 'a t -> 'b t
val mapi : key -> 'a -> 'b -> 'a t -> 'b t
val to_string : 'a -> string -> 'a t -> string
Pretty-printing
val to_json : 'a -> OpamJson.t -> 'a t -> OpamJson.t
Return a JSON representation of the given map.
val values : 'a t -> 'a list
Return the values in the map.
val keys : 'a t -> key list
Return the keys in the map.
val union : 'a -> 'a -> 'a -> 'a t -> 'a t -> 'a t
A key will be in the union of m1 and m2 if it is appears either m1 or m2, with the corresponding value. If a key appears in both m1 and m2, then the resulting value is built using the function given as argument.
val of_list : (key * 'a) list -> 'a t
Convert an assoc list to a map
end
module Set : sig
type elt = string
type t
val empty : t
val is_empty : t -> bool
val mem : elt -> t -> bool
val add : elt -> t -> t
val singleton : elt -> t
val remove : elt -> t -> t
val union : t -> t -> t
val inter : t -> t -> t
val diff : t -> t -> t
val compare : t -> t -> int
val equal : t -> t -> bool
val subset : t -> t -> bool
val iter : elt -> unit -> t -> unit
val fold : elt -> 'a -> 'a -> t -> 'a -> 'a
val for_all : elt -> bool -> t -> bool
val exists : elt -> bool -> t -> bool
val filter : elt -> bool -> t -> t
val partition : elt -> bool -> t -> (t * t)
val cardinal : t -> int
val elements : t -> elt list
val min_elt : t -> elt
val max_elt : t -> elt
val choose : t -> elt
val split : elt -> t -> (t * bool * t)
val map : elt -> elt -> t -> t
auto-map
val choose_one : t -> elt
Return one element. Fail if the set is not a singleton.
val of_list : elt list -> t
Make a set from a list
val to_string : t -> string
Pretty-print a set
val to_json : t -> OpamJson.t
Return a JSON representation of the given set
val find : elt -> bool -> t -> elt
Find an element in the list
module Op : sig
val (++) : t -> t -> t
Infix set union
val (--) : t -> t -> t
Infix set difference
val (%%) : t -> t -> t
Infix set intersection
end
end
end
module IntMap : sig
Map of ints
type key = int
type 'a t
val empty : 'a t
val is_empty : 'a t -> bool
val mem : key -> 'a t -> bool
val add : key -> 'a -> 'a t -> 'a t
val singleton : key -> 'a -> 'a t
val remove : key -> 'a t -> 'a t
val merge : key -> 'a option -> 'b option -> 'c option -> 'a t -> 'b t -> 'c t
val compare : 'a -> 'a -> int -> 'a t -> 'a t -> int
val equal : 'a -> 'a -> bool -> 'a t -> 'a t -> bool
val iter : key -> 'a -> unit -> 'a t -> unit
val fold : key -> 'a -> 'b -> 'b -> 'a t -> 'b -> 'b
val for_all : key -> 'a -> bool -> 'a t -> bool
val exists : key -> 'a -> bool -> 'a t -> bool
val filter : key -> 'a -> bool -> 'a t -> 'a t
val partition : key -> 'a -> bool -> 'a t -> ('a t * 'a t)
val cardinal : 'a t -> int
val bindings : 'a t -> (key * 'a) list
val min_binding : 'a t -> (key * 'a)
val max_binding : 'a t -> (key * 'a)
val choose : 'a t -> (key * 'a)
val split : key -> 'a t -> ('a t * 'a option * 'a t)
val find : key -> 'a t -> 'a
val map : 'a -> 'b -> 'a t -> 'b t
val mapi : key -> 'a -> 'b -> 'a t -> 'b t
val to_string : 'a -> string -> 'a t -> string
Pretty-printing
val to_json : 'a -> OpamJson.t -> 'a t -> OpamJson.t
Return a JSON representation of the given map.
val values : 'a t -> 'a list
Return the values in the map.
val keys : 'a t -> key list
Return the keys in the map.
val union : 'a -> 'a -> 'a -> 'a t -> 'a t -> 'a t
A key will be in the union of m1 and m2 if it is appears either m1 or m2, with the corresponding value. If a key appears in both m1 and m2, then the resulting value is built using the function given as argument.
val of_list : (key * 'a) list -> 'a t
Convert an assoc list to a map
end
module IntSet : sig
Set of ints
type elt = int
type t
val empty : t
val is_empty : t -> bool
val mem : elt -> t -> bool
val add : elt -> t -> t
val singleton : elt -> t
val remove : elt -> t -> t
val union : t -> t -> t
val inter : t -> t -> t
val diff : t -> t -> t
val compare : t -> t -> int
val equal : t -> t -> bool
val subset : t -> t -> bool
val iter : elt -> unit -> t -> unit
val fold : elt -> 'a -> 'a -> t -> 'a -> 'a
val for_all : elt -> bool -> t -> bool
val exists : elt -> bool -> t -> bool
val filter : elt -> bool -> t -> t
val partition : elt -> bool -> t -> (t * t)
val cardinal : t -> int
val elements : t -> elt list
val min_elt : t -> elt
val max_elt : t -> elt
val choose : t -> elt
val split : elt -> t -> (t * bool * t)
val map : elt -> elt -> t -> t
auto-map
val choose_one : t -> elt
Return one element. Fail if the set is not a singleton.
val of_list : elt list -> t
Make a set from a list
val to_string : t -> string
Pretty-print a set
val to_json : t -> OpamJson.t
Return a JSON representation of the given set
val find : elt -> bool -> t -> elt
Find an element in the list
module Op : sig
val (++) : t -> t -> t
Infix set union
val (--) : t -> t -> t
Infix set difference
val (%%) : t -> t -> t
Infix set intersection
end
end
val string_of_list : 'a -> string -> 'a list -> string
Display a list of strings
val string_map : char -> char -> string -> string
val pretty_list : ?last:string -> string list -> string
Display a pretty list: "x";"y";"z" -> "x, y and z". "and" can be changed by specifying last
val remove_duplicates : 'a list -> 'a list
Removes consecutive duplicates in a list
module StringMap : sig
Map of strings
type key = string
type 'a t
val empty : 'a t
val is_empty : 'a t -> bool
val mem : key -> 'a t -> bool
val add : key -> 'a -> 'a t -> 'a t
val singleton : key -> 'a -> 'a t
val remove : key -> 'a t -> 'a t
val merge : key -> 'a option -> 'b option -> 'c option -> 'a t -> 'b t -> 'c t
val compare : 'a -> 'a -> int -> 'a t -> 'a t -> int
val equal : 'a -> 'a -> bool -> 'a t -> 'a t -> bool
val iter : key -> 'a -> unit -> 'a t -> unit
val fold : key -> 'a -> 'b -> 'b -> 'a t -> 'b -> 'b
val for_all : key -> 'a -> bool -> 'a t -> bool
val exists : key -> 'a -> bool -> 'a t -> bool
val filter : key -> 'a -> bool -> 'a t -> 'a t
val partition : key -> 'a -> bool -> 'a t -> ('a t * 'a t)
val cardinal : 'a t -> int
val bindings : 'a t -> (key * 'a) list
val min_binding : 'a t -> (key * 'a)
val max_binding : 'a t -> (key * 'a)
val choose : 'a t -> (key * 'a)
val split : key -> 'a t -> ('a t * 'a option * 'a t)
val find : key -> 'a t -> 'a
val map : 'a -> 'b -> 'a t -> 'b t
val mapi : key -> 'a -> 'b -> 'a t -> 'b t
val to_string : 'a -> string -> 'a t -> string
Pretty-printing
val to_json : 'a -> OpamJson.t -> 'a t -> OpamJson.t
Return a JSON representation of the given map.
val values : 'a t -> 'a list
Return the values in the map.
val keys : 'a t -> key list
Return the keys in the map.
val union : 'a -> 'a -> 'a -> 'a t -> 'a t -> 'a t
A key will be in the union of m1 and m2 if it is appears either m1 or m2, with the corresponding value. If a key appears in both m1 and m2, then the resulting value is built using the function given as argument.
val of_list : (key * 'a) list -> 'a t
Convert an assoc list to a map
end
module StringSet : sig
Set of strings
type elt = string
type t
val empty : t
val is_empty : t -> bool
val mem : elt -> t -> bool
val add : elt -> t -> t
val singleton : elt -> t
val remove : elt -> t -> t
val union : t -> t -> t
val inter : t -> t -> t
val diff : t -> t -> t
val compare : t -> t -> int
val equal : t -> t -> bool
val subset : t -> t -> bool
val iter : elt -> unit -> t -> unit
val fold : elt -> 'a -> 'a -> t -> 'a -> 'a
val for_all : elt -> bool -> t -> bool
val exists : elt -> bool -> t -> bool
val filter : elt -> bool -> t -> t
val partition : elt -> bool -> t -> (t * t)
val cardinal : t -> int
val elements : t -> elt list
val min_elt : t -> elt
val max_elt : t -> elt
val choose : t -> elt
val split : elt -> t -> (t * bool * t)
val map : elt -> elt -> t -> t
auto-map
val choose_one : t -> elt
Return one element. Fail if the set is not a singleton.
val of_list : elt list -> t
Make a set from a list
val to_string : t -> string
Pretty-print a set
val to_json : t -> OpamJson.t
Return a JSON representation of the given set
val find : elt -> bool -> t -> elt
Find an element in the list
module Op : sig
val (++) : t -> t -> t
Infix set union
val (--) : t -> t -> t
Infix set difference
val (%%) : t -> t -> t
Infix set intersection
end
end
module StringSetSet : sig
Set of string sets
type elt = StringSet.t
type t
val empty : t
val is_empty : t -> bool
val mem : elt -> t -> bool
val add : elt -> t -> t
val singleton : elt -> t
val remove : elt -> t -> t
val union : t -> t -> t
val inter : t -> t -> t
val diff : t -> t -> t
val compare : t -> t -> int
val equal : t -> t -> bool
val subset : t -> t -> bool
val iter : elt -> unit -> t -> unit
val fold : elt -> 'a -> 'a -> t -> 'a -> 'a
val for_all : elt -> bool -> t -> bool
val exists : elt -> bool -> t -> bool
val filter : elt -> bool -> t -> t
val partition : elt -> bool -> t -> (t * t)
val cardinal : t -> int
val elements : t -> elt list
val min_elt : t -> elt
val max_elt : t -> elt
val choose : t -> elt
val split : elt -> t -> (t * bool * t)
val map : elt -> elt -> t -> t
auto-map
val choose_one : t -> elt
Return one element. Fail if the set is not a singleton.
val of_list : elt list -> t
Make a set from a list
val to_string : t -> string
Pretty-print a set
val to_json : t -> OpamJson.t
Return a JSON representation of the given set
val find : elt -> bool -> t -> elt
Find an element in the list
module Op : sig
val (++) : t -> t -> t
Infix set union
val (--) : t -> t -> t
Infix set difference
val (%%) : t -> t -> t
Infix set intersection
end
end
module StringSetMap : sig
Map of string sets
type key = StringSet.t
type 'a t
val empty : 'a t
val is_empty : 'a t -> bool
val mem : key -> 'a t -> bool
val add : key -> 'a -> 'a t -> 'a t
val singleton : key -> 'a -> 'a t
val remove : key -> 'a t -> 'a t
val merge : key -> 'a option -> 'b option -> 'c option -> 'a t -> 'b t -> 'c t
val compare : 'a -> 'a -> int -> 'a t -> 'a t -> int
val equal : 'a -> 'a -> bool -> 'a t -> 'a t -> bool
val iter : key -> 'a -> unit -> 'a t -> unit
val fold : key -> 'a -> 'b -> 'b -> 'a t -> 'b -> 'b
val for_all : key -> 'a -> bool -> 'a t -> bool
val exists : key -> 'a -> bool -> 'a t -> bool
val filter : key -> 'a -> bool -> 'a t -> 'a t
val partition : key -> 'a -> bool -> 'a t -> ('a t * 'a t)
val cardinal : 'a t -> int
val bindings : 'a t -> (key * 'a) list
val min_binding : 'a t -> (key * 'a)
val max_binding : 'a t -> (key * 'a)
val choose : 'a t -> (key * 'a)
val split : key -> 'a t -> ('a t * 'a option * 'a t)
val find : key -> 'a t -> 'a
val map : 'a -> 'b -> 'a t -> 'b t
val mapi : key -> 'a -> 'b -> 'a t -> 'b t
val to_string : 'a -> string -> 'a t -> string
Pretty-printing
val to_json : 'a -> OpamJson.t -> 'a t -> OpamJson.t
Return a JSON representation of the given map.
val values : 'a t -> 'a list
Return the values in the map.
val keys : 'a t -> key list
Return the keys in the map.
val union : 'a -> 'a -> 'a -> 'a t -> 'a t -> 'a t
A key will be in the union of m1 and m2 if it is appears either m1 or m2, with the corresponding value. If a key appears in both m1 and m2, then the resulting value is built using the function given as argument.
val of_list : (key * 'a) list -> 'a t
Convert an assoc list to a map
end
val strip : string -> string
Strip a string
val starts_with : prefix:string -> string -> bool
Does a string starts with the given prefix ?
val ends_with : suffix:string -> string -> bool
Does a string ends with the given suffix ?
val remove_prefix : prefix:string -> string -> string
Remove a prefix
val remove_suffix : suffix:string -> string -> string
Remove a suffix
val cut_at : string -> char -> (string * string) option
Cut a string at the first occurence of the given char
val rcut_at : string -> char -> (string * string) option
Same as cut_at, but starts from the right
val contains : string -> char -> bool
Does a string contains the given chars ?
val split : string -> char -> string list
Split a string
val indent_left : string -> ?visual:string -> int -> string
left indenting. ~visual can be used to indent eg. ANSI colored strings and should correspond to the visible characters of s
val indent_right : string -> ?visual:string -> int -> string
right indenting
val sub_at : int -> string -> string
Cut a string
module Option : sig
val map : 'a -> 'b -> 'a option -> 'b option
val iter : 'a -> unit -> 'a option -> unit
val default : 'a -> 'a option -> 'a
val default_map : 'a option -> 'a option -> 'a option
module Op : sig
val (>>=) : 'a option -> 'a -> 'b option -> 'b option
val (>>|) : 'a option -> 'a -> 'b -> 'b option
val (+!) : 'a option -> 'a -> 'a
val (++) : 'a option -> 'a option -> 'a option
end
end
val reset_env_value : prefix:string -> char -> string -> string list
Remove from a c-separated list of string the one with the given prefix
val cut_env_value : prefix:string -> char -> string -> (string list * string list)
split a c-separated list of string in two according to the first occurrences of the string with the given prefix. The list of elements occurring before is returned in reverse order. If there are other elements with the same prefix they are kept in the second list.
val rsync_trim : string list -> string list
if rsync -arv return 4 lines, this means that no files have changed
val exact_match : Re.re -> string -> bool
Exact regexp matching
val filter_map : 'a -> 'b option -> 'a list -> 'b list
Filter and map
val insert : 'a -> 'a -> int -> 'a -> 'a list -> 'a list
Insert a value in an ordered list
val getenv : string -> string
Lazy environment variable
val env : unit -> (string * string) list
Lazy environment
val fatal : exn -> unit
To use when catching default exceptions: ensures we don't catch fatal errors like C-c. try-with should _always_ (by decreasing order of preference):
  • either catch specific exceptions
  • or re-raise the same exception
  • or call this function on the caught exception
val register_backtrace : exn -> unit
Register a backtrace for when you need to process a finalizer (that internally uses exceptions) and then re-raise the same exception. To be printed by pretty_backtrace.
val pretty_backtrace : exn -> string
Return a pretty-printed backtrace
val prettify_path : string -> string
Prettify a local path (eg. replace /home/me/ by '~')
module OP : sig
val (@@) : 'a -> 'b -> 'a -> 'b
Function application (with lower priority) (predefined in OCaml 4.01+)
val (|>) : 'a -> 'a -> 'b -> 'b
Pipe operator -- reverse application (predefined in OCaml 4.01+)
val (@*) : 'b -> 'c -> 'a -> 'b -> 'a -> 'c
Function composition : (f @* g) x =~ f (g x)
val (@>) : 'a -> 'b -> 'b -> 'c -> 'a -> 'c
Reverse function composition : (f @> g) x =~ g (f x)
end
val terminal_columns : unit -> int
When stdout refers to a terminal, query the number of columns. Otherwise return max_int.
val uname_s : unit -> string option
Get the output of uname -s
val uname_m : unit -> string option
Get the output of uname -m
val guess_shell_compat : unit -> TODO: a
Guess the shell compat-mode
val guess_dot_profile : TODO: a -> string
Guess the location of .profile
val debug : bool Pervasives.ref