Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005377OCamlOCaml generalpublic2011-10-17 16:162014-04-16 18:53
Reporterygrek 
Assigned Togarrigue 
PrioritynormalSeverityfeatureReproducibilityalways
StatusacknowledgedResolutionreopened 
PlatformOSOS Version
Product Version3.11.2 
Target VersionFixed in Version3.13.0+dev 
Summary0005377: toplevel should provide an option to limit recursion when printing nested modules
DescriptionThis would make exploring libraries from toplevel much easier. For each package one can get the list of modules (with findlib), but the only way to explore modules is to include them (or alias) - and for big libraries this can produce lots and lots of output, while one usually wants to see only the first level and explore deeper as needed. This should probably be a directive similar to #print_depth

Example:
# #use "topfind";;
- : unit = ()
# #require "camomile";;
/usr/lib/ocaml/unix.cma: loaded
/usr/lib/ocaml/bigarray.cma: loaded
/usr/local/lib/ocaml/3.11.2/camomile: added to search path
/usr/local/lib/ocaml/3.11.2/camomile/camomile.cma: loaded
# include CamomileLibraryDefault;;
[0001276:0001000 lines of output]
Tagspatch
Attached Filesdiff file icon show_types2.diff [^] (9,461 bytes) 2011-12-15 11:29 [Show Content]
diff file icon show_types.diff [^] (14,574 bytes) 2013-07-31 09:35 [Show Content]

- Relationships
related to 0005430assignedgarrigue Enhanced toplevel 

-  Notes
(0006176)
garrigue (manager)
2011-10-24 01:06

You were lucky: I have reports of messages of more than 1MB...

This is now fixed in trunk: long traces are omitted, replaced by logical and physical locations for the error. (commits 11225-11230)
(0006178)
ygrek (reporter)
2011-10-24 12:04
edited on: 2011-10-24 12:05

The patch affects printing of error locations, but I am talking here about toplevel's normal way to display the contents of module.

Sorry, if I am mistaken - current trunk doesn't build - http://build.ygrek.org.ua/jenkins/job/ocaml/label=master/66/console [^] - so I can't verify it.

(0006180)
garrigue (manager)
2011-10-25 03:42

OK, it seems that I misunderstood what you wanted.
Indeed, there is no support for exploring modules in the toplevel,
other than printing the full signature by aliasing a module.
However, a pragma for changing the logical print depth of
modules seems a rather hacky way to go; one would rather
use a real cli library browser...
This might be nice if we can find a minimal language to do that.
Something like
 #show value <path>
 #show type <path>
 #show module <path> [<depth>]
 #show module type <path> [<depth>]
...
And also
 #search value "<regexp>"
 ....

Note that there are also GUI tools to do that, like ocamlbrowser
(which works with just .cmi), or ocamldoc.

By the way, at least for me trunk compiles perfectly.
But don't forget 'make clean' before you start.
(0006182)
ygrek (reporter)
2011-10-25 09:40

I definitely like the #show pragma :)
Exploring with external tools is fine, but an ability to do this directly from toplevel, in ad-hoc manner, is invaluable.

PS I did check the build failure with clean svn checkout
(0006300)
garrigue (manager)
2011-12-15 09:17

A simple patch is now available in trunk/experimental/garrigue/show_types.diffs
It defines directives

#show_value
#show_type
#show_exception
#show_module
#show_module_type
#show_class
#show_class_type

There is no depth option at this point (they all only take a path).
(0006301)
garrigue (manager)
2011-12-15 09:22

Concerning the depth, printing uses the standard formatter, so you can just do
Format.set_max_boxes 6 to get only in the immediate contents of a module.
(0006310)
ygrek (reporter)
2011-12-15 11:27

Here is an updated patch that sticks to single #show directive.

Thanks for the trick with Format - it helps, but is not a proper solution - e.g. it works for CamomileLibrary (this module consists of only other modules) but not for say CamomileLibrary.UChar (types are not displayed).
(0010038)
garrigue (manager)
2013-07-31 09:15

I updated show_types.diff, based on show_types2.diff
Sorry for the long delay.
It looks like a good addition.
(0011260)
lpw25 (developer)
2014-04-11 13:38

I think we should probably merge this `#show` directive in 4.02, since module aliases remove the usual method people use for exploring APIs (i.e. `module F = Foo` to print the contents of `Foo`).
(0011274)
frisch (developer)
2014-04-14 18:36

The patch seems very useful to me as well (actually I was just in the middle of writing an email to complain about our broken "module F = Foo" idiom in the toplevel -- call me old school -- when I remembered about this ticket).

I'm a bit concerned by the implementation which extends the parsetree with a quite ad hoc construction. Wouldn't it work to change Ptop_dir's argument from directive_argument to "directive_argument list" (and remove Pdir_none)?
(0011292)
frisch (developer)
2014-04-16 18:53

I've committed to trunk (rev 14616) a change corresponding to my previous note.

- Issue History
Date Modified Username Field Change
2011-10-17 16:16 ygrek New Issue
2011-10-24 01:06 garrigue Note Added: 0006176
2011-10-24 01:06 garrigue Status new => resolved
2011-10-24 01:06 garrigue Fixed in Version => 3.13.0+dev
2011-10-24 01:06 garrigue Resolution open => fixed
2011-10-24 01:06 garrigue Assigned To => garrigue
2011-10-24 12:04 ygrek Note Added: 0006178
2011-10-24 12:04 ygrek Status resolved => feedback
2011-10-24 12:04 ygrek Resolution fixed => reopened
2011-10-24 12:05 ygrek Note Edited: 0006178
2011-10-25 03:42 garrigue Note Added: 0006180
2011-10-25 09:40 ygrek Note Added: 0006182
2011-12-15 09:17 garrigue Note Added: 0006300
2011-12-15 09:17 garrigue Status feedback => acknowledged
2011-12-15 09:22 garrigue Note Added: 0006301
2011-12-15 11:27 ygrek Note Added: 0006310
2011-12-15 11:29 ygrek File Added: show_types2.diff
2011-12-16 07:01 garrigue Relationship added related to 0005430
2013-07-31 09:14 garrigue File Added: show_types.diff
2013-07-31 09:15 garrigue Note Added: 0010038
2013-07-31 09:35 garrigue File Deleted: show_types.diff
2013-07-31 09:35 garrigue File Added: show_types.diff
2013-10-09 14:37 doligez Tag Attached: patch
2014-04-11 13:38 lpw25 Note Added: 0011260
2014-04-14 18:36 frisch Note Added: 0011274
2014-04-16 18:53 frisch Note Added: 0011292


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker