Journal entry for
Some notes while working on GHC:
Wouldn’t it be great if we could statically ensure that AST structure stays the same on certain passes? I’m not sure there are actual use cases right now but it’s an interesting question.
You’d need something that can traverse the AST, know about the context like the constructor being handled, but then have a guarantee that only some extention point will be modified, like type information being added.
On the other hand many passes want to return something else or translate to a different AST, like the renamer going from “parse result” AST to “renamed” AST.