This is the case of `a < T` for some structured T. By relaxing, we are
actually allowing `a` to be a _supertype_ of T as far as abilities go,
which is not correct. Seems like it was just erroneously mirrored from
the opposite case.
This rephrases part of it and includes instructions to run the `help`
command (rather than including the `help` output directly). In future,
we may directly include shorter `help` outputs or a separate set of
examples. But for now the `help` output may overshadow the error message
we intend to show the user.
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.
In a separate part of the change this PR was extracted from,
`Path.prefixName` ensures the result is absolute, but that is more
involved than other changes here, so this uses the previous technique of
calling `Name.makeAbsolute` afterward.
I don’t think this changes anything important, but the `Name` _is_
always absolute after `Path.prefixName`, so this just ensures that it’s
tracked.
```ucm
@unison/base/main> lib.install blah.blah.blah
Sorry, I couldn’t understand your request. I expected a project or
branch, but saw ”blah.blah.blah”.
Usage:
The `lib.install` command installs a dependency into the `lib` namespace.
`lib.install @unison/base/releases/latest` installs the latest release of `@unison/base`
`lib.install @unison/base/releases/3.0.0` installs version 3.0.0 of `@unison/base`
`lib.install @unison/base/topic` installs the `topic` branch of `@unison/base`
```
Almost everywhere we produce a `Reference` for numbered args, we also have a
`HashQualified Name` handy, which is much more consumable by commands.
The only case we don’t have an `HQ` is in the `todo` command output, so that now explicitly builds
a `HQ.HashOnly`.
This also fixes an issue with `StructuredArgument` handling where `alias.term`
and `alias.type` wouldn’t make an alias to a `HQ.HashOnly` `StructuredArgument`.
Fixes#4898.
Previously, when given a numbered arg, from some commands (e.g., `find`), it
would fail to find the docs because the hash associated with the definition was
applied to the `doc`, which then would be incorrect.
This now discards hashes up-front, so it can add the `doc` suffix to the name.
Fixes#3939.
This should avoid any possibility of picking conflicting names for
distinct functions. I'm not aware of any actual examples of this, but it
could in principle happen.
I decided to use the full length hashes because picking just-long-enough
names starts to become very cumbersome when doing dynamic loading. You
need to keep track of all your past choices, not just the choices for
the module you're loading, because the one you're loading could refer to
things in previously loaded modules. It would be possible to use shorter
names in a compile-time context, since you have all the names up front.
But you'd still have to remember _those_ for runtime loading, and it
seemed not worth it.
This doesn't include any custom error formatting, because I'd like to
see error messages in the wild before doing anything, but if they're too
verbose, it's possible to override the Racket error reporting to produce
shorter names there, rather than generating them up front.