package dolmen

  1. Overview
  2. Docs

Comparison helpers

val (<?>) : int -> (('a -> 'a -> int) * 'a * 'a) -> int

Composition of comparison functions.

val lexicographic : ('a -> 'a -> int) -> 'a list -> 'a list -> int

Lexicogrphic comparison on lsits.

Hash helpers

val hash_int : int -> int
val hash_string : string -> int
val hash_list : ('a -> int) -> 'a list -> int
val hash2 : int -> int -> int
val hash3 : int -> int -> int -> int
val hash4 : int -> int -> int -> int -> int

Hash combinators.

Misc functions

val get_extension : string -> string

Returns the extension of a file, i.e the shortest suffix containing the character '.'. Returns an empty string if such a suffix does not exists.

val split_on_char : char -> string -> string list

Split on characters in a string (see Stdlib's split_on_char).

val replicate : int -> 'a -> 'a list

Returns a list with n times the given value. Returns an empty list if n

val opt_map : 'a option -> ('a -> 'b) -> 'b option

Map on option.

val opt_bind : 'a option -> ('a -> 'b option) -> 'b option

Bind on option.

Printing helpers

val pp_opt : ?none:string -> (Stdlib.Buffer.t -> 'a -> unit) -> Stdlib.Buffer.t -> 'a option -> unit

Print an option

val pp_list : pp_sep:(Stdlib.Buffer.t -> 'a -> unit) -> sep:'a -> pp:(Stdlib.Buffer.t -> 'b -> unit) -> Stdlib.Buffer.t -> 'b list -> unit

Print a list with separator into a buffer

val print_opt : ?none:string -> (Stdlib.Format.formatter -> 'a -> unit) -> Stdlib.Format.formatter -> 'a option -> unit

Print an option.

val print_list : print_sep:(Stdlib.Format.formatter -> 'a -> unit) -> sep:'a -> print:(Stdlib.Format.formatter -> 'b -> unit) -> Stdlib.Format.formatter -> 'b list -> unit

Print a list with separator into a buffer

Lexbuf helpers

val filename_of_input : [ `Stdin | `File of string | `Contents of string * string ] -> string

Filename string of an input.

val filename_of_input_source : [ `Stdin | `File of string | `Raw of string * string ] -> string

Filename string of an input source.

val mk_lexbuf : [ `Stdin | `File of string | `Contents of string * string ] -> Stdlib.Lexing.lexbuf * (unit -> unit)

Returns the lexbuf associetd with the given file or stdin, with the correct filename, together with a function to close the associated file descriptor. The `Contents constructor expect first a name for the input stream (to report errors), and then a string with the actual contents to be parsed.

OCaml

Innovation. Community. Security.