Commit Graph

399 Commits

Author SHA1 Message Date
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
Chris Penner
035f75ab36 Merge trunk 2024-06-03 08:44:11 -07:00
Greg Pfeil
5a7e001d7c
Merge remote-tracking branch 'upstream/trunk' into restrict-NameSegment 2024-05-31 15:43:27 -06:00
Greg Pfeil
ae70852257
Move sentinel segment names to Unison.NameSegment
They don’t belong in `Unison.Syntax.NameSegment` because they are not
part of the syntax – they are names stored in the codebase that need to
match regardless of the syntax used.
2024-05-31 14:11:51 -06:00
Chris Penner
6384038ee0 Don't expose Branch0 internals, (and add add lens utils to prelude) 2024-05-30 15:21:47 -07:00
Greg Pfeil
b9c62164f8
Restrict NameSegment operations
With `OverloadedStrings` enabled globally and an `IsString` instance, the
`newtype` was rendered useless.

This extracts the `NameSegment` constructor/eliminator to a `.Internal` module,
has `Unison.NameSegment` only re-export the type, and moves the `*Segment`
members to `Unison.Syntax.NameSegment`.

This forces cascading changes, including eliminating a bunch of magic literals
scattered throughout the code.
2024-05-24 15:50:17 -06:00
Arya Irani
8b762c7908
Merge branch 'trunk' into cp/definition-diffs 2024-05-18 10:31:26 -04:00
Chris Penner
240cddcc3f Add definition diff apis and tests 2024-05-17 09:43:19 -07:00
Chris Penner
c4dce53fd2 Build definition diff api 2024-05-17 09:19:44 -07:00
Chris Penner
33ab40c454 Implement defn diff endpoints 2024-05-16 16:01:12 -07:00
Chris Penner
aa93ac1d58 Implement typeDefinitionByName 2024-05-16 15:32:55 -07:00
Chris Penner
3e3f59333d Implement termDefinitionByName 2024-05-16 15:30:03 -07:00
Chris Penner
61ecd6ed73 Add missing api instances 2024-05-16 14:55:35 -07:00
hojberg
baf6098365 automatically run ormolu 2024-05-09 15:31:57 +00:00
Simon Højberg
37c1e961c7 doc.to-tml: Add space between Paragraph elements
This fixes an issue where sub elements of a Paragraph doesn't have a
literal space between them after using the `mergeWords` function.
Previously this was fixed with CSS margin, but that doesn't work well
for copy and paste, instead intersperse a space (" ") between the
  elements, similar to the ui-core method.
2024-05-09 11:25:53 -04:00
Chris Penner
6b6cd4581d Rename diffing primitives From/To -> Old/New 2024-04-17 15:20:08 -07:00
Chris Penner
c5f1b8df90 Merge remote-tracking branch 'origin/trunk' into cp/definition-diffs 2024-04-17 10:59:21 -07:00
Chris Penner
c057a76da9 Rename testResultType -> testResultListType 2024-04-03 15:30:08 -07:00
Chris Penner
0264c6ac39 Add NameSegment ToJSON orphan instance 2024-04-03 10:48:26 -07:00
Chris Penner
3560a6e8c5 Fix conversion from referent2to1 for Doc fuzzyfind results 2024-03-28 09:19:33 -07:00
aryairani
f88d652383 [create-pull-request] automated change 2024-03-12 18:35:54 +00:00
Chris Penner
fbd3d55397 Remove unused diff responses 2024-03-08 10:48:56 -08:00
Chris Penner
5a434d360c Docs 2024-03-08 09:18:38 -08:00
Chris Penner
f59acef785 Clean unneeded pragma 2024-03-08 09:03:42 -08:00
Chris Penner
2457dbf3c8 Fix syntax text diffing 2024-03-07 11:24:34 -08:00
Chris Penner
ae3c01964c Add single typeDefinition fetching helpers 2024-03-07 10:47:55 -08:00
Chris Penner
c5aa6a0bf1 definition diffs 2024-03-06 17:47:26 -08:00
Chris Penner
b6b7c3e478 Merge remote-tracking branch 'origin/trunk' into cp/definition-diffs 2024-03-06 15:35:04 -08:00
Chris Penner
b6d22a9a4b
Merge pull request #4716 from unisonweb/cp/entity-validation-csv
Enable Hash Validation in UCM
2024-02-27 08:47:53 -08:00
Mitchell Rosen
08ae88c681 fix ancient bug in the local ui that reared its head at last 2024-02-20 17:00:18 -05:00
Mitchell Rosen
aa2107982f ⅄ trunk → 22-10-18-backticky-parser 2024-02-20 11:10:58 -05:00
Chris Penner
7b5289f474 Fix local hash validation 2024-02-14 15:33:41 -08:00
Chris Penner
f670522403 JSON instances for diffs 2024-02-08 10:41:50 -08:00
Chris Penner
e548c4cc25 Add diff types for terms 2024-02-08 10:22:31 -08:00
Chris Penner
4b9ca79ddc Add Name ToJSONKey instance 2024-02-05 11:56:07 -08:00
Mitchell Rosen
3044255060 sytax work 2024-02-01 02:39:48 -05:00
Mitchell Rosen
0504bca1b3 ⅄ trunk → 22-10-18-backticky-parser 2024-01-31 11:19:37 -05:00
Mitchell Rosen
7f93853228 add instance IsString NameSegment 2024-01-31 11:08:47 -05:00
Mitchell Rosen
acce2ea1df ⅄ trunk → 22-10-18-backticky-parser 2024-01-30 08:02:55 -05:00
Chris Penner
1876d23328 Speed up docs-to-html 2024-01-29 13:53:05 -08:00
Mitchell Rosen
8871927c6e more path, name, and name segment work (doesn't build yet) 2024-01-24 11:01:22 -05:00
Mitchell Rosen
3677c6bfbb use name parser in parseSplit' 2024-01-18 13:55:25 -05:00
Chris Penner
8e410b17ff Merge remote-tracking branch 'origin/trunk' into pg/sync 2024-01-18 09:23:45 -08:00
Chris Penner
ff47ec7813 Merge remote-tracking branch 'origin/trunk' into cp/remove-global-names-again 2024-01-16 11:49:07 -08:00
mergify[bot]
47b383c608
Merge pull request #4381 from unisonweb/cp/pull-hash-validation-types
Add decl verification
2024-01-15 19:17:16 +00:00
mergify[bot]
367684a939
Merge pull request #4613 from unisonweb/24-01-09-better-suffixification
feat: better suffixification in update and upgrade
2024-01-15 18:18:23 +00:00
Arya Irani
6f2a94392b
Merge pull request #4408 from unisonweb/cp/type-tag-exact-match
Exact match on term types when determining whether doc or test.
2024-01-11 18:56:53 -10:00
Chris Penner
a6cc182272 Merge remote-tracking branch 'origin/trunk' into cp/remove-global-names-again 2024-01-11 15:35:36 -08:00
Chris Penner
9cd855068c Fix hoist 2024-01-10 15:32:22 -08:00
Chris Penner
8aace56a47 Merge remote-tracking branch 'origin/trunk' into cp/pull-hash-validation-types 2024-01-10 15:21:17 -08:00