* type_declaration in env.ml
@ 2007-06-15 12:41 Pietro Abate
2007-06-15 14:39 ` [Caml-list] " Xavier Leroy
0 siblings, 1 reply; 2+ messages in thread
From: Pietro Abate @ 2007-06-15 12:41 UTC (permalink / raw)
To: ocaml 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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] type_declaration in env.ml
2007-06-15 12:41 type_declaration in env.ml Pietro Abate
@ 2007-06-15 14:39 ` Xavier Leroy
0 siblings, 0 replies; 2+ messages in thread
From: Xavier Leroy @ 2007-06-15 14:39 UTC (permalink / raw)
To: Pietro Abate, ocaml ml
Pietro Abate wrote:
> 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 ?
Yes, with type_manifest = None.
> what if I have just
> type t = int ?
As above, except
type_kind = Type_abstract
type_manifest = Some <the representation of type "int">
And before you ask,
type t = M.t = A of int | B of float
would be
type_kind = Type_variant ( ["A", ... ; "B", ....], false)
type_manifest = Some <the representation of type "M.t">
> where I store the type identifier "t" in both cases ?
The typing environment (type Env.t) maps type identifiers such as "t"
to type declarations such as the above.
> Can anybody explain me the semantic of these fields ? I can guess some,
> but I'm not very confident...
Section 6.8.1 of the reference manual could help you understand the
interaction between the "type_kind" and "type_manifest" fields, and in
particular the reason why these are two separate fields.
Hope this helps,
- Xavier Leroy
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-06-15 14:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-15 12:41 type_declaration in env.ml Pietro Abate
2007-06-15 14:39 ` [Caml-list] " Xavier Leroy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox