mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-19 22:37:12 +03:00
ce33057385
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. |
||
---|---|---|
.. | ||
src/Unison | ||
package.yaml | ||
README.md | ||
unison-share-api.cabal |
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.