From f833e8823013febb1a2cc17f8ce6feb552f4191b Mon Sep 17 00:00:00 2001 From: klntsky Date: Sat, 13 Jul 2019 18:44:10 +0300 Subject: [PATCH 1/2] fix #395 --- src/SearchIndex.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SearchIndex.hs b/src/SearchIndex.hs index fb45c74..41d3fb4 100644 --- a/src/SearchIndex.hs +++ b/src/SearchIndex.hs @@ -398,6 +398,7 @@ compareTypes type1 type2 = go :: D.Type' -> D.Type' -> WriterT [(Text, Text)] Maybe Int go (P.TypeVar _ v1) (P.TypeVar _ v2) = tell [(v1, v2)] *> pure 0 go t (P.TypeVar _ _) = pure (1 + typeComplexity t) + go (P.TypeVar _ _) t = pure (typeComplexity t) go (P.TypeLevelString _ s1) (P.TypeLevelString _ s2) | s1 == s2 = pure 0 go (P.TypeWildcard _ _) t = pure (typeComplexity t) go (P.TypeConstructor _ q1) (P.TypeConstructor _ q2) | compareQual q1 q2 = pure 0 From 9ff7390c195370fc0a8f66bb7570b18b36c0f89b Mon Sep 17 00:00:00 2001 From: klntsky Date: Mon, 15 Jul 2019 20:43:47 +0300 Subject: [PATCH 2/2] update the comment --- src/SearchIndex.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SearchIndex.hs b/src/SearchIndex.hs index 41d3fb4..5769655 100644 --- a/src/SearchIndex.hs +++ b/src/SearchIndex.hs @@ -381,12 +381,12 @@ tryStripPrefix pre s = fromMaybe s (T.stripPrefix pre s) -- let compare s1 s2 = compareTypes <$> parseType s2 <*> parseType s2 -- -- >>> compare "a" "Int" --- Just Nothing +-- Just (Just 0) -- >>> compare "Int" "a" -- Just (Just 1) -- --- (The idea here being it's ok to show a more general version of the query, --- but usually not helpful to show a more concrete version of it.) +-- (The idea here being it's preferred to show a more concrete version of the +-- query, rather than showing a more general version of it.) -- compareTypes :: D.Type' -> D.Type' -> Maybe Int compareTypes type1 type2 =