Version française
Home     About     Download     Resources     Contact us    
Browse thread
annotate a .ml file with type information
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] annotate a .ml file with type information
On Wed, Nov 19, 2008 at 02:32:09PM +0000, Thomas Gazagnaire wrote:
> I would like to write a camlp4 extension which use infered-type information.
> To do that, I can see two ways:
> * either calling an type-inference function of the compiler, giving it an
> AST and a context associating identifiers to types which seems to me a bit
> complicated (and maybe impossible),

IIRC this isn't possible from a camlp4 extension, partly because you
can't call into the compiler like this, but mainly because at this
stage in compilation you haven't even looked up which symbols come
from which modules.  You can't do that lookup because you don't have
access to the command line (eg. the -I arguments), and anyway it'd be
really hairy to try even if you did.

> * or annotating the original source code with infered-type information -
> which seems to me simpler. In this case, I believe that it is not difficult
> to merge an ml file and its corresponding .annot file to produce a file
> where every identifier is type annotated,[...]

I'm sure that merging the .annot & .ml files together is going to be
the easiest way.

Rich.

-- 
Richard Jones
Red Hat