2016-09-08 21:13:10 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Copyright (c) 2014 - 2016. *)
|
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
|
|
|
module StringMap : Map.S with type key = string
|
|
|
|
|
|
|
|
(** Splits a string on slashes, grouping multiple slashes, and
|
|
|
|
ignoring slashes at the beginning and end of string. *)
|
|
|
|
val split_path: string -> string list
|
|
|
|
|
|
|
|
(** Splits a string on a delimier character, grouping multiple
|
|
|
|
delimiters, and ignoring delimiters at the beginning and end of
|
|
|
|
string, if [limit] is passed, stops after [limit] split(s). *)
|
2017-01-23 14:09:33 +04:00
|
|
|
val split: char -> ?dup:bool -> ?limit: int -> string -> string list
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
val map_option: f:('a -> 'b) -> 'a option -> 'b option
|
2016-11-14 19:26:34 +04:00
|
|
|
val apply_option: f:('a -> 'b option) -> 'a option -> 'b option
|
2016-09-08 21:13:10 +04:00
|
|
|
val iter_option: f:('a -> unit) -> 'a option -> unit
|
2017-01-23 14:09:33 +04:00
|
|
|
val unopt: default:'a -> 'a option -> 'a
|
2017-01-14 16:13:09 +04:00
|
|
|
val unopt_map: f:('a -> 'b) -> default:'b -> 'a option -> 'b
|
2016-09-08 21:13:10 +04:00
|
|
|
val unopt_list: 'a option list -> 'a list
|
2016-11-29 17:51:36 +04:00
|
|
|
val first_some: 'a option -> 'a option -> 'a option
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
val display_paragraph: Format.formatter -> string -> unit
|
|
|
|
|
|
|
|
(** [remove nb list] remove the first [nb] elements from the list [list]. *)
|
|
|
|
val remove_elem_from_list: int -> 'a list -> 'a list
|
2017-02-24 20:17:53 +04:00
|
|
|
val split_list_at: int -> 'a list -> 'a list * 'a list
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-02-19 21:22:32 +04:00
|
|
|
val has_prefix: prefix:string -> string -> bool
|
2016-10-06 20:30:04 +04:00
|
|
|
val remove_prefix: prefix:string -> string -> string option
|
2017-02-19 21:22:32 +04:00
|
|
|
val common_prefix: string -> string -> int
|
|
|
|
|
2016-10-06 20:30:04 +04:00
|
|
|
|
2016-09-08 21:13:10 +04:00
|
|
|
val filter_map: ('a -> 'b option) -> 'a list -> 'b list
|
|
|
|
|
2017-01-14 16:13:09 +04:00
|
|
|
(** [list_rev_sub l n] is (List.rev l) capped to max n elements *)
|
|
|
|
val list_rev_sub : 'a list -> int -> 'a list
|
|
|
|
(** [list_sub l n] is l capped to max n elements *)
|
|
|
|
val list_sub: 'a list -> int -> 'a list
|
2017-01-30 22:10:16 +04:00
|
|
|
val list_hd_opt: 'a list -> 'a option
|
2017-01-14 16:13:09 +04:00
|
|
|
|
2016-10-24 21:12:57 +04:00
|
|
|
val finalize: (unit -> 'a) -> (unit -> unit) -> 'a
|
2016-11-16 04:19:13 +04:00
|
|
|
|
2016-10-24 21:12:57 +04:00
|
|
|
val read_file: ?bin:bool -> string -> string
|
|
|
|
val write_file: ?bin:bool -> string -> string -> unit
|
2016-11-16 04:19:13 +04:00
|
|
|
|
2016-11-04 23:22:22 +04:00
|
|
|
(** Compose functions from right to left. *)
|
|
|
|
val (<<) : ('b -> 'c) -> ('a -> 'b) -> 'a -> 'c
|
2017-01-14 16:13:09 +04:00
|
|
|
|
|
|
|
(** Sequence: [i--j] is the sequence [i;i+1;...;j-1;j] *)
|
|
|
|
val (--) : int -> int -> int list
|
|
|
|
|
2017-01-23 14:09:33 +04:00
|
|
|
val repeat: int -> 'a -> 'a list
|
|
|
|
|
2017-01-14 16:13:09 +04:00
|
|
|
(** [take_n n l] returns the [n] first elements of [n]. When [compare]
|
|
|
|
is provided, it returns the [n] greatest element of [l]. *)
|
|
|
|
val take_n: ?compare:('a -> 'a -> int) -> int -> 'a list -> 'a list
|
|
|
|
|
|
|
|
(** Bounded sequence: keep only the [n] greatest elements. *)
|
|
|
|
module Bounded(E: Set.OrderedType) : sig
|
|
|
|
type t
|
|
|
|
val create: int -> t
|
|
|
|
val insert: E.t -> t -> unit
|
|
|
|
val get: t -> E.t list
|
|
|
|
end
|
|
|
|
|
|
|
|
val select: int -> 'a list -> 'a * 'a list
|
2017-01-30 22:10:16 +04:00
|
|
|
|
|
|
|
(** [split_url_port uri] is (node, service) where [node] is the DNS or
|
|
|
|
IP and service is the optional port number or service name. *)
|
|
|
|
val parse_addr_port: string -> string * string
|