package dolmen
Module Dolmen_std.MiscSource
Comparison helpers
Composition of comparison functions.
Lexicogrphic comparison on lsits.
Hash helpers
Hash combinators.
Misc functions
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.
Split on characters in a string (see Stdlib's split_on_char).
Returns a list with n times the given value. Returns an empty list if n
Map on option.
Bind on option.
Equivalent to String.for_all (which is only available on ocaml >= 4.10)
val string_unicode_map :
?encoding_from:Uutf.decoder_encoding ->
?encoding_to:Uutf.encoding ->
(int -> Uchar.t option -> Uchar.t list) ->
string ->
stringPrinting helpers
Print an option
val pp_list :
pp_sep:(Buffer.t -> 'a -> unit) ->
sep:'a ->
pp:(Buffer.t -> 'b -> unit) ->
Buffer.t ->
'b list ->
unitPrint a list with separator into a buffer
val print_opt :
?none:string ->
(Format.formatter -> 'a -> unit) ->
Format.formatter ->
'a option ->
unitPrint an option.
val print_list :
print_sep:(Format.formatter -> 'a -> unit) ->
sep:'a ->
print:(Format.formatter -> 'b -> unit) ->
Format.formatter ->
'b list ->
unitPrint a list with separator into a buffer
Iteration helpers
Applies the given function n times.
Same as
ist.concat_map
(which is not available on ocaml.4.08).
Same as `List.map` but if all elements of the new lists are physically equal to the ones from the original list, then the original list is returned.
val list_partition_map :
('a -> [ `Left of 'b | `Right of 'c ]) ->
'a list ->
'b list * 'c listRe-implementation of List.partition_map (which was added in ocaml 4.12).
String helpers
Simialr to stdlib's String.exists, but without require recent enough versions of the compiler.
Lexbuf helpers
Filename string of an input.
val filename_of_input_source :
[ `Stdin | `File of string | `Raw of string * string ] ->
stringFilename string of an input source.
val mk_lexbuf :
[ `Stdin | `File of string | `Contents of string * string ] ->
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.
Tries and parse the string with the given lexer rule.