Skip to content

Commit 298de3c

Browse files
committed
Add WithStage
1 parent e4aec8f commit 298de3c

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

cabal-install/cabal-install.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ library
184184
Distribution.Client.ProjectPlanOutput
185185
Distribution.Client.ProjectPlanning
186186
Distribution.Client.ProjectPlanning.SetupPolicy
187+
Distribution.Client.ProjectPlanning.Stage
187188
Distribution.Client.ProjectPlanning.Types
188189
Distribution.Client.RebuildMonad
189190
Distribution.Client.Reconfigure
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{-# LANGUAGE DeriveGeneric #-}
2+
{-# LANGUAGE DeriveTraversable #-}
3+
{-# LANGUAGE TypeFamilies #-}
4+
module Distribution.Client.ProjectPlanning.Stage
5+
( WithStage(..)
6+
, Stage(..)
7+
, HasStage(..)
8+
) where
9+
10+
import Distribution.Client.Compat.Prelude
11+
import Prelude ()
12+
13+
import Distribution.Compat.Graph (IsNode (..))
14+
import Distribution.Package (HasUnitId(..), Package(..))
15+
import Distribution.Client.Types.ConfiguredId (HasConfiguredId(..))
16+
import Distribution.Solver.Types.Stage (Stage(..))
17+
import Text.PrettyPrint (colon)
18+
19+
-- FIXME: blaaah
20+
data WithStage a = WithStage Stage a
21+
deriving (Eq, Ord, Show, Generic, Functor, Foldable, Traversable)
22+
23+
instance Binary a => Binary (WithStage a)
24+
instance Structured a => Structured (WithStage a)
25+
26+
instance Package pkg => Package (WithStage pkg) where
27+
packageId (WithStage _stage pkg) = packageId pkg
28+
29+
instance IsNode a => IsNode (WithStage a) where
30+
type Key (WithStage a) = WithStage (Key a)
31+
nodeKey = fmap nodeKey
32+
nodeNeighbors = traverse nodeNeighbors
33+
34+
instance HasUnitId a => HasUnitId (WithStage a) where
35+
installedUnitId (WithStage _stage pkg) = installedUnitId pkg
36+
37+
instance HasConfiguredId a => HasConfiguredId (WithStage a) where
38+
configuredId (WithStage _stage pkg) = configuredId pkg
39+
40+
instance Pretty a => Pretty (WithStage a) where
41+
pretty (WithStage s pkg) = pretty s <> colon <> pretty pkg
42+
43+
class HasStage a where
44+
stageOf :: a -> Stage
45+
46+
instance HasStage (WithStage a) where
47+
stageOf (WithStage s _) = s

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ module Distribution.Client.ProjectPlanning.Types
5858
, isBenchComponentTarget
5959
, componentOptionalStanza
6060

61+
-- * Blaah
62+
, WithStage(..)
63+
6164
-- * Toolchain
6265
, Toolchain (..)
6366
, Toolchains
@@ -117,6 +120,7 @@ import Distribution.Solver.Types.ComponentDeps (ComponentDeps)
117120
import qualified Distribution.Solver.Types.ComponentDeps as CD
118121
import Distribution.Solver.Types.OptionalStanza
119122
import Distribution.Solver.Types.Toolchain
123+
import Distribution.Client.ProjectPlanning.Stage
120124
import Distribution.Types.ComponentRequestedSpec
121125
import qualified Distribution.Types.LocalBuildConfig as LBC
122126
import Distribution.Types.PackageDescription (PackageDescription (..))

0 commit comments

Comments
 (0)