Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Cabal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
9b3686fb
Commit
9b3686fb
authored
May 14, 2020
by
Oleg Grenrus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add NonEmptySet and use it in Dependency
parent
8d9e8afe
Changes
58
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
58 changed files
with
731 additions
and
776 deletions
+731
-776
Cabal/Cabal-QuickCheck/Cabal-QuickCheck.cabal
Cabal/Cabal-QuickCheck/Cabal-QuickCheck.cabal
+3
-0
Cabal/Cabal-QuickCheck/src/Test/QuickCheck/Instances/Cabal.hs
...l/Cabal-QuickCheck/src/Test/QuickCheck/Instances/Cabal.hs
+17
-0
Cabal/Cabal-described/src/Distribution/Described.hs
Cabal/Cabal-described/src/Distribution/Described.hs
+1
-1
Cabal/Cabal-tree-diff/src/Data/TreeDiff/Instances/Cabal.hs
Cabal/Cabal-tree-diff/src/Data/TreeDiff/Instances/Cabal.hs
+11
-2
Cabal/Cabal.cabal
Cabal/Cabal.cabal
+4
-0
Cabal/Distribution/Backpack/ConfiguredComponent.hs
Cabal/Distribution/Backpack/ConfiguredComponent.hs
+2
-1
Cabal/Distribution/Compat/NonEmptySet.hs
Cabal/Distribution/Compat/NonEmptySet.hs
+128
-0
Cabal/Distribution/Compat/Prelude.hs
Cabal/Distribution/Compat/Prelude.hs
+2
-0
Cabal/Distribution/PackageDescription/Check.hs
Cabal/Distribution/PackageDescription/Check.hs
+1
-1
Cabal/Distribution/PackageDescription/Configuration.hs
Cabal/Distribution/PackageDescription/Configuration.hs
+14
-17
Cabal/Distribution/Parsec.hs
Cabal/Distribution/Parsec.hs
+4
-0
Cabal/Distribution/Simple/Build.hs
Cabal/Distribution/Simple/Build.hs
+1
-1
Cabal/Distribution/Simple/Configure.hs
Cabal/Distribution/Simple/Configure.hs
+4
-4
Cabal/Distribution/Types/Dependency.hs
Cabal/Distribution/Types/Dependency.hs
+24
-24
Cabal/Distribution/Types/DependencyMap.hs
Cabal/Distribution/Types/DependencyMap.hs
+4
-4
Cabal/Distribution/Types/PackageVersionConstraint.hs
Cabal/Distribution/Types/PackageVersionConstraint.hs
+7
-1
Cabal/Distribution/Utils/MD5.hs
Cabal/Distribution/Utils/MD5.hs
+25
-0
Cabal/tests/ParserTests/regressions/Octree-0.5.expr
Cabal/tests/ParserTests/regressions/Octree-0.5.expr
+20
-30
Cabal/tests/ParserTests/regressions/anynone.expr
Cabal/tests/ParserTests/regressions/anynone.expr
+2
-3
Cabal/tests/ParserTests/regressions/common-conditional.expr
Cabal/tests/ParserTests/regressions/common-conditional.expr
+18
-34
Cabal/tests/ParserTests/regressions/common.expr
Cabal/tests/ParserTests/regressions/common.expr
+4
-6
Cabal/tests/ParserTests/regressions/common2.expr
Cabal/tests/ParserTests/regressions/common2.expr
+26
-43
Cabal/tests/ParserTests/regressions/common3.expr
Cabal/tests/ParserTests/regressions/common3.expr
+8
-12
Cabal/tests/ParserTests/regressions/elif.expr
Cabal/tests/ParserTests/regressions/elif.expr
+2
-4
Cabal/tests/ParserTests/regressions/elif2.expr
Cabal/tests/ParserTests/regressions/elif2.expr
+4
-8
Cabal/tests/ParserTests/regressions/encoding-0.8.expr
Cabal/tests/ParserTests/regressions/encoding-0.8.expr
+4
-5
Cabal/tests/ParserTests/regressions/generics-sop.expr
Cabal/tests/ParserTests/regressions/generics-sop.expr
+25
-39
Cabal/tests/ParserTests/regressions/hidden-main-lib.expr
Cabal/tests/ParserTests/regressions/hidden-main-lib.expr
+2
-3
Cabal/tests/ParserTests/regressions/issue-5055.expr
Cabal/tests/ParserTests/regressions/issue-5055.expr
+4
-6
Cabal/tests/ParserTests/regressions/issue-5846.expr
Cabal/tests/ParserTests/regressions/issue-5846.expr
+40
-32
Cabal/tests/ParserTests/regressions/issue-6083-pkg-pkg.expr
Cabal/tests/ParserTests/regressions/issue-6083-pkg-pkg.expr
+4
-6
Cabal/tests/ParserTests/regressions/jaeger-flamegraph.expr
Cabal/tests/ParserTests/regressions/jaeger-flamegraph.expr
+30
-45
Cabal/tests/ParserTests/regressions/leading-comma-2.expr
Cabal/tests/ParserTests/regressions/leading-comma-2.expr
+12
-18
Cabal/tests/ParserTests/regressions/leading-comma.expr
Cabal/tests/ParserTests/regressions/leading-comma.expr
+12
-18
Cabal/tests/ParserTests/regressions/libpq1.expr
Cabal/tests/ParserTests/regressions/libpq1.expr
+10
-16
Cabal/tests/ParserTests/regressions/libpq2.expr
Cabal/tests/ParserTests/regressions/libpq2.expr
+10
-16
Cabal/tests/ParserTests/regressions/mixin-1.expr
Cabal/tests/ParserTests/regressions/mixin-1.expr
+6
-9
Cabal/tests/ParserTests/regressions/mixin-2.expr
Cabal/tests/ParserTests/regressions/mixin-2.expr
+6
-9
Cabal/tests/ParserTests/regressions/mixin-3.expr
Cabal/tests/ParserTests/regressions/mixin-3.expr
+6
-9
Cabal/tests/ParserTests/regressions/monad-param.expr
Cabal/tests/ParserTests/regressions/monad-param.expr
+6
-9
Cabal/tests/ParserTests/regressions/multiple-libs-2.expr
Cabal/tests/ParserTests/regressions/multiple-libs-2.expr
+4
-6
Cabal/tests/ParserTests/regressions/noVersion.expr
Cabal/tests/ParserTests/regressions/noVersion.expr
+2
-3
Cabal/tests/ParserTests/regressions/shake.expr
Cabal/tests/ParserTests/regressions/shake.expr
+118
-186
Cabal/tests/ParserTests/regressions/th-lift-instances.expr
Cabal/tests/ParserTests/regressions/th-lift-instances.expr
+38
-57
Cabal/tests/ParserTests/regressions/version-sets.expr
Cabal/tests/ParserTests/regressions/version-sets.expr
+16
-24
Cabal/tests/ParserTests/regressions/wl-pprint-indef.expr
Cabal/tests/ParserTests/regressions/wl-pprint-indef.expr
+10
-15
Cabal/tests/UnitTests/Distribution/Utils/Structured.hs
Cabal/tests/UnitTests/Distribution/Utils/Structured.hs
+5
-5
Makefile
Makefile
+3
-0
cabal-install/Distribution/Client/CmdRepl.hs
cabal-install/Distribution/Client/CmdRepl.hs
+2
-4
cabal-install/Distribution/Client/Dependency.hs
cabal-install/Distribution/Client/Dependency.hs
+1
-2
cabal-install/Distribution/Client/Init/Command.hs
cabal-install/Distribution/Client/Init/Command.hs
+2
-5
cabal-install/Distribution/Client/Init/FileCreators.hs
cabal-install/Distribution/Client/Init/FileCreators.hs
+2
-8
cabal-install/Distribution/Client/Install.hs
cabal-install/Distribution/Client/Install.hs
+2
-4
cabal-install/Distribution/Client/Outdated.hs
cabal-install/Distribution/Client/Outdated.hs
+3
-7
cabal-install/Distribution/Client/ProjectPlanning.hs
cabal-install/Distribution/Client/ProjectPlanning.hs
+4
-4
cabal-install/solver-dsl/UnitTests/Distribution/Solver/Modular/DSL.hs
...l/solver-dsl/UnitTests/Distribution/Solver/Modular/DSL.hs
+1
-2
cabal-install/tests/UnitTests/Distribution/Client/Init/FileCreators.hs
.../tests/UnitTests/Distribution/Client/Init/FileCreators.hs
+4
-7
cabal-testsuite/PackageTests/MultipleLibraries/cabal.out
cabal-testsuite/PackageTests/MultipleLibraries/cabal.out
+1
-1
No files found.
Cabal/Cabal-QuickCheck/Cabal-QuickCheck.cabal
View file @
9b3686fb
...
...
@@ -15,6 +15,9 @@ library
, Cabal ^>=3.3.0.0
, QuickCheck ^>=2.13.2
if !impl(ghc >= 8.0)
build-depends: semigroups
exposed-modules:
Test.QuickCheck.GenericArbitrary
Test.QuickCheck.Instances.Cabal
Cabal/Cabal-QuickCheck/src/Test/QuickCheck/Instances/Cabal.hs
View file @
9b3686fb
...
...
@@ -6,10 +6,12 @@ module Test.QuickCheck.Instances.Cabal () where
import
Control.Applicative
(
liftA2
)
import
Data.Char
(
isAlphaNum
,
isDigit
)
import
Data.List
(
intercalate
)
import
Data.List.NonEmpty
(
NonEmpty
(
..
))
import
Distribution.Utils.Generic
(
lowercase
)
import
Test.QuickCheck
import
Distribution.CabalSpecVersion
import
Distribution.Compat.NonEmptySet
(
NonEmptySet
)
import
Distribution.Compiler
import
Distribution.FieldGrammar.Newtypes
import
Distribution.ModuleName
...
...
@@ -30,6 +32,8 @@ import Distribution.Version
import
Test.QuickCheck.GenericArbitrary
import
qualified
Distribution.Compat.NonEmptySet
as
NES
#
if
!
MIN_VERSION_base
(
4
,
8
,
0
)
import
Control.Applicative
(
pure
,
(
<$>
),
(
<*>
))
#
endif
...
...
@@ -332,6 +336,19 @@ instance Arbitrary CompilerId where
arbitrary
=
genericArbitrary
shrink
=
genericShrink
-------------------------------------------------------------------------------
-- NonEmptySet
-------------------------------------------------------------------------------
instance
(
Arbitrary
a
,
Ord
a
)
=>
Arbitrary
(
NonEmptySet
a
)
where
arbitrary
=
mk
<$>
arbitrary
<*>
arbitrary
where
mk
x
xs
=
NES
.
fromNonEmpty
(
x
:|
xs
)
shrink
nes
=
case
NES
.
toNonEmpty
nes
of
x
:|
xs
->
map
mk
(
shrink
(
x
,
xs
))
where
mk
(
x
,
xs
)
=
NES
.
fromNonEmpty
(
x
:|
xs
)
-------------------------------------------------------------------------------
-- Helpers
-------------------------------------------------------------------------------
...
...
Cabal/Cabal-described/src/Distribution/Described.hs
View file @
9b3686fb
...
...
@@ -372,7 +372,7 @@ instance Described Dependency where
[
reChar
'{'
,
RESpaces
-- no leading or trailing comma
,
REMunch
reSpacedComma
reUnqualComponent
,
REMunch
1
reSpacedComma
reUnqualComponent
,
RESpaces
,
reChar
'}'
]
...
...
Cabal/Cabal-tree-diff/src/Data/TreeDiff/Instances/Cabal.hs
View file @
9b3686fb
...
...
@@ -20,7 +20,7 @@ import Distribution.CabalSpecVersion (CabalSpecVersion)
import
Distribution.Compiler
(
CompilerFlavor
,
CompilerId
,
PerCompilerFlavor
)
import
Distribution.InstalledPackageInfo
(
AbiDependency
,
ExposedModule
,
InstalledPackageInfo
)
import
Distribution.ModuleName
(
ModuleName
)
import
Distribution.Package
(
Dependency
,
PackageIdentifier
,
PackageName
)
import
Distribution.Package
(
PackageIdentifier
,
PackageName
)
import
Distribution.PackageDescription
import
Distribution.Simple.Compiler
(
DebugInfoLevel
,
OptimisationLevel
,
ProfDetailLevel
)
import
Distribution.Simple.Flag
(
Flag
)
...
...
@@ -31,6 +31,7 @@ import Distribution.System
import
Distribution.Types.AbiHash
(
AbiHash
)
import
Distribution.Types.ComponentId
(
ComponentId
)
import
Distribution.Types.CondTree
import
Distribution.Types.Dependency
(
Dependency
(
..
),
mainLibSet
)
import
Distribution.Types.ExecutableScope
import
Distribution.Types.ExeDependency
import
Distribution.Types.ForeignLib
...
...
@@ -52,6 +53,8 @@ import Distribution.Utils.ShortText (ShortText, fromShortText)
import
Distribution.Verbosity
import
Distribution.Verbosity.Internal
import
qualified
Distribution.Compat.NonEmptySet
as
NES
-------------------------------------------------------------------------------
-- instances
-------------------------------------------------------------------------------
...
...
@@ -61,9 +64,16 @@ instance (Show a, ToExpr b, ToExpr c, Show b, Show c, Eq a, Eq c, Eq b) => ToExp
instance
(
Show
a
,
ToExpr
b
,
ToExpr
c
,
Show
b
,
Show
c
,
Eq
a
,
Eq
c
,
Eq
b
)
=>
ToExpr
(
CondBranch
a
b
c
)
instance
(
ToExpr
a
)
=>
ToExpr
(
NubList
a
)
instance
(
ToExpr
a
)
=>
ToExpr
(
Flag
a
)
instance
ToExpr
a
=>
ToExpr
(
NES
.
NonEmptySet
a
)
where
toExpr
xs
=
App
"NonEmptySet.fromNonEmpty"
[
toExpr
$
NES
.
toNonEmpty
xs
]
instance
ToExpr
a
=>
ToExpr
(
PerCompilerFlavor
a
)
instance
ToExpr
Dependency
where
toExpr
d
@
(
Dependency
pn
vr
cs
)
|
cs
==
mainLibSet
=
App
"Dependency"
[
toExpr
pn
,
toExpr
vr
,
App
"mainLibSet"
[]
]
|
otherwise
=
genericToExpr
d
instance
ToExpr
AbiDependency
instance
ToExpr
AbiHash
instance
ToExpr
Arch
...
...
@@ -78,7 +88,6 @@ instance ToExpr CompilerId
instance
ToExpr
ComponentId
instance
ToExpr
DebugInfoLevel
instance
ToExpr
DefUnitId
instance
ToExpr
Dependency
instance
ToExpr
ExeDependency
instance
ToExpr
Executable
instance
ToExpr
ExecutableScope
...
...
Cabal/Cabal.cabal
View file @
9b3686fb
...
...
@@ -352,6 +352,7 @@ library
Distribution.Compat.Graph
Distribution.Compat.Internal.TempFile
Distribution.Compat.Newtype
Distribution.Compat.NonEmptySet
Distribution.Compat.ResponseFile
Distribution.Compat.Prelude.Internal
Distribution.Compat.Process
...
...
@@ -693,6 +694,9 @@ test-suite unit-tests
if !impl(ghc >= 7.10)
build-depends: void
if !impl(ghc >= 8.0)
build-depends: semigroups
test-suite parser-tests
type: exitcode-stdio-1.0
hs-source-dirs: tests
...
...
Cabal/Distribution/Backpack/ConfiguredComponent.hs
View file @
9b3686fb
...
...
@@ -45,6 +45,7 @@ import Distribution.Utils.Generic
import
Control.Monad
import
qualified
Data.Set
as
Set
import
qualified
Distribution.Compat.NonEmptySet
as
NonEmptySet
import
qualified
Data.Map
as
Map
import
Distribution.Pretty
import
Text.PrettyPrint
...
...
@@ -179,7 +180,7 @@ toConfiguredComponent pkg_descr this_cid lib_dep_map exe_dep_map component = do
text
"package"
<+>
pretty
pn
Just
p
->
return
p
-- Return all library components
forM
(
Set
.
toList
sublibs
)
$
\
lib
->
forM
(
NonEmpty
Set
.
toList
sublibs
)
$
\
lib
->
let
comp
=
CLibName
lib
in
case
Map
.
lookup
(
CLibName
$
LSubLibName
$
packageNameToUnqualComponentName
name
)
pkg
...
...
Cabal/Distribution/Compat/NonEmptySet.hs
0 → 100644
View file @
9b3686fb
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-}
module
Distribution.Compat.NonEmptySet
(
NonEmptySet
,
-- * Construction
singleton
,
-- * Conversions
toNonEmpty
,
fromNonEmpty
,
toList
,
-- * Query
member
,
-- * Map
map
,
)
where
import
Prelude
(
Bool
(
..
),
Eq
,
Ord
(
..
),
Read
,
Show
(
..
),
String
,
error
,
return
,
showParen
,
showString
,
(
$
),
(
++
),
(
.
))
import
Control.DeepSeq
(
NFData
(
..
))
import
Data.Data
(
Data
)
import
Data.List.NonEmpty
(
NonEmpty
(
..
))
import
Data.Semigroup
(
Semigroup
(
..
))
import
Data.Typeable
(
Typeable
)
import
qualified
Data.Foldable
as
F
import
qualified
Data.Set
as
Set
import
Distribution.Compat.Binary
(
Binary
(
..
))
import
Distribution.Utils.Structured
#
if
MIN_VERSION_binary
(
0
,
6
,
0
)
import
Control.Applicative
(
empty
)
#
else
import
Control.Monad
(
fail
)
#
endif
newtype
NonEmptySet
a
=
NES
(
Set
.
Set
a
)
deriving
(
Eq
,
Ord
,
Typeable
,
Data
,
Read
)
-------------------------------------------------------------------------------
-- Instances
-------------------------------------------------------------------------------
instance
Show
a
=>
Show
(
NonEmptySet
a
)
where
showsPrec
d
s
=
showParen
(
d
>
10
)
$
showString
"fromNonEmpty "
.
showsPrec
11
(
toNonEmpty
s
)
instance
Binary
a
=>
Binary
(
NonEmptySet
a
)
where
put
(
NES
s
)
=
put
s
get
=
do
xs
<-
get
if
Set
.
null
xs
#
if
MIN_VERSION_binary
(
0
,
6
,
0
)
then
empty
#
else
then
fail
"NonEmptySet: empty"
#
endif
else
return
(
NES
xs
)
instance
Structured
a
=>
Structured
(
NonEmptySet
a
)
where
structure
=
containerStructure
instance
NFData
a
=>
NFData
(
NonEmptySet
a
)
where
rnf
(
NES
x
)
=
rnf
x
-- | Note: there aren't @Monoid@ instance.
instance
Ord
a
=>
Semigroup
(
NonEmptySet
a
)
where
NES
x
<>
NES
y
=
NES
(
Set
.
union
x
y
)
instance
F
.
Foldable
NonEmptySet
where
foldMap
f
(
NES
s
)
=
F
.
foldMap
f
s
foldr
f
z
(
NES
s
)
=
F
.
foldr
f
z
s
#
if
MIN_VERSION_base
(
4
,
8
,
0
)
toList
=
toList
null
_
=
False
length
(
NES
s
)
=
F
.
length
s
#
endif
-------------------------------------------------------------------------------
-- Constructors
-------------------------------------------------------------------------------
singleton
::
a
->
NonEmptySet
a
singleton
=
NES
.
Set
.
singleton
-------------------------------------------------------------------------------
-- Conversions
-------------------------------------------------------------------------------
fromNonEmpty
::
Ord
a
=>
NonEmpty
a
->
NonEmptySet
a
fromNonEmpty
(
x
:|
xs
)
=
NES
(
Set
.
fromList
(
x
:
xs
))
toNonEmpty
::
NonEmptySet
a
->
NonEmpty
a
toNonEmpty
(
NES
s
)
=
case
Set
.
toList
s
of
[]
->
panic
"toNonEmpty"
x
:
xs
->
x
:|
xs
toList
::
NonEmptySet
a
->
[
a
]
toList
(
NES
s
)
=
Set
.
toList
s
-------------------------------------------------------------------------------
-- Query
-------------------------------------------------------------------------------
member
::
Ord
a
=>
a
->
NonEmptySet
a
->
Bool
member
x
(
NES
xs
)
=
Set
.
member
x
xs
-------------------------------------------------------------------------------
-- Map
-------------------------------------------------------------------------------
map
::
(
Ord
b
#
if
!
MIN_VERSION_containers
(
0
,
5
,
2
)
,
Ord
a
#
endif
)
=>
(
a
->
b
)
->
NonEmptySet
a
->
NonEmptySet
b
map
f
(
NES
x
)
=
NES
(
Set
.
map
f
x
)
-------------------------------------------------------------------------------
-- Internal
-------------------------------------------------------------------------------
panic
::
String
->
a
panic
msg
=
error
$
"NonEmptySet invariant violated: "
++
msg
Cabal/Distribution/Compat/Prelude.hs
View file @
9b3686fb
...
...
@@ -47,6 +47,7 @@ module Distribution.Compat.Prelude (
-- * Some types
Map
,
Set
,
NonEmptySet
,
Identity
(
..
),
Proxy
(
..
),
Void
,
...
...
@@ -171,6 +172,7 @@ import Text.Read (readMaybe)
import
qualified
Text.PrettyPrint
as
Disp
import
Distribution.Utils.Structured
(
Structured
)
import
Distribution.Compat.NonEmptySet
(
NonEmptySet
)
-- | New name for 'Text.PrettyPrint.<>'
(
<<>>
)
::
Disp
.
Doc
->
Disp
.
Doc
->
Disp
.
Doc
...
...
Cabal/Distribution/PackageDescription/Check.hs
View file @
9b3686fb
...
...
@@ -594,7 +594,7 @@ checkFields pkg =
,
name
`
elem
`
map
prettyShow
knownLanguages
]
testedWithImpossibleRanges
=
[
Dependency
(
mkPackageName
(
prettyShow
compiler
))
vr
Set
.
empty
[
Dependency
(
mkPackageName
(
prettyShow
compiler
))
vr
mainLibSet
|
(
compiler
,
vr
)
<-
testedWith
pkg
,
isNoVersion
vr
]
...
...
Cabal/Distribution/PackageDescription/Configuration.hs
View file @
9b3686fb
...
...
@@ -64,9 +64,7 @@ import Distribution.Types.CondTree
import
Distribution.Types.Condition
import
Distribution.Types.DependencyMap
import
qualified
Data.Map.Strict
as
Map.Strict
import
qualified
Data.Map.Lazy
as
Map
import
qualified
Data.Set
as
Set
import
Data.Tree
(
Tree
(
Node
)
)
------------------------------------------------------------------------------
...
...
@@ -188,7 +186,7 @@ resolveWithFlags dom enabled os arch impl constrs trees checkDeps =
either
(
Left
.
fromDepMapUnion
)
Right
$
explore
(
build
mempty
dom
)
where
extraConstrs
=
toDepMap
[
Dependency
pn
ver
m
empty
[
Dependency
pn
ver
m
ainLibSet
|
PackageVersionConstraint
pn
ver
<-
constrs
]
...
...
@@ -232,11 +230,7 @@ resolveWithFlags dom enabled os arch impl constrs trees checkDeps =
mp
::
Either
DepMapUnion
a
->
Either
DepMapUnion
a
->
Either
DepMapUnion
a
mp
m
@
(
Right
_
)
_
=
m
mp
_
m
@
(
Right
_
)
=
m
mp
(
Left
xs
)
(
Left
ys
)
=
let
union
=
Map
.
foldrWithKey
(
Map
.
Strict
.
insertWith
combine
)
(
unDepMapUnion
xs
)
(
unDepMapUnion
ys
)
combine
x
y
=
(
\
(
vr
,
cs
)
->
(
simplifyVersionRange
vr
,
cs
))
$
unionVersionRanges'
x
y
in
union
`
seq
`
Left
(
DepMapUnion
union
)
mp
(
Left
xs
)
(
Left
ys
)
=
Left
(
xs
<>
ys
)
-- `mzero'
mz
::
Either
DepMapUnion
a
...
...
@@ -312,21 +306,24 @@ extractConditions f gpkg =
]
-- | A map of
dependencie
s that combines version ranges using 'unionVersionRanges'.
newtype
DepMapUnion
=
DepMapUnion
{
unDepMapUnion
::
Map
PackageName
(
VersionRange
,
Set
LibraryName
)
}
-- | A map of
package constraint
s that combines version ranges using 'unionVersionRanges'.
newtype
DepMapUnion
=
DepMapUnion
{
unDepMapUnion
::
Map
PackageName
(
VersionRange
,
NonEmpty
Set
LibraryName
)
}
-- An union of versions should correspond to an intersection of the components.
-- The intersection may not be necessary.
unionVersionRanges'
::
(
VersionRange
,
Set
LibraryName
)
->
(
VersionRange
,
Set
LibraryName
)
->
(
VersionRange
,
Set
LibraryName
)
unionVersionRanges'
(
vra
,
csa
)
(
vrb
,
csb
)
=
(
unionVersionRanges
vra
vrb
,
Set
.
intersection
csa
csb
)
instance
Semigroup
DepMapUnion
where
DepMapUnion
x
<>
DepMapUnion
y
=
DepMapUnion
$
Map
.
unionWith
unionVersionRanges'
x
y
unionVersionRanges'
::
(
VersionRange
,
NonEmptySet
LibraryName
)
->
(
VersionRange
,
NonEmptySet
LibraryName
)
->
(
VersionRange
,
NonEmptySet
LibraryName
)
unionVersionRanges'
(
vr
,
cs
)
(
vr'
,
cs'
)
=
(
unionVersionRanges
vr
vr'
,
cs
<>
cs'
)
toDepMapUnion
::
[
Dependency
]
->
DepMapUnion
toDepMapUnion
ds
=
DepMapUnion
$
Map
.
fromListWith
unionVersionRanges'
[
(
p
,(
vr
,
cs
))
|
Dependency
p
vr
cs
<-
ds
]
fromDepMapUnion
::
DepMapUnion
->
[
Dependency
]
fromDepMapUnion
m
=
[
Dependency
p
vr
cs
|
(
p
,(
vr
,
cs
))
<-
Map
.
toList
(
unDepMapUnion
m
)
]
...
...
Cabal/Distribution/Parsec.hs
View file @
9b3686fb
...
...
@@ -39,6 +39,7 @@ module Distribution.Parsec (
parsecQuoted
,
parsecMaybeQuoted
,
parsecCommaList
,
parsecCommaNonEmpty
,
parsecLeadingCommaList
,
parsecLeadingCommaNonEmpty
,
parsecOptCommaList
,
...
...
@@ -293,6 +294,9 @@ parsecStandard f = do
parsecCommaList
::
CabalParsing
m
=>
m
a
->
m
[
a
]
parsecCommaList
p
=
P
.
sepBy
(
p
<*
P
.
spaces
)
(
P
.
char
','
*>
P
.
spaces
P
.<?>
"comma"
)
parsecCommaNonEmpty
::
CabalParsing
m
=>
m
a
->
m
(
NonEmpty
a
)
parsecCommaNonEmpty
p
=
P
.
sepByNonEmpty
(
p
<*
P
.
spaces
)
(
P
.
char
','
*>
P
.
spaces
P
.<?>
"comma"
)
-- | Like 'parsecCommaList' but accept leading or trailing comma.
--
-- @
...
...
Cabal/Distribution/Simple/Build.hs
View file @
9b3686fb
...
...
@@ -549,7 +549,7 @@ testSuiteLibV09AsLibAndExe pkg_descr
testLibDep
=
Dependency
pkgName'
(
thisVersion
$
pkgVersion
$
package
pkg_descr
)
(
Set
.
singleton
LMainLibName
)
mainLibSet
exe
=
Executable
{
exeName
=
mkUnqualComponentName
$
stubName
test
,
modulePath
=
stubFilePath
test
,
...
...
Cabal/Distribution/Simple/Configure.hs
View file @
9b3686fb
...
...
@@ -146,7 +146,7 @@ import Text.PrettyPrint
import
Distribution.Compat.Environment
(
lookupEnv
)
import
Distribution.Compat.Exception
(
catchExit
,
catchIO
)
import
qualified
D
ata.Set
as
Set
import
qualified
D
istribution.Compat.NonEmptySet
as
NonEmpty
Set
type
UseExternalInternalDeps
=
Bool
...
...
@@ -936,7 +936,7 @@ dependencySatisfiable
then
True
else
-- Backward compatibility for the old sublibrary syntax
(
sublibs
==
Set
.
singleton
LMainLibName
(
sublibs
==
mainLibSet
&&
Map
.
member
(
pn
,
CLibName
$
LSubLibName
$
packageNameToUnqualComponentName
depName
)
...
...
@@ -1291,10 +1291,10 @@ selectDependency pkgid internalIndex installedIndex requiredDepsMap
case
Map
.
lookup
dep_pkgname
internalIndex
of
Just
cname
->
if
use_external_internal_deps
then
do_external
(
Just
$
maybeToLibraryName
cname
)
<$>
Set
.
toList
libs
then
do_external
(
Just
$
maybeToLibraryName
cname
)
<$>
NonEmpty
Set
.
toList
libs
else
do_internal
_
->
do_external
Nothing
<$>
Set
.
toList
libs
do_external
Nothing
<$>
NonEmpty
Set
.
toList
libs
where
-- It's an internal library, and we're not per-component build
...
...
Cabal/Distribution/Types/Dependency.hs
View file @
9b3686fb
...
...
@@ -7,14 +7,14 @@ module Distribution.Types.Dependency
,
depVerRange
,
depLibraries
,
simplifyDependency
,
mainLibSet
)
where
import
Distribution.Compat.Prelude
import
Prelude
()
import
Distribution.Version
(
VersionRange
,
anyVersion
,
simplifyVersionRange
)
import
Distribution.Types.VersionRange
(
isAnyVersionLight
)
import
Distribution.Version
(
VersionRange
,
anyVersion
,
simplifyVersionRange
)
import
Distribution.CabalSpecVersion
import
Distribution.Compat.CharParsing
(
char
,
spaces
)
...
...
@@ -26,8 +26,8 @@ import Distribution.Types.PackageName
import
Distribution.Types.UnqualComponentName
import
Text.PrettyPrint
((
<+>
))
import
qualified
D
ata.Set
as
Set
import
qualified
Text.PrettyPrint
as
PP
import
qualified
D
istribution.Compat.NonEmptySet
as
NonEmpty
Set
import
qualified
Text.PrettyPrint
as
PP
-- | Describes a dependency on a source package (API)
--
...
...
@@ -37,7 +37,7 @@ import qualified Text.PrettyPrint as PP
data
Dependency
=
Dependency
PackageName
VersionRange
(
Set
LibraryName
)
(
NonEmpty
Set
LibraryName
)
-- ^ The set of libraries required from the package.
-- Only the selected libraries will be built.
-- It does not affect the cabal-install solver yet.
...
...
@@ -49,7 +49,7 @@ depPkgName (Dependency pn _ _) = pn
depVerRange
::
Dependency
->
VersionRange
depVerRange
(
Dependency
_
vr
_
)
=
vr
depLibraries
::
Dependency
->
Set
LibraryName
depLibraries
::
Dependency
->
NonEmpty
Set
LibraryName
depLibraries
(
Dependency
_
_
cs
)
=
cs
-- | Smart constructor of 'Dependency'.
...
...
@@ -59,8 +59,8 @@ depLibraries (Dependency _ _ cs) = cs
--
-- @since 3.4.0.0
--
mkDependency
::
PackageName
->
VersionRange
->
Set
LibraryName
->
Dependency
mkDependency
pn
vr
lb
=
Dependency
pn
vr
(
Set
.
map
conv
lb
)
mkDependency
::
PackageName
->
VersionRange
->
NonEmpty
Set
LibraryName
->
Dependency
mkDependency
pn
vr
lb
=
Dependency
pn
vr
(
NonEmpty
Set
.
map
conv
lb
)
where
pn'
=
packageNameToUnqualComponentName
pn
...
...
@@ -80,10 +80,10 @@ instance Pretty Dependency where
|
otherwise
=
pretty
ver
withSubLibs
doc
|
sublibs
==
mainLib
=
doc
|
sublibs
==
mainLib
Set
=
doc
|
otherwise
=
doc
<<>>
PP
.
colon
<<>>
PP
.
braces
prettySublibs
prettySublibs
=
PP
.
hsep
$
PP
.
punctuate
PP
.
comma
$
prettySublib
<$>
Set
.
toList
sublibs
prettySublibs
=
PP
.
hsep
$
PP
.
punctuate
PP
.
comma
$
prettySublib
<$>
NonEmpty
Set
.
toList
sublibs
prettySublib
LMainLibName
=
PP
.
text
$
unPackageName
name
prettySublib
(
LSubLibName
un
)
=
PP
.
text
$
unUnqualComponentName
un
...
...
@@ -91,24 +91,24 @@ instance Pretty Dependency where
-- |
--
-- >>> simpleParsec "mylib:sub" :: Maybe Dependency
-- Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (from
List [LSubLibName (UnqualComponentName "sub")]
))
-- Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (from
NonEmpty (LSubLibName (UnqualComponentName "sub") :| [])
))
--
-- >>> simpleParsec "mylib:{sub1,sub2}" :: Maybe Dependency
-- Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (from
List [LSubLibName (UnqualComponentName "sub1"),LSubLibName (UnqualComponentName "sub2")]
))
-- Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (from
NonEmpty (LSubLibName (UnqualComponentName "sub1") :| [LSubLibName (UnqualComponentName "sub2")])
))
--
-- >>> simpleParsec "mylib:{ sub1 , sub2 }" :: Maybe Dependency
-- Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (from
List [LSubLibName (UnqualComponentName "sub1"),LSubLibName (UnqualComponentName "sub2")]
))
-- Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (from
NonEmpty (LSubLibName (UnqualComponentName "sub1") :| [LSubLibName (UnqualComponentName "sub2")])
))
--
-- >>> simpleParsec "mylib:{ sub1 , sub2 } ^>= 42" :: Maybe Dependency
-- Just (Dependency (PackageName "mylib") (MajorBoundVersion (mkVersion [42])) (from
List [LSubLibName (UnqualComponentName "sub1"),LSubLibName (UnqualComponentName "sub2")]
))
-- Just (Dependency (PackageName "mylib") (MajorBoundVersion (mkVersion [42])) (from
NonEmpty (LSubLibName (UnqualComponentName "sub1") :| [LSubLibName (UnqualComponentName "sub2")])
))
--
-- >>> simpleParsec "mylib:{ } ^>= 42" :: Maybe Dependency
--
Just (Dependency (PackageName "mylib") (MajorBoundVersion (mkVersion [42])) (fromList []))
--
Nothing
--
-- >>> traverse_ print (map simpleParsec ["mylib:mylib", "mylib:{mylib}", "mylib:{mylib,sublib}" ] :: [Maybe Dependency])
-- Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (from
List [LMainLibName]
))
-- Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (from
List [LMainLibName]
))
-- Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (from
List [LMainLibName,LSubLibName (UnqualComponentName "sublib")]
))
-- Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (from
NonEmpty (LMainLibName :| [])
))
-- Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (from
NonEmpty (LMainLibName :| [])
))
-- Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (from
NonEmpty (LMainLibName :| [LSubLibName (UnqualComponentName "sublib")])
))
--
-- Spaces around colon are not allowed:
--
...
...
@@ -118,17 +118,17 @@ instance Pretty Dependency where
-- Sublibrary syntax is accepted since @cabal-version: 3.0@
--
-- >>> map (`simpleParsec'` "mylib:sub") [CabalSpecV2_4, CabalSpecV3_0] :: [Maybe Dependency]
-- [Nothing,Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (from
List [LSubLibName (UnqualComponentName "sub")]
))]
-- [Nothing,Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (from
NonEmpty (LSubLibName (UnqualComponentName "sub") :| [])
))]
--
instance
Parsec
Dependency
where
parsec
=
do
name
<-
parsec
libs
<-
option
mainLib
$
do
libs
<-
option
mainLib
Set
$
do
_
<-
char
':'
versionGuardMultilibs
parsecWarning
PWTExperimental
"colon specifier is experimental feature (issue #5660)"
Set
.
singleton
<$>
parseLib
<|>
parseMultipleLibs
NonEmpty
Set
.
singleton
<$>
parseLib
<|>
parseMultipleLibs
spaces
-- https://github.com/haskell/cabal/issues/5846
...
...
@@ -139,7 +139,7 @@ instance Parsec Dependency where
parseMultipleLibs
=
between
(
char
'{'
*>
spaces
)
(
spaces
*>
char
'}'
)
(
Set
.
fromList
<$>
parsecCommaList
parseLib
)
(
NonEmptySet
.
fromNonEmpty
<$>
parsecCommaNonEmpty
parseLib
)
versionGuardMultilibs
::
CabalParsing
m
=>
m
()
versionGuardMultilibs
=
do
...
...
@@ -152,8 +152,8 @@ versionGuardMultilibs = do
]
-- | Library set with main library.
mainLib
::
Set
LibraryName
mainLib
=
Set
.
singleton
LMainLibName
mainLib
Set
::
NonEmpty
Set
LibraryName
mainLib
Set
=
NonEmpty
Set
.
singleton
LMainLibName
-- | Simplify the 'VersionRange' expression in a 'Dependency'.
-- See 'simplifyVersionRange'.
...
...
Cabal/Distribution/Types/DependencyMap.hs
View file @
9b3686fb
...
...
@@ -17,7 +17,7 @@ import qualified Data.Map.Lazy as Map
-- | A map of dependencies. Newtyped since the default monoid instance is not
-- appropriate. The monoid instance uses 'intersectVersionRanges'.
newtype
DependencyMap
=
DependencyMap
{
unDependencyMap
::
Map
PackageName
(
VersionRange
,
Set
LibraryName
)
}
newtype
DependencyMap
=
DependencyMap
{
unDependencyMap
::
Map
PackageName
(
VersionRange
,
NonEmpty
Set
LibraryName
)
}
deriving
(
Show
,
Read
)
instance
Monoid
DependencyMap
where
...
...
@@ -28,9 +28,9 @@ instance Semigroup DependencyMap where
(
DependencyMap
a
)
<>
(
DependencyMap
b
)
=
DependencyMap
(
Map
.
unionWith
intersectVersionRangesAndJoinComponents
a
b
)
intersectVersionRangesAndJoinComponents
::
(
VersionRange
,
Set
LibraryName
)
->
(
VersionRange
,
Set
LibraryName
)
->
(
VersionRange
,
Set
LibraryName
)
intersectVersionRangesAndJoinComponents
::
(
VersionRange
,
NonEmpty
Set
LibraryName
)
->
(
VersionRange
,
NonEmpty
Set
LibraryName
)
->
(
VersionRange
,
NonEmpty
Set
LibraryName
)
intersectVersionRangesAndJoinComponents
(
va
,
ca
)
(
vb
,
cb
)
=
(
intersectVersionRanges
va
vb
,
ca
<>
cb
)
...
...
Cabal/Distribution/Types/PackageVersionConstraint.hs
View file @
9b3686fb
...
...
@@ -3,6 +3,7 @@
module
Distribution.Types.PackageVersionConstraint
(
PackageVersionConstraint
(
..
),
thisPackageVersionConstraint
,
simplifyPackageVersionConstraint
,
)
where
import
Distribution.Compat.Prelude
...
...
@@ -10,10 +11,11 @@ import Prelude ()
import
Distribution.Parsec
import
Distribution.Pretty
import
Distribution.Types.PackageName
import
Distribution.Types.PackageId
import
Distribution.Types.PackageName
import
Distribution.Types.Version
import
Distribution.Types.VersionRange.Internal
import
Distribution.Version
(
simplifyVersionRange
)
import
qualified
Distribution.Compat.CharParsing
as
P
import
Text.PrettyPrint
((
<+>
))
...
...
@@ -66,3 +68,7 @@ instance Parsec PackageVersionConstraint where
thisPackageVersionConstraint
::
PackageIdentifier
->
PackageVersionConstraint