Skip to content

Commit

Permalink
Fixity parser: don't require trailing newline
Browse files Browse the repository at this point in the history
  • Loading branch information
amesgen authored and mrkkrp committed Jun 11, 2024
1 parent d90d5f6 commit d90413c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
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

0 comments on commit d90413c

Please sign in to comment.