@@ -69,6 +69,7 @@ module Distribution.Client.InstallPlan (
69
69
70
70
import Distribution.Client.Compat.Prelude hiding (toList , lookup , tail )
71
71
import Prelude (tail )
72
+ import Distribution.Compat.Stack (WithCallStack )
72
73
73
74
import Distribution.Client.Types hiding (BuildOutcomes )
74
75
import qualified Distribution.PackageDescription as PD
@@ -83,6 +84,7 @@ import Distribution.Package
83
84
import Distribution.Solver.Types.SolverPackage
84
85
import Distribution.Client.JobControl
85
86
import Distribution.Deprecated.Text
87
+ import Distribution.Pretty (prettyShow )
86
88
import Text.PrettyPrint
87
89
import qualified Distribution.Client.SolverInstallPlan as SolverInstallPlan
88
90
import Distribution.Client.SolverInstallPlan (SolverInstallPlan )
@@ -165,6 +167,11 @@ data GenericPlanPackage ipkg srcpkg
165
167
| Installed srcpkg
166
168
deriving (Eq , Show , Generic )
167
169
170
+ displayGenericPlanPackage :: (IsUnit ipkg , IsUnit srcpkg ) => GenericPlanPackage ipkg srcpkg -> String
171
+ displayGenericPlanPackage (PreExisting pkg) = " PreExisting " ++ prettyShow (nodeKey pkg)
172
+ displayGenericPlanPackage (Configured pkg) = " Configured " ++ prettyShow (nodeKey pkg)
173
+ displayGenericPlanPackage (Installed pkg) = " Installed " ++ prettyShow (nodeKey pkg)
174
+
168
175
-- | Convenience combinator for destructing 'GenericPlanPackage'.
169
176
-- This is handy because if you case manually, you have to handle
170
177
-- 'Configured' and 'Installed' separately (where often you want
@@ -249,7 +256,7 @@ mkInstallPlan loc graph indepGoals =
249
256
planIndepGoals = indepGoals
250
257
}
251
258
252
- internalError :: String -> String -> a
259
+ internalError :: WithCallStack ( String -> String -> a )
253
260
internalError loc msg = error $ " internal error in InstallPlan." ++ loc
254
261
++ if null msg then " " else " : " ++ msg
255
262
@@ -619,7 +626,7 @@ isInstalled _ = False
619
626
-- and return any packages that are newly in the processing state (ie ready to
620
627
-- process), along with the updated 'Processing' state.
621
628
--
622
- completed :: (IsUnit ipkg , IsUnit srcpkg )
629
+ completed :: forall ipkg srcpkg . (IsUnit ipkg , IsUnit srcpkg )
623
630
=> GenericInstallPlan ipkg srcpkg
624
631
-> Processing -> UnitId
625
632
-> ([GenericReadyPackage srcpkg ], Processing )
@@ -644,8 +651,9 @@ completed plan (Processing processingSet completedSet failedSet) pkgid =
644
651
(map nodeKey newlyReady)
645
652
processing' = Processing processingSet' completedSet' failedSet
646
653
647
- asReadyPackage (Configured pkg) = ReadyPackage pkg
648
- asReadyPackage _ = internalError " completed" " "
654
+ asReadyPackage :: GenericPlanPackage ipkg srcpkg -> GenericReadyPackage srcpkg
655
+ asReadyPackage (Configured pkg) = ReadyPackage pkg
656
+ asReadyPackage pkg = internalError " completed" $ " not in configured state: " ++ displayGenericPlanPackage pkg
649
657
650
658
failed :: (IsUnit ipkg , IsUnit srcpkg )
651
659
=> GenericInstallPlan ipkg srcpkg
@@ -671,7 +679,7 @@ failed plan (Processing processingSet completedSet failedSet) pkgid =
671
679
processing' = Processing processingSet' completedSet failedSet'
672
680
673
681
asConfiguredPackage (Configured pkg) = pkg
674
- asConfiguredPackage _ = internalError " failed" " not in configured state"
682
+ asConfiguredPackage pkg = internalError " failed" $ " not in configured state: " ++ displayGenericPlanPackage pkg
675
683
676
684
processingInvariant :: (IsUnit ipkg , IsUnit srcpkg )
677
685
=> GenericInstallPlan ipkg srcpkg
0 commit comments