hoogle
Haskell API Search
Version on this page: | 5.0.18.4 |
LTS Haskell 21.25: | 5.0.18.3 |
Stackage Nightly 2024-10-31: | 5.0.18.4 |
Latest on Hackage: | 5.0.18.4@rev:1 |
hoogle-5.0.18.4@sha256:1372458e97dff541fcda099236af7936bf93ee6b8c5d15695ee6d9426dff5eed,3171
Module documentation for 5.0.18.4
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. The online version can be found at https://hoogle.haskell.org/ and searches Stackage.
- Online version: https://hoogle.haskell.org/
- Hackage page: https://hackage.haskell.org/package/hoogle
- Source code: https://github.com/ndmitchell/hoogle
- Bug tracker: https://github.com/ndmitchell/hoogle/issues
Hoogle Use
Hoogle can be used in several ways:
- Online, with the web interface at https://hoogle.haskell.org/
- In IRC, using the Lambdabot plugin with
@hoogle
and@hoogle+
- From
emacs
, by means ofengine-mode
- Installed locally, with either a command line or in a browser
- As a developer, through Haskell or JSON APIs.
Searches
Searching
Here are some example searches:
map
searches as text, findingmap
,concatMap
,mapM
con map
searches for the text “map” and “con” findingconcatMap
, but notmap
a -> a
searches by type, findingid :: 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 and Haskell keywords. However, all Stackage packages are available to search. As some examples:
mode +cmdargs
searches only the “cmdargs” packagefile -base
searches the Haskell Platform, excluding the “base” packagemode +platform +cmdargs
searches both the Haskell Platform and the “cmdargs” packagecount +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 asSystem.IO
,System.FilePath.Windows
andDistribution.System
fold +Data.Map
finds results in theData.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 generate
Which will download and build Hoogle databases.
Command Line UI
There is a terminal/curses based UI available through cabal install bhoogle
.
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 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 in Firefox and click on the ⋯
symbol at the right of the URL bar, and select the “Add Search Engine” option. Click the hoogle logo at the bottom of the completion dropdown when searching to perform a Hoogle search.
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 in Firefox, right-click in the Hoogle search field and select “Add a Keyword for this Search…”. Given it a keyword such as “h”.
Others
The Source Code
$ git clone https://github.com/ndmitchell/hoogle.git
Contributions are most welcome. Hoogle is written in Haskell 98 + Heirarchical Modules, I do not wish to change this. Other than that, I’m pretty flexible about most aspects of Hoogle. The issue tracker has many outstanding tasks, but please contact me if you have thoughts on doing something major to Hoogle, so I can give some advice.
Background
Hoogle work is licensed under the BSD-3-Clause license.
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.
- Mikael Rittri, Using Types as Search Keys in Function Libraries. Proceedings of the fourth international conference on Functional Programming languages and Computer Architecture: 174-183, June 1989.
- Colin Runciman and Ian Toyn, Retrieving reusable software components by polymorphic type. Journal of Functional Programming 1 (2): 191-211, April 1991.
- Roberto Di Cosmo, Isomorphisms of types: from lambda-calculus to information retrieval and language design. Birkhauser, 1995. ISBN-0-8176-3763-X
I have given several presentations on type searching all available from my home page.
Project Structure
The folders in the repository, and their meaning are:
cbits - C implementation of the text search used by hoogle
docs - documention on hoogle
html - resources for hoogle’s web front-end (html, css, javascript, images, etc.)
misc - scripts, logos, sample data, etc.
src - haskell source code
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, the leader in online search
- Hayoo, similar to Hoogle, but with less focus on type search
- Krugle, search code, but no Haskell :(
- Cloogle, for the Clean language
Acknowledgements
All code is all © Neil Mitchell, 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 with the 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, and various members of the Plasma group. In addition, the following people have also contributed code or significant debugging work:
- Thomas “Bob” Davie
- Don Stewart
- Thomas Jager
- Gaal Yahas
- Mike Dodds
- Niklas Broberg
- Esa Ilari Vuokko
- Udo Stenzel
- Henk-Jan van Tuyl
- Gwern Branwen
- Tillmann Rendel
- David Waern
- Ganesh Sittampalam
- Duncan Coutts
- Peter Collingbourne
- Andrea Vezzosi
- Ian Lynagh
- Alfredo Di Napoli
In previous versions, all the data was taken from Zvon’s Haskell Guide. 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.
Interesting links
Changes
5.0.18.4, released 2024-01-14
Don't test on GHC 9.2 or earlier
Fix up the output of /stats to account for API changes
#380, move results before left anchors in tab focus order
5.0.18.3, released 2021-12-24
Compatibility with aeson-2.0
5.0.18.2, released 2021-09-01
Compatibility with extra-1.7.10
#370, add --jsonl to produce JSON on separate lines
5.0.18.1, released 2020-12-27
#365, add flag to disable network tests
5.0.18, released 2020-07-19
#356, make server --haddock work better
@ #339, support enough names to index all of Hackage
#353, remove leading latex comments
#351, partially fixed ghc-pkg output parsing for GHC 8.8
5.0.17.15, released 2020-02-15
#342, have --local flag generate a set with the directory name
Consider packages in Stackage Nightly and LTS part of Stackage
#338, add format=text to strip HTML from the JSON
5.0.17.14, released 2020-01-08
#334, allow haskell-src-exts-1.23
#333, disable Aelve Codesearch links
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
#323, fix escaping in packages list (on the left)
5.0.17.11, released 2019-08-23
#318, allow --json to get results JSON from the command line
5.0.17.10, released 2019-08-02
#314, fix bad URL trying to access package on Hoogle with --local
#311, fix an overflow with weight computations
Fix up the /log page to avoid raising CSP errors
Avoid raising error when you see a bad URL
Make errors from the server be code 400 rather than 500
5.0.17.9, released 2019-05-30
#306, fix a potential directory traversal bug
#305, add a flag to disable security headers
5.0.17.8, released 2019-05-14
#299, add some security-improving headers
#298, use Blaze for constructing most HTML
5.0.17.7, released 2019-05-10
Fix an XSS vulnerability, reported by @alexanderGugel
#297, make Uses for packages point at reverse deps
#261, add support for pattern synonyms
5.0.17.6, released 2019-03-27
#291, optimise the log parsing (5x speedup)
#289, change to use autofocus attribute
Add --links flag to integrate with https://codesearch.aelve.com/
Remove warning about type search
5.0.17.5, released 2019-01-27
* #285, remove accidental API break in 5.0.17.4
Lots of improvements in type search
5.0.17.4, released 2018-12-10
* #285, change targetPackage/Module to be opaque
Require haskell-src-exts-1.21
#271, added FromJSON instance for Target
#253, adds JSON pagination from query parameters
Make sure <h1> works well in doc snippets
#251, make sure transformers is more popular than mtl
Require network-uri >= 2.6, don't require network
5.0.17.3, released 2018-04-17
Require extra-1.6.6
Fix the reported memory sizes
5.0.17.2, released 2018-03-16
Remove support for GHC 7.10
Require conduit-1.3.0
#245, add support for GHC 8.4
5.0.17.1, released 2018-01-27
#238, only identify the database by the first three version components
#236, in --local mode replace file:// links in Haddock pages
5.0.17, released 2018-01-17
Add lower bounds for time and bytestring
#234, allow http-conduit-0.15
5.0.16, released 2018-01-03
#232, allow haskell-src-exts-1.18-1.20
5.0.15, released 2017-12-12
Allow haskell-src-exts-1.20
5.0.14, released 2017-11-28
#228, add --datadir for overriding data directory on servers
#223, don't break on foldl'
#222, make sure all packages appear in the search
5.0.13, released 2017-07-30
#219, treat the query "a->b" the same as "a -> b"
#215, if a specified module/package is missing, give no results
#220, start on port 8080 by default
Rely on the fact ghc API is now on Hackage
#217, fix the mode tag propagating to child links
5.0.12, released 2017-05-06
#210, expose targetInfo and targetSearchDisplay
5.0.11, released 2017-05-02
#209, add a defaultDatabaseLocation function
5.0.10, released 2017-04-17
#205, change how the link URL is computed
#206, put newer versions of a package first
5.0.9, released 2017-01-16
#202, add --haddock functionality
5.0.8, released 2016-12-29
#194, make --local work regardless of code page
5.0.7, released 2016-12-27
#200, make sure the content-type is set properly
5.0.6, released 2016-11-30
#196, make --local look for .cabal files as well
Fix up Frege documentation generation
5.0.5, released 2016-11-24
#193, support multiple --local flags
#195, add --home flag to server mode
Allow haskell-src-exts-1.19
5.0.4, released 2016-09-11
#184, use file URLs for local docs
#183, make --local look for .txt files recursively
5.0.3, released 2016-08-28
#181, use the proper network constraints
Avoid deprecated Aeson modules
5.0.2, released 2016-07-25
Move to haskell-src-exts-1.18
5.0.1, released 2016-07-12
#178, support the --link argument
#178, add module names to results on the command line
#177, require containers 0.5 or above
5.0, released 2016-06-24
#172, make sure --local links work on Linux
#116, store data files in getAppUserDataDirectory by default
G472, be robust to corrupt Hoogle files
G521, make sure it works with inverted color preferences
Rewrite from scratch
4.2.38, released 2015-01-28
#96, allow certicate verification failures
#95, allow a higher version of Cabal on older GHCs
4.2.37, released 2015-01-13
#94, GHC 7.10 support
4.2.36, released 2014-10-12
#85, add support for missing type constructors
4.2.35, released 2014-09-15
Allow haskell-src-exts-1.16
4.2.34, released 2014-07-09
Add defaultDatabaseLocation
4.2.33, released 2014-06-15
Allow WAI-3.0
4.2.32, released 2014-04-14
Allow haskell-src-exts-1.15
4.2.31, released 2014-04-03
#61, support conduit-1.1
4.2.30, released 2014-03-23
#57, support QuickCheck-2.7
4.2.29, released 2014-02-23
#55, if reading as UTF8 fails, explicitly try Latin1
Add QuickCheck as a dependency
Change createDatabase to also save the file
Disable rank feature
Remove running a hoogle query without converting the database
Ignore packages without documentation to hoogle data
4.2.28, released 2014-01-03
Upgrade to shake-0.11
#49, update "hoogle data" to be incremental
4.2.27, released 2014-01-01
Rewrite how "hoogle data" works
#45, if you are building all, also depend on default
#47, switch to using Shake to build the recipes
Add a dependency on Shake
4.2.26, released 2013-12-10
Fix omission of the Test file
4.2.25, released 2013-12-09
Fix timestamps in .tar.gz dist file
4.2.24, released 2013-12-08
Allow WAI 2.0
Fix the Keyword generator
4.2.23, released 2013-09-29
Improvements to Haddock conversion
4.2.22, released 2013-09-29
Download Hoogle data from the old Hackage server
4.2.21, released 2013-09-01
#25, make the tarball pass the tests
#26, GHC 7.8 compatibility
Ensure alias resolution is bottom-up and recursive
4.2.20, released 2013-08-25
#619, do not depend on unix on Windows
4.2.19, released 2013-08-20
Fix version bounds
4.2.18, released 2013-08-20
Allow bytestring-0.9
4.2.17, released 2013-08-20
Upgrade to haskell-src-exts-1.14
Visual redesign
Require bytestring-0.10 or above, due to NFData instances
Add NFData instance to Database
4.2.16, released 2013-02-21
Remove lots of explicit upper bounds
4.2.15, released 2013-01-29
Allow http-types-0.8
Allow case-insensitive-1.0
Support --local for GHC docs
#568, rewrite Haddock links in --local
4.2.14, released 2012-11-06
Switch license from GPL to BSD3
GHC 7.6 fixes
##4, Allow Cabal-1.16.*
4.2.13, released 2012-08-18
Allow cmdargs-0.10.*
4.2.12, released 2012-07-15
Allow conduit-0.5, wai-1.3 and warp-1.3
Upgrade to http-types-0.7.*
In embedded mode, don't hijack the URL bar or title
Upgrade to jQuery 1.7.2
#89, add a format=json output mode
#476, update the URL as you type
Improve iPhone support
Update the copyright year in the footer
Double the speed of hoogle server responses
4.2.11, released 2012-04-05
Allow transformers-0.3
Allow conduit-0.4, wai-1.2 and warp-1.2
Allow haskell-src-exts-1.12 and 1.13
4.2.10, released 2012-03-04
#533, be paranoid when parsing Cabal files
4.2.9, released 2012-03-01
Upgrade to WAI-1.1 and Warp-1.1
#525, don't rely on a redirect to find files
Allow Cabal-1.14
4.2.8, released 2011-11-27
Allow cmdargs-0.9
Fix setting the global read flags and unsetting them properly
Allow case-insensitive-0.4.*
Make data --local have a good default on Linux
Make server --local work on Windows
#407, rewrite OpenSearch plugin to work regardless of the server
4.2.7, released 2011-09-03
Allow cmdargs-0.8
4.2.6, released 2011-08-12
Permit GHC 7.2
Allow case-insensitive-0.3.*
Fix bug when searching for toString in the embed mode
Make --redownload work on the tarballs
4.2.5, released 2011-06-12
Fix hyperlinks to symbols (i.e. &&) in Haddock
4.2.4, released 2011-05-26
#434, use either wget or curl to download the files
Allow haskell-src-exts 1.11.*
Upgrade to cmdargs==0.7.*
4.2.3, released 2011-05-01
Generate database for ghc internals
Give an error if the database is the wrong version
Add -fno-cse, to make cmdargs work (was losing args annotations)
4.2.2, released 2011-04-25
Upgrade to WAI==0.4.* and Warp==0.4.*
Allow parsec 3, since various people have reported it works
Default module URL's correctly when not on Hackage
#417, use proper Haddock parsing for package descriptions
Make sure https: links work through the web mode
Rewrite the binary defer layer, cleaner and slightly faster
Eliminate escaping problems when entering "'s in the search
Some work on #375, add links to the library page
Add --template to override the templates at runtime
Add --dynamic flag to server mode, include update stamps
Upgrade wai and warp, adds an exception handler
#82, rewrite showing document snippets, better expand/collapse
Support <em> tags in Haddock output (as well as <i>)
Make package matching case insensitive
#372, add features to improve module name search
Make module name searching case insensitive
4.2.1, released 2011-01-26
Fix for pattern match failure when searching for "to"
Fix for not sending text/html when serving local files
Eliminate the --nostdin flag, now unnecessary
Change to use WAI/Warp instead of HTTP and custom server
Fix a bug, didn't ever show Waiting... on the real website
Make embed work in IE8
4.2, released 2011-01-23
Make the CGI interface send the right number of newlines
Accept prefix and suffix web parameters
Eliminate isBlankQuery, make Query a Monoid
Make Query abstract, add queryPackages/querySetPackage
Rename querySuggestions/queryCompletions by dropping the query
Add mode=embed support
Add some log analysis features
Ignore some whitespace in the input file
Work around a cabal bug, include jquery.cookie.js
Add ?version=xxx to .css and .js, to make it auto refresh
4.1.5, released 2011-01-16
#399, rehabilitate mode=suggest
Stop mode=suggest failing entirely, now cleanly gives no answers
Combine --web and --webmode
Complete the command line flag help
#327, ensure utf8 is found
#187, ensure LT is found
Use the Hoogle tarball direct from Hackage
#54, rework packages, entries and keywords
#87, make all database files lowercase
Various javascript/ajax enhancements
4.1.4, released 2011-01-15
Running data on Posix sets all files to global read/execute
Relax haskell-src-exts to allow 1.10.1
Rework the web page display further
4.1.3, released 2011-01-09
Read and write all database files in UTF8
#391, add tar -xzf when extracting from the tarball
Change search results display, packages/modules on separate line
Exclude haskellN* from the platform, they are in base
Add --nostdin to server mode, to support running with nohup
Loosen dependencies for tagsoup (typo'd it before)
4.1.2, released 2010-12-19
Loosen dependencies for tagsoup and HTTP (but not parsec)
Avoid self circular dependencies
4.1.1, released 2010-12-18
#195, include all the necessary resources to run as a server
When in server mode, be more robust to errors
4.1, released 2010-12-18
#320, make sure system is found
#146, preserve forall's in everywhere
#186, switch to using haskell-src-exts to parse input files
#249, make sure you find MonadWriter
#235, make sure you find forall
#309, make sure there are links for keywords
#78, add --link flag
#59, operators look nicer, and have blue brackets round them
#352, can now parse ( # ) as a function name in the input
#280, searching for "~ +keyword" should find keyword
#116, fix links for types/classes
#83, all searching for package-name
#94, allow textbases to be used automatically
#92, short flags are now handled by cmdargs, so work
#51, test mode now does what test and testfile did
#66, turn Hoogle into a library
Add --server flag, to run as a server
4.0.7, released 2009-07-19
Start of changelog