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 -> stringstring_of_charconverts a givencharto astring- parameter c
The
charto convert
- returns
The
stringform ofc
val string_of_pair : ('a -> string) -> ('b -> string) -> ('a * 'b) -> stringstring_of_pairreturns the given pair as astring- 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
stringform of the given pair
val string_of_triple : ('a -> string) -> ('b -> string) -> ('c -> string) -> ('a * 'b * 'c) -> stringstring_of_triplereturns the given* 'b * 'ctriple 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
stringform of the given triple
type 'a fold_string_fn_t= 'a -> string list -> string listThe 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 listThe type corresponding to the fold function for
string_of_foldable
val string_of_foldable : ('a -> string) -> ('a, 'b) fold_string_t -> 'b -> stringstring_of_foldableconverts a data structure that has a fold function in the form('a -> 'c -> 'c) -> 'b -> 'c -> 'cto astringcomposed of elementstrings, 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
stringform ofds
val string_of_foldable_exp : ('a -> string) -> ('a, 'b) fold_string_t -> 'b -> stringstring_of_foldable_expconverts a data structure that has a fold function in the form('a -> 'c -> 'c) -> 'b -> 'c -> 'cto astringcomposed of elementstrings, 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
stringform ofds
val string_of_list : ('a -> string) -> 'a list -> stringstring_of_listreturns the givenlistas astring- parameter string_of_el
The function used to turn each element of the
listto astring
- parameter lst
The
listto convert to astring
- returns
The given
listas a string
val string_of_list_exp : ('a -> string) -> 'a list -> stringstring_of_list_expreturns the givenlistas astringin expanded form- parameter string_of_el
The function used to turn each element of the
listto astring
- parameter lst
The
listto convert to astring
- returns
The given
listas a string in expanded form
val string_of_array : ('a -> string) -> 'a array -> stringstring_of_arrayreturns givenarrayas astring- parameter string_of_el
The function used to turn each element of the
arrayto astring
- parameter arr
The
arrayto convert to astring
- returns
The given
arrayas astring
val string_of_array_exp : ('a -> string) -> 'a array -> stringstring_of_array_expreturns givenarrayas astringin expanded form- parameter string_of_el
The function used to turn each element of the
arrayto astring
- parameter arr
The
arrayto convert to astring
- returns
The given
arrayas astringin expanded form
type ('a, 'b, 'd) map_fold_fn_t= 'a -> 'b -> 'd -> 'dThe 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 -> 'dThe 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 -> stringstring_of_foldable_map_dsreturns the given map-like data structure (such as Hashtbl.t and Map.S.t) as astring- 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
stringform ofds
val string_of_foldable_map_ds_exp : ('a -> string) -> ('b -> string) -> ('a, 'b, 'c, ('a * 'b) list) map_fold_t -> 'c -> stringstring_of_foldable_map_ds_expreturns the given map-like data structure (such as Hashtbl.t and Map.S.t) as astringin 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
stringform ofdsin expanded form
val string_of_hashtbl : ('a -> string) -> ('b -> string) -> ('a, 'b) Stdlib.Hashtbl.t -> stringstring_of_hashtblreturns given('a, 'b) Hashtbl.t as astringin 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 astringin expanded form
val string_of_hashtbl_exp : ('a -> string) -> ('b -> string) -> ('a, 'b) Stdlib.Hashtbl.t -> stringstring_of_hashtbl_expreturns given('a, 'b) Hashtbl.t as astringin 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 astringin expanded form
module StringOfSet : functor (S : Stdlib.Set.S) -> sig ... endStringOfSetis a submodule functor that, given a moduleSthat is implemented using Set.Make, will create a module capable of converting instances ofStostringform
module StringOfMap : functor (M : Stdlib.Map.S) -> sig ... endStringOfMapis a submodule functor that, given a moduleMthat is implemented using Map.Make, will create a module capable of converting instances ofMtostringform