3 , defaultSelectSettings
6import qualified Data.Map as Map
7import Data.Maybe (mapMaybe)
8import Data.Either (partitionEithers)
10import qualified Data.Set as Set
11import Prelude hiding (pi)
13import Stackage.InstallInfo
17defaultSelectSettings :: SelectSettings
18defaultSelectSettings = SelectSettings
19 { extraCore = defaultExtraCore
20 , expectedFailuresSelect = defaultExpectedFailures
21 , stablePackages = defaultStablePackages
22 , haskellPlatformCabal = "haskell-platform/haskell-platform.cabal"
23 , requireHaskellPlatform = True
24 , excludedPackages = empty
25 , flags = Set.fromList $ words "blaze_html_0_5"
26 , allowedPackage = const $ Right ()
29select :: SelectSettings -> IO BuildPlan
31 ii <- getInstallInfo settings'
34 case iiBuildTools ii of
35 Left s -> error $ "Could not topologically sort build tools: " ++ s
40 , bpPackages = iiPackages ii
41 , bpOptionalCore = iiOptionalCore ii
45-- | Get all of the build tools required.
46iiBuildTools :: InstallInfo -> Either String [String]
47iiBuildTools InstallInfo { iiPackageDB = PackageDB m, iiPackages = packages } =
48 fmap (map packageVersionString)
51 $ filter (flip Set.notMember coreTools . fst)
52 $ mapMaybe (flip Map.lookup buildToolMap)
57 $ Map.filterWithKey isSelected m
59 isSelected name _ = name `Set.member` selected
60 selected = Set.fromList $ Map.keys packages
62 -- Build tools shipped with GHC which we should not attempt to build
64 coreTools = Set.fromList $ map PackageName $ words "hsc2hs"
66 -- The map from build tool name to the package it comes from.
67 buildToolMap :: Map Executable (PackageName, Version)
68 buildToolMap = Map.unions $ map toBuildToolMap $ Map.toList m
70 toBuildToolMap :: (PackageName, PackageInfo) -> Map Executable (PackageName, Version)
71 toBuildToolMap (pn, pi) = Map.unions
72 $ map (flip Map.singleton (pn, piVersion pi))
76 addDependencies :: (PackageName, Version) -> ((PackageName, Version), Set (PackageName, Version))
77 addDependencies (pn, pv) =
81 case Map.lookup pn m of
83 Just pi -> Set.fromList
84 $ mapMaybe (flip Map.lookup buildToolMap)
88topSort :: (Show a, Ord a) => [(a, Set a)] -> Either String [a]
90 uncurry go . partitionEithers . map (splitter . limitDeps) $ orig
94 | otherwise = Right (x, y)
97 go [] y = Left $ "The following form a cycle: " ++ show (map fst y)
99 let (xs', ys') = partitionEithers $ map (splitter . dropDep x) ys
100 rest <- go (xs ++ xs') ys'
103 dropDep x (y, z) = (y, Set.delete x z)
105 allVertices = Set.fromList $ map fst orig
106 limitDeps (x, y) = (x, Set.intersection allVertices 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