Skip to content

Commit 6ba2c92

Browse files
committed
feat: add a bunch of HasCallStack
1 parent 4509880 commit 6ba2c92

File tree

10 files changed

+43
-20
lines changed

10 files changed

+43
-20
lines changed

Cabal-syntax/src/Distribution/Compat/Graph.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ import qualified Data.Map.Strict as Map
104104
import qualified Data.Set as Set
105105
import qualified Data.Tree as Tree
106106
import qualified Distribution.Compat.Prelude as Prelude
107+
import GHC.Stack (HasCallStack)
107108

108109
-- | A graph of nodes @a@. The nodes are expected to have instance
109110
-- of class 'IsNode'.
@@ -377,7 +378,7 @@ fromMap m =
377378
bounds = (0, Map.size m - 1)
378379

379380
-- | /O(V log V)/. Convert a list of nodes (with distinct keys) into a graph.
380-
fromDistinctList :: (IsNode a, Show (Key a)) => [a] -> Graph a
381+
fromDistinctList :: HasCallStack => (IsNode a, Show (Key a)) => [a] -> Graph a
381382
fromDistinctList =
382383
fromMap
383384
. Map.fromListWith (\_ -> duplicateError)

Cabal/src/Distribution/Backpack/ComponentsGraph.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import Distribution.Utils.Generic
2323

2424
import Distribution.Pretty (pretty)
2525
import Text.PrettyPrint
26+
import GHC.Stack (HasCallStack)
2627

2728
------------------------------------------------------------------------------
2829
-- Components graph
@@ -50,7 +51,8 @@ dispComponentsWithDeps graph =
5051
-- | Create a 'Graph' of 'Component', or report a cycle if there is a
5152
-- problem.
5253
mkComponentsGraph
53-
:: ComponentRequestedSpec
54+
:: HasCallStack
55+
=> ComponentRequestedSpec
5456
-> PackageDescription
5557
-> Either [ComponentName] ComponentsGraph
5658
mkComponentsGraph enabled pkg_descr =

Cabal/src/Distribution/Backpack/Configure.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@ import qualified Data.Map as Map
5555
import qualified Data.Set as Set
5656
import Distribution.Pretty
5757
import Text.PrettyPrint
58+
import GHC.Stack (HasCallStack)
5859

5960
------------------------------------------------------------------------------
6061
-- Pipeline
6162
------------------------------------------------------------------------------
6263

6364
configureComponentLocalBuildInfos
64-
:: Verbosity
65+
:: HasCallStack
66+
=> Verbosity
6567
-> Bool -- use_external_internal_deps
6668
-> ComponentRequestedSpec
6769
-> Bool -- deterministic
@@ -206,7 +208,8 @@ configureComponentLocalBuildInfos
206208
------------------------------------------------------------------------------
207209

208210
toComponentLocalBuildInfos
209-
:: Compiler
211+
:: HasCallStack
212+
=> Compiler
210213
-> InstalledPackageIndex -- FULL set
211214
-> [ConfiguredPromisedComponent]
212215
-> PackageDescription
@@ -232,12 +235,12 @@ toComponentLocalBuildInfos
232235
-- since we will pay for the ALL installed packages even if
233236
-- they are not related to what we are building. This was true
234237
-- in the old configure code.
235-
external_graph :: Graph (Either InstalledPackageInfo ReadyComponent)
238+
external_graph :: HasCallStack => Graph (Either InstalledPackageInfo ReadyComponent)
236239
external_graph =
237240
Graph.fromDistinctList
238241
. map Left
239242
$ PackageIndex.allPackages installedPackageSet
240-
internal_graph :: Graph (Either InstalledPackageInfo ReadyComponent)
243+
internal_graph :: HasCallStack => Graph (Either InstalledPackageInfo ReadyComponent)
241244
internal_graph =
242245
Graph.fromDistinctList
243246
. map Right

Cabal/src/Distribution/Simple/Configure.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ import Text.PrettyPrint
183183
import qualified Data.Maybe as M
184184
import qualified Data.Set as Set
185185
import qualified Distribution.Compat.NonEmptySet as NES
186+
import GHC.Stack (HasCallStack)
186187

187188
type UseExternalInternalDeps = Bool
188189

@@ -1208,7 +1209,8 @@ finalCheckPackage
12081209
enabled
12091210

12101211
configureComponents
1211-
:: LBC.LocalBuildConfig
1212+
:: HasCallStack
1213+
=> LBC.LocalBuildConfig
12121214
-> LBC.PackageBuildDescr
12131215
-> PackageInfo
12141216
-> ([PreExistingComponent], [ConfiguredPromisedComponent])

Cabal/src/Distribution/Types/LocalBuildInfo.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ import Distribution.Compat.Graph (Graph)
132132
import qualified Distribution.Compat.Graph as Graph
133133

