3 , defaultSelectSettings
6import Data.Either (partitionEithers)
7import qualified Data.Map as Map
8import Data.Maybe (mapMaybe)
10import qualified Data.Set as Set
11import Distribution.Text (simpleParse)
12import Distribution.Version (withinRange)
13import Prelude hiding (pi)
15import Stackage.InstallInfo
19defaultSelectSettings :: SelectSettings
20defaultSelectSettings = SelectSettings
21 { extraCore = defaultExtraCore
22 , expectedFailuresSelect = defaultExpectedFailures
23 , stablePackages = defaultStablePackages
24 , haskellPlatformCabal = "haskell-platform/haskell-platform.cabal"
25 , requireHaskellPlatform = True
26 , excludedPackages = empty
28 Set.fromList (words "blaze_html_0_5") `Set.union`
29 -- Support for containers-unicode-symbols
30 (case Map.lookup (PackageName "containers") coreMap of
31 Just v | Just range <- simpleParse "< 0.5", v `withinRange` range
32 -> Set.singleton "containers-old"
34 , disabledFlags = Set.fromList $ words "bytestring-in-base"
35 , allowedPackage = const $ Right ()
36 , useGlobalDatabase = False
39select :: SelectSettings -> IO BuildPlan
41 ii <- getInstallInfo settings'
44 case iiBuildTools ii of
45 Left s -> error $ "Could not topologically sort build tools: " ++ s
50 , bpPackages = iiPackages ii
51 , bpOptionalCore = iiOptionalCore ii
55-- | Get all of the build tools required.
56iiBuildTools :: InstallInfo -> Either String [String]
57iiBuildTools InstallInfo { iiPackageDB = PackageDB m, iiPackages = packages } =
58 fmap (map packageVersionString)
61 $ filter (flip Set.notMember coreTools . fst)
64 $ mapMaybe (flip Map.lookup buildToolMap)
69 $ Map.filterWithKey isSelected m
71 isSelected name _ = name `Set.member` selected
72 selected = Set.fromList $ Map.keys packages
74 -- Build tools shipped with GHC which we should not attempt to build
76 coreTools = Set.fromList $ map PackageName $ words "hsc2hs"
78 -- The map from build tool name to the package it comes from.
79 buildToolMap :: Map Executable (PackageName, Version)
80 buildToolMap = Map.unions $ map toBuildToolMap $ Map.toList m
82 toBuildToolMap :: (PackageName, PackageInfo) -> Map Executable (PackageName, Version)
83 toBuildToolMap (pn, pi) = Map.unions
84 $ map (flip Map.singleton (pn, piVersion pi))
88 addDependencies :: (PackageName, Version) -> ((PackageName, Version), Set (PackageName, Version))
89 addDependencies (pn, pv) =
93 case Map.lookup pn m of
95 Just pi -> Set.fromList
96 $ mapMaybe (flip Map.lookup buildToolMap)
100topSort :: (Show a, Ord a) => [(a, Set a)] -> Either String [a]
102 uncurry go . partitionEithers . map (splitter . limitDeps) $ orig
105 | Set.null y = Left x
106 | otherwise = Right (x, y)
109 go [] y = Left $ "The following form a cycle: " ++ show (map fst y)
111 let (xs', ys') = partitionEithers $ map (splitter . dropDep x) ys
112 rest <- go (xs ++ xs') ys'
115 dropDep x (y, z) = (y, Set.delete x z)
117 allVertices = Set.fromList $ map fst orig
118 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