Stog library reference documentation : Stog_misc

Module Stog_misc

module Stog_misc: sig .. end
Utilities.

val safe_main : (unit -> unit) -> unit
safe_main f calls f () but handles Sys_error and Failure exceptions by exiting with error code 1.
Author(s): Maxence Guesdon
Version: 1.0
val string_of_file : string -> string
string_of_file filename returns the content of filename in the form of one string.
Author(s): Maxence Guesdon
Version: 1.0
Raises Sys_error if the file could not be opened.
val file_of_string : file:string -> string -> unit
file_of_string ~file str creates a file named filename whose content is str.
Author(s): Fabrice Lefessant
Version: 1.1
Raises Sys_error if the file could not be opened.
val create_log_fun : ?prefix:string ->
?print:(string -> unit) ->
string -> ?loc:string -> ?level:int -> (unit -> string) -> unit
Creating a log function. create_log_fun env_var get the log level (an integer) from the given environment variable, and returns a function to print messages. This function takes a level (default is 1) and a function returning the message do print. The function is called only if the log level is higher than or equal to the given level. The loc parameter of the returned function can be used to indicate an additional string to print before the log message. If the environment variable is empty or does not contain an integer, then the log level is set to 0.
prefix : can be used to indicate a string prefixing every message
print : can be given to the function build the log function, to indicate an alternative way to display the message; default is to call prerr_endline.
val create_log_fun_with_set : ?prefix:string ->
?print:(string -> unit) ->
string ->
(?loc:string -> ?level:int -> (unit -> string) -> unit) * (int -> unit)
Same as create_log_fun but also return a function to change the log level.
val split_string : ?keep_empty:bool -> string -> char list -> string list
Separate the given string according to the given list of characters.
Author(s): Maxence Guesdon
Version: 1.1
keep_empty : is false by default. If set to true, the empty strings between separators are kept.
val strip_string : string -> string
strip_string s removes all leading and trailing spaces from the given string.
Author(s): Maxence Guesdon
Version: 1.0
val strip_blank_lines : string -> string
strip_blank_lines s works as Stog_misc.strip_string, but only strips full blank lines, without touching spaces or tabulations.
val lowercase : string -> string
lowercase s lowers the case of the given string, including accentuated characters.
Author(s): Maxence Guesdon
Version: 1.0
val list_chop : int -> 'h list -> 'h list
list_chop n l returns the n first documents of list l or the whole list if n >= List.length l.
Author(s): Maxence Guesdon
Version: 1.0
val mkdir : string -> unit
val is_prefix : string -> string -> bool
is_prefix pattern s returns true if string s begins with pattern.
Author(s): Maxence Guesdon
Version: 1.0
val list_remove_doubles : ?pred:('k -> 'k -> bool) -> 'k list -> 'k list
list_remove_doubles ?pred l remove doubles in the given list l, according to the optional equality function pred. Default equality function is (=).
Author(s): Maxence Guesdon
Version: 1.0
val md5 : string -> string
val count_char : string -> char -> int
val encode_string : string -> string
val map_opt : ('a -> 'b) -> 'a option -> 'b option
val list_concat : ?sep:'a -> 'a list -> 'a list
val dot_to_svg : string -> string
val list_compare : ('a -> 'a -> int) -> 'a list -> 'a list -> int
val filename_extension : string -> string
filename_extension filename returns extension of filename or "" if there is no extension.
val safe_mkdir : string -> unit
val opt_of_string : string -> string option
opt_of_string s returns None if the string if empty (length is 0) or Some s.
Version: 1.0
val string_of_opt : string option -> string
string_of_opt s_opt returns the empty string if s_opt = None or s if s_opt = Some s.
Version: 1.0
val file_mtime : string -> float option
Return mdification time of the given file, or None if the file does not exist.
val path_under : parent:string -> string -> string
path_under ~parent file returns the path to file from parent.
Raises Failure if parent is not a prefix of file.
val string_of_time : float -> string