unison/unison-share-api
Greg Pfeil ce33057385
Refine Path-prefixing operations
This replaces `prefix :: Absolute -> Path' -> Path` with a couple
alternatives:
- `prefixAbs :: Absolute -> Relative -> Absolute`,
- `maybePrefix :: Path' -> Path' -> Maybe Path'`, and
- `prefix :: Path' -> Relative -> Path'`.

The previous `prefix` could fail to prefix (covered by either the new
`prefix` or `maybePrefix`, depending on whether you want to guarantee
success or capture failure), always threw away the knowledge that the
result was necessarily `Absolute` (covered by `prefixAbs`), and then
always returned an ambiguous result type (covered by all three
replacements).

Then it also provides `prefixRel` as the complement of `prefixAbs` (both
of which are used in the implementation of `prefix`).

Similar changes are made in the replacements for `prefixName :: Absolute
-> Name -> Name`. First, we don’t currently have absolute/relative
variants of `Name`, so we can generalize the first argument to `Path'`.
Then `maybePrefixName :: Path' -> Name -> Maybe Name` exposes the case
where prefixing can’t succeed, and `prefixNameIfRel :: Path' -> Name ->
Name` handles the common case of using the original `Name` if it can’t
be prefixed. Both of these new functions also preserve the `Position` of
the new `Name`, whereas the old implementation always returned a
`Relative` `Name`, despite knowing when it was `Absolute`. And
`prefixName2 :: Path -> Name -> Name` has been removed as there is no
ambiguous variant of `Name` (as `Split` is to `Split'`), so prefixing
with a `Path` isn’t particularly meaningful.

Finally, `nameFromSplit'` is added as a dual to `splitFromName'` to make
it possible to operate on the `Path'` portion of a `Name` without introducing partiality.

These new operations are then propagated through the code, and enable a
couple other type changes: `StructuredArgument.ShallowListEntry` and
`StructuredArgument.SearchResult` now take a `Path'` prefix rather than
the `Path.Absolute` and `Path` prefixes they took previously. This fixes
the absolute `Name` issue in `ls` results.
2024-06-06 23:53:00 -05:00
..
src/Unison Refine Path-prefixing operations 2024-06-06 23:53:00 -05:00
package.yaml Add diff types for terms 2024-02-08 10:22:31 -08:00
README.md Add unison-share-api package with Sync APIs (#3018) 2022-04-01 10:14:01 -06:00
unison-share-api.cabal definition diffs 2024-03-06 17:47:26 -08:00

unison-share-api

This package serves as a shared place to store the API definitions and types for all of Share's APIs. This facilitates the use of servant-client to easily generate clients for the API, and provides an always-up-to-date view of Share's APIs.