caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Why is the parameter of a type declaration a coretype?
@ 2015-10-26 13:20 Christoph Höger
  2015-10-26 13:33 ` Leo White
  0 siblings, 1 reply; 2+ messages in thread
From: Christoph Höger @ 2015-10-26 13:20 UTC (permalink / raw)
  To: caml-list

I am writing a syntax extension for OCaml and the following puzzles me:

and type_declaration =
    {
     ptype_name: string loc;
     ptype_params: (core_type * variance) list;
                    ^^^^^^^^^

Why is a type-parameter a core_type and not just a string? What is the
meaning of a non-variable parameter?


-- 
Christoph Höger

Technische Universität Berlin
Fakultät IV - Elektrotechnik und Informatik
Übersetzerbau und Programmiersprachen

Sekr. TEL12-2, Ernst-Reuter-Platz 7, 10587 Berlin

Tel.: +49 (30) 314-24890
E-Mail: christoph.hoeger@tu-berlin.de

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

* Re: [Caml-list] Why is the parameter of a type declaration a coretype?
  2015-10-26 13:20 [Caml-list] Why is the parameter of a type declaration a coretype? Christoph Höger
@ 2015-10-26 13:33 ` Leo White
  0 siblings, 0 replies; 2+ messages in thread
From: Leo White @ 2015-10-26 13:33 UTC (permalink / raw)
  To: caml-list

It used to be a string option, but I changed it at some point. The
fundemental reason is that whilst it is syntactically an optional string
(optional because of "_"), semantically it is a core_type. For
example:

  type 'a t = T of 'b
    constraint 'a = 'b list

is essentially equivalent to (using made-up syntax):

  type 'b list t = T of 'b

This manifests as the params field in the *typed* AST being the
typed equivalent of core_type. It is slightly more convenient in
some places if the typed and untyped ASTs agree about such
things so the untyped AST uses a core type as well.

Regards,

Leo

On Mon, 26 Oct 2015, at 09:20 AM, Christoph Höger wrote:
> I am writing a syntax extension for OCaml and the following puzzles me:
> 
> and type_declaration =
>     {
>      ptype_name: string loc;
>      ptype_params: (core_type * variance) list;
>                     ^^^^^^^^^
> 
> Why is a type-parameter a core_type and not just a string? What is the
> meaning of a non-variable parameter?
> 
> 
> -- 
> Christoph Höger
> 
> Technische Universität Berlin
> Fakultät IV - Elektrotechnik und Informatik
> Übersetzerbau und Programmiersprachen
> 
> Sekr. TEL12-2, Ernst-Reuter-Platz 7, 10587 Berlin
> 
> Tel.: +49 (30) 314-24890
> E-Mail: christoph.hoeger@tu-berlin.de
> 
> -- 
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs

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

end of thread, other threads:[~2015-10-26 13:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-26 13:20 [Caml-list] Why is the parameter of a type declaration a coretype? Christoph Höger
2015-10-26 13:33 ` Leo White

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