caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* annotate a .ml file with type information
@ 2008-11-19 14:32 Thomas Gazagnaire
  2008-11-19 17:42 ` [Caml-list] " Richard Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Gazagnaire @ 2008-11-19 14:32 UTC (permalink / raw)
  To: OCaml List

[-- Attachment #1: Type: text/plain, Size: 1142 bytes --]

Hi all,

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),
* 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, but it seems to me a bit overkill
to do it at this stage as it would be simpler to do it directly after the
type-inference phase of the compilation. So, patching the compiler to make
it producing such a file with a special option (as -infertypes) seems also
good to me.

I would like to ask people what they are thinking of this problem and before
starting to work on it, I wondering if someone is aware or either an
existing ml-annot merger or a hidden compiler flag to produce such a file ?
Or if there is a reason why it should be not possible to do so :-)

Cheers,
Thomas

[-- Attachment #2: Type: text/html, Size: 1178 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] annotate a .ml file with type information
  2008-11-19 14:32 annotate a .ml file with type information Thomas Gazagnaire
@ 2008-11-19 17:42 ` Richard Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Jones @ 2008-11-19 17:42 UTC (permalink / raw)
  To: Thomas Gazagnaire; +Cc: OCaml List

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-11-19 17:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-19 14:32 annotate a .ml file with type information Thomas Gazagnaire
2008-11-19 17:42 ` [Caml-list] " Richard Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).