Safe Haskell | None |
---|
The Hoogle API. To perform a search you call search
with a Database
(obtained by loadDatabase
) and a
Query
(obtained by parseQuery
).
- data TagStr
- showTagText :: TagStr -> String
- showTagANSI :: TagStr -> String
- showTagHTML :: TagStr -> String
- showTagHTMLWith :: (TagStr -> Maybe String) -> TagStr -> String
- data ParseError = ParseError {
- lineNo :: Int
- columnNo :: Int
- errorMessage :: String
- parseInput :: TagStr
- type URL = String
- data Language = Haskell
- data Database
- loadDatabase :: FilePath -> IO Database
- saveDatabase :: FilePath -> Database -> IO ()
- createDatabase :: Language -> [Database] -> String -> ([ParseError], Database)
- showDatabase :: Database -> Maybe [String] -> String
- data Query
- parseQuery :: Language -> String -> Either ParseError Query
- renderQuery :: Query -> TagStr
- queryDatabases :: Query -> [String]
- queryPackages :: Query -> [(Bool, String)]
- querySetPackage :: Maybe Bool -> String -> Query -> Query
- data Score
- scoring :: [(Score, Score)] -> IO String
- data Result = Result {}
- search :: Database -> Query -> [(Score, Result)]
- suggestions :: Database -> Query -> Maybe TagStr
- completions :: Database -> String -> [String]
- queryExact :: Maybe ItemKind -> Query -> Query
- data ItemKind
Utility types
showTagText :: TagStr -> StringSource
Show a TagStr
as a string, without any formatting.
showTagANSI :: TagStr -> StringSource
Show a TagStr
on a console with ANSI escape sequences.
showTagHTML :: TagStr -> StringSource
Show a TagStr
as HTML, using CSS classes for color styling.
showTagHTMLWith :: (TagStr -> Maybe String) -> TagStr -> StringSource
Show TagStr with an override for specific tags.
data ParseError Source
Data type representing a parse error. All indecies are 1-based.
ParseError | |
|
A URL, or internet address. These addresses will usually start with either
http://
or file://
.
The languages supported by Hoogle.
Haskell | The Haskell language (http://haskell.org/), along with many GHC specific extensions. |
Database
A Hoogle database, containing a set of functions/items which can be searched. The Database
type is used
for a variety of purposes:
- Creation
- A database is created by merging existing databases with the
Monoid
instance andmappend
, or by creating a newDatabase
from an input file withcreateDatabase
. - Serialization
- A database is saved to disk with
saveDatabase
and loaded from disk withloadDatabase
. - Searching
- A database is searched using
search
.
loadDatabase :: FilePath -> IO DatabaseSource
Load a database from a file. If the database was not saved with the same version of Hoogle, it will probably throw an error.
saveDatabase :: FilePath -> Database -> IO ()Source
Save a database to a file.
:: Language | Which format the input definition is in. |
-> [Database] | A list of databases which contain definitions this input definition relies upon (e.g. types, aliases, instances). |
-> String | The input definitions, usually with one definition per line, in a format specified by the |
-> ([ParseError], Database) | A pair containing any parse errors present in the input definition, and the database ignoring any parse errors. |
Create a database from an input definition. Source files for Hoogle databases are usually
stored in UTF8 format, and should be read using hSetEncoding
and utf8
.
showDatabase :: Database -> Maybe [String] -> StringSource
Show debugging information on some parts of the database. If the second argument
is Nothing
the whole database will be shown. Otherwise, the listed parts will be shown.
Query
A query, representing a user input.
parseQuery :: Language -> String -> Either ParseError QuerySource
Parse a query for a given language, returning either a parse error, or a query.
renderQuery :: Query -> TagStrSource
Render a query, in particular using TagColor
for any type signature argument positions.
queryDatabases :: Query -> [String]Source
Given a query, return the list of packages that should be searched. Each package will be the name of a database, without any file path or extension included.
queryPackages :: Query -> [(Bool, String)]Source
Score
A score, representing how close a match is. Lower scores are better.
scoring :: [(Score, Score)] -> IO StringSource
Given a set of scores, where the first is lower than the second, returns details for how to rank scores.
This function is in the IO
monad since it may require randomness, and it may output status messages while solving,
particularly if in Verbose mode.
Search
search :: Database -> Query -> [(Score, Result)]Source
Perform a search. The results are returned lazily.
suggestions :: Database -> Query -> Maybe TagStrSource
Given a query and a database optionally give a list of what the user might have meant.
completions :: Database -> String -> [String]Source
Given a query string and a database return a list of the possible completions for the search.