access Hackage's package database via Data.Map


Version on this page:1.22@rev:1
LTS Haskell 22.25:2.1.3
Stackage Nightly 2024-06-13:2.1.3
Latest on Hackage:2.1.3

See all snapshots hackage-db appears in

BSD-3-Clause licensed and maintained by Peter Simons
This version can be pinned in stack with:hackage-db-1.22@sha256:b5277a8cbbfcfba81f29db4910003c2fa7e34c06bceb4f3e7318510e1ce74376,2010

Module documentation for 1.22

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.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