hoogle 4.2.34 → 4.2.35
raw patch · 12 files changed
+198/−72 lines, 12 filesdep +temporarydep ~haskell-src-extsPVP ok
version bump matches the API change (PVP)
Dependencies added: temporary
Dependency ranges changed: haskell-src-exts
API changes (from Hackage documentation)
Files
- CHANGES.txt +2/−0
- README.md +140/−0
- README.txt +0/−40
- hoogle.cabal +5/−5
- src/CmdLine/Type.hs +4/−1
- src/General/Web.hs +1/−1
- src/Hoogle/Language/Haskell.hs +13/−12
- src/Hoogle/Type/TypeSig.hs +5/−0
- src/Recipe/All.hs +6/−2
- src/Recipe/Command.hs +6/−2
- src/Test.hs +13/−6
- src/Web/Server.hs +3/−3
CHANGES.txt view
@@ -1,5 +1,7 @@ Changelog for Hoogle +4.2.35+ Allow haskell-src-exts-1.16 4.2.34 Add defaultDatabaseLocation 4.2.33
+ README.md view
@@ -0,0 +1,140 @@+# Hoogle [](https://travis-ci.org/ndmitchell/hoogle)++Hoogle is a Haskell API search engine, which allows you to search many standard Haskell libraries by either function name, or by approximate type signature. To experiment, visit the online version at http://haskell.org/hoogle.++* **Online version:** http://haskell.org/hoogle+* **Hackage page:** http://hackage.haskell.org/packages/hoogle+* **Source code:** http://github.com/ndmitchell/hoogle+* **Bug tracker:** http://code.google.com/p/ndmitchell/issues/list++## Hoogle Use++Hoogle can be used in several ways:++* **Online**, with the web interface at http://haskell.org/hoogle+* **In [IRC](http://haskell.org/haskellwiki/Haskell_IRC_channel)**, using the [Lambdabot](http://haskell.org/haskellwiki/Lambdabot) plugin with `@hoogle` and `@hoogle+`+* **[Installed locally](https://github.com/ndmitchell/hoogle/blob/master/docs/Local-Install.md)**, with either a command line or in a browser+* **[As a developer](https://github.com/ndmitchell/hoogle/blob/master/docs/Developers.md)**, through Haskell or JSON APIs.++# Searches++## Searching++Here are some example searches:++* `map` searches as text, finding `map`, `concatMap`, `mapM`+* `con map` searches for the text "map" and "con" finding `concatMap`, but not `map`+* `a -> a` searches by type, finding `id :: a -> a`+* `a` searches for the text "a"+* `:: a` searches for the type "a"+* `id :: a -> a` searches for the text "id" and the type "a -> a"+++## Scope++By default, searches look at the [Haskell Platform](http://hackage.haskell.org/platform) and [Haskell keywords](http://haskell.org/haskellwiki/Keywords). However, all [Hackage](http://hackage.haskell.org) packages are available to search. As some examples:++* `mode +cmdargs` searches only the "cmdargs" package+* `file -base` searches the Haskell Platform, excluding the "base" package+* `mode +platform +cmdargs` searches both the Haskell Platform and the "cmdargs" package+* `count +missingh` searches only the "MissingH" package - all packages are written in lower-case++With the set of packages you are searching, you can also restrict the set of modules searched:++* `file -System` excludes results from modules such as `System.IO`, `System.FilePath.Windows` and `Distribution.System`+* `fold +Data.Map` finds results in the `Data.Map` module+++# Integration++## Command Line Version++To invoke Hoogle type:++ hoogle "[a] -> [b]"++Note the quotes, otherwise you will redirect the output to the file [b].++To ensure you have data files for the Hackage modules, you will first need to+type:++ hoogle data++Which will download and build Hoogle databases.++## Chrome Integration++**As a keyword search:** With a keyword search you can type `h map` directly into the location bar to perform a Hoogle search. Go to the [Hoogle website](http://haskell.org/hoogle/) in Chrome, right-click in the Hoogle search field and select "Add as a search engine...". Give it a keyword such as "h".+++## Firefox Integration++**From the search bar:** Go to the [Hoogle website](http://haskell.org/hoogle/) in Firefox and click on the drop-down arrow at the left of the search bar, and select the "Add Hoogle" option. Click the arrow again to select Hoogle as your search engine.++**As a keyword search:** With a keyword search you can type `h map` directly into the location bar to perform a Hoogle search. Go to the [Hoogle website](http://haskell.org/hoogle/) in Firefox, right-click in the Hoogle search field and select "Add a Keyword for this Search...". Given it a keyword such as "h".++If you want to search for special symbols in Firefox keyword search, modify the keyword search URL to be: `javascript:window.location.href="http://haskell.org/hoogle?q=" + encodeURIComponent("%s")`+++## Firefox Ubiquity Integration++[Ubiquity](https://wiki.mozilla.org/Labs/Ubiquity) provides a graphical command-line for Firefox. To install the Ubiquity Hoogle command, visit the [this page](http://www.randomhacks.net/git/ubiquity/hoogle/) and click "Subscribe..." when asked whether you want to install it. Further information is available [here](http://www.randomhacks.net/articles/2008/09/01/ubiquitous-hoogle).+++# Background++Hoogle work is licensed under the [GPL version 2.0](https://github.com/ndmitchell/hoogle/blob/master/docs/LICENSE). Any patches are assumed to be dual licensed under the BSD license and the GPL, to allow re-licensing Hoogle under the BSD license in future, if that proves beneficial to the Haskell community. The work is intended to be helpful, open and free. If the license doesn't meet your needs then talk to me.++## Theoretical Foundations++A lot of related work was done by Rittri [1] and Runciman [2] in the late 80's. Since then Di Cosmo [3] has produced a book on type isomorphisms. Unfortunately the implementations that accompanied the earlier works were for functional languages that have since become less popular.++1. [Mikael Rittri, Using Types as Search Keys in Function Libraries](http://portal.acm.org/citation.cfm?id=99384). Proceedings of the fourth international conference on Functional Programming languages and Computer Architecture: 174-183, June 1989.+2. [Colin Runciman and Ian Toyn, Retrieving reusable software components by polymorphic type](http://portal.acm.org/citation.cfm?id=99383). Journal of Functional Programming 1 (2): 191-211, April 1991.+3. [Roberto Di Cosmo, Isomorphisms of types: from lambda-calculus to information retrieval and language design](http://www.pps.jussieu.fr/~dicosmo/Publications/ISObook.html). Birkhauser, 1995. ISBN-0-8176-3763-X++I have given several presentations on type searching all available from [my home page](http://community.haskell.org/~ndm/hoogle).++## Folders++The folders in the distribution, and their meaning are:++data - tools to generate a hoogle data file+docs - documentation on hoogle+misc - presentations, icons, emacs scripts, logos+src - source code+web - additional resources for the web front end (css, jpg etc.)++## Similar Tools++I was unaware of any similar tools before starting development, and no other tool has really influenced this tool (except the first on this list). Some related tools are:++* [Google](http://www.google.com/), the leader in online search+* [Hayoo](http://holumbus.fh-wedel.de/hayoo/hayoo.html), similar to Hoogle, but with less focus on type search+* [Krugle](http://www.krugle.com/), search code, but no Haskell :(+++## Acknowledgements++All code is all © [Neil Mitchell](http://community.haskell.org/~ndm/), 2004-present. The initial version was done over my summer holiday, and further work was done during my PhD. During Summer 2008 I was funded to full-time on Hoogle by [Google Summer of Code](http://code.google.com/soc/) with the [haskell.org](http://haskell.org/) mentoring organisation. Since then I have been working on Hoogle in my spare time. Various people have given lots of useful ideas, including my PhD supervisor [Colin Runciman](http://www.cs.york.ac.uk/~colin/), and various members of the [Plasma group](http://www.cs.york.ac.uk/plasma/). In addition, the following people have also contributed code or significant debugging work:++* [Thomas "Bob" Davie](http://www.cs.kent.ac.uk/people/rpg/tatd2/)+* [Don Stewart](http://www.cse.unsw.edu.au/~dons/)+* Thomas Jager+* [Gaal Yahas](http://gaal.livejournal.com/)+* [Mike Dodds](http://www-users.cs.york.ac.uk/~miked/)+* [Niklas Broberg](http://www.cs.chalmers.se/~d00nibro/)+* Esa Ilari Vuokko+* Udo Stenzel+* [Henk-Jan van Tuyl](http://members.chello.nl/hjgtuyl/)+* Gwern Branwen+* Tillmann Rendel+* David Waern+* Ganesh Sittampalam+* Duncan Coutts+* Peter Collingbourne+* Andrea Vezzosi+* Ian Lynagh+* [Alfredo Di Napoli](http://www.alfredodinapoli.com)++In previous versions, all the data was taken from [Zvon's Haskell Guide](http://www.zvon.org/other/haskell/Outputglobal/). Thanks to their open and friendly policy of allowing the data to be reused, this project became possible. More recent versions use the Hierarchical Libraries as distributed with GHC, and databases generated by Haddock.
− README.txt
@@ -1,40 +0,0 @@-Hoogle - a Haskell API search. - -This repo is being migrated to git and from my laptop. - -Command Line Version --------------------- - -To invoke Hoogle type: - - hoogle "[a] -> [b]" - -Note the quotes, otherwise you will redirect the output to the file [b]. - -To ensure you have data files for the Hackage modules, you will first need to -type: - - hoogle data - -Which will download and build Hoogle databases. - - -Web Version ------------ - -A web version is available at http://www.haskell.org/hoogle - -All the appropriate documentation/credits/reference material is on the -Haskell wiki at http://www.haskell.org/haskellwiki/Hoogle - - -Folders -------- - -The folders in the distribution, and their meaning are: - -data - tools to generate a hoogle data file -docs - documentation on hoogle -misc - presentations, icons, emacs scripts, logos -src - source code -web - additional resources for the web front end (css, jpg etc.)
hoogle.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.10 build-type: Simple name: hoogle-version: 4.2.34+version: 4.2.35 license: BSD3 license-file: docs/LICENSE category: Development@@ -17,7 +17,7 @@ bug-reports: https://github.com/ndmitchell/hoogle/issues tested-with: GHC==7.8.2, GHC==7.6.3, GHC==7.4.2 extra-source-files:- README.txt+ README.md CHANGES.txt datadir/*.txt @@ -59,7 +59,7 @@ vector >= 0.9, vector-algorithms >= 0.6, QuickCheck,- haskell-src-exts >= 1.14 && < 1.16+ haskell-src-exts >= 1.16 && < 1.17 if !os(mingw32) build-depends: unix@@ -153,7 +153,7 @@ Cabal >= 1.8, shake >= 0.11, QuickCheck,- haskell-src-exts >= 1.14 && < 1.16+ haskell-src-exts >= 1.16 && < 1.17 if !os(mingw32) build-depends: unix@@ -192,4 +192,4 @@ default-language: Haskell98 type: exitcode-stdio-1.0- build-depends: base >= 3, process, directory, filepath+ build-depends: base >= 3, process, directory, filepath, temporary >= 1.1
src/CmdLine/Type.hs view
@@ -38,7 +38,9 @@ , local :: [String] , datadir :: FilePath , threads :: Int- , actions :: [String]}+ , actions :: [String]+ , nodownload :: Bool+ } | Server {port :: Int, local_ :: Bool, databases :: [FilePath], resources :: FilePath, dynamic :: Bool, template :: [FilePath]} | Combine {srcfiles :: [FilePath], outfile :: String} | Convert {@@ -120,6 +122,7 @@ ,threads = 1 &= typ "INT" &= name "j" &= help "Number of threads to use" ,actions = def &= args &= typ "RULE" ,local = def &= opt "" &= typ "FILEPATH" &= help "Use local documentation if available"+ ,nodownload = def &= explicit &= name "no-download" &= help "Abort if any of the needed source files are missing, instead of downloading them" } &= help "Generate Hoogle databases" &= details ["Each argument should be the name of a database you want to generate" ,"optionally followed by which files to combine. Common options:"
src/General/Web.hs view
@@ -131,7 +131,7 @@ where f x | isAlphaNum x || x `elem` "-" = [x] | x == ' ' = "+"- | otherwise = '%' : ['0'|length s == 1] ++ s+ | otherwise = '%' : ['0' | length s == 1] ++ s where s = showHex (ord x) ""
src/Hoogle/Language/Haskell.hs view
@@ -124,7 +124,7 @@ transDecl :: String -> Decl S -> Maybe ([Fact],[TextItem]) transDecl x (GDataDecl s dat ctxt hd _ [] _) = transDecl x $ DataDecl s dat ctxt hd [] Nothing-transDecl x (GDataDecl _ _ _ _ _ [GadtDecl s name ty] _) = transDecl x $ HSE.TypeSig s [name] ty+transDecl x (GDataDecl _ _ _ _ _ [GadtDecl s name _ ty] _) = transDecl x $ HSE.TypeSig s [name] ty transDecl x (HSE.TypeSig _ [name] tyy) = Just $ fact (ctr++kinds False typ) $ textItem{itemName=nam,itemKey=nam, itemType=Just typ, itemKind=kind,@@ -161,8 +161,8 @@ ,itemDisp=x `formatTags` [(cols $ srcInfoSpan $ ann dat, TagEmph),(cols snam,TagBold)]} where (snam,nam) = findName hd -transDecl x (InstDecl _ ctxt hd _) = Just (FactInstance t:kinds True t, [])- where t = transInstHead ctxt hd+transDecl x (InstDecl _ _ hd _) = Just (FactInstance t:kinds True t, [])+ where t = transInstRule hd transDecl _ _ = Nothing @@ -215,7 +215,6 @@ where g (CxSingle _ x) = f x g (CxTuple _ xs) = concatMap f xs- g (CxParen _ x) = g x g _ = [] f (ClassA _ x ys) = [TApp (TLit $ unbracket $ prettyPrint x) $ map transType ys]@@ -231,23 +230,25 @@ transDeclHead :: Maybe (Context S) -> DeclHead S -> TypeSig transDeclHead x y = TypeSig (transContext x) $ f y- where f (DHead _ name vars) = TApp (TLit $ unbracket $ prettyPrint name) $ map transVar vars+ where f (DHead _ name) = TLit $ unbracket $ prettyPrint name+ f (DHInfix s a b) = f $ DHApp s (DHead s b) a f (DHParen _ x) = f x- f (DHInfix s x y z) = f $ DHead s y [x,z]+ f (DHApp _ a b) = ttApp (f a) [transVar b] +transInstRule :: InstRule S -> TypeSig+transInstRule (IParen _ x) = transInstRule x+transInstRule (IRule _ _ ctxt hd) = transInstHead ctxt hd+ transInstHead :: Maybe (Context S) -> InstHead S -> TypeSig transInstHead x y = TypeSig (transContext x) $ f y- where f (IHead _ name vars) = TApp (TLit $ unbracket $ prettyPrint name) $ map transType vars+ where f (IHCon _ name) = TLit $ unbracket $ prettyPrint name+ f (IHInfix s x y) = f $ IHApp s (IHCon s y) x f (IHParen _ x) = f x- f (IHInfix s x y z) = f $ IHead s y [x,z]-+ f (IHApp _ t x) = ttApp (f t) [transType x] transVar :: TyVarBind S -> Type transVar (KindedVar _ nam _) = TVar $ prettyPrint nam transVar (UnkindedVar _ nam) = TVar $ prettyPrint nam--- ---------------------------------------------------------------------
src/Hoogle/Type/TypeSig.hs view
@@ -50,6 +50,11 @@ tApp t [] = t tApp t ts = TApp t ts +ttApp :: Type -> [Type] -> Type+ttApp t [] = t+ttApp (TApp t ts) ts2 = TApp t (ts++ts2)+ttApp t ts = TApp t ts+ fromTFun :: Type -> [Type] fromTFun (TFun x) = x
src/Recipe/All.hs view
@@ -31,7 +31,9 @@ createDirectoryIfMissing True datadir withDirectory datadir $ do when redownload $ do- forM_ (urls opt) $ \(file,_) -> removeFile_ $ "downloads" </> file+ if nodownload+ then error "Downloads are disabled, cannot re-download"+ else forM_ (urls opt) $ \(file,_) -> removeFile_ $ "downloads" </> file when rebuild $ removeFile ".shake.database" (count, file) <- withWarnings $ \warn -> shake shakeOptions{shakeVersion=showVersion V.version, shakeThreads=threads, shakeProgress=progressSimple} $@@ -50,9 +52,11 @@ (\x -> "downloads/*" ?== x && isJust (lookup (takeFileName x) (urls opts))) ?> \out -> do+ when nodownload $+ error "Downloads are disabled; you need to acquire the source files manually." let Just url = lookup (takeFileName out) (urls opts) putNormal $ "Downloading " ++ out- wget url out+ wget opts url out putNormal $ "Downloaded " ++ out "downloads/*.cache" *> \out -> do
src/Recipe/Command.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE RecordWildCards #-} module Recipe.Command(wget, ungzip, tarExtract, tarList) where @@ -5,10 +6,13 @@ import General.System import Development.Shake import Development.Shake.FilePath+import CmdLine.All -wget :: URL -> FilePath -> Action ()-wget from to = do+wget :: CmdLine -> URL -> FilePath -> Action ()+wget opt@Data{..} from to = do+ when nodownload $+ error "Downloads are disabled." dl <- liftIO findDownloader command [Shell] (dl to from) []
src/Test.hs view
@@ -1,4 +1,3 @@- module Main(main) where import Control.Monad@@ -7,6 +6,7 @@ import System.Exit import System.FilePath import System.Environment+import System.IO.Temp main :: IO ()@@ -15,14 +15,21 @@ ,"./hoogle.exe","./hoogle" ,"../hoogle/hoogle.exe","../hoogle/hoogle"] found <- filterM doesFileExist files- let hoogle args = do+ let hoogle args want_success = do let cmd = normalise (head (found ++ ["hoogle"])) ++ " " ++ args res <- system cmd- when (res /= ExitSuccess) $ error $ "Command: " ++ cmd ++ "\nFailed with: " ++ show res+ when (res /= ExitSuccess && want_success) $+ error $ "Command: " ++ cmd ++ "\nFailed with: " ++ show res+ when (res == ExitSuccess && not want_success) $+ error $ "Command: " ++ cmd ++ "\nExpected failure but didn't fail." args <- getArgs if "--no-net" `elem` args then- hoogle "test"+ hoogle "test" True else do- hoogle "data"- hoogle "test --example"+ hoogle "data" True+ hoogle "test --example" True++ -- Check --no-download functionality in an empty data directory.+ withSystemTempDirectory "hoogle-no-download.test." $ \tempdir -> do+ hoogle ("data --no-download -d" ++ tempdir) False
src/Web/Server.hs view
@@ -32,7 +32,7 @@ resp <- respArgs q v <- newMVar () putStrLn $ "Starting Hoogle Server on port " ++ show port- runSettings defaultSettings{settingsOnException=exception, settingsPort=port}+ runSettings (setOnException exception $ setPort port defaultSettings) #if MIN_VERSION_wai(3, 0, 0) $ \r sendResponse -> do #else@@ -112,7 +112,7 @@ | path == "/res/search.xml" = serveSearch resources (fmap bsUnpack $ join $ lookup (fromString "domain") $ queryString r) | takeDirectory path == "/res" = serveFile True (resources </> takeFileName path) False | local_, Just path <- stripPrefix "/file/" path =- let hasDrive = "/" `isPrefixOf` path && ":" `isPrefixOf` (drop 2 path)+ let hasDrive = "/" `isPrefixOf` path && ":" `isPrefixOf` drop 2 path in serveFile False (if hasDrive then drop 1 path else path) local_ | otherwise = return $ responseNotFound $ show path where (path,query) = (bsUnpack path_, bsUnpack query_)@@ -134,7 +134,7 @@ else (if rewriteLinks then rewriteHaddockFileLinks else return) $ ResponseFile ok200 hdr file Nothing - where hdr = [(hContentType, fromString $ contentExt $ takeExtension file)] +++ where hdr = (hContentType, fromString $ contentExt $ takeExtension file) : [(hCacheControl, fromString "max-age=604800" {- 1 week -}) | cache]