1module Stackage.GhcPkg where
5import Distribution.Text (simpleParse)
6import Data.Char (isSpace)
7import qualified Data.Set as Set
8import Data.Maybe (fromMaybe)
9import Control.Monad (guard)
11getGlobalPackages :: IO (Set PackageIdentifier)
13 -- Account for a change in command line option name
14 versionOutput <- readProcess "ghc-pkg" ["--version"] ""
15 let arg = fromMaybe "--no-user-package-db" $ do
16 verS:_ <- Just $ reverse $ words versionOutput
17 v76 <- simpleParse "7.6"
18 ver <- simpleParse verS
19 guard $ ver < (v76 :: Version)
20 return "--no-user-package-conf"
21 output <- readProcess "ghc-pkg" [arg, "list"] ""
22 fmap Set.unions $ mapM parse $ drop 1 $ lines output
26 "" -> return Set.empty
28 case simpleParse s' of
29 Just x -> return $ Set.singleton x
30 Nothing -> error $ "Could not parse ghc-pkg output: " ++ show s
31 clean = stripParens . dropWhile isSpace . reverse . dropWhile isSpace . reverse
32 stripParens x@('(':_:_)
33 | last x == ')' = tail $ init $ x
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