on master help sign in
Fix non-idempotent transformation of partly documented data definition
commit1fb65a218ce9baa0516717b42e7f50f83fc01b89 authorMark Karpov <markkarpov92@gmail.com> dateThu 14 May 2020, 17:15 (6 years ago) parentb0092e1
5 files changed+14−9
CHANGELOG.md+3 data/examples/declaration/data/partly-documented-out.hs+5 data/examples/declaration/data/partly-documented.hs+2 expected-failures/idris.txt−6 src/Ormolu/Printer/Meat/Declaration/Data.hs+4−3
CHANGELOG.md+3
@@ -32,6 +32,9 @@
3232 syntax. [Issue 445](https://github.com/tweag/ormolu/issues/445) and [Issue
3333 428](https://github.com/tweag/ormolu/issues/428).
3434
35+* Fixed non-idempotent transformation of partly documented data definition.
36+ [Issue 590](https://github.com/tweag/ormolu/issues/590).
37+
3538* Renamed the `--check-idempotency` flag to `--check-idempotence`.
3639 Apparently only the latter is correct.
3740
data/examples/declaration/data/partly-documented-out.hsnew file+5
@@ -0,0 +1,5 @@
1+data Optimisation
2+ = PETransform
3+ | -- | partial eval and associated transforms
4+ GeneralisedNatHack
5+ deriving (Show, Eq, Generic)
data/examples/declaration/data/partly-documented.hsnew file+2
@@ -0,0 +1,2 @@
1+data Optimisation = PETransform | GeneralisedNatHack -- ^ partial eval and associated transforms
2+ deriving (Show, Eq, Generic)
expected-failures/idris.txt−6
@@ -10,12 +10,6 @@ Formatting is not idempotent:
1010 after: " text op\n <"
1111Please, consider reporting the bug.
1212
13−Formatting is not idempotent:
14− src/Idris/Options.hs<rendered>:178:15
15− before: "ETransform | -- | pa"
16− after: "ETransform\n | -- | "
17−Please, consider reporting the bug.
18−
1913The GHC parser (in Haddock mode) failed:
2014 src/Idris/Parser.hs:1052:1
2115 parse error on input `@'
src/Ormolu/Printer/Meat/Declaration/Data.hs+4−3
@@ -72,10 +72,11 @@ p_dataDecl style name tpats fixity HsDataDefn {..} = do
7272 else breakpoint
7373 equals
7474 space
75+ layout <- getLayout
7576 let s =
76− vlayout
77− (space >> txt "|" >> space)
78− (newline >> txt "|" >> space)
77+ if layout == MultiLine || hasHaddocks dd_cons
78+ then newline >> txt "|" >> space
79+ else space >> txt "|" >> space
7980 sitcc' =
8081 if singleConstRec
8182 then id