caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Print values like the toplevel's printer
@ 2004-11-05 12:23 Wolfgang Müller
  2004-11-05 13:31 ` [Caml-list] " padiolea
  2004-11-06 11:15 ` [Caml-list] " Jim
  0 siblings, 2 replies; 12+ messages in thread
From: Wolfgang Müller @ 2004-11-05 12:23 UTC (permalink / raw)
  To: caml-list

Hi,

I would like to print values to a file in a human-readable manner without 
having to compose the output writers of print_int and friends. In short, I 
would like to use the toplevel's function for screen output of structured 
values.

Is there a simple way, a FM or a mailing list you can point me to?

I googled quite a bit, but apparently not with the right terms.

Cheers,
Wolfgang
-- 
Dr. Wolfgang Müller
LS AI 1
Universität Bayreuth


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] Print values like the toplevel's printer
  2004-11-05 12:23 Print values like the toplevel's printer Wolfgang Müller
@ 2004-11-05 13:31 ` padiolea
  2004-11-05 13:54   ` Wolfgang Müller
  2004-11-06 11:15 ` [Caml-list] " Jim
  1 sibling, 1 reply; 12+ messages in thread
From: padiolea @ 2004-11-05 13:31 UTC (permalink / raw)
  To: Wolfgang Müller; +Cc: caml-list

> Hi,
>
> I would like to print values to a file in a human-readable manner without
> having to compose the output writers of print_int and friends. In short, I
> would like to use the toplevel's function for screen output of structured
> values.

I recently post a message to allow this (with generic print in the subject
of the message).

the code is available at:
 http://www.irisa.fr/prive/padiolea/hacks/generic_print.ml

example:
  let _ = print_string (generic_print [[1;3];[2;9;8];[3;4]] "int list
list" in
  let _ = print_string (generic_print [1;3;2;9;8;3;4] "int list") in
   ...

 test:
  ./test_generic
  ==>
   [[1; 3]; [2; 9; 8]; [3; 4]]
   [1; 3; 2; 9; 8; 3; 4]




>
> Is there a simple way, a FM or a mailing list you can point me to?



>
> I googled quite a bit, but apparently not with the right terms.
>
> Cheers,
> Wolfgang
> --
> Dr. Wolfgang Müller
> LS AI 1
> Universität Bayreuth
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] Print values like the toplevel's printer
  2004-11-05 13:31 ` [Caml-list] " padiolea
@ 2004-11-05 13:54   ` Wolfgang Müller
  2004-11-05 15:51     ` pad
  0 siblings, 1 reply; 12+ messages in thread
From: Wolfgang Müller @ 2004-11-05 13:54 UTC (permalink / raw)
  To: caml-list

> I recently post a message to allow this (with generic print in the subject
> of the message).

Thanks a lot, but isn't there something more simple without forking processes?

Is there no way to reuse the code that is already in the toplevel?

Cheers,
Wolfgang

-- 
Dr. Wolfgang Müller
LS AI 1
Universität Bayreuth


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] Print values like the toplevel's printer
  2004-11-05 13:54   ` Wolfgang Müller
@ 2004-11-05 15:51     ` pad
  2004-11-05 18:07       ` [Too hard?] Print values like the toplevel's printerI Wolfgang Müller
  0 siblings, 1 reply; 12+ messages in thread
From: pad @ 2004-11-05 15:51 UTC (permalink / raw)
  To: Wolfgang Müller; +Cc: caml-list

Wolfgang Müller <Wolfgang.Mueller2@uni-bayreuth.de> writes:

> > I recently post a message to allow this (with generic print in the subject
> > of the message).
> 
> Thanks a lot, but isn't there something more simple without forking processes?

well it is quite simple to fork a process :) and it is maximum reuse :)

why don't you like this solution ? is it because it is slow ? ugly ?
there is some way to improve easily my solution by not forking each time for each
call to generic_print  by using a pipe with the toplevel
(I plan to do a tracer for ocaml better than the #trace using this technique)


> 
> Is there no way to reuse the code that is already in the toplevel?
> 
> Cheers,
> Wolfgang


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Too hard?] Print values like the toplevel's printerI
  2004-11-05 15:51     ` pad
@ 2004-11-05 18:07       ` Wolfgang Müller
  2004-11-05 18:28         ` [Caml-list] " pad
  2004-11-05 18:54         ` Martin Jambon
  0 siblings, 2 replies; 12+ messages in thread
From: Wolfgang Müller @ 2004-11-05 18:07 UTC (permalink / raw)
  To: padiolea; +Cc: pad, Wolfgang.Mueller2, caml-list

> why don't you like this solution ? is it because it is slow ? ugly ?

I think your solution gives me the feeling that there must be something
simpler than that.

This is not criticizing you, it is rather a question to the Caml people,
like e.g. X. Leroy and colleagues and/or the ExtLibs:

(Why?) is there no really simple way getting the print functionality of
the standard toplevel?

Cheers,
Wolfgang




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] [Too hard?] Print values like the toplevel's printerI
  2004-11-05 18:07       ` [Too hard?] Print values like the toplevel's printerI Wolfgang Müller
