Re: Print set and maps

"Johan Mazel [email protected] [ocaml_beginners]" <[email protected]>
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <CAKS5mhQUYB+8XD=ZDwVgDDAht9KdYn5XTExfVJVLsj_HyDrxUg@mail.gmail.com>
Well I am aware of the s-exp conversion but it is a bit too verbose for me.

I want something closer to what the "print" function is doing in Batteries'
modules but without the BatInnerIO.output related stuff and a simple string
output.

I am currently using module include to transparently add new function but
it is a bit cumbersome.

Regards,
Johan

2015-06-24 22:14 GMT+09:00 Ashish Agarwal [email protected]
[ocaml_beginners] <[email protected]>:

>
>
> Core provides functions to convert from and to s-expressions for most data
> types it has. Maybe you'll be happy with that, but it depends on your
> needs. For example:
>
> # let x = String.Map.of_alist_exn [("a",1); ("b",2)];;
> val x : int String.Map.t = <abstr>
>
> # String.Map.sexp_of_t sexp_of_int x |> Sexp.to_string_hum;;
> - : string = "((a 1) (b 2))"
>
>
>
> On Wed, Jun 24, 2015 at 1:10 AM, Johan Mazel [email protected]
> [ocaml_beginners] <[email protected]> wrote:
>
>>
>>
>> Hi
>> Is there any standard way to generate strings that contain the content of
>> sets/maps (standard, Batteries or Core) ?
>> I wrote several to_string functions (either using the print function of
>> Batteries or just by converting type to lists and then printing it with the
>> BatList module's print function) for these types.
>> I however would rather use something from the library instead (especially
>> for Core). I tried to read the doc (
>> https://ocaml.janestreet.com/ocaml-core/latest/doc/) but I did not get
>> any results.
>> Is there anything that would do the job ?
>> Thank you for your time.
>> Johan
>>
>>
>>
>>
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.