Skip to content

Add check for "dotlines" with cabal 3.0+#11571

Open
tbidne wants to merge 3 commits intohaskell:masterfrom
tbidne:tbidne/11518-check
Open

Add check for "dotlines" with cabal 3.0+#11571
tbidne wants to merge 3 commits intohaskell:masterfrom
tbidne:tbidne/11518-check

Conversation

@tbidne
Copy link
Contributor

@tbidne tbidne commented Mar 3, 2026

Adds a warning for #11518. I'm not too familiar with this part of the codebase, but the changes seem straightforward.

Essentially wraps

fromUTF8BS :: ByteString -> String

with

parseLine3 :: Position -> BS.ByteString -> ParseResult src String

which adds a warning if the string matches the same dot check pre-3.0 (trim bs == "."). The rest is just mechanical changes to accommodate the ParseResult.


Template Α: This PR modifies behaviour or interface

Include the following checklist in your PR:

@tbidne tbidne force-pushed the tbidne/11518-check branch from 61c1fc5 to 9fbdaaa Compare March 3, 2026 23:34
@tbidne tbidne force-pushed the tbidne/11518-check branch from 9fbdaaa to 11d71af Compare March 4, 2026 00:46
@tbidne tbidne force-pushed the tbidne/11518-check branch from 11d71af to 050a595 Compare March 4, 2026 10:31
Comment on lines +455 to +464
parseLine3 p bs = do
when (s' == ".") $ parseWarning p PWTDotline msg
pure s
where
s = fromUTF8BS bs
s' = trim s

msg =
"Empty lines with a dot '.' are unnecessary for creating newlines "
++ "(and treated literally) in cabal 3.0+"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With -XViewPatterns, you could skip binding bs. Bindings for s' and msg could also be skipped.

Suggested change
parseLine3 p bs = do
when (s' == ".") $ parseWarning p PWTDotline msg
pure s
where
s = fromUTF8BS bs
s' = trim s
msg =
"Empty lines with a dot '.' are unnecessary for creating newlines "
++ "(and treated literally) in cabal 3.0+"
parseLine3 p (fromUTF8BS -> s) = do
when (trim s == ".") . parseWarning p PWTDotline $
"Empty lines with a dot '.' are unnecessary for creating newlines "
++ "(and treated literally) in cabal 3.0+"
pure s

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reasonable, though I think turning on ViewPatterns for the whole module is overkill, just for this. I don't feel strongly though.

@tbidne tbidne force-pushed the tbidne/11518-check branch from 050a595 to f17b0bc Compare March 4, 2026 19:11
philderbeast and others added 3 commits March 5, 2026 08:18
- Follow cabal suggestion: use findWithDefault
Cabal 3.0 changed the parser for "free text" fields (e.g. description)
such that:

  1. Empty lines and indentation are preserved.

  2. Empty lines with a dot '.' (and possible whitespace) are
     interpreted literally; they are no longer interpreted as an
     empty line.

Consequently, dotlines no longer serve a purpose and only add extra
noise, hence are given a warning.

See haskell#11518.
@tbidne tbidne force-pushed the tbidne/11518-check branch from f17b0bc to 06a5812 Compare March 4, 2026 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants