Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixity parser: don't require trailing newline #1123

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
## Unreleased

* Fix Haddock comments on infix constructors
[Issue 758](https://github.com/tweag/ormolu/issues/758)
[Issue 758](https://github.com/tweag/ormolu/issues/758).

* Don't require a trailing newline in `.ormolu` files. [Issue
1122](https://github.com/tweag/ormolu/issues/1122).

## Ormolu 0.7.5.0

Expand Down
8 changes: 2 additions & 6 deletions src/Ormolu/Fixity/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,10 @@ pDotOrmolu =
(FixityOverrides . Map.fromList . mconcat)
(ModuleReexports . Map.map NE.sort . Map.fromListWith (<>))
. partitionEithers
<$> many configLine
<$> (configLine `sepEndBy` (void eol *> hidden space))
<* eof
where
configLine = do
x <- eitherP pFixity pModuleReexport
void eol
hidden space
return x
configLine = eitherP pFixity pModuleReexport

-- | Parse a single fixity declaration, such as
--
Expand Down
7 changes: 7 additions & 0 deletions tests/Ormolu/Fixity/ParserSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ spec = do
[ "infixr 9 .",
"infixr 5 ++"
]
it "parses inputs without a trailing newline" $
parseDotOrmolu ""
`shouldSucceedOn` T.intercalate
"\n"
[ "infixr 9 .",
"infixr 5 ++"
]
it "fails with correct parse error (keyword wrong second line)" $
parseDotOrmolu "" "infixr 5 .\nfoobar 5 $"
`shouldFailWith` err
Expand Down