Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005377OCamlOCaml generalpublic2011-10-17 16:162011-12-16 07:01
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]
TagsNo tags attached.
Attached Filesdiff file icon show_types2.diff [^] (9,461 bytes) 2011-12-15 11:29 [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).

- 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


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker