Module StringOf

The StringOf module is used to convert various data structures to strings that do not have a string_of function associated with it

Credit to Shawn for advice on generalization with fold for the Hashtbl.t and Map.S.t structures

Copyright (C) 2020 Nikunj Chawla

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see https://www.gnu.org/licenses/.

val string_of_char : char -> string

string_of_char converts a given char to a string

parameter c

The char to convert

returns

The string form of c

val string_of_pair : ('a -> string) -> ('b -> string) -> ('a * 'b) -> string

string_of_pair returns the given pair as a string

parameter string_of_fst

The function to convert the first element of the pair to a string

parameter string_of_snd

The function to convert the second element of the pair to a string

parameter fst

The first element of the pair

parameter snd

The second element of the pair

returns

The string form of the given pair

val string_of_triple : ('a -> string) -> ('b -> string) -> ('c -> string) -> ('a * 'b * 'c) -> string

string_of_triple returns the given * 'b * 'c triple as a string

parameter string_of_fst

The function to convert the first element of the triple to a string

parameter string_of_snd

The function to convert the second element of the triple to a string

parameter string_of_trd

The function to convert the third element of the triple to a string

parameter fst

The first element of the triple

parameter snd

The second element of the triple

parameter trd

The third element of the triple

returns

The string form of the given triple

type 'a fold_string_fn_t = 'a -> string list -> string list

The type corresponding to the function passed to the fold function for string_of_foldable

type ('a, 'b) fold_string_t = 'a fold_string_fn_t -> 'b -> string list -> string list

The type corresponding to the fold function for string_of_foldable

val string_of_foldable : ('a -> string) -> ('a'b) fold_string_t -> 'b -> string

string_of_foldable converts a data structure that has a fold function in the form ('a -> 'c -> 'c) -> 'b -> 'c -> 'c to a string composed of element strings, concatenated with "; "

parameter string_of_el

The function used to turn each element of the data structure to a string

parameter fold

The fold function in the aforementioned format to use with the given data structure

parameter ds

The data structure to convert to a string

returns

The string form of ds

val string_of_foldable_exp : ('a -> string) -> ('a'b) fold_string_t -> 'b -> string

string_of_foldable_exp converts a data structure that has a fold function in the form ('a -> 'c -> 'c) -> 'b -> 'c -> 'c to a string composed of element strings, concatenated with ";\n"

parameter string_of_el

The function used to turn each element of the data structure to a string

parameter fold

The fold function in the aforementioned format to use with the given data structure

parameter ds

The data structure to convert to a string

returns

The string form of ds

val string_of_list : ('a -> string) -> 'a list -> string

string_of_list returns the given list as a string

parameter string_of_el

The function used to turn each element of the list to a string

parameter lst

The list to convert to a string

returns

The given list as a string

val string_of_list_exp : ('a -> string) -> 'a list -> string

string_of_list_exp returns the given list as a string in expanded form

parameter string_of_el

The function used to turn each element of the list to a string

parameter lst

The list to convert to a string

returns

The given list as a string in expanded form

val string_of_array : ('a -> string) -> 'a array -> string

string_of_array returns given array as a string

parameter string_of_el

The function used to turn each element of the array to a string

parameter arr

The array to convert to a string

returns

The given array as a string

val string_of_array_exp : ('a -> string) -> 'a array -> string

string_of_array_exp returns given array as a string in expanded form

parameter string_of_el

The function used to turn each element of the array to a string

parameter arr

The array to convert to a string

returns

The given array as a string in expanded form

type ('a, 'b, 'd) map_fold_fn_t = 'a -> 'b -> 'd -> 'd

The type corresponding to the function passed to the fold function for Hashtbl.t and Map.S.t for string_of_foldable_map_ds

type ('a, 'b, 'c, 'd) map_fold_t = ('a'b'd) map_fold_fn_t -> 'c -> 'd -> 'd

The type corresponding to the fold function for Hashtbl.t and Map.S.t for string_of_foldable_map_ds

val string_of_foldable_map_ds : ('a -> string) -> ('b -> string) -> ('a'b'c('a * 'b) list) map_fold_t -> 'c -> string

string_of_foldable_map_ds returns the given map-like data structure (such as Hashtbl.t and Map.S.t) as a string

parameter string_of_key

The function used to turn each key of the data structure to a string

parameter string_of_val

The function used to turn each value of the data structure to a string

parameter map_fold

The function that can be used to fold ds

parameter ds

The map-like data structure to convert to a string

returns

The string form of ds

val string_of_foldable_map_ds_exp : ('a -> string) -> ('b -> string) -> ('a'b'c('a * 'b) list) map_fold_t -> 'c -> string

string_of_foldable_map_ds_exp returns the given map-like data structure (such as Hashtbl.t and Map.S.t) as a string in expanded form

parameter string_of_key

The function used to turn each key of the data structure to a string

parameter string_of_val

The function used to turn each value of the data structure to a string

parameter map_fold

The function that can be used to fold ds

parameter ds

The map-like data structure to convert to a string

returns

The string form of ds in expanded form

val string_of_hashtbl : ('a -> string) -> ('b -> string) -> ('a'b) Stdlib.Hashtbl.t -> string

string_of_hashtbl returns given ('a, 'b) Hashtbl.t as a string in expanded form

parameter string_of_key

The function used to turn each key of the Hashtbl.t to a string

parameter string_of_val

The function used to turn each value of the Hashtbl.t to a string

parameter tbl

The Hashtbl.t to convert to a string

returns

The given ('a, 'b) Hashtbl.t as a string in expanded form

val string_of_hashtbl_exp : ('a -> string) -> ('b -> string) -> ('a'b) Stdlib.Hashtbl.t -> string

string_of_hashtbl_exp returns given ('a, 'b) Hashtbl.t as a string in expanded form

parameter string_of_key

The function used to turn each key of the Hashtbl.t to a string

parameter string_of_val

The function used to turn each value of the Hashtbl.t to a string

parameter tbl

The Hashtbl.t to convert to a string

returns

The given ('a, 'b) Hashtbl.t as a string in expanded form

module StringOfSet : functor (S : Stdlib.Set.S) -> sig ... end

StringOfSet is a submodule functor that, given a module S that is implemented using Set.Make, will create a module capable of converting instances of S to string form

module StringOfMap : functor (M : Stdlib.Map.S) -> sig ... end

StringOfMap is a submodule functor that, given a module M that is implemented using Map.Make, will create a module capable of converting instances of M to string form