The Haskell Trees that Grow (TTG) idiom can be used to provide different forms of extensions and variations on an AST, something that GHC is using actively.
How would I implement this in OCaml?
I’m thinking of using a list of polymorphic variants, e.g.
type annotation =
[ `Location of int * int
| `Type of ...
| ...
]
then leaving an annotation field in each node and combining that with GADTs, somehow.
Is this the way?