From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id DAA25056; Sat, 22 Nov 2003 03:42:36 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id DAA26333 for ; Sat, 22 Nov 2003 03:42:32 +0100 (MET) Received: from colossus.systems.pipex.net (colossus.systems.pipex.net [62.241.160.73]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id hAM2gT123980 for ; Sat, 22 Nov 2003 03:42:32 +0100 (MET) Received: from draco.dyndns.org (81-86-132-151.dsl.pipex.com [81.86.132.151]) by colossus.systems.pipex.net (Postfix) with ESMTP id 2894A16000067 for ; Sat, 22 Nov 2003 02:42:29 +0000 (GMT) Received: from jim by draco.dyndns.org with local (Exim 4.21) id 1ANNgj-0002t9-Bk for caml-list@inria.fr; Sat, 22 Nov 2003 02:39:57 +0000 Date: Sat, 22 Nov 2003 02:39:57 +0000 From: Jim To: Caml Mailing List Subject: [Caml-list] AutoMLI (Was: GC and file descriptors) Message-ID: <20031122023957.GC16747@draco.skynet> References: <1069168323.18363.83.camel@pelican> <3FBA4D97.9060309@dcs.qmul.ac.uk> <3FBA6459.3000000@socialtools.net> <20031118202438.A9506@pauillac.inria.fr> <3FBAC938.8080309@dcs.qmul.ac.uk> <1069248814.23700.81.camel@pelican> <20031119170139.GB16427@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031119170139.GB16427@redhat.com> X-Mail-Key: JimbosMagicMailKey User-Agent: Mutt/1.5.4i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; farrand:01 inference:01 mli:01 0.1.:01 foo:01 foo:01 mla:99 val:01 qux:99 qux:99 mli:01 mla:99 camlp:01 sanity:01 mlast:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, Nov 19, 2003 at 05:01:39PM +0000, Richard Jones wrote: > It's a bit of a flaw in the language that you have all this lovely > type inference working for you, but then you have to go and declare > your types anyway in the .mli files. It occured to me that this should be fairly easy to fix using some kind of preprocessor, so this afternoon I had a go at throwing one together. http://draco.dyndns.org/~jim/files/automli-0.1.tar.gz Using this program, you write foo.ml, then create a foo.mla file containing something like: export none ; export val foo ; export type bar ; export type qux ; export typedef qux ; Then running automli foo >foo.mli will generate an interface containing the definition for function foo, the abstract type bar, and the concrete type qux, all taken automagically from foo.ml. If you prefer to say which things you DON'T want exported, instead of those you do, you can write a foo.mla file like this: export all ; hide typedef bar ; It should handle values, types, classes, class types, and exceptions. It also works for modules and module types, except there is no way to specify what from a module declaration should be exported. (i.e., the whole thing gets exported.) It also works for the revised syntax. Use automlir instead of automli. Note, this program is in the "very dodgy hack" category, and I haven't tested it in any real life situations. I knew nothing about camlp4 before today, (nor do I know much about it now ;) ) so I have no idea if what I have done is sane, except that it seems to work for me on my simple test data, using O'Caml 3.07. There are many bugs, I'm sure. For example, it doesn't do any kind of error or sanity checking. I'm going to play with this program in my own project, as I am often annoyed by the need to keep my mli files in sync with my ml files, and if it turns out to be useful I may develop it further. (Unless anyone else feels inspired to do it for me. :) ) Feedback welcome. What can be exported in a mli file that I have missed? There are definitely more declarations in MLast, but as it isn't documented, I don't know what they are. Can anyone tell me how I can get pr_r.cmo to send output to a file, instead of stdout? Regards, Jim ------------------- 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