diff --git a/parser-typechecker/src/Unison/Runtime/IOSource.hs b/parser-typechecker/src/Unison/Runtime/IOSource.hs index f344bb0a06..f690671fc5 100644 --- a/parser-typechecker/src/Unison/Runtime/IOSource.hs +++ b/parser-typechecker/src/Unison/Runtime/IOSource.hs @@ -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 diff --git a/unison-core/src/Unison/Name.hs b/unison-core/src/Unison/Name.hs index 9b8aaa5275..573f254869 100644 --- a/unison-core/src/Unison/Name.hs +++ b/unison-core/src/Unison/Name.hs @@ -36,7 +36,6 @@ module Unison.Name -- * To organize later commonPrefix, - isBlank, preferShallowLibDepth, searchByRankedSuffix, searchBySuffix, @@ -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. diff --git a/unison-core/src/Unison/Term.hs b/unison-core/src/Unison/Term.hs index 6d0acc1cc3..d3608bc426 100644 --- a/unison-core/src/Unison/Term.hs +++ b/unison-core/src/Unison/Term.hs @@ -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 diff --git a/unison-src/transcripts-using-base/base.u b/unison-src/transcripts-using-base/base.u index 51d572aa1d..b1023f558a 100644 --- a/unison-src/transcripts-using-base/base.u +++ b/unison-src/transcripts-using-base/base.u @@ -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} () diff --git a/unison-syntax/src/Unison/Syntax/Parser.hs b/unison-syntax/src/Unison/Syntax/Parser.hs index f3f944091e..51bdc1e367 100644 --- a/unison-syntax/src/Unison/Syntax/Parser.hs +++ b/unison-syntax/src/Unison/Syntax/Parser.hs @@ -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 (..)) @@ -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