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
d1736bd9
Commit
d1736bd9
authored
3 years ago
by
Patrick Augusto
Browse files
Options
Downloads
Patches
Plain Diff
Make cabal init conform with --no-comments flag for commented fields
parent
e74a53b3
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-install/src/Distribution/Client/Init/Format.hs
+12
-14
12 additions, 14 deletions
cabal-install/src/Distribution/Client/Init/Format.hs
with
12 additions
and
14 deletions
cabal-install/src/Distribution/Client/Init/Format.hs
+
12
−
14
View file @
d1736bd9
...
...
@@ -64,18 +64,9 @@ fieldD
->
WriteOpts
->
PrettyField
FieldAnnotation
fieldD
fieldName
fieldContents
fieldComments
includeField
opts
|
fieldContents
==
empty
=
-- If there is no content, optionally produce a commented out field.
fieldSEmptyContents
$
CommentBefore
fieldComments
|
otherwise
=
-- If the "--no-comments" or "--minimal" flag is set, strip comments.
let
comments
|
isMinimal
=
[]
|
hasNoComments
=
[]
|
otherwise
=
fieldComments
-- If the "--minimal" flag is set, strip comments.
in
fieldSWithContents
comments
-- If the "--no-comments" or "--minimal" flag is set, strip comments.
|
hasNoComments
||
isMinimal
=
contents
NoComment
|
otherwise
=
contents
$
commentPositionFor
fieldName
fieldComments
where
commentPositionFor
fn
|
fn
==
"cabal-version"
=
CommentAfter
...
...
@@ -84,6 +75,11 @@ fieldD fieldName fieldContents fieldComments includeField opts
isMinimal
=
_optMinimal
opts
hasNoComments
=
_optNoComments
opts
contents
-- If there is no content, optionally produce a commented out field.
|
fieldContents
==
empty
=
fieldSEmptyContents
|
otherwise
=
fieldSWithContents
fieldSEmptyContents
cs
|
not
includeField
||
isMinimal
=
PrettyEmpty
|
otherwise
=
PrettyField
...
...
@@ -92,7 +88,7 @@ fieldD fieldName fieldContents fieldComments includeField opts
empty
fieldSWithContents
cs
=
PrettyField
(
withComments
.
commentPositionFor
fieldName
$
map
(
"-- "
++
)
cs
)
fieldName
fieldContents
PrettyField
(
withComments
cs
)
fieldName
fieldContents
-- | A field annotation instructing the pretty printer to comment out the field
...
...
@@ -104,7 +100,9 @@ commentedOutWithComments NoComment = FieldAnnotation True NoComment
-- | A field annotation with the specified comment lines.
withComments
::
CommentPosition
->
FieldAnnotation
withComments
=
FieldAnnotation
False
withComments
(
CommentBefore
cs
)
=
FieldAnnotation
False
.
CommentBefore
$
map
(
"-- "
++
)
cs
withComments
(
CommentAfter
cs
)
=
FieldAnnotation
False
.
CommentAfter
$
map
(
"-- "
++
)
cs
withComments
NoComment
=
FieldAnnotation
False
NoComment
-- | A field annotation with no comments.
annNoComments
::
FieldAnnotation
...
...
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