134134
import qualified System.FilePath as FilePath (takeDirectory)
135+
import GHC.Stack (HasCallStack)
135136

136137
-- | Data cached after configuration step. See also
137138
-- 'Distribution.Simple.Setup.ConfigFlags'.
@@ -415,7 +416,7 @@ withAllTargetsInBuildOrder' pkg_descr lbi f =
415416
-- the order they need to be built.
416417
-- Has a prime because it takes a 'PackageDescription' argument
417418
-- which may disagree with 'localPkgDescr' in 'LocalBuildInfo'.
418-
neededTargetsInBuildOrder' :: PackageDescription -> LocalBuildInfo -> [UnitId] -> [TargetInfo]
419+
neededTargetsInBuildOrder' :: HasCallStack => PackageDescription -> LocalBuildInfo -> [UnitId] -> [TargetInfo]
419420
neededTargetsInBuildOrder' pkg_descr lbi@(LocalBuildInfo{componentGraph = compsGraph}) uids =
420421
case Graph.closure compsGraph uids of
421422
Nothing -> error $ "localBuildPlan: missing uids " ++ intercalate ", " (map prettyShow uids)

cabal-install-solver/src/Distribution/Solver/Modular/Cycles.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import Distribution.Solver.Modular.Tree
1515
import qualified Distribution.Solver.Modular.ConflictSet as CS
1616
import Distribution.Solver.Types.ComponentDeps (Component)
1717
import Distribution.Solver.Types.PackagePath
18+
import GHC.Stack (HasCallStack)
1819

1920
-- | Find and reject any nodes with cyclic dependencies
2021
detectCyclesPhase :: Tree d c -> Tree d c
@@ -51,7 +52,7 @@ detectCyclesPhase = go
5152
-- all decisions that could potentially break the cycle.
5253
--
5354
-- TODO: The conflict set should also contain flag and stanza variables.
54-
findCycles :: QPN -> RevDepMap -> Maybe ConflictSet
55+
findCycles :: HasCallStack => QPN -> RevDepMap -> Maybe ConflictSet
5556
findCycles pkg rdm =
5657
-- This function has two parts: a faster cycle check that is called at every
5758
-- step and a slower calculation of the conflict set.
@@ -115,6 +116,6 @@ instance G.IsNode RevDepMapNode where
115116
nodeKey (RevDepMapNode qpn _) = qpn
116117
nodeNeighbors (RevDepMapNode _ ns) = ordNub $ map snd ns
117118

118-
revDepMapToGraph :: RevDepMap -> G.Graph RevDepMapNode
119+
revDepMapToGraph :: HasCallStack => RevDepMap -> G.Graph RevDepMapNode
119120
revDepMapToGraph rdm = G.fromDistinctList
120121
[RevDepMapNode qpn ns | (qpn, ns) <- M.toList rdm]

cabal-install/src/Distribution/Client/Dependency.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ import Data.List
175175
import qualified Data.Map as Map
176176
import qualified Data.Set as Set
177177
import Text.PrettyPrint
178+
import GHC.Stack (HasCallStack)
178179

179180
-- ------------------------------------------------------------
180181

@@ -907,7 +908,8 @@ interpretPackagesPreference selected defaultPref prefs =
907908
-- | Make an install plan from the output of the dep resolver.
908909
-- It checks that the plan is valid, or it's an error in the dep resolver.
909910
validateSolverResult
910-
:: Staged (CompilerInfo, Platform)
911+
:: HasCallStack
912+
=> Staged (CompilerInfo, Platform)
911913
-> [ResolverPackage UnresolvedPkgLoc]
912914
-> Progress String String SolverInstallPlan
913915
validateSolverResult toolchains pkgs =

cabal-install/src/Distribution/Client/ProjectPlanOutput.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ import System.FilePath
7676
import System.IO
7777

7878
import Distribution.Simple.Program.GHC (packageDbArgsDb)
79+
import GHC.Stack (HasCallStack)
7980

8081
-----------------------------------------------------------------------------
8182
-- Writing plan.json files
@@ -528,7 +529,8 @@ data PostBuildProjectStatus = PostBuildProjectStatus
528529

529530
-- | Work out which packages are out of date or invalid after a build.
530531
postBuildProjectStatus
531-
:: ElaboratedInstallPlan
532+
:: HasCallStack
533+
=> ElaboratedInstallPlan
532534
-> PackagesUpToDate
533535
-> BuildStatusMap
534536
-> BuildOutcomes
@@ -625,7 +627,7 @@ postBuildProjectStatus
625627
)
626628

