Version française
Home     About     Download     Resources     Contact us    
Browse thread
type_declaration in env.ml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pietro Abate <Pietro.Abate@a...>
Subject: type_declaration in env.ml
hi all,
I'm trying to understand this data structure in env.ml in the ocaml src
files.

type type_declaration =
  { type_params: type_expr list;
    type_arity: int;
    type_kind: type_kind;
    type_manifest: type_expr option;
    type_variance: (bool * bool * bool) list }

and type_kind =
    Type_abstract
  | Type_variant of (string * type_expr list) list * private_flag
  | Type_record of (string * mutable_flag * type_expr) list
                 * record_representation * private_flag


If I've a type  like :
type t = A of int | B of float

I'll get 

type_params = []
type_arity = 0 
type_kind = Type_variant ( 
                [ "A", [ { desc = Tvar ; level = ?? ; id = ?? }] ;
                  "B", [ { desc = Tvar ; level = ?? ; id = ?? }] ] , false )
type_manifest = ??
type_variance = []

correct ?
what if I have just
type t = int ?
where I store the type identifier "t" in both cases ?

Can anybody explain me the semantic of these fields ? I can guess some, 
but I'm not very confident...

thanks.

pietro

-- 
++ Blog: http://blog.rsise.anu.edu.au/?q=pietro
++ 
++ "All great truths begin as blasphemies." -George Bernard Shaw
++ Please avoid sending me Word or PowerPoint attachments.
   See http://www.fsf.org/philosophy/no-word-attachments.html