ocsigen / macaque

Other
38 stars 12 forks source link

Replace camlp4 with ppx #40

Open rgrinberg opened 8 years ago

rgrinberg commented 8 years ago

I'm evaluating macaque for my own project which already moved to ppx. Unfortunately that means that macaque's camlp4 makes it incompatible. Are there any plans to port macaque to ppx?

gasche commented 8 years ago

It should not be terribly hard to implement this in a minimal way. Macaque was intentionally designed to avoid extending the OCaml grammar, it almost exclusively relies on <:foo< .. >> quotations, which directly translate into [%foo {| ... |}] extensions. The easy way to do this is to keep using the Camlp4-based parsers to parse the in-extension quotation, which means the result would be a ppx extension that depends on Camlp4 as a library. One still has to update the ast-production facility at the end of the chain to produce OCaml Ast directly instead of Camlp4's representation of the AST, but that should not be a lot of work.

There is one (optional) part of Macaque that changes the OCaml grammar, it is pa_banana that allows chaining of structured row data access, using the foo#!bar#!baz syntax. I don't recall the exact detail of what was integrated in the OCaml syntax to allow this, but I think the exact syntax or something very close (possibly ##! and ##?). In any case, this small surface syntax is non-essential and could also be dropped.

However, I don't have time to implement this in the short-term. I would be happy to accept contributions and provide code review and recomendations, though; it is in that spirit that I tried to provide a detailed forward path above.

Finally, as I have already discussed with several Macaque users, I would be interested in eventually transitioning from the set-comprehension syntax to something closer to the actual SQL syntax (to avoid having to do big syntactic brainstorming each time we want to add a new SQL feature; just reuse the damn thing). @Drup started working on that but nothing conclusive emerged so far, and I think his work on this is stalled. @hnrgrgr has developped a SQL parser in OCaml that I think we could reuse. Developing a ppx extension means changing the syntax, so it could be a good time to think about also providing a SQL-based one -- but there is no hurry on this one.

chrismamo1 commented 5 years ago

Has there been any motion on this? If not, I'm currently looking at a project where I may be needing something like this, in which case I'd be happy to do the footwork.

gasche commented 5 years ago

No, I don't think anyone has worked on it since my last message above, sorry. If you are willing to implement something, I would be happy to help review and integrate it. (I don't remember anything about the implementation, so we would be on an equal footing :-)

Drup commented 5 years ago

there are now several SQL query parsers in the community which we could rely on directly, in order to apply @gasche's plan.

Although, to be really serious about this, I think one would need to evaluate all the other SQL type encoding that have emerged since then, notably Oleg's one.

XVilka commented 4 years ago

Camlp4 release for OCaml 4.08 is the last release ever - see the official announcement.