1{-# LANGUAGE NoImplicitPrelude #-}
2{-# LANGUAGE OverloadedStrings #-}
3module Stackage2.CorePackages
9import qualified Data.Text as T
10import Filesystem (listDirectory)
11import Stackage2.Prelude
12import System.Directory (findExecutable)
14-- | Get a @Map@ of all of the core packages. Core packages are defined as
15-- packages which ship with GHC itself.
17-- Precondition: GHC global package database has only core packages, and GHC
18-- ships with just a single version of each packages.
19getCorePackages :: IO (Map PackageName Version)
21 withCheckedProcess cp $ \ClosedStream src Inherited ->
22 src $$ decodeUtf8C =$ linesUnboundedC =$ foldMapMC parsePackage
24 cp = proc "ghc-pkg" ["--no-user-package-conf", "list"]
26 | ":" `isInfixOf` t = return mempty
27 | Just p <- stripSuffix "-" p' = singletonMap
30 | otherwise = return mempty
32 (p', v) = T.breakOnEnd "-" $ dropParens $ T.strip t
35 | length s > 2 && headEx s == '(' && lastEx s == ')' =
39-- | A list of executables that are shipped with GHC.
40getCoreExecutables :: IO (Set ExeName)
41getCoreExecutables = do
42 mfp <- findExecutable "ghc"
45 Nothing -> error "No ghc executable found on PATH"
46 Just fp -> return $ directory $ fpFromString fp
47 (setFromList . map (ExeName . fpToText . filename)) <$> listDirectory dir
49getGhcVersion :: IO Version
51 withCheckedProcess (proc "ghc" ["--numeric-version"]) $
52 \ClosedStream src Inherited ->
53 (src $$ decodeUtf8C =$ foldC) >>= simpleParse
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