Skip to content

Commit

Permalink
revert a couple now-unnecessary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellwrosen committed Aug 27, 2024
1 parent 6dd0fea commit 01d3454
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
4 changes: 2 additions & 2 deletions parser-typechecker/src/Unison/Runtime/IOSource.hs
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,8 @@ d1 Doc.++ d2 =
use Doc2
match (d1,d2) with
(Join ds, Join ds2) -> Join (ds List.++ ds2)
(Join ds, _) -> Join (ds List.:+ d2)
(_, Join ds) -> Join (d1 List.+: ds)
(Join ds, _) -> Join (List.snoc ds d2)
(_, Join ds) -> Join (List.cons d1 ds)
_ -> Join [d1,d2]

unique[q1905679b27a97a4098bc965574da880c1074183a2c55ff1d481619c7fb8a1e1] type
Expand Down
5 changes: 0 additions & 5 deletions unison-core/src/Unison/Name.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ module Unison.Name

-- * To organize later
commonPrefix,
isBlank,
preferShallowLibDepth,
searchByRankedSuffix,
searchBySuffix,
Expand Down Expand Up @@ -547,10 +546,6 @@ suffixifyByHash fqn rel =
refs =
R.searchDom (compareSuffix suffix) rel

-- | A `Name` is blank when it is unqualified and begins with a `_` (also implying that it is wordy)
isBlank :: Name -> Bool
isBlank n = isUnqualified n && Text.isPrefixOf "_" (NameSegment.toUnescapedText $ lastSegment n)

-- | Returns the common prefix of two names as segments
--
-- Note: the returned segments are NOT reversed.
Expand Down
6 changes: 1 addition & 5 deletions unison-core/src/Unison/Term.hs
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,13 @@ bindNames unsafeVarToName nameToVar localVars ns term = do
in case (Set.size exactNamespaceMatches, Set.size suffixNamespaceMatches, Set.size localMatches) of
(1, _, _) -> good (ResolvesToNamespace (Set.findMin exactNamespaceMatches))
(n, _, _) | n > 1 -> leaveFreeForTdnr
(_, 0, 0) ->
if Name.isBlank name
then leaveFreeForHoleSuggestions
else leaveFreeForTellingUserAboutExpectedType
(_, 0, 0) -> leaveFreeForTellingUserAboutExpectedType
(_, 1, 0) -> good (ResolvesToNamespace (Set.findMin suffixNamespaceMatches))
(_, 0, 1) -> good (ResolvesToLocal (Set.findMin localMatches))
_ -> leaveFreeForTdnr
where
name = unsafeVarToName v
good = Right . Just . (v,)
leaveFreeForHoleSuggestions = Right Nothing
leaveFreeForTdnr = Right Nothing
leaveFreeForTellingUserAboutExpectedType = Right Nothing

Expand Down
2 changes: 1 addition & 1 deletion unison-src/transcripts-using-base/base.u
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ List.filter: (a -> Boolean) -> [a] -> [a]
List.filter f all =
go acc = cases
[] -> acc
a +: as -> if (f a) then go (a +: acc) as else go acc as
a +: as -> if (f a) then go (cons a acc) as else go acc as
go [] all

List.forEach : [a] -> (a ->{e} ()) ->{e} ()
Expand Down
9 changes: 7 additions & 2 deletions unison-syntax/src/Unison/Syntax/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import Unison.HashQualifiedPrime qualified as HQ'
import Unison.Hashable qualified as Hashable
import Unison.Name as Name
import Unison.NameSegment (NameSegment)
import Unison.NameSegment qualified as NameSegment
import Unison.Names (Names)
import Unison.Names.ResolutionResult qualified as Names
import Unison.Parser.Ann (Ann (..), Annotated (..))
Expand Down Expand Up @@ -302,15 +303,19 @@ closeBlock = void <$> matchToken L.Close
optionalCloseBlock :: (Ord v) => P v m (L.Token ())
optionalCloseBlock = closeBlock <|> (\() -> L.Token () mempty mempty) <$> P.eof

-- | A `Name` is blank when it is unqualified and begins with a `_` (also implying that it is wordy)
isBlank :: Name -> Bool
isBlank n = isUnqualified n && Text.isPrefixOf "_" (NameSegment.toUnescapedText $ lastSegment n)

-- | A HQ Name is blank when its Name is blank and it has no hash.
isBlank' :: HQ'.HashQualified Name -> Bool
isBlank' = \case
HQ'.NameOnly n -> Name.isBlank n
HQ'.NameOnly n -> isBlank n
HQ'.HashQualified _ _ -> False

wordyPatternName :: (Var v) => P v m (L.Token v)
wordyPatternName = queryToken \case
L.WordyId (HQ'.NameOnly n) -> if Name.isBlank n then Nothing else Just $ Name.toVar n
L.WordyId (HQ'.NameOnly n) -> if isBlank n then Nothing else Just $ Name.toVar n
_ -> Nothing

-- | Parse a prefix identifier e.g. Foo or (+), discarding any hash
Expand Down

0 comments on commit 01d3454

Please sign in to comment.