[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Zheng.Li@pps.jussieu.fr: "ocaml_beginners"::[] [ANN] Enhtop: patch for an enhanced OCaml toplevel]



What about packaging this? Any takers?

----- Forwarded message from Zheng Li <Zheng.Li@pps.jussieu.fr> -----

Date: Sat, 03 Mar 2007 23:21:24 +0100
From: Zheng Li <Zheng.Li@pps.jussieu.fr>
To: ocaml_beginners@yahoogroups.com
Subject: "ocaml_beginners"::[] [ANN] Enhtop: patch for an enhanced OCaml toplevel


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.


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


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








------------------------ Yahoo! Groups Sponsor --------------------~--> 
Yahoo! Groups gets a make over. See the new email design.
http://us.click.yahoo.com/hOt0.A/lOaOAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

Archives up to November 11, 2006 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors' one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid flames etc. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ocaml_beginners/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ocaml_beginners/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:ocaml_beginners-digest@yahoogroups.com 
    mailto:ocaml_beginners-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    ocaml_beginners-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


----- End forwarded message -----

-- 
Stefano Zacchiroli -*- Computer Science PhD student @ Uny Bologna, Italy
zack@{cs.unibo.it,debian.org,bononia.it} -%- http://www.bononia.it/zack/
(15:56:48)  Zack: e la demo dema ?    /\    All one has to do is hit the
(15:57:15)  Bac: no, la demo scema    \/    right keys at the right time



Reply to: