Skip to content

Commit 9b7301c

Browse files
committed
feat: add a bunch of HasCallStack
1 parent 5b1512a commit 9b7301c

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
@@ -22,6 +22,7 @@ import Distribution.Types.ComponentRequestedSpec
2222
import Distribution.Utils.Generic
2323

2424
import Distribution.Pretty (pretty)
25+
import GHC.Stack (HasCallStack)
2526
import Text.PrettyPrint
2627

2728
------------------------------------------------------------------------------
@@ -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
@@ -54,14 +54,16 @@ import Data.Either
5454
import qualified Data.Map as Map
5555
import qualified Data.Set as Set
5656
import Distribution.Pretty
57+
import GHC.Stack (HasCallStack)
5758
import Text.PrettyPrint
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
@@ -131,6 +131,7 @@ import qualified Data.Map as Map
131131
import Distribution.Compat.Graph (Graph)
132132
import qualified Distribution.Compat.Graph as Graph
133133

134+
import GHC.Stack (HasCallStack)
134135
import qualified System.FilePath as FilePath (takeDirectory)
135136

136137
-- | Data cached after configuration step. See also
@@ -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
@@ -174,6 +174,7 @@ import Data.List
174174
)
175175
import qualified Data.Map as Map
176176
import qualified Data.Set as Set
177+
import GHC.Stack (HasCallStack)
177178
import Text.PrettyPrint
178179

179180
-- ------------------------------------------------------------
@@ -912,7 +913,8 @@ interpretPackagesPreference selected defaultPref prefs =
912913
-- | Make an install plan from the output of the dep resolver.
913914
-- It checks that the plan is valid, or it's an error in the dep resolver.
914915
validateSolverResult
915-
:: Staged (CompilerInfo, Platform)
916+
:: HasCallStack
917+
=> Staged (CompilerInfo, Platform)
916918
-> [ResolverPackage UnresolvedPkgLoc]
917919
-> Progress String String SolverInstallPlan
918920
validateSolverResult toolchains pkgs =

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

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

7979
import Distribution.Simple.Program.GHC (packageDbArgsDb)
80+
import GHC.Stack (HasCallStack)
8081

8182
-----------------------------------------------------------------------------
8283
-- Writing plan.json files
@@ -529,7 +530,8 @@ data PostBuildProjectStatus = PostBuildProjectStatus
529530

530531
-- | Work out which packages are out of date or invalid after a build.
531532
postBuildProjectStatus
532-
:: ElaboratedInstallPlan
533+
:: HasCallStack
534+
=> ElaboratedInstallPlan
533535
-> PackagesUpToDate
534536
-> BuildStatusMap
535537
-> BuildOutcomes
@@ -626,7 +628,7 @@ postBuildProjectStatus
626628
)
627629

628630
-- The plan graph but only counting dependency-on-library edges
629-
packagesLibDepGraph :: Graph (Node UnitId ElaboratedPlanPackage)
631+
packagesLibDepGraph :: HasCallStack => Graph (Node UnitId ElaboratedPlanPackage)
630632
packagesLibDepGraph =
631633
Graph.fromDistinctList
632634
[ 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
@@ -232,6 +232,7 @@ import qualified Data.Map as Map
232232
import qualified Data.Set as Set
233233
import Distribution.Client.Errors
234234
import Distribution.Solver.Types.ProjectConfigPath
235+
import GHC.Stack (HasCallStack)
235236
import System.Directory (getCurrentDirectory)
236237
import System.FilePath
237238
import qualified Text.PrettyPrint as Disp
@@ -1694,7 +1695,8 @@ elaborateInstallPlan
16941695
-- NB: We don't INSTANTIATE packages at this point. That's
16951696
-- a post-pass. This makes it simpler to compute dependencies.
16961697
elaborateSolverToComponents
1697-
:: (SolverId -> [ElaboratedPlanPackage])
1698+
:: HasCallStack
1699+
=> (SolverId -> [ElaboratedPlanPackage])
16981700
-> SolverPackage UnresolvedPkgLoc
16991701
-> LogProgress [ElaboratedConfiguredPackage]
17001702
elaborateSolverToComponents mapDep spkg@(SolverPackage _ _ _ _ _ deps0 exe_deps0) =
@@ -1831,7 +1833,8 @@ elaborateInstallPlan
18311833
++ " not implemented yet"
18321834

18331835
buildComponent
1834-
:: ( ConfiguredComponentMap
1836+
:: HasCallStack
1837+
=> ( ConfiguredComponentMap
18351838
, LinkedComponentMap
18361839
, Map ComponentId FilePath
18371840
)
@@ -2767,7 +2770,8 @@ extractElabBuildStyle _ = BuildAndInstall
27672770
-- we don't instantiate the same thing multiple times.
27682771
--
27692772
instantiateInstallPlan
2770-
:: StoreDirLayout
2773+
:: HasCallStack
2774+
=> StoreDirLayout
27712775
-> Staged InstallDirs.InstallDirTemplates
27722776
-> ElaboratedSharedConfig
27732777
-> ElaboratedInstallPlan
@@ -3298,7 +3302,8 @@ data TargetAction
32983302
-- will prune differently depending on what is already installed (to
32993303
-- implement "sticky" test suite enabling behavior).
33003304
pruneInstallPlanToTargets
3301-
:: TargetAction
3305+
:: HasCallStack
3306+
=> TargetAction
33023307
-> Map UnitId [ComponentTarget]
33033308
-> ElaboratedInstallPlan
33043309
-> ElaboratedInstallPlan
@@ -3394,7 +3399,8 @@ setRootTargets targetAction perPkgTargetsMap =
33943399
-- are used only by unneeded optional stanzas. These pruned deps are only
33953400
-- used for the dependency closure and are not persisted in this pass.
33963401
pruneInstallPlanPass1
3397-
:: [ElaboratedPlanPackage]
3402+
:: HasCallStack
3403+
=> [ElaboratedPlanPackage]
33983404
-> [ElaboratedPlanPackage]
33993405
pruneInstallPlanPass1 pkgs
34003406
-- if there are repl targets, we need to do a bit more work
@@ -3754,7 +3760,8 @@ mapConfiguredPackage _ (InstallPlan.PreExisting pkg) =
37543760
--
37553761
-- This is not always possible.
37563762
pruneInstallPlanToDependencies
3757-
:: Set UnitId
3763+
:: HasCallStack
3764+
=> Set UnitId
37583765
-> ElaboratedInstallPlan
37593766
-> Either
37603767
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)