caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Is there a typed bin-annot cmt tree with module and type aliases resolved?
@ 2012-12-04  1:08 yoann padioleau
  2012-12-04  8:18 ` Esther Baruk
  0 siblings, 1 reply; 2+ messages in thread
From: yoann padioleau @ 2012-12-04  1:08 UTC (permalink / raw)
  To: caml-list

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?

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

end of thread, other threads:[~2012-12-04  8:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-04  1:08 [Caml-list] Is there a typed bin-annot cmt tree with module and type aliases resolved? yoann padioleau
2012-12-04  8:18 ` Esther Baruk

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).