@ 2004-11-05 18:28         ` pad
  2004-11-05 18:54         ` Martin Jambon
  1 sibling, 0 replies; 12+ messages in thread
From: pad @ 2004-11-05 18:28 UTC (permalink / raw)
  To: Wolfgang Müller; +Cc: padiolea, pad, caml-list

"Wolfgang Müller" <Wolfgang.Mueller2@uni-bayreuth.de> writes:

> > why don't you like this solution ? is it because it is slow ? ugly ?
> 
> I think your solution gives me the feeling that there must be something
> simpler than that.

:) 

> 
> This is not criticizing you, it is rather a question to the Caml people,
> like e.g. X. Leroy and colleagues and/or the ExtLibs:
> 
> (Why?) is there no really simple way getting the print functionality of
> the standard toplevel?

Here is my 50 cent:

First because the type of this function will be wierd, 
 print: 'a -> string 
 (of course there are other wierd stuff in Ocaml such as the type of printf, or the type of exn)

Haskell have solved this problem by introducing overloading (and the deriving Show)

Secondly it would requires to add type information in the code.
The toplevel have to maintain more information than the native code program
(which leads to less efficiency).
One of the advance of ML over Lisp is that it is strongly typed which allows to have
code that dont have anymore type information and typecheck. All is done at compile-time.


> 
> Cheers,
> Wolfgang
> 
> 
> 
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] [Too hard?] Print values like the toplevel's printerI
  2004-11-05 18:07       ` [Too hard?] Print values like the toplevel's printerI Wolfgang Müller
  2004-11-05 18:28         ` [Caml-list] " pad
@ 2004-11-05 18:54         ` Martin Jambon
  2004-11-05 19:26           ` Frédéric Gava
  1 sibling, 1 reply; 12+ messages in thread
From: Martin Jambon @ 2004-11-05 18:54 UTC (permalink / raw)
  To: Wolfgang Müller; +Cc: padiolea, pad, caml-list

On Fri, 5 Nov 2004, Wolfgang Müller wrote:

> > why don't you like this solution ? is it because it is slow ? ugly ?
>
> I think your solution gives me the feeling that there must be something
> simpler than that.
>
> This is not criticizing you, it is rather a question to the Caml people,
> like e.g. X. Leroy and colleagues and/or the ExtLibs:
>
> (Why?) is there no really simple way getting the print functionality of
> the standard toplevel?

Daniel de Rauglaudre wrote a Camlp4 extension that lets you export (and
import) non-circular data to XML (it reads type definitions and uses this
to insert the ad hoc export/import functions).
This is called IoXML. Maybe it has not been updated for the 3.08
version of Camlp4.
It should be not too difficult to adapt it for printing data with an
OCaml-compliant syntax.


Martin

--
Martin Jambon, PhD
Researcher in Structural Bioinformatics since the 20th Century
The Burnham Institute http://www.burnham.org
San Diego, California



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] [Too hard?] Print values like the toplevel's printerI
  2004-11-05 18:54         ` Martin Jambon
@ 2004-11-05 19:26           ` Frédéric Gava
  2004-11-05 20:01             ` [Caml-list] [Too hard?] Print values like the toplevel's printer Wolfgang Müller
  0 siblings, 1 reply; 12+ messages in thread
From: Frédéric Gava @ 2004-11-05 19:26 UTC (permalink / raw)
  To: Martin Jambon, Wolfgang Müller; +Cc: padiolea, pad, caml-list

> Daniel de Rauglaudre wrote a Camlp4 extension that lets you export (and
> import) non-circular data to XML (it reads type definitions and uses this
> to insert the ad hoc export/import functions).
> This is called IoXML. Maybe it has not been updated for the 3.08
> version of Camlp4.
I used it all the times and this library does not work with OCaml 3.08. If
have made
a little modification and it seems to work (for my data). If you need it, I
could sent you
this modification.

Frédéric Gava

ps:
> It should be not too difficult to adapt it for printing data with an
> OCaml-compliant syntax.
Juste change the name and the type of some functions.






^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] [Too hard?] Print values like the toplevel's printer
  2004-11-05 19:26           ` Frédéric Gava
