@@ -65,6 +65,8 @@ instance ExtensionClass HoogleDb where
65
65
--
66
66
-- If no hoogle database has been found, Nothing is returned
67
67
-- and we will have no access to the hoogle database.
68
+ -- However, it is still safe to use the hoogle API,
69
+ -- e.g. either error or default values are returned.
68
70
initializeHoogleDb :: IdeGhcM (Maybe FilePath )
69
71
initializeHoogleDb = do
70
72
explicitDbLocation <- liftIO $ lookupEnv " HIE_HOOGLE_DATABASE"
@@ -138,16 +140,16 @@ renderTarget t = T.intercalate "\n\n" $
138
140
-- | Search for modules that satisfy the given search text.
139
141
-- Will return at most five, unique results.
140
142
--
141
- -- If an error happens , such as no has been hoogle database found,
142
- -- an empty list will be returned.
143
+ -- If an error occurs , such as no hoogle database has been found,
144
+ -- or the search term has no match, an empty list will be returned.
143
145
searchModules :: T. Text -> IdeM [T. Text ]
144
146
searchModules = fmap (nub . take 5 ) . searchTargets (fmap (T. pack . fst ) . targetModule)
145
147
146
148
-- | Search for packages that satisfy the given search text.
147
149
-- Will return at most five, unique results.
148
150
--
149
- -- If an error happens , such as no has been hoogle database found,
150
- -- an empty list will be returned.
151
+ -- If an error occurs , such as no hoogle database has been found,
152
+ -- or the search term has no match, an empty list will be returned.
151
153
searchPackages :: T. Text -> IdeM [T. Text ]
152
154
searchPackages = fmap (nub . take 5 ) . searchTargets (fmap (T. pack . fst ) . targetPackage)
153
155
@@ -157,8 +159,8 @@ searchPackages = fmap (nub . take 5) . searchTargets (fmap (T.pack . fst) . targ
157
159
-- although there are matches, if none of the first ten matches
158
160
-- satisfies the predicate.
159
161
--
160
- -- If an error happens , such as no hoogle database found,
161
- -- an empty list will be returned.
162
+ -- If an error occurs , such as no hoogle database has been found,
163
+ -- or the search term has no match, an empty list will be returned.
162
164
searchTargets :: (Target -> Maybe a ) -> T. Text -> IdeM [a ]
163
165
searchTargets f term = do
164
166
HoogleDb mdb <- get
0 commit comments