Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Precise AST datatypes don’t support diffing #482

@patrickt

Description

@patrickt

(Forked off of/supersedes tree-sitter/haskell-tree-sitter#263. The below text, originally written by Rob, follows.)

The TH code currently produces AST datatypes which don’t support diffing: we can’t e.g. replace a subterm with a diff of that subterm.

We will likely need to employ higher-kinded data, à la:

data If f a = If { ann :: a, condition :: f (Expr f a), consequence :: f (Stmt f a), alternative :: f (Stmt f a) }

Ordinary terms will then be represented by e.g. If Identity (tho I suspect we will wish to use type/pattern synonyms to improve the ergonomics of this), while we could represent possibly-missing/-ignored subterms with If Maybe. This would likewise allow some appropriately-configured Diff datatype to represent the term positions.

We might also need to move the responsibility for holding or applying the annotations into f to allow us to e.g. represent both original annotations for common nodes, but only one for deletions/insertions. We might need to use an even weirder kind to allow diffs to represent deletions/insertions of unchanged terms. Experimentation will be required

Metadata

Metadata

Assignees

No one assigned

    Labels

    ast:codegenBugs in Template Haskell AST generation

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions