unison icon indicating copy to clipboard operation
unison copied to clipboard

implementation plan for delete directives

Open aryairani opened this issue 1 year ago • 1 comments

For planning/estimation purposes, a discussion of how to implement scratch file delete/delete.term/delete.type directives

aryairani avatar Jun 12 '24 21:06 aryairani

Here is a rough plan:

  • Add delete directives field to UnisonFile and TypecheckedUnisonFile data structures
    • data 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 update will 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 SlurpResult
    • data SlurpResult = SlurpResult { ... deleteTerms :: Set Symbol, deleteTypes :: Set Symbol }
  • Modify Typechecked output message to include info about deletes
  • Process delete directives in update handler
    • 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)
    • 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)

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.

mitchellwrosen avatar Jul 15 '24 17:07 mitchellwrosen