1module Stackage.GhcPkg where
5import Distribution.Text (simpleParse)
6import Distribution.Version (Version (Version))
7import Data.Char (isSpace)
8import qualified Data.Set as Set
10getGlobalPackages :: GhcMajorVersion -> IO (Set PackageIdentifier)
11getGlobalPackages version = do
12 output <- readProcess "ghc-pkg" [arg, "list"] ""
13 fmap Set.unions $ mapM parse $ drop 1 $ lines output
15 -- Account for a change in command line option name
17 | version >= GhcMajorVersion 7 6 = "--no-user-package-db"
18 | otherwise = "--no-user-package-conf"
21 "" -> return Set.empty
23 case simpleParse s' of
24 Just x -> return $ Set.singleton x
25 Nothing -> error $ "Could not parse ghc-pkg output: " ++ show s
26 clean = stripParens . dropWhile isSpace . reverse . dropWhile isSpace . reverse
27 stripParens x@('(':_:_)
28 | last x == ')' = tail $ init $ x
31getGhcVersion :: IO GhcMajorVersion
33 versionOutput <- readProcess "ghc-pkg" ["--version"] ""
34 maybe (error $ "Invalid version output: " ++ show versionOutput) return $ do
35 verS:_ <- Just $ reverse $ words versionOutput
36 Version (x:y:_) _ <- simpleParse verS
37 return $ GhcMajorVersion x y
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list