gleam-lang / suggestions

📙 A place for ideas and feedback
26 stars 2 forks source link

JSON represention of AST #102

Open michaeljones opened 3 years ago

michaeljones commented 3 years ago

I've never really done anything with one but I find myself quite keen on the idea of a pipeline for generating an JSON version of the Gleam AST and being able to convert that to & from source code.

I believe it would make it easier to source code generation from other languages. This could be useful for generating Gleam types that match a SQL table or something.

I'm not sure if this has been suggested before or if it might be something to avoid for some reason. I realise that the AST is internal and it might be too frustrating to have it exposed in some format if it is potentially going to change a lot. Perhaps it would be enough to flag it as unstable and then consistently version it in some way but I realise it might be a big ask.

lpil commented 3 years ago

As you have noted the problem with this is that it is making the AST a public API which would mean we are not able to iterate and make changes as much as we might like at this early stage.

Having said that some form of metaprogramming would be wonderful! We should do more research in this area in future.

RE the SQL example I think we could generate strings of Gleam code directly from a database query schema. I was hoping to make a tool for this in future :)

CrowdHailer commented 3 years ago

Related question, is there a Gleam version of the Gleam AST? my understanding is that it's all in Rust at the moment.

lpil commented 3 years ago

No Gleam version, just the Rust one at the moment.

On Fri, 15 Jan 2021, 09:26 Peter Saxton, notifications@github.com wrote:

Related question, is there a Gleam version of the Gleam AST? my understanding is that it's all in Rust at the moment.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gleam-lang/suggestions/issues/102#issuecomment-760777921, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOZVBTSQ4WZ64IFTVL2FEDS2AC33ANCNFSM4T4YLF4Q .