627629
-- The plan graph but only counting dependency-on-library edges
628-
packagesLibDepGraph :: Graph (Node UnitId ElaboratedPlanPackage)
630+
packagesLibDepGraph :: HasCallStack => Graph (Node UnitId ElaboratedPlanPackage)
629631
packagesLibDepGraph =
630632
Graph.fromDistinctList
631633
[ Graph.N pkg (installedUnitId pkg) libdeps

cabal-install/src/Distribution/Client/ProjectPlanning.hs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ import Distribution.Solver.Types.ProjectConfigPath
236236
import System.Directory (getCurrentDirectory)
237237
import System.FilePath
238238
import qualified Text.PrettyPrint as Disp
239+
import GHC.Stack (HasCallStack)
239240

240241
-- | Check that an 'ElaboratedConfiguredPackage' actually makes
241242
-- sense under some 'ElaboratedSharedConfig'.
@@ -1693,7 +1694,8 @@ elaborateInstallPlan
16931694
-- NB: We don't INSTANTIATE packages at this point. That's
16941695
-- a post-pass. This makes it simpler to compute dependencies.
16951696
elaborateSolverToComponents
1696-
:: (SolverId -> [ElaboratedPlanPackage])
1697+
:: HasCallStack
1698+
=> (SolverId -> [ElaboratedPlanPackage])
16971699
-> SolverPackage UnresolvedPkgLoc
16981700
-> LogProgress [ElaboratedConfiguredPackage]
16991701
elaborateSolverToComponents mapDep spkg@(SolverPackage _ _ _ _ _ deps0 exe_deps0) =
@@ -1830,7 +1832,8 @@ elaborateInstallPlan
18301832
++ " not implemented yet"
18311833

18321834
buildComponent
1833-
:: ( ConfiguredComponentMap
1835+
:: HasCallStack
1836+
=> ( ConfiguredComponentMap
18341837
, LinkedComponentMap
18351838
, Map ComponentId FilePath
18361839
)
@@ -2766,7 +2769,8 @@ extractElabBuildStyle _ = BuildAndInstall
27662769
-- we don't instantiate the same thing multiple times.
27672770
--
27682771
instantiateInstallPlan
2769-
:: StoreDirLayout
2772+
:: HasCallStack
2773+
=> StoreDirLayout
27702774
-> Staged InstallDirs.InstallDirTemplates
27712775
-> ElaboratedSharedConfig
27722776
-> ElaboratedInstallPlan
@@ -3297,7 +3301,8 @@ data TargetAction
32973301
-- will prune differently depending on what is already installed (to
32983302
-- implement "sticky" test suite enabling behavior).
32993303
pruneInstallPlanToTargets
3300-
:: TargetAction
3304+
:: HasCallStack
3305+
=> TargetAction
33013306
-> Map UnitId [ComponentTarget]
33023307
-> ElaboratedInstallPlan
33033308
-> ElaboratedInstallPlan
@@ -3393,7 +3398,8 @@ setRootTargets targetAction perPkgTargetsMap =
33933398
-- are used only by unneeded optional stanzas. These pruned deps are only
33943399
-- used for the dependency closure and are not persisted in this pass.
33953400
pruneInstallPlanPass1
3396-
:: [ElaboratedPlanPackage]
3401+
:: HasCallStack
3402+
=> [ElaboratedPlanPackage]
33973403
-> [ElaboratedPlanPackage]
33983404
pruneInstallPlanPass1 pkgs
33993405
-- if there are repl targets, we need to do a bit more work
@@ -3753,7 +3759,8 @@ mapConfiguredPackage _ (InstallPlan.PreExisting pkg) =
37533759
--
37543760
-- This is not always possible.
37553761
pruneInstallPlanToDependencies
3756-
:: Set UnitId
3762+
:: HasCallStack
3763+
=> Set UnitId
37573764
-> ElaboratedInstallPlan
37583765
-> Either
37593766
CannotPruneDependencies

cabal-install/src/Distribution/Client/SolverInstallPlan.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ import qualified Data.Graph as OldGraph
7676
import qualified Data.Map as Map
7777
import Distribution.Compat.Graph (Graph, IsNode (..))
7878
import qualified Distribution.Compat.Graph as Graph
79+
import GHC.Stack (HasCallStack)
7980

8081
type SolverPlanPackage = ResolverPackage UnresolvedPkgLoc
8182

@@ -153,7 +154,8 @@ toMap = Graph.toMap . planIndex
153154
-- the dependencies of a package or set of packages without actually
154155
-- installing the package itself, as when doing development.
155156
remove
156-
:: (SolverPlanPackage -> Bool)
157+
:: HasCallStack
158+
=> (SolverPlanPackage -> Bool)
157159
-> SolverInstallPlan
158160
-> Either
159161
[SolverPlanProblem]

0 commit comments

Comments
 (0)