* [Caml-list] view types in ocaml? @ 2003-01-21 3:13 Ed L Cashin 2003-01-21 11:48 ` Remi VANICAT 0 siblings, 1 reply; 7+ messages in thread From: Ed L Cashin @ 2003-01-21 3:13 UTC (permalink / raw) To: caml-list Hi. I like ocamlbrowser well enough, but is there a way to view type info right from the interactive ocaml prompt? Here's what I'm thinking of (which won't work, of course). Objective Caml version 3.06 # #load "unix.cma";; # Unix.LargeFile.lseek;; - : Unix.file_descr -> int64 -> Unix.seek_command -> int64 = <fun> # Unix.LargeFile.stats;; type stats = { st_dev : int; st_ino : int; st_kind : Unix.file_kind; st_perm : Unix.file_perm; st_nlink : int; st_uid : int; st_gid : int; st_rdev : int; st_size : int64; st_atime : float; st_mtime : float; st_ctime : float; } -- --Ed L Cashin | PGP public key: cashin@cs.uga.edu | http://noserose.net/e/pgp/ ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] view types in ocaml? 2003-01-21 3:13 [Caml-list] view types in ocaml? Ed L Cashin @ 2003-01-21 11:48 ` Remi VANICAT 2003-01-21 12:55 ` Ed L Cashin 0 siblings, 1 reply; 7+ messages in thread From: Remi VANICAT @ 2003-01-21 11:48 UTC (permalink / raw) To: caml-list Ed L Cashin <cashin@cs.uga.edu> writes: > Hi. I like ocamlbrowser well enough, but is there a way to view type > info right from the interactive ocaml prompt? > > Here's what I'm thinking of (which won't work, of course). > > Objective Caml version 3.06 > > # #load "unix.cma";; > # Unix.LargeFile.lseek;; > - : Unix.file_descr -> int64 -> Unix.seek_command -> int64 = <fun> > # Unix.LargeFile.stats;; > type stats = { > st_dev : int; [...] > st_ctime : float; > } well, there is alway the module redefinition trick : # module M = Unix.LargeFile;; module M : sig val lseek : Unix.file_descr -> int64 -> Unix.seek_command -> int64 [...] type stats = Unix.LargeFile.stats = { st_dev : int; [...] st_ctime : float; } val stat : string -> stats val lstat : string -> stats val fstat : Unix.file_descr -> stats end of course, for very big module, this is not a solution. -- Rémi Vanicat vanicat@labri.u-bordeaux.fr http://dept-info.labri.u-bordeaux.fr/~vanicat ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] view types in ocaml? 2003-01-21 11:48 ` Remi VANICAT @ 2003-01-21 12:55 ` Ed L Cashin 0 siblings, 0 replies; 7+ messages in thread From: Ed L Cashin @ 2003-01-21 12:55 UTC (permalink / raw) To: Remi VANICAT; +Cc: caml-list Remi VANICAT <vanicat@labri.u-bordeaux.fr> writes: ... > well, there is alway the module redefinition trick : > > # module M = Unix.LargeFile;; [shows sig] That's great. Thanks. ... > of course, for very big module, this is not a solution. I'm using run-caml in emacs, so it's still very helpful for, e.g., the whole Unix module. -- --Ed L Cashin | PGP public key: ecashin@uga.edu | http://noserose.net/e/pgp/ ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Caml-list] view types in ocaml? @ 2003-01-21 1:14 Ed L Cashin 2003-01-21 12:54 ` Yaron M. Minsky 0 siblings, 1 reply; 7+ messages in thread From: Ed L Cashin @ 2003-01-21 1:14 UTC (permalink / raw) To: caml-list Hi. I like ocamlbrowser well enough, but is there a way to view type info right from the interactive ocaml prompt. Here's what I'm thinking of (which won't work, of course). Objective Caml version 3.06 # #load "unix.cma";; # Unix.LargeFile.lseek;; - : Unix.file_descr -> int64 -> Unix.seek_command -> int64 = <fun> # Unix.LargeFile.stats;; type stats = { st_dev : int; st_ino : int; st_kind : Unix.file_kind; st_perm : Unix.file_perm; st_nlink : int; st_uid : int; st_gid : int; st_rdev : int; st_size : int64; st_atime : float; st_mtime : float; st_ctime : float; } -- --Ed L Cashin | PGP public key: ecashin@uga.edu | http://noserose.net/e/pgp/ ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] view types in ocaml? 2003-01-21 1:14 Ed L Cashin @ 2003-01-21 12:54 ` Yaron M. Minsky [not found] ` <20030121134608.GA495@first.in-berlin.de> 0 siblings, 1 reply; 7+ messages in thread From: Yaron M. Minsky @ 2003-01-21 12:54 UTC (permalink / raw) To: Caml List Speaking of suggestions for toplevel improvements, I've got a couple: - don't print really long strings. The mechanism for ensuring that overly long things don't get printed to the screen apparently doesn't work for strings. The result is that if you do anything with a large string (say, allocate a 100K buffer), every character gets printed to the screen. (and if that buffer is mostly zeros, each buffer character is printed as '\000', taking 4 characters. Argh!) - don't print let-bound values If I type an expression, such "let x = foobar a b c", the value of x is dumped to the screen. This is contrary to the behavior of most language interpreters (see python or matlab for examples.) It means you have no way of supressing the printing of the values you generate, which is quite inconvenient. Perhaps the type should always be printed (although maybe not), but printing the value every time make no sense. Suggestively, y On Mon, 2003-01-20 at 20:14, Ed L Cashin wrote: > Hi. I like ocamlbrowser well enough, but is there a way to view type > info right from the interactive ocaml prompt. Here's what I'm > thinking of (which won't work, of course). > > Objective Caml version 3.06 > > # #load "unix.cma";; > # Unix.LargeFile.lseek;; > - : Unix.file_descr -> int64 -> Unix.seek_command -> int64 = <fun> > # Unix.LargeFile.stats;; > type stats = { > st_dev : int; > st_ino : int; > st_kind : Unix.file_kind; > st_perm : Unix.file_perm; > st_nlink : int; > st_uid : int; > st_gid : int; > st_rdev : int; > st_size : int64; > st_atime : float; > st_mtime : float; > st_ctime : float; > } ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <20030121134608.GA495@first.in-berlin.de>]
* Re: [Caml-list] view types in ocaml? [not found] ` <20030121134608.GA495@first.in-berlin.de> @ 2003-01-21 14:42 ` Yaron M. Minsky 2003-01-21 16:40 ` Gérard Huet 0 siblings, 1 reply; 7+ messages in thread From: Yaron M. Minsky @ 2003-01-21 14:42 UTC (permalink / raw) To: Oliver Bandel; +Cc: Caml List On Tue, 2003-01-21 at 08:46, Oliver Bandel wrote: > > Well, I think that it is very good to have the values printed > always. > > I like that. > > The toplevel is very good for testing code and doing > experiments - and therefore it is very good to have > the values printed always. For the record, my suggestion is only that let-bound value printing should be suppressed. You could always see the result by just not binding it (e.g., typing "foo x y z" instead of "let a = foo x y z".) And you can always get the contents of any variable printed by typing it's name on the command line (e.g. "a;;" to see the contents of variable a). > If I don't need such helpers and code my code directly, > I can write it into a file and let ocamlc or > ocamlopt do its work. But if you're doing interactive work with data of non-trivial size, the constant printing is real pain. I do an enormous amount of work interactively at the command line, and more often than not, the data structure print-outs are so long that I can't see the line I just typed into the interpreter. > But maybe it makes sense to have options in the toplevel > to disable such printings. Making the suppression controllable by command-line options is sensible. But I do think that it should be the default. There's a reason that most language interpreters have this suppression, and I don't think there's anything special about ocaml that makes it different in this regard. Another useful extension to the ocaml toplevel which has been proposed in the past is to have some kind of default "this" variable which stores unbound variables. That would make the supression of let-bound easier to use, since if you wanted to see how something printed out, you could refrain from let-binding it, and still get access to the result using the "this" variable. > But it is no good idea to disable it hardcoded. > > I prefer the possibility to have such printings, > but think optionally turining it off would be ok. > > Ciao, > Oliver ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] view types in ocaml? 2003-01-21 14:42 ` Yaron M. Minsky @ 2003-01-21 16:40 ` Gérard Huet 0 siblings, 0 replies; 7+ messages in thread From: Gérard Huet @ 2003-01-21 16:40 UTC (permalink / raw) To: Yaron M. Minsky; +Cc: Caml List Le mardi, 21 jan 2003, à 15:42 Europe/Paris, Yaron M. Minsky a écrit : > Another useful extension to the ocaml toplevel which has been proposed > in the past is to have some kind of default "this" variable which > stores > unbound variables. That would make the supression of let-bound easier > to use, since if you wanted to see how something printed out, you could > refrain from let-binding it, and still get access to the result using > the "this" variable. For the record, this facility existed in the original ML from LCF 20 years ago, the variable was called "it" and it was extremely useful in top-level debugging. It was still there in ML V6.2 circa 1985, and thus also in early versions of Caml. I do not remember who took "it" off, but maybe "it" could be resurrected... GH ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2003-01-21 18:58 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2003-01-21 3:13 [Caml-list] view types in ocaml? Ed L Cashin 2003-01-21 11:48 ` Remi VANICAT 2003-01-21 12:55 ` Ed L Cashin -- strict thread matches above, loose matches on Subject: below -- 2003-01-21 1:14 Ed L Cashin 2003-01-21 12:54 ` Yaron M. Minsky [not found] ` <20030121134608.GA495@first.in-berlin.de> 2003-01-21 14:42 ` Yaron M. Minsky 2003-01-21 16:40 ` Gérard Huet
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox