Reconsider AOT vs. compile-time generation of syntax trees #622
Labels
ast:codegen
Bugs in Template Haskell AST generation
bazel
Bazel-specific build concerns
build
Issues arising when building semantic
help wanted
Up for grabs
infrastructure
Items relating to packaging, project management, releases, etc.
language-support
Language support in general (e.g. new languages, etc.)
Our current formulation of syntax trees assumes that we’ll be able to read the contents of
node-types.json
files at compile time. This is only true for local development, and files pulled in via pinned Git dependencies. For all other cases, the official word is that this is not expected to work. This means that any future publishing to Hackage is off the table, though things work for local dev and our downstream dependent projects.But even the situation as it stands is not a hugely optimal one. For example, though Bazel tends to provide better in-IDE tooling, it doesn’t know how to find node-types files in REPLs, and even during standard builds doesn’t know how to find them without preprocessor trickery.
I think it’s time to consider whether generation of this code ahead-of-time is worth exploring. Here are some upsides and downsides of AOT code generation.
Upsides
cabal
due to implementation details of the build/REPL process.Semantic_Proto
serialization files. Note that that file, even though it comes out to like 8000 SLoC, is well-behaved re. compile time and IDE support, in contrast to our stuff that does complicated Template Haskell splices. Indeed, I anticipate that the authors ofproto-lens
avoided TH generation because, much like us, TH has difficulty finding .proto files, and needs to work with massive protobuf definitions.lingo-haskell
.tree-sitter
).Downsides
Another approach we could take is to drop
cabal
support entirely, which would also preclude any Hackage releases, still needs some love to get working in a REPL context, and would entail a degree of tediousl downstream changes. We could also shudder download the grammar definitions in the TH splices themselves, but I hardly think that invoking network calls in TH is something we should encourage, though that’s the only way I can envision this possibly working withcabal
.The text was updated successfully, but these errors were encountered: