hoogle 5.0.17.12 → 5.0.17.13
raw patch · 7 files changed
+22/−15 lines, 7 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGES.txt +4/−0
- hoogle.cabal +1/−1
- html/index.html +1/−1
- src/Action/CmdLine.hs +4/−4
- src/Action/Generate.hs +1/−1
- src/Action/Search.hs +6/−5
- src/Action/Server.hs +5/−3
CHANGES.txt view
@@ -1,5 +1,9 @@ Changelog for Hoogle (* = breaking change) +5.0.17.13, released 2019-12-07+ #331, make --count work with --json+ #332, support ?q= as well as ?hoogle= (since it used to be q)+ #330, work with more browsers when JavaScript is disabled 5.0.17.12, released 2019-11-02 Allow haskell-src-exts-1.22 #324, make unicode search work more
hoogle.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.18 build-type: Simple name: hoogle-version: 5.0.17.12+version: 5.0.17.13 license: BSD3 license-file: LICENSE category: Development
html/index.html view
@@ -22,7 +22,7 @@ <li><a href="https://www.haskell.org">haskell.org</a></li> </ul> </div>-<form action="." method="get" id="search">+<form action="" method="get" id="search"> <a id="logo" href="#{home}"> <img src="#{cdn}hoogle.png" width="160" height="58" alt="Hoogle" /></a>
src/Action/CmdLine.hs view
@@ -27,7 +27,7 @@ ,numbers :: Bool ,info :: Bool ,database :: FilePath- ,count :: Int+ ,count :: Maybe Int ,query :: [String] ,repeat_ :: Int ,language :: Language@@ -38,7 +38,7 @@ ,database :: FilePath ,insecure :: Bool ,include :: [String]- ,count :: Int+ ,count :: Maybe Int ,local_ :: [FilePath] ,haddock :: Maybe FilePath ,debug :: Bool@@ -114,7 +114,7 @@ ,numbers = def &= help "Give counter for each result" ,info = def &= help "Give extended information about the first result" ,database = def &= typFile &= help "Name of database to use (use .hoo extension)"- ,count = 10 &= name "n" &= help "Maximum number of results to return"+ ,count = Nothing &= name "n" &= help "Maximum number of results to return (defaults to 10)" ,query = def &= args &= typ "QUERY" ,repeat_ = 1 &= help "Number of times to repeat (for benchmarking)" ,language = enum [x &= explicit &= name (lower $ show x) &= help ("Work with " ++ show x) | x <- [minBound..maxBound]] &= groupname "Language"@@ -126,7 +126,7 @@ ,insecure = def &= help "Allow insecure HTTPS connections" ,include = def &= args &= typ "PACKAGE" ,local_ = def &= opt "" &= help "Index local packages and link to local haddock docs"- ,count = 0 &= name "n" &= help "Maximum number of packages to index (defaults to all)"+ ,count = Nothing &= name "n" &= help "Maximum number of packages to index (defaults to all)" ,haddock = def &= help "Use local haddocks" ,debug = def &= help "Generate debug information" } &= help "Generate Hoogle databases"
src/Action/Generate.hs view
@@ -211,7 +211,7 @@ popularity <- evaluate $ Map.adjust (max $ 1 + Map.findWithDefault 0 (strPack "mtl") popularity) (strPack "transformers") popularity want <- return $ if include /= [] then Set.fromList $ map strPack include else want- want <- return $ if count == 0 then want else Set.fromList $ take count $ Set.toList want+ want <- return $ case count of Nothing -> want; Just count -> Set.fromList $ take count $ Set.toList want (stats, _) <- storeWriteFile database $ \store -> do xs <- withBinaryFile (database `replaceExtension` "warn") WriteMode $ \warnings -> do
src/Action/Search.hs view
@@ -39,18 +39,19 @@ actionSearch Search{..} = replicateM_ repeat_ $ -- deliberately reopen the database each time withSearch database $ \store -> if null compare_ then do+ count' <- return $ fromMaybe 10 count (q, res) <- return $ search store $ parseQuery $ unwords query whenLoud $ putStrLn $ "Query: " ++ unescapeHTML (LBS.unpack $ renderMarkup $ renderQuery q)- let (shown, hidden) = splitAt count $ nubOrd $ map (targetResultDisplay link) res+ let (shown, hidden) = splitAt count' $ nubOrd $ map (targetResultDisplay link) res if null res then putStrLn "No results found" else if info then do putStr $ targetInfo $ head res else do let toShow = if numbers && not info then addCounter shown else shown- if json then LBS.putStrLn $ JSON.encode $ map unHTMLtargetItem res else putStr $ unlines toShow+ if json then LBS.putStrLn $ JSON.encode $ maybe id take count $ map unHTMLtargetItem res else putStr $ unlines toShow when (hidden /= [] && not json) $ do- whenNormal $ putStrLn $ "-- plus more results not shown, pass --count=" ++ show (count+10) ++ " to see more"+ whenNormal $ putStrLn $ "-- plus more results not shown, pass --count=" ++ show (count'+10) ++ " to see more" else do let parseType x = case parseQuery x of [QueryType t] -> (pretty t, hseToSig t)@@ -258,12 +259,12 @@ [ InTop 3 ("fmap" `inPackage` "base") ] query "IO a -> m a"- [ InTop 3 ("liftIO" `inPackage` "base")+ [ InTop 5 ("liftIO" `inPackage` "base") ] query "a -> m a" -- see GitHub issue #180 [ InTop 20 ("pure" `inPackage` "base") , InTop 50 ("return" `inPackage` "base")- , InTop 3 ("pure" `inPackage` "base")+ , InTop 5 ("pure" `inPackage` "base") , KnownFailure "GitHub issue #267" $ InTop 3 ("return" `inPackage` "base") ]
src/Action/Server.hs view
@@ -88,11 +88,13 @@ replyServer log local links haddock store cdn home htmlDir scope Input{..} = case inputURL of -- without -fno-state-hack things can get folded under this lambda [] -> do- let grab name = [x | (a,x) <- inputArgs, a == name, x /= ""]+ let grabBy name = [x | (a,x) <- inputArgs, name a, x /= ""]+ grab name = grabBy (== name) grabInt name def = fromMaybe def $ readMaybe =<< listToMaybe (grab name) :: Int let qScope = let xs = grab "scope" in [scope | null xs && scope /= ""] ++ xs- let qSource = grab "hoogle" ++ filter (/= "set:stackage") qScope+ let qSearch = grabBy (`elem` ["hoogle","q"])+ let qSource = qSearch ++ filter (/= "set:stackage") qScope let q = concatMap parseQuery qSource let (q2, results) = search store q let body = showResults local links haddock (filter ((/= "mode") . fst) inputArgs) q2 $@@ -102,7 +104,7 @@ [("tags", html $ tagOptions qScope) ,("body", html body) ,("title", text $ unwords qSource ++ " - Hoogle")- ,("search", text $ unwords $ grab "hoogle")+ ,("search", text $ unwords qSearch) ,("robots", text $ if any isQueryScope q then "none" else "index")] | otherwise -> OutputHTML <$> templateRender templateHome [] Just "body" -> OutputHTML <$> if null qSource then templateRender templateEmpty [] else templateRender (html body) []