Search the web
Sign In
New User? Sign Up
ocaml_beginners · Ocaml Beginners
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
[ANN] Enhtop: patch for an enhanced OCaml toplevel   Message List  
Reply | Forward Message #7393 of 11666 |

Hi, there

I'd like to announce the availability of a patch to enhance the OCaml toplevel
with addition features.

It's available, in the forms of source patch, testing executable and Debian
packages, at the following address:

http://www.pps.jussieu.fr/~li/software/index.html#enhtop

You should first read relevant sections of READE before taking any actions. It
contains various information, and especially, the detailed instructions on how
to test/deploy it in different ways.

Enjoy! :)


- li


-------------------------------------------------------------------------------
The following sections are extracted from the README:


DESCRIPTION
===========

This is a experimental patch for an enhanced OCaml toplevel with following
features: For all kinds of bindings (value, type, module, class etc.):

* Identifiers already been rebound are shown differently by default
* New directive for querying and showing both current and history bindings
* New directive show current binding of any identifier without evaluating
or rebinding it
* A type-check-only test mode with directive to enable/disable it



FEATURES
========

Rebound Id
----------

There are always confusing phenomenons caused by identifier rebound in a
toplevel. Now we'll shows all identifiers already being rebound differently,
with extra unique number, as hints. Identifiers not being rebound are shown
normally.

E.g.,

# type t = int * float;;
type t = int * float
# let x : t = 3, 3.14;;
val x : t = (3, 3.14)
# type t = unit;;
type t = unit
# let y = (3, x);;
val y : int * t/65 = (3, (3, 3.14))

# module Q = Queue;;
module Q:
sig
.......
end
# let q = Q.create ();;
val q : '_a Q.t = <abstr>
# module Q = struct end;;
module Q : sig end
# q;;
- : '_a Q/70.t = <abstr>


Directive #show
---------------

#show directive is used to query and show both current and history bindings in
ascent order. Query works with both kinds and names, compositional query is
allowed through a simple syntax:

#show <command>

<command> ::=
| "open" | "value" | "type" | "exception" # query by kinds
| "module" | "modtype" | "class" | "cltype" # query by kinds
| "all" # all history
| any_string_as_name # query by name
| <command>^" "^<command> # OR relation

Note that

- concatenating commands simple produce a OR query
- any string except the predefined commands will be considered as a name
- query
- the same identifier of different kinds (e.g. value "t" and type "t") will
all response a name query

E.g., (continued)

# #show "open";;
open Pervasives
# let t = 999;;
val t : int = 999
# #show "Q value";;
val x : t/65 = (3, 3.14)
val y : int * t/65 = (3, (3, 3.14))
module Q/70 :
sig
..........
end
val q : '_a Q/70.t = <abstr>
module Q : sig end
val t : int = 999
# #show "t";;
type t/65 = int * float
type t = unit
val t : int = 999
# #show "all";;
........


Directive #tell
---------------

#tell can help to show the current bindings of any identifier without
evaluating or rebinding it. Previously, we get to know the current definition
of

- a value, by reevaluating it in the toplevel (# v;;)
- a module, by rebounding it in the toplevel (# module Q = Queue;;)
- a type, a class, a module type, a class type ... no way, maybe check input
history :(

Now you can do these with tell. The syntax is just "#tell <name>", the bindings
of the same identifier of different kinds will all response.

E.g., (continued)

# #tell "t";;
type t = unit
val t : int = 999
# #tell "Q";;
module Q : sig end
# #tell "Stack";;
module Stack :
sig
......
end


Type mode
---------

In type mode, all the input will only be type checked but won't be evaluated,
i.e. being evaluated in type system but not in value system. The type/binding
information entered in type mode is preserved and usable until you exist type
mode. That means as far as you are still in the mode, you may do sophisticated
type inference based on bindings defined both currently inside type mode or
previously outside this type mode. As soon as you leave the mode, all the
dirties played inside type mode are gone.

The #typemode directive is used to enter/leave the type mode. The syntax is
just "#typemode <bool>", to enter and leave. It's consistent with all other
directives. For example, in type mode, #show exhibits bindings both defined
inside the mode and defined before entering the mode; once quit, those defined
inside the mode will just disappear. Consecutive entering or leaving type mode
won't produce any effects and is safe.

E.g., (continued)

# typemode true;;
# let x = "ocaml";;
val x : string
# let y = x, x, x;;
val y : string * string * string
# let z = [y; y], Queue.add;;
val z : (string * string * string) list * ('a -> 'a Queue.t -> unit)
# #show "x y z";;
val x/66 : t/65
val y/68 : int * t/65
val x : string
val y : string * string * string
val z : (string * string * string) list * ('a -> 'a Queue.t -> unit)
# #typemode false;;
# z;;
Characters 0-1:
z;;
^
Unbound value z
# #show "x y z";;
val x : t/65 = (3, 3.14)
val y : int * t/65 = (3, (3, 3.14))



COMPATIBILITY
=============

Since we do not touch any other source files except those inside the toplevel
directory, there are no changes to the compilers (ocamlc/ocamlopt), runtime,
libraries ... everything. So both the compilers themselves and any executable
generated by them should be 100% *identical* to the original ones, it should
be safe to just substitute the toplevel.

There is only one case where it requires extra work: 3rd party modules
compiled against toploop.cmi should be recompiled (if they need to talk with
the new toplevel, otherwise unnecessary). At this moment, I'm just aware of
the camlp4 toplevel modules and topfind. Simple recompilation should be just
fine, as we did not modify or remove any entries from toploop.cmi, but added
a few.

I once tried a version to make toploop.mli unchanged, yes it's possible for the
current requirements, through some dirty tricks. It's ugly, as separating extra
functionalists to another module produces recursive dependency, which won't be
solved cleanly without changing the code structure. Considering more new
feasible features in the future, I guess it's just hard to always literally
persist in the old interface all along.


............


-------------------------------------------------------------------------------









Sat Mar 3, 2007 10:21 pm

Zheng.Li@...
Send Email Send Email

Forward
Message #7393 of 11666 |
Expand Messages Author Sort by Date

Hi, there I'd like to announce the availability of a patch to enhance the OCaml toplevel with addition features. It's available, in the forms of source patch,...
Zheng Li
Zheng.Li@...
Send Email
Mar 3, 2007
10:46 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help