-
Notifications
You must be signed in to change notification settings - Fork 697
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
ConstraintSource
to local packages
Before: [__0] rejecting: memory-0.18.0 (constraint from user target requires ==0.17.0) After: [__0] rejecting: memory-0.18.0 (constraint from cabal.project requires ==0.17.0)
- Loading branch information
Showing
46 changed files
with
1,781 additions
and
1,043 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
50 changes: 50 additions & 0 deletions
50
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,50 @@ | ||
{-# LANGUAGE DeriveFoldable #-} | ||
{-# LANGUAGE DeriveFunctor #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE DeriveTraversable #-} | ||
{-# 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, Traversable, Foldable, 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
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.