-
Notifications
You must be signed in to change notification settings - Fork 696
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add provenance information to PackageLocation
- Loading branch information
Showing
42 changed files
with
1,688 additions
and
1,007 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
cabal-install-solver/src/Distribution/Solver/Types/NamedPackage.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{-# LANGUAGE NamedFieldPuns #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE DeriveFunctor #-} | ||
|
||
module Distribution.Solver.Types.NamedPackage | ||
( NamedPackage (..) | ||
, NamedPackageConstraint | ||
) where | ||
|
||
import Distribution.Solver.Compat.Prelude | ||
import Prelude () | ||
|
||
import Distribution.Types.PackageName (PackageName) | ||
import Distribution.Solver.Types.PackageConstraint (PackageProperty) | ||
import Distribution.Solver.Types.WithConstraintSource (WithConstraintSource) | ||
import Distribution.Pretty (Pretty (pretty), commaSpaceSep) | ||
import Text.PrettyPrint | ||
|
||
-- | A package, identified by a name and properties. | ||
data NamedPackage = NamedPackage PackageName [PackageProperty] | ||
deriving (Show, Eq, Ord, Generic, Typeable) | ||
|
||
instance Binary NamedPackage | ||
instance Structured NamedPackage | ||
|
||
instance Pretty NamedPackage where | ||
pretty (NamedPackage name properties) = | ||
pretty name <+> parens (commaSpaceSep properties) | ||
|
||
type NamedPackageConstraint = WithConstraintSource NamedPackage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
cabal-install-solver/src/Distribution/Solver/Types/WithConstraintSource.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{-# LANGUAGE DeriveFunctor #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE NamedFieldPuns #-} | ||
|
||
module Distribution.Solver.Types.WithConstraintSource | ||
( WithConstraintSource (..) | ||
, showWithConstraintSource | ||
, withUnknownConstraint | ||
) where | ||
|
||
import Distribution.Solver.Compat.Prelude | ||
|
||
import Distribution.Solver.Types.ConstraintSource (ConstraintSource (..), showConstraintSource) | ||
import Distribution.Pretty (Pretty (pretty)) | ||
import Text.PrettyPrint | ||
|
||
-- | A package bundled with a `ConstraintSource`. | ||
data WithConstraintSource pkg = | ||
WithConstraintSource | ||
{ constraintPackage :: pkg | ||
-- ^ The package. | ||
, constraintConstraint :: ConstraintSource | ||
-- ^ The constraint source for the package. | ||
} | ||
deriving (Show, Functor, Eq, Ord, Generic, Typeable) | ||
|
||
instance Binary pkg => Binary (WithConstraintSource pkg) | ||
instance Structured pkg => Structured (WithConstraintSource pkg) | ||
|
||
withUnknownConstraint :: pkg -> WithConstraintSource pkg | ||
withUnknownConstraint constraintPackage = | ||
WithConstraintSource | ||
{ constraintPackage | ||
, constraintConstraint = ConstraintSourceUnknown | ||
} | ||
|
||
showWithConstraintSource :: (pkg -> String) -> WithConstraintSource pkg -> String | ||
showWithConstraintSource | ||
showPackage | ||
(WithConstraintSource { constraintPackage, constraintConstraint }) = | ||
showPackage constraintPackage ++ " (" ++ showConstraintSource constraintConstraint ++ ")" | ||
|
||
instance Pretty pkg => Pretty (WithConstraintSource pkg) where | ||
pretty (WithConstraintSource { constraintPackage, constraintConstraint = ConstraintSourceUnknown }) | ||
= pretty constraintPackage | ||
pretty (WithConstraintSource { constraintPackage, constraintConstraint }) | ||
= pretty constraintPackage | ||
<+> parens (text "from" <+> pretty constraintConstraint) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.