summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDaniel Burrows <dburrows@debian.org>2009-04-05 07:47:12 -0700
committerDaniel Burrows <dburrows@debian.org>2009-04-05 07:47:12 -0700
commit3a2d9d411cabf3dfb4efc91f443216e6dcc7d981 (patch)
tree25e2c3ac66f1fb2226f2591ad6e6c585761b4694 /tools
parent99420e5b827315c154eaa0dc3ccd50b3f670883a (diff)
downloadaptitude-3a2d9d411cabf3dfb4efc91f443216e6dcc7d981.tar.gz
Show user-friendly names for the top and bottom tiers.
Diffstat (limited to 'tools')
-rw-r--r--tools/resolver-visualize/Resolver/Types.hs26
1 files changed, 16 insertions, 10 deletions
diff --git a/tools/resolver-visualize/Resolver/Types.hs b/tools/resolver-visualize/Resolver/Types.hs
index 53eb5054..9adbef93 100644
--- a/tools/resolver-visualize/Resolver/Types.hs
+++ b/tools/resolver-visualize/Resolver/Types.hs
@@ -99,25 +99,31 @@ instance Ord Solution where
combine o1 _ = o1
maximumTierNum = 2147483647
+alreadyGeneratedTierNum = maximumTierNum - 1
+deferTierNum = alreadyGeneratedTierNum - 1
minimumTierNum = -2147483648
newtype Tier = Tier { tierLevels :: [Integer] } deriving(Ord, Eq)
maximumTier = Tier [maximumTierNum]
conflictTier = maximumTier
-alreadyGeneratedTier = Tier [maximumTierNum - 1]
-deferTier = Tier [maximumTierNum - 2]
+alreadyGeneratedTier = Tier [alreadyGeneratedTierNum]
+deferTier = Tier [deferTierNum]
minimumTier = Tier [minimumTierNum]
-- The Show instance mainly special-cases the special tiers so they
-- get pretty-printed.
instance Show Tier where
- showsPrec _ tier
- | tier == conflictTier = ("T:conflict"++)
- | tier == deferTier = ("T:defer"++)
- | tier == alreadyGeneratedTier = ("T:redundant"++)
- | tier == minimumTier = ("T:minimum"++)
- | otherwise = case tier of
- Tier [num] -> ('T':) . shows (num)
- Tier nums -> ("T("++) . foldr (.) id (intersperse (", "++) (map shows nums)) . (')':)
+ showsPrec _ (Tier [num]) = ('T':) . showsTierComponent num
+ showsPrec _ (Tier nums) = ("T("++) .
+ foldr (.) id (intersperse (", "++) (map showsTierComponent nums)) .
+ (')':)
+
+-- | Display a user-friendly description of a tier number.
+showsTierComponent tierNum
+ | tierNum == maximumTierNum = ("maximum"++)
+ | tierNum == deferTierNum = ("defer"++)
+ | tierNum == alreadyGeneratedTierNum = ("redundant"++)
+ | tierNum == minimumTierNum = ("minimum"++)
+ | otherwise = shows tierNum
-- | Represents a promotion to a tier.
data Promotion = Promotion { -- | The choices that produced this promotion.