Re: [Caml-list] Generic printer patch

2011-12-09 Thread Gabriel Scherer
> If think my hack is reasonable too, you just have to replace ocamlc and > ocamlopt (if you already use ocaml 3.12.1) by the new compilers and it > will work. Indeed. It's just that in some cases (eg. you are no expert user and/or use the ocaml binary packages of your distribution) the cost of pa

Re: [Caml-list] Generic printer patch

2011-12-08 Thread Jérémie Dimino
Le jeudi 08 décembre 2011 à 22:39 +0100, Gabriel Scherer a écrit : > Of course, the "right" way to print/marshal data without changing the > language is to build a printer for your type from printer combinators. > Such combinators are available for example: > - in Jane Street Core library ( a Sexp

Re: [Caml-list] Generic printer patch

2011-12-08 Thread Jérémie Dimino
Le jeudi 08 décembre 2011 à 10:20 -0800, Martin Jambon a écrit : > I understand that this feature could be replaced in the future by a more > complete solution, but we would be happy if it were provided as an > "experimental extension" of OCaml. If you want to use it i can maintain it (and make i

Re: [Caml-list] Generic printer patch

2011-12-08 Thread Gabriel Scherer
Martin, in the meantime, you can use Extlib's (Std.dump : 'a -> string) function, which is also integrated into Batteries. `dump` does not require any modification to the compiler or toolchain. For those that are not familiar with it, 'dump' uses the low-level representation of OCaml values to pri

Re: [Caml-list] Generic printer patch

2011-12-08 Thread Martin Jambon
On 12/08/2011 04:00 AM, Romain Bardou wrote: >>> 2) Could you imagine to generalize it to Format.formatter or to >>> out_channel (without creating a string and concatenating)? Romain Bardou >>> add in the mantis tracker (I can't give you the bugtracking number since >>> mantis "is currently offline

Re: [Caml-list] Generic printer patch

2011-12-08 Thread Gerd Stolpmann
>>> 2) Could you imagine to generalize it to Format.formatter or to >>> out_channel (without creating a string and concatenating)? Romain >>> Bardou >>> add in the mantis tracker (I can't give you the bugtracking number >>> since >>> mantis "is currently offline for maintenance") a feature wish fo

Re: [Caml-list] Generic printer patch

2011-12-08 Thread Romain Bardou
2) Could you imagine to generalize it to Format.formatter or to out_channel (without creating a string and concatenating)? Romain Bardou add in the mantis tracker (I can't give you the bugtracking number since mantis "is currently offline for maintenance") a feature wish for a new conversion speci

Re: [Caml-list] Generic printer patch

2011-12-08 Thread Philippe Veber
And the SQL schema generation lib as well :o) ? 2011/12/8 Jonathan Protzenko > Do you plan on opening up your automated gui generation library and have > it distributed so that other users can take advantage of it? Say, make it > rely on lablgtk and bundle it as a semi-official 3rd-party library

Re: [Caml-list] Generic printer patch

2011-12-08 Thread Jonathan Protzenko
Do you plan on opening up your automated gui generation library and have it distributed so that other users can take advantage of it? Say, make it rely on lablgtk and bundle it as a semi-official 3rd-party library that other people can reuse :-). jonathan On Thu 08 Dec 2011 11:32:28 AM CET, A

Re: [Caml-list] Generic printer patch

2011-12-08 Thread Alain Frisch
On 12/08/2011 10:24 AM, Gerd Stolpmann wrote: http://www.lexifi.com/blog/runtime-types Want it! Want it! Want it! Any plans for including this into the official compiler? Since the reception was not bad when I presented it to the Caml Consortium meeting, yes, I'm proposing this as an extens

Re: [Caml-list] Generic printer patch

2011-12-08 Thread Jérémie Dimino
Le mercredi 07 décembre 2011 à 23:44 -0800, Martin Jambon a écrit : > What do you think of moving the project to GitHub so we could follow its > progress and contribute more easily? This projet is just a quick hack. If i do something more serious i will consider creating a real project. > For now

Re: [Caml-list] Generic printer patch

2011-12-08 Thread Gerd Stolpmann
> On 12/08/2011 03:33 AM, Edgar Friendly wrote: >> On 12/07/2011 10:28 AM, Jérémie Dimino wrote: >>> Hi, >>> >>> I have made a patch for ocaml 3.12.1 which allow to have a generic >>> printing function. The patch is available here: >>> >>> external show : 'a -> string = "%show" >>> >>> Of course

