Ensure Names are absolute after prefixing

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.
This commit is contained in:
Greg Pfeil 2024-06-05 11:12:51 -06:00
parent 4c12fe8a47
commit cf6ab11088
No known key found for this signature in database
GPG Key ID: 1193ACD196ED61F2
2 changed files with 6 additions and 6 deletions

View File

@ -405,7 +405,7 @@ handleHashQualifiedNameArg =
SA.HashQualifiedWithBranchPrefix mprefix hqname ->
pure . HQ'.toHQ $ foldr (\prefix -> fmap $ Name.makeAbsolute . Path.prefixName prefix) hqname mprefix
SA.ShallowListEntry prefix entry ->
pure . HQ'.toHQ . fmap (Path.prefixName prefix) $ shallowListEntryToHQ' entry
pure . HQ'.toHQ . fmap (Name.makeAbsolute . Path.prefixName prefix) $ shallowListEntryToHQ' entry
SA.SearchResult mpath result -> pure $ searchResultToHQ mpath result
otherArgType -> Left $ wrongStructuredArgument "a hash-qualified name" otherArgType
@ -580,7 +580,7 @@ handleHashQualifiedSplit'Arg =
SA.HashQualifiedWithBranchPrefix (Right prefix) hqname ->
pure . hq'NameToSplit' $ Name.makeAbsolute . Path.prefixName prefix <$> hqname
SA.ShallowListEntry prefix entry ->
pure . hq'NameToSplit' . fmap (Path.prefixName prefix) $ shallowListEntryToHQ' entry
pure . hq'NameToSplit' . fmap (Name.makeAbsolute . Path.prefixName prefix) $ shallowListEntryToHQ' entry
sr@(SA.SearchResult mpath result) ->
first (const $ expectedButActually "a name" sr "a hash") . hqNameToSplit' $ searchResultToHQ mpath result
otherNumArg -> Left $ wrongStructuredArgument "a name" otherNumArg
@ -626,7 +626,7 @@ handleShortHashOrHQSplit'Arg =
SA.HashQualifiedWithBranchPrefix (Right prefix) hqname ->
pure . pure $ hq'NameToSplit' (Name.makeAbsolute . Path.prefixName prefix <$> hqname)
SA.ShallowListEntry prefix entry ->
pure . pure . hq'NameToSplit' . fmap (Path.prefixName prefix) $ shallowListEntryToHQ' entry
pure . pure . hq'NameToSplit' . fmap (Name.makeAbsolute . Path.prefixName prefix) $ shallowListEntryToHQ' entry
SA.SearchResult mpath result -> pure . hqNameToSplit' $ searchResultToHQ mpath result
otherNumArg -> Left $ wrongStructuredArgument "a hash or name" otherNumArg
@ -651,7 +651,7 @@ handleNameArg =
SA.HashQualifiedWithBranchPrefix (Right prefix) hqname ->
pure . Name.makeAbsolute . Path.prefixName prefix $ HQ'.toName hqname
SA.ShallowListEntry prefix entry ->
pure . HQ'.toName . fmap (Path.prefixName prefix) $ shallowListEntryToHQ' entry
pure . HQ'.toName . fmap (Name.makeAbsolute . Path.prefixName prefix) $ shallowListEntryToHQ' entry
SA.SearchResult mpath result ->
maybe (Left "cant find a name from the numbered arg") pure . HQ.toName $ searchResultToHQ mpath result
otherNumArg -> Left $ wrongStructuredArgument "a name" otherNumArg

View File

@ -39,8 +39,8 @@ foo.subtract x y = x Int.- y
.> view 1
foo.add : Int -> Int -> Int
foo.add x y =
.foo.add : Int -> Int -> Int
.foo.add x y =
use Int +
x + y