Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] GC and file descriptors
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jim <jim@f...>
Subject: [Caml-list] AutoMLI (Was: GC and file descriptors)
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