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
e6bff69d
Commit
e6bff69d
authored
9 years ago
by
Oleg Grenrus
Browse files
Options
Downloads
Patches
Plain Diff
Fix #2598. Omit empty CondTree branches
parent
49dba823
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Cabal/Distribution/PackageDescription.hs
+6
-0
6 additions, 0 deletions
Cabal/Distribution/PackageDescription.hs
Cabal/Distribution/PackageDescription/PrettyPrint.hs
+32
-13
32 additions, 13 deletions
Cabal/Distribution/PackageDescription/PrettyPrint.hs
with
38 additions
and
13 deletions
Cabal/Distribution/PackageDescription.hs
+
6
−
0
View file @
e6bff69d
...
...
@@ -98,6 +98,7 @@ module Distribution.PackageDescription (
GenericPackageDescription
(
..
),
Flag
(
..
),
FlagName
(
..
),
FlagAssignment
,
CondTree
(
..
),
ConfVar
(
..
),
Condition
(
..
),
cNot
,
-- * Source repositories
SourceRepo
(
..
),
...
...
@@ -1176,6 +1177,11 @@ data Condition c = Var c
|
CAnd
(
Condition
c
)
(
Condition
c
)
deriving
(
Show
,
Eq
,
Typeable
,
Data
)
cNot
::
Condition
a
->
Condition
a
cNot
(
Lit
b
)
=
Lit
(
not
b
)
cNot
(
CNot
c
)
=
c
cNot
c
=
CNot
c
instance
Functor
Condition
where
f
`
fmap
`
Var
c
=
Var
(
f
c
)
_
`
fmap
`
Lit
c
=
Lit
c
...
...
This diff is collapsed.
Click to expand it.
Cabal/Distribution/PackageDescription/PrettyPrint.hs
+
32
−
13
View file @
e6bff69d
...
...
@@ -25,7 +25,7 @@ import Distribution.PackageDescription
(
Benchmark
(
..
),
BenchmarkInterface
(
..
),
benchmarkType
,
TestSuite
(
..
),
TestSuiteInterface
(
..
),
testType
,
SourceRepo
(
..
),
customFieldsBI
,
CondTree
(
..
),
Condition
(
..
),
customFieldsBI
,
CondTree
(
..
),
Condition
(
..
),
cNot
,
FlagName
(
..
),
ConfVar
(
..
),
Executable
(
..
),
Library
(
..
),
Flag
(
..
),
PackageDescription
(
..
),
GenericPackageDescription
(
..
))
...
...
@@ -38,7 +38,7 @@ import Distribution.PackageDescription.Parse (pkgDescrFieldDescrs,binfoFieldDesc
sourceRepoFieldDescrs
,
flagFieldDescrs
)
import
Distribution.Package
(
Dependency
(
..
))
import
Distribution.Text
(
Text
(
..
))
import
Data.Maybe
(
isJust
,
fromJust
,
isNothing
)
import
Data.Maybe
(
isJust
)
-- | Recompile with false for regression testing
simplifiedPrinting
::
Bool
...
...
@@ -226,18 +226,37 @@ ppCondTree ct@(CondNode it _ ifs) mbIt ppIt =
else
res
where
-- TODO: this ends up printing trailing spaces when combined with nest.
ppIf
(
c
,
thenTree
,
mElseTree
)
=
((
emptyLine
$
text
"if"
<+>
ppCondition
c
)
$$
nest
indentWith
(
ppCondTree
thenTree
(
if
simplifiedPrinting
then
(
Just
it
)
else
Nothing
)
ppIt
))
$+$
(
if
isNothing
mElseTree
then
empty
else
text
"else"
$$
nest
indentWith
(
ppCondTree
(
fromJust
mElseTree
)
(
if
simplifiedPrinting
then
(
Just
it
)
else
Nothing
)
ppIt
))
ppIf
(
c
,
thenTree
,
Just
elseTree
)
=
ppIfElse
it
ppIt
c
thenTree
elseTree
ppIf
(
c
,
thenTree
,
Nothing
)
=
ppIf'
it
ppIt
c
thenTree
ppIfCondition
::
(
Condition
ConfVar
)
->
Doc
ppIfCondition
c
=
(
emptyLine
$
text
"if"
<+>
ppCondition
c
)
ppIf'
::
a
->
(
a
->
Maybe
a
->
Doc
)
->
Condition
ConfVar
->
CondTree
ConfVar
[
Dependency
]
a
->
Doc
ppIf'
it
ppIt
c
thenTree
=
if
isEmpty
thenDoc
then
mempty
else
ppIfCondition
c
$$
nest
indentWith
thenDoc
where
thenDoc
=
ppCondTree
thenTree
(
if
simplifiedPrinting
then
(
Just
it
)
else
Nothing
)
ppIt
ppIfElse
::
a
->
(
a
->
Maybe
a
->
Doc
)
->
Condition
ConfVar
->
CondTree
ConfVar
[
Dependency
]
a
->
CondTree
ConfVar
[
Dependency
]
a
->
Doc
ppIfElse
it
ppIt
c
thenTree
elseTree
=
case
(
isEmpty
thenDoc
,
isEmpty
elseDoc
)
of
(
True
,
True
)
->
mempty
(
False
,
True
)
->
ppIfCondition
c
$$
nest
indentWith
thenDoc
(
True
,
False
)
->
ppIfCondition
(
cNot
c
)
$$
nest
indentWith
elseDoc
(
False
,
False
)
->
(
ppIfCondition
c
$$
nest
indentWith
thenDoc
)
$+$
(
text
"else"
$$
nest
indentWith
elseDoc
)
where
thenDoc
=
ppCondTree
thenTree
(
if
simplifiedPrinting
then
(
Just
it
)
else
Nothing
)
ppIt
elseDoc
=
ppCondTree
elseTree
(
if
simplifiedPrinting
then
(
Just
it
)
else
Nothing
)
ppIt
emptyLine
::
Doc
->
Doc
emptyLine
d
=
text
""
$+$
d
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