@ 2004-11-05 20:01             ` Wolfgang Müller
  0 siblings, 0 replies; 12+ messages in thread
From: Wolfgang Müller @ 2004-11-05 20:01 UTC (permalink / raw)
  To: frederic.gava; +Cc: martin_jambon, Wolfgang.Mueller2, padiolea, pad, caml-list

>> Daniel de Rauglaudre wrote a Camlp4 extension that lets you export
>> (and import) non-circular data to XML (it reads type definitions and
>> uses this to insert the ad hoc export/import functions).
>> This is called IoXML. Maybe it has not been updated for the 3.08
>> version of Camlp4.
> I used it all the times and this library does not work with OCaml 3.08.
> If have made
> a little modification and it seems to work (for my data). If you need
> it, I could sent you
> this modification.

Oh, this looks very much as if it would be interesting for me. I am mainly
interested in generating quickly human readable output as I am a
"debugging by logging" person. This sounds exactly like what I need.

Thanks a lot to all of you who answered for your helpful postings.

Wolfgang

> ps:
>> It should be not too difficult to adapt it for printing data with an
>> OCaml-compliant syntax.
> Juste change the name and the type of some functions.

This sounds very attractive.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] Print values like the toplevel's printer
  2004-11-05 12:23 Print values like the toplevel's printer Wolfgang Müller
  2004-11-05 13:31 ` [Caml-list] " padiolea
@ 2004-11-06 11:15 ` Jim
  2004-11-08 23:44   ` brogoff
  1 sibling, 1 reply; 12+ messages in thread
From: Jim @ 2004-11-06 11:15 UTC (permalink / raw)
  To: caml-list

On Fri, Nov 05, 2004 at 01:23:13PM +0100, Wolfgang Müller wrote:

> I would like to print values to a file in a human-readable manner without 
> having to compose the output writers of print_int and friends. In short, I 
> would like to use the toplevel's function for screen output of structured 
> values.
> 
> Is there a simple way, a FM or a mailing list you can point me to?
> 
> I googled quite a bit, but apparently not with the right terms.

Aside from clever uses of various bits of the top level, you can also
use camlp4 to automatically generate print functions for types.  I think
there is an example in the camlp4 manual.

What we really need is generics.  I thought there was a post in the
mailing list some time ago saying that generics was going to be
appear in O'Caml at some point, but I haven't seen anything for a long
time.  Does anyone know if it is still planned?

Regards,
Jim


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] Print values like the toplevel's printer
  2004-11-06 11:15 ` [Caml-list] " Jim
@ 2004-11-08 23:44   ` brogoff
  2004-11-09  8:48     ` Daniel Bünzli
  0 siblings, 1 reply; 12+ messages in thread
From: brogoff @ 2004-11-08 23:44 UTC (permalink / raw)
  To: caml-list

On Sat, 6 Nov 2004, Jim wrote:
> What we really need is generics.  I thought there was a post in the
> mailing list some time ago saying that generics was going to be
> appear in O'Caml at some point, but I haven't seen anything for a long
> time.  Does anyone know if it is still planned?
>
> Regards,
> Jim

I thought that development was to continue in the OCaml branch after 3.08.
Looking at the CVS, whre nothing has been updated for over seven months, it
appears abandoned. If that's the case, I wonder if there is an alternative
approach being considered to provide some of the desired features, like
safe value IO, dynamic typing, and overloading? I was previously under the
impression that safe value IO was a very desired feature, and that once the
machinery for that was aded that the rest of GCaml would be folded in quickly.

It isn't clear to me how the GCaml extensions would work with all of the
other extensions in OCaml (objects and variants and...) and it is already a
kind of complicated language. It would be a lot easier if the generics were just
being added to Caml Special Light.

-- Brian


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] Print values like the toplevel's printer
  2004-11-08 23:44   ` brogoff
@ 2004-11-09  8:48     ` Daniel Bünzli
  0 siblings, 0 replies; 12+ messages in thread
From: Daniel Bünzli @ 2004-11-09  8:48 UTC (permalink / raw)
  To: caml-list

Le 9 nov. 04, à 00:44, brogoff a écrit :

> I wonder if there is an alternative
> approach being considered to provide some of the desired features, like
> safe value IO, dynamic typing, and overloading?

Although research oriented you may want to have a look at acute, an 
extension of an ocaml core to support, among other things, type safe 
value IO :

<http://www.cl.cam.ac.uk/users/pes20/acute/>

Daniel


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2004-11-09  8:47 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-05 12:23 Print values like the toplevel's printer Wolfgang Müller
2004-11-05 13:31 ` [Caml-list] " padiolea
2004-11-05 13:54   ` Wolfgang Müller
2004-11-05 15:51     ` pad
2004-11-05 18:07       ` [Too hard?] Print values like the toplevel's printerI Wolfgang Müller
2004-11-05 18:28         ` [Caml-list] " pad
2004-11-05 18:54         ` Martin Jambon
2004-11-05 19:26           ` Frédéric Gava
2004-11-05 20:01             ` [Caml-list] [Too hard?] Print values like the toplevel's printer Wolfgang Müller
2004-11-06 11:15 ` [Caml-list] " Jim
2004-11-08 23:44   ` brogoff
2004-11-09  8:48     ` Daniel Bünzli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).