[wg-camlp4] Pending issues

Wojciech Meyer wojciech.meyer at gmail.com
Thu Feb 14 11:48:26 GMT 2013


Another way of providing these simple asts would be to treat any
flavor of variants uniformly and then in the end transform it back to
what was expected (only if it's needed).

(I don't know if that what wasn't originally proposed by Pierre).

So regardless if it's a polymorphic variant, GADT, or plain data type,
we would have one AST - the common denominator and what matters of
these is usually the tag name and general signature. Once we have that
we will match from that simple AST our type driven plugin that will
generate JSON, XML, visitors. etc The idea is to have something that
is good enough and reflects general structure to get rid of
complicated parse tree or/and quotations on the LHS and/or factor out
the common pattern matchers using some meta object.

We could go even further and generate all the bolier plate pattern
matchers via visitor pattern by default, of course it needs to be
thought - but the idea is to not look at types at all - now it turns
to be it's already a meta-meta programming.

On Wed, Feb 13, 2013 at 5:56 PM, Leo White <lpw25 at cam.ac.uk> wrote:
>> What I was thinking of whas that a ppx rewriter could get whatever
>> expression as attributes, but what remains after applying all rewriters
>> must be included in a subset that could map to a type like (maybe a bit
>> too restricitve)
>>
>> type expr =
>>  | List of expr list
>>  | Sum of string * expr
>>  | Cst of string
>>
>
> This interface can be provided by:
>
> ------
>  (* Ast.mli *)
>
>  type expr
>
>  type simple_expr =  | List of expr list
>  | Sum of string * simple_expr
>  | Cst of string
>
>  val simplify_expr: expr -> simple_expr
>
> ------
>  (* Ast.ml *)
>
>  type expr = Parsetree.expression
>
>  type simple_expr =
>  | List of expr list
>  | Sum of string * simple_expr
>  | Cst of string
>
>  let simplify_expr expr = ...
>
> ------
>  (* Parsetree.mli *)
>
>  type expression = ...
>
>  val of_ast_expr: Ast.expr -> expression
>
> ------
>  (* Parsetree.ml *)
>
>  type expression = ...
>
>  external of_ast_expr: Ast.expr -> expression = "%identity"
>
> ------
>
> This would allow users to use the fixed simple interface, or the full
> parsetree interface.
>
>
> _______________________________________________
> wg-camlp4 mailing list
> wg-camlp4 at lists.ocaml.org
> http://lists.ocaml.org/listinfo/wg-camlp4


More information about the wg-camlp4 mailing list