Re: [Caml-list] Generic printer patch

2011-12-08 Thread Alain Frisch
On 12/08/2011 03:33 AM, Edgar Friendly wrote: On 12/07/2011 10:28 AM, Jérémie Dimino wrote: Hi, I have made a patch for ocaml 3.12.1 which allow to have a generic printing function. The patch is available here: external show : 'a -> string = "%show" Of course it is limited to what the compile

Re: [Caml-list] Generic printer patch

2011-12-07 Thread Martin Jambon
On 12/07/2011 10:52 PM, Jérémie Dimino wrote: > Le mercredi 07 décembre 2011 à 21:26 -0800, Martin Jambon a écrit : >> I would like to fetch the git repository but it won't let me: >> >> $ git clone 'http://www.dimino.org/git/ocaml-3.12.1-print.git' >> Cloning into ocaml-3.12.1-print... >> fatal:

Re: [Caml-list] Generic printer patch

2011-12-07 Thread François Bobot
Le 08/12/2011 03:33, Edgar Friendly a écrit : I'm interested in having compile-time reflection like this, but maybe with a bit more generality. Maybe an identifier can be built out of the type in a generic way... external show : 'a -> string = "%type_to_string" external print : out_channel -> 'a

Re: [Caml-list] Generic printer patch

2011-12-07 Thread Jérémie Dimino
Le mercredi 07 décembre 2011 à 21:26 -0800, Martin Jambon a écrit : > I would like to fetch the git repository but it won't let me: > > $ git clone 'http://www.dimino.org/git/ocaml-3.12.1-print.git' > Cloning into ocaml-3.12.1-print... > fatal: http://www.dimino.org/git/ocaml-3.12.1-print.git/inf

Re: [Caml-list] Generic printer patch

2011-12-07 Thread Martin Jambon
Thanks Jérémie for doing this, it's a very useful feature. I would like to fetch the git repository but it won't let me: $ git clone 'http://www.dimino.org/git/ocaml-3.12.1-print.git' Cloning into ocaml-3.12.1-print... fatal: http://www.dimino.org/git/ocaml-3.12.1-print.git/info/refs not found: d

Re: [Caml-list] Generic printer patch

2011-12-07 Thread Edgar Friendly
On 12/07/2011 10:28 AM, Jérémie Dimino wrote: Hi, I have made a patch for ocaml 3.12.1 which allow to have a generic printing function. The patch is available here: external show : 'a -> string = "%show" Of course it is limited to what the compiler knows, for example the following function

Re: [Caml-list] Generic printer patch

2011-12-07 Thread Jérémie Dimino
Le mercredi 07 décembre 2011 à 17:56 +0100, François Bobot a écrit : > 1) If I understand well the "%show" command is expanded into the ocaml > code (lambda-code) which can print the type. So, for instance, in the > case of a list, your code generates a recursive function "aux" and it > applies

Re: [Caml-list] Generic printer patch

2011-12-07 Thread Jérémie Dimino
Le mercredi 07 décembre 2011 à 11:46 -0500, Alex Rubinsteyn a écrit : > Cool! Thanks for writing this. Can you explain how defining a custom > printer works? The new language features still bewilder me. If you want to define a custom printer for a type named foo, you have to define a function name

Re: [Caml-list] Generic printer patch

2011-12-07 Thread François Bobot
Le 07/12/2011 16:28, Jérémie Dimino a écrit : Hi, I have made a patch for ocaml 3.12.1 which allow to have a generic printing function. The patch is available here: [...] Of course it is limited to what the compiler knows, for example the following function will always returns "[;]": let f x

Re: [Caml-list] Generic printer patch

2011-12-07 Thread Alex Rubinsteyn
Cool! Thanks for writing this. Can you explain how defining a custom printer works? The new language features still bewilder me. On Dec 7, 2011 10:29 AM, "Jérémie Dimino" wrote: > Hi, > > I have made a patch for ocaml 3.12.1 which allow to have a generic > printing function. The patch is availabl

[Caml-list] Generic printer patch

2011-12-07 Thread Jérémie Dimino
Hi, I have made a patch for ocaml 3.12.1 which allow to have a generic printing function. The patch is available here: http://www.dimino.org/ocaml-3.12.1-generic-print.patch Here is how to use it: external show : 'a -> string = "%show" let () = print_endline (show ([1; 2; 3], Some "foo")