Put most into FileCodebase.Common due to cyclic imports.
Would like to do a tighter cleanup, but too hard.
When we're under less pressure, we could do proper benchmarks of these
with Criterion or something, my hand-done results have been confusing.
For #1385 (missing dependencies on push), I think we should use an
approach like the new sync algorithms use, where we use State to collect
dependencies as we traverse the Branch.
I will add the fix to all three, and then I think we can merge this even
though we will still be using the old algorithm for now.
- Codebase functions are now parameterized by Reference.Id or Referent.Id
(a Referent that doesn't refer to a built-in) where appropriate, to
enforce at the type level that Codebases can't contain builtins, and
to eliminate jank that was enforcing or assuming this at runtime.
ditto CodeLookup
ditto `UnisonFile` and `TypecheckedUnisonFile`; with some backwards-
compatible functions and pattern synonyms to support the old types,
and some new functions for the new types.
- Codebase.getRootBranch and .getBranchForHash return a sum type instead
of a magic value (`Branch.empty`) on error. `BranchLoadMode` goes away.
`getRootBranch`'s result distinguishes between "I don't know what the
head is supposed to be" vs "I do know what it is supposed to be but
couldn't find it".
- Not strictly related to Referent.Id (oops) but I moved the actual
builtin Decls from `unison-core/Unison.DataDeclaration` to
`unison-parser-typechecker/Unison.Builtin.Decls`.
I left these qualified as `DD` to minimize diffs, although it may
make it harder to know which module a `DD.` definition is coming from.
Issue was that it was unilaterally deleting the D2 dimension for whatever type was being unlinked (this is the dimension that supports efficient lookup by metadata type - "find me all the docs"). Correct behavior is to only delete from this dimension when there are no more metadata values for a metadata type - for instance, if you delete the last `Doc`, you can delete the index that lets you find all the docs.
- Revamped LinkI and UnlinkI - the md value is a HashQualified, so you can unlink by hash only now
- Support unnamed metadata in the diff display
- Remove HQ'.unsafeFromHQ, which was used in one place and was causing a crash
- Better output messages for various link/unlink failures