Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Cabal
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Glasgow Haskell Compiler
Packages
Cabal
Commits
e69aafa8
Commit
e69aafa8
authored
8 years ago
by
John Ericson
Browse files
Options
Downloads
Patches
Plain Diff
finalizedPD: Simplify with Either monad
parent
15c935ab
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Cabal/Distribution/PackageDescription/Configuration.hs
+24
-32
24 additions, 32 deletions
Cabal/Distribution/PackageDescription/Configuration.hs
with
24 additions
and
32 deletions
Cabal/Distribution/PackageDescription/Configuration.hs
+
24
−
32
View file @
e69aafa8
...
...
@@ -426,21 +426,30 @@ finalizePD ::
-- description along with the flag assignments chosen.
finalizePD
userflags
enabled
satisfyDep
(
Platform
arch
os
)
impl
constraints
(
GenericPackageDescription
pkg
flags
mb_lib0
sub_libs0
flibs0
exes0
tests0
bms0
)
=
case
resolveFlags
of
Right
((
mb_lib'
,
comps'
),
targetSet
,
flagVals
)
->
let
(
sub_libs'
,
flibs'
,
exes'
,
tests'
,
bms'
)
=
partitionComponents
comps'
in
Right
(
pkg
{
library
=
mb_lib'
,
subLibraries
=
sub_libs'
,
foreignLibs
=
flibs'
,
executables
=
exes'
,
testSuites
=
tests'
,
benchmarks
=
bms'
,
buildDepends
=
fromDepMap
(
overallDependencies
enabled
targetSet
)
}
,
flagVals
)
Left
missing
->
Left
missing
(
GenericPackageDescription
pkg
flags
mb_lib0
sub_libs0
flibs0
exes0
tests0
bms0
)
=
do
(
targetSet
,
flagVals
)
<-
resolveWithFlags
flagChoices
enabled
os
arch
impl
constraints
condTrees
check
let
(
mb_lib
,
comps
)
=
flattenTaggedTargets
targetSet
mb_lib'
=
fmap
libFillInDefaults
mb_lib
comps'
=
flip
map
comps
$
\
(
n
,
c
)
->
foldComponent
(
\
l
->
CLib
(
libFillInDefaults
l
)
{
libName
=
Just
n
,
libExposed
=
False
})
(
\
l
->
CFLib
(
flibFillInDefaults
l
)
{
foreignLibName
=
n
})
(
\
e
->
CExe
(
exeFillInDefaults
e
)
{
exeName
=
n
})
(
\
t
->
CTest
(
testFillInDefaults
t
)
{
testName
=
n
})
(
\
b
->
CBench
(
benchFillInDefaults
b
)
{
benchmarkName
=
n
})
c
(
sub_libs'
,
flibs'
,
exes'
,
tests'
,
bms'
)
=
partitionComponents
comps'
return
(
pkg
{
library
=
mb_lib'
,
subLibraries
=
sub_libs'
,
foreignLibs
=
flibs'
,
executables
=
exes'
,
testSuites
=
tests'
,
benchmarks
=
bms'
,
buildDepends
=
fromDepMap
(
overallDependencies
enabled
targetSet
)
}
,
flagVals
)
where
-- Combine lib, exes, and tests into one list of @CondTree@s with tagged data
condTrees
=
maybeToList
(
fmap
(
mapTreeData
Lib
)
mb_lib0
)
...
...
@@ -450,23 +459,6 @@ finalizePD userflags enabled satisfyDep
++
map
(
\
(
name
,
tree
)
->
mapTreeData
(
SubComp
name
.
CTest
)
tree
)
tests0
++
map
(
\
(
name
,
tree
)
->
mapTreeData
(
SubComp
name
.
CBench
)
tree
)
bms0
resolveFlags
=
case
resolveWithFlags
flagChoices
enabled
os
arch
impl
constraints
condTrees
check
of
Right
(
targetSet
,
fs
)
->
let
(
mb_lib
,
comps
)
=
flattenTaggedTargets
targetSet
in
Right
(
(
fmap
libFillInDefaults
mb_lib
,
map
(
\
(
n
,
c
)
->
foldComponent
(
\
l
->
CLib
(
libFillInDefaults
l
)
{
libName
=
Just
n
,
libExposed
=
False
})
(
\
l
->
CFLib
(
flibFillInDefaults
l
)
{
foreignLibName
=
n
})
(
\
e
->
CExe
(
exeFillInDefaults
e
)
{
exeName
=
n
})
(
\
t
->
CTest
(
testFillInDefaults
t
)
{
testName
=
n
})
(
\
b
->
CBench
(
benchFillInDefaults
b
)
{
benchmarkName
=
n
})
c
)
comps
),
targetSet
,
fs
)
Left
missing
->
Left
missing
flagChoices
=
map
(
\
(
MkFlag
n
_
d
manual
)
->
(
n
,
d2c
manual
n
d
))
flags
d2c
manual
n
b
=
case
lookup
n
userflags
of
Just
val
->
[
val
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment