Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

38 lines (32 sloc) 1.225 kB
module Query where
import Verbosity
import Error
import Control.Exception
import Network.Hackage.Client
import Distribution.Package
import Data.Version
import Data.List (nub,find)
import Text.ParserCombinators.ReadP
import Prelude hiding(catch)
getPackageVersions :: Verbosity -> String -> String -> IO [Version]
getPackageVersions verb server name = do
pkgs <- listPackages server
`sayDebug` ("Getting package list from '"++server++"'... ",const "done.\n")
`catch` (\x->throwDyn $ ConnectionFailed (show x))
let foundpkgs = filter (\(pkg,_,_,_)->pkgName pkg == name) pkgs
case foundpkgs of
[] -> throwDyn (PackageNotFound (Left name))
_ -> return $ map (\(pkg,_,_,_)->pkgVersion pkg) foundpkgs
sayDebug = verboseDebug verb
getPackages :: Verbosity -> String -> IO [String]
getPackages verb server = do
pkgs <- getPackageIdentifiers server
`sayDebug` ("Getting package list from '"++server++"'... ",const "done.\n")
return $ nub $ map pkgName pkgs
sayDebug = verboseDebug verb
getPackageIdentifiers :: String -> IO [PackageIdentifier]
getPackageIdentifiers server = do
pkgs <- listPackages server `catch` (\x->throwDyn $ ConnectionFailed (show x))
return $ map (\(pkg,_,_,_)->pkg) pkgs
Jump to Line
Something went wrong with that request. Please try again.