hoogle 5.0.11 → 5.0.12
raw patch · 5 files changed
+32/−17 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Hoogle: targetInfo :: Target -> String
+ Hoogle: targetResultDisplay :: Bool -> Target -> String
Files
- CHANGES.txt +2/−0
- hoogle.cabal +1/−1
- src/Action/Search.hs +22/−14
- src/General/Util.hs +4/−1
- src/Hoogle.hs +3/−1
CHANGES.txt view
@@ -1,5 +1,7 @@ Changelog for Hoogle +5.0.12+ #210, expose targetInfo and targetSearchDisplay 5.0.11 #209, add a defaultDatabaseLocation function 5.0.10
hoogle.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.18 build-type: Simple name: hoogle-version: 5.0.11+version: 5.0.12 license: BSD3 license-file: LICENSE category: Development
src/Action/Search.hs view
@@ -1,6 +1,9 @@ {-# LANGUAGE TupleSections, RecordWildCards, ScopedTypeVariables #-} -module Action.Search(actionSearch, withSearch, search, action_search_test) where+module Action.Search(actionSearch, withSearch, search,+ targetInfo,+ targetResultDisplay,+ action_search_test) where import Control.Monad.Extra import Control.DeepSeq@@ -32,23 +35,14 @@ if null compare_ then do (q, res) <- return $ search store $ parseQuery $ unwords query whenLoud $ putStrLn $ "Query: " ++ unescapeHTML (renderQuery q)- let disp Target{..} = unwords $- fmap fst (maybeToList targetModule) ++- [targetItem] ++- ["-- " ++ targetURL | link]- let (shown, hidden) = splitAt count $ nubOrd $ map disp res+ let (shown, hidden) = splitAt count $ nubOrd $ map (targetResultDisplay link) res if null res then putStrLn "No results found" else if info then do- let Target{..} = head res- putStrLn (unHTML targetItem)- let packageModule = map fst $ catMaybes [targetPackage, targetModule]- unless (null packageModule) $ do- putStrLn (unwords packageModule)- putStrLn (unHTML targetDocs)+ putStr $ targetInfo $ head res else do let toShow = if numbers && not info then addCounter shown else shown- putStr $ unlines $ map unHTML toShow+ putStr $ unlines toShow when (hidden /= []) $ do whenNormal $ putStrLn $ "-- plus more results not shown, pass --count=" ++ show (count+10) ++ " to see more" else do@@ -57,7 +51,21 @@ _ -> error $ "Expected a type signature, got: " ++ x putStr $ unlines $ searchTypesDebug store (parseType $ unwords query) (map parseType compare_) - where unHTML = unescapeHTML . innerTextHTML+-- | Returns the details printed out when hoogle --info is called+targetInfo :: Target -> String+targetInfo Target{..} = + unlines $ [ unHTML targetItem ] +++ [ unwords packageModule | not $ null packageModule] +++ [ unHTML targetDocs ]+ where packageModule = map fst $ catMaybes [targetPackage, targetModule]++-- | Returns the Target formatted as an item to display in the results+-- | Bool argument decides whether links are shown+targetResultDisplay :: Bool -> Target -> String+targetResultDisplay link Target{..} = unHTML $ unwords $+ fmap fst (maybeToList targetModule) +++ [targetItem] +++ ["-- " ++ targetURL | link] addCounter :: [String] -> [String] addCounter = zipWith (\i x -> show i ++ ") " ++ x) [1..]
src/General/Util.hs view
@@ -11,7 +11,7 @@ showUTCTime, strict, withs,- escapeHTML, unescapeHTML, innerTextHTML, tag, tag_,+ escapeHTML, unescapeHTML, innerTextHTML, unHTML, tag, tag_, takeSortOn, Average, toAverage, fromAverage, inRanges,@@ -179,6 +179,9 @@ innerTextHTML ('<':xs) = innerTextHTML $ drop 1 $ dropWhile (/= '>') xs innerTextHTML (x:xs) = x : innerTextHTML xs innerTextHTML [] = []++unHTML :: String -> String+unHTML = unescapeHTML . innerTextHTML isUpper1 (x:xs) = isUpper x isUpper1 _ = False
src/Hoogle.hs view
@@ -3,7 +3,9 @@ module Hoogle( Database, withDatabase, searchDatabase, defaultDatabaseLocation, Target(..), URL,- hoogle+ hoogle,+ targetInfo,+ targetResultDisplay ) where import Control.DeepSeq (NFData)