unison
unison copied to clipboard
implementation plan for delete directives
For planning/estimation purposes, a discussion of how to implement scratch file delete/delete.term/delete.type directives
Here is a rough plan:
- Add delete directives field to
UnisonFileandTypecheckedUnisonFiledata structuresdata UnisonFile v a = UnisonFileId { ..., deleteTerms :: Set v, deleteTypes :: Set v, ... }data TypecheckedUnisonFile v a = TypecheckedUnisonFileId { ..., deleteTerms :: Set v, deleteTypes :: Set v, ... }
- Parse delete directives in
Unison.Syntax.FileParser.file - Decide exactly how much work we want to do at "slurp" time, with respect to informing the user whether their
updatewill succeed- Minimal work option: just say "ok, I'll delete these things" (even if they have dependents in either the namespace or the file itself, either of which would prevent deletion)
- Add delete directives field to
SlurpResultdata SlurpResult = SlurpResult { ... deleteTerms :: Set Symbol, deleteTypes :: Set Symbol }
- Modify
Typecheckedoutput message to include info about deletes - Process
deletedirectives inupdatehandler- Deleting a definition that doesn't exist in the codebase nor in the file
- Ok, do nothing (no-op)
- Deleting a definition that doesn't exist in the codebase but does exist in the file
- Nonsensical file, complain and abort (can do this check at slurp time too)
- Option: complain but don't abort (letting delete or update take precedence; probably delete)
- Nonsensical file, complain and abort (can do this check at slurp time too)
- Deleting a definition that does exist in the codebase
- Proceed with update as normal, but find dependents of the deletes, too
- Pretty-print in an environment that does include the requested deletes, but not for the only name of something (so it never gets printed as a hash, but will otherwise never use the deleted name if there are more aliases)
- Parse in an environment that does include the requested deletes (so we get out-of-scope variable errors for dependents)
- Deleting a definition that doesn't exist in the codebase nor in the file
If I had to ballpark it, the above might take about 3 weeks, to account for all of that work, plus the unknown unknowns. Some of the other tickets (#5149, #5150, perhaps #5151) isn't exactly related to getting delete directives into the codebase, but would make them much more usable.