caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: yoann padioleau <yoann.padioleau@gmail.com>
To: caml-list@inria.fr
Subject: [Caml-list] Is there a typed bin-annot cmt tree with module and type aliases resolved?
Date: Mon, 3 Dec 2012 17:08:44 -0800	[thread overview]
Message-ID: <CAFksq2_T4=ArqM+8EJONx4O_fHi78x5GqttxFNTdxss=b3RjQQ@mail.gmail.com> (raw)

Hi,

I want to use the .cmt files generated by -bin-annot for some
dependency analysis. The
problem is that not all names are resolved, especially module aliases
and type aliases are not
resolved. For instance on this file:

module X = Variant
open Nested_module
module Y = Nested

let use_variant = function
  | X.Constructor1 -> 1
  | _ -> 2


I got this dump for the AST/CMT file:
{
 str_items=[Tstr_module("X", (), Tmod_ident("Variant", ()));
            Tstr_open("Nested_module", ());
            Tstr_module("Y", (), Tmod_ident("Nested_module.Nested", ()));
            Tstr_value((),
              [(Tpat_var("use_variant", ()),
                Texp_function((),
                  [(Tpat_construct("X.Constructor1", (), (), [], false),
                    Texp_constant(())); (Tpat_any, Texp_constant(()))], ()))])];
 str_type=(); str_final_env=(); }

but I would really like an AST where all names are fully resolved, so
X.Constructor1 becomes
Variant.Constructor1. In the example above Nested_module.Nested is
resolved (so the open Nested_module
is handled), but not X.Constructor1.

Same for types, with this file:
type list2 = int list

type use_list2 =
  | Constructor of list2

let f = function
  | Constructor [] -> 1
  | _ -> 2


I got this dump of the AST/CMT:
{
 str_items=[Tstr_type(
              [("list2", (),
                {typ_params=[]; typ_type=(); typ_cstrs=[];
                 typ_kind=Ttype_abstract; typ_private=();
                 typ_manifest=Some(Ttyp_constr("list", (),
                                     [Ttyp_constr("int", (), [])]));
                 typ_variance=[]; typ_loc=(); })]);
            Tstr_type(
              [("use_list2", (),
                {typ_params=[]; typ_type=(); typ_cstrs=[];
                 typ_kind=Ttype_variant(
                            [("Constructor", (),
                              [Ttyp_constr("list2", (), [])], ())]);
                 typ_private=(); typ_manifest=None; typ_variance=[];
                 typ_loc=(); })]);
            Tstr_value((),
              [(Tpat_var("f", ()),
                Texp_function((),
                  [(Tpat_construct("Constructor", (), (),
                      [Tpat_construct("[]", (), (), [], false)], false),
                    Texp_constant(())); (Tpat_any, Texp_constant(()))], ()))])];
 str_type=(); str_final_env=(); }

and when I ask the type of [], it says list2, but I would really like
the final type that is int list2.

Should I use env.ml for resolving?

             reply	other threads:[~2012-12-04  1:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-04  1:08 yoann padioleau [this message]
2012-12-04  8:18 ` Esther Baruk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFksq2_T4=ArqM+8EJONx4O_fHi78x5GqttxFNTdxss=b3RjQQ@mail.gmail.com' \
    --to=yoann.padioleau@gmail.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).