-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | provide access to the Hackage database via Data.Map -- -- This module provides simple access to the Hackage database by means of -- Data.Map. Suppose you wanted to implement a utility that -- queries the set of available versions for a given package, the -- following program would do the trick: -- --
-- import qualified Distribution.Hackage.DB as DB -- import Distribution.Text ( display ) -- import System.Environment ( getArgs ) -- -- main :: IO () -- main = do -- pkgs <- getArgs -- db <- DB.readHackage -- let getVersions name = maybe [] DB.keys (DB.lookup name db) -- mapM_ (putStrLn . unwords . map display . getVersions) pkgs ---- -- When run, it would produce the following output: -- --
-- ./a.out containers deepseq cabal-install -- 0.1.0.0 0.1.0.1 0.2.0.0 0.2.0.1 0.3.0.0 0.4.0.0 -- 1.0.0.0 1.1.0.0 1.1.0.1 1.1.0.2 -- 0.4.0 0.5.0 0.5.1 0.5.2 0.6.0 0.6.2 0.6.4 0.8.0 0.8.2 0.10.0 0.10.2 ---- -- Note that once the database has been parsed, it can be accessed -- quickly, but the inital cost of reading 00-index.tar is -- fairly high. -- -- This package is known to work on Linux and Mac OS X, but not Windows. @package hackage-db @version 1.7 -- | This module provides simple access to the Hackage database by means of -- Map. Note that once the database has been parsed, it can be -- accessed quickly, but the inital cost of reading 00-index.tar -- is fairly high. module Distribution.Hackage.DB -- | A Map representation of the Hackage database. For sake of -- simplicity, we use String rather than PackageName to -- represent the name of a package. type Hackage = Map String (Map Version GenericPackageDescription) -- | Read the Hackage database from $HOME/<package database -- path>/hackage.haskell.org/00-index.tar and return a -- Map that provides fast access to its contents. That -- tar file is typically created by running the command -- "cabal update". readHackage :: IO Hackage -- | Read the Hackage database from the given FilePath and return a -- Hackage map that provides fast access to its contents. readHackage' :: FilePath -> IO Hackage -- | Parse the contents of Hackage's 00-index.tar into a -- Hackage map. parseHackage :: ByteString -> Hackage