[wg-camlp4] Changes to the parsetree

Leo White lpw25 at cam.ac.uk
Wed Apr 10 20:34:22 BST 2013


> I think that having additional constructors in core_type that are
> semantically meaningless (the variance annotations) will not help
> third-party extension writers either. What are the reasons for having
> the whole core_type in place where type variables are expected?

In addition to the reasons Alain gave, type parameters should be
core_types because, in the Typedtree, they have a corresponding
Types.type_expr. Although they are syntactically always a Ptyp_var or
Ptyp_any, after constraints have been taken into account they represent
a general type expression. 

For example:

  type 'a t constraint 'a = 'b list

is morally equivalent to:

  type 'b list t

By representing type parameters as core_types in the Typedtree they can include a
reference to the corresponding type_expr. For consistency they should be
represented as core_types in the Parsetree as well.



More information about the wg-camlp4 mailing list