Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat variables in type queries same as type wildcards #396

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/SearchIndex.hs
Expand Up @@ -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 =
Expand All @@ -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
Expand Down