1
1
mirror of https://github.com/google/ormolu.git synced 2024-11-30 14:46:39 +03:00
Commit Graph

220 Commits

Author SHA1 Message Date
Utku Demir
f55021d89b Fix printing of the rewrite rule names 2019-08-14 21:34:05 +02:00
Utku Demir
a392aef71e Fix the issue with promoted containers with promoted elements 2019-08-14 21:31:50 +02:00
Utku Demir
57373e536d Fix formatting of infix type synonyms using ‘p_infixDefHelper’ 2019-08-14 21:30:43 +02:00
Utku Demir
acc77002e4 Support inline specs inside specialize pragmas 2019-08-14 21:24:04 +02:00
Utku Demir
0cf6d654eb Fix TH quoting of operators 2019-08-14 21:23:21 +02:00
mrkkrp
e21e4ef119 Fix mis-formatting of per-argument comments in certain cases 2019-08-13 20:59:22 +02:00
mrkkrp
825171a16d Group deprecation declarations with data types as well 2019-08-11 21:41:23 +02:00
mrkkrp
0233f6ddec Misc corrections 2019-08-11 16:04:42 +02:00
Utku Demir
b6c29bdf12 Handle OPTIONS_GHC and OPTIONS_HADDOCK pragmas
This change adds an ad-hoc parser for module pragmas to handle
OPTIONS_* pragmas. I did not want to use an existing tokenizer,
because I felt like tokenizing and pretty printing the GHC options
are more prone to error without providing much benefit.
2019-08-11 16:04:42 +02:00
Utku Demir
be6d09d148 Workaround GHC tokenizer bug while extracting LANGUAGE pragmas 2019-08-09 11:24:11 +02:00
Utku Demir
c2b32da3b5 Tweak formatting of warning pragmas 2019-08-09 11:00:06 +02:00
mrkkrp
93271b2551 Make sure no comments are swallowed at the end 2019-08-08 20:20:17 +02:00
mrkkrp
ca1a2e9e5c
Remove the relaxed comments flag from context or ‘R’ monad
We do not use this anymore.
2019-08-08 20:09:48 +02:00
Utku Demir
a0aa410741 Fix printing of TH brackets
The issue was simply indenting the closing `|]` one more level. However
there were a few more issues around them, which led me to a slightly
bigger refactor.

main reason is that, all `p_*Decl` functions used to print a trailing
newline. This makes sense for top-level constructs, however it was making
printing something like `[d|data Foo = Foo|]` impossible.

In this commit, I removed trailing newlines from individual printers
and gave that responsibility to `p_hsDecls`, and inserted an additional
trailing newline when printing modules.

While doing that, I noticed a few bugs/inconsistencies, and I had to
fix them in the process:

* Warning pragmas used to not print a trailing newline, so they were
always attached to the next expression. I made it more like the other
pragmas, where we attach it to a neighbour function if the name matches,
otherwise we separate it with a newline.
* We used to print single line GADT's and single line `do` notations
using multiple lines, which breaks idempotency. I tweak them to prefer
single line layout if possible (sometimes it is not possible because
of the semicolon syntax).
2019-08-08 11:30:20 +02:00
Utku Demir
e2a6305bd3 Change the way operators are formatted 2019-08-07 20:50:30 +02:00
Teodoro Freund
5955c514ee Fix backticks and parens in multiline function declarations
Function id obtained through pattern matching on ‘FunBind’ should not be
used to print the actual equations because the different ‘RdrNames’ used in
the equations may have different “decorations” (such as backticks and
paretheses) associated with them. It is necessary to use per-equation names
obtained from ‘m_ctxt’ of ‘Match’.
2019-08-07 19:14:59 +02:00
mrkkrp
75869e1590
Do not export ‘p_hsDecl’ because it's not used anywhere 2019-08-06 19:48:51 +02:00
mrkkrp
094e70a2eb Avoid failing when comments get before an operator
This puts out the fire, but I'm not fully content with the solution. I also
do not understand why it fails in the original issue but succeeds for e.g.:

  foo = do
    1
    +
    2
2019-08-05 22:25:38 +02:00
mrkkrp
8fdc9739f0 Fine-tune placement of lambdas after operators 2019-08-05 21:25:34 +02:00
mrkkrp
8870acd41f
Replace weird whitespace characters by normal spaces
I'm just curios of their origin. If I'm not mistaken they were introduced by
@yumiova.
2019-08-05 21:01:52 +02:00
Basile Henry
09e2a538ef Add printer for ‘HsSpliceTy’ 2019-08-05 19:46:47 +02:00
mrkkrp
c6a6193525
Do not run tests when trying Ormolu on Hackage packages 2019-08-05 15:15:45 +02:00
mrkkrp
f86e01ea3b Avoid crashing on unboxed string literals 2019-08-04 23:27:31 +02:00
Mauricio Fierro
bdb22b96ac Fix record pattern synonyms 2019-08-04 22:41:48 +02:00
gabriele.lana
be53b3e504 Format unboxed sum pattern 2019-08-04 21:47:52 +02:00
mrkkrp
54749b889a
A couple of minor corrections to the readme
[skip ci]
2019-08-04 21:20:30 +02:00
mrkkrp
e344f61d33 Fix some inconsistency in indentation 2019-08-04 16:50:38 +02:00
mrkkrp
85de7ce38c Add support for the CONLIKE modifier in inlining pragmas 2019-08-04 13:54:08 +02:00
mrkkrp
85d5f78b4b Change parens style and how separated lists of items are printed
Goals:

* Make the set of combinators clearer and smaller.
* Solve a number of issues, such as those about parse failures related to
  patterns.
* Solve the bug from #244.

The idea is very simple, we stop doing this

  ( foo
  , bar
  )

and start doing this

( foo,
  bar
  )

* We switch to trailing commas which solves the indentation issues for
  patterns automatically.
* The new general ‘sep’ combinator finally is clear enough, and all the old
  zoo of ‘velt’ and ‘velt'’ and ‘sepWith’, etc. which was confusing and
  overlapping goes away.
2019-08-04 13:32:06 +02:00
Mitchell Rosen
180df38a71 Fix mixing names with double dot in export lists 2019-07-29 23:14:31 +02:00
Mitchell Rosen
81b291929e Don't separate pattern signature from pattern (fixes #192) 2019-07-29 22:28:28 +02:00
mrkkrp
004c8d0256 Adjust when we put parentheses around TH-quoted names 2019-07-29 22:27:06 +02:00
mrkkrp
d61b9101ca Always put parens around kind signatures 2019-07-21 22:43:55 +02:00
sphaso
116a5a81df Insert space before promoted types where necessary 2019-07-21 21:34:45 +02:00
mrkkrp
46a1c221ab
Also add parentheses around TH-quoted qualified operators 2019-07-21 12:36:30 +02:00
mrkkrp
560c498688 Handle inline comments before let correctly 2019-07-21 12:25:39 +02:00
mrkkrp
de1b33788d Fix parentheses around TH-quoted operators 2019-07-21 12:14:32 +02:00
mrkkrp
ab4885ff0f Preserve empty where clause 2019-07-21 00:30:24 +02:00
sphaso
174a0847d4 Keep comma on multiple GADT declaration 2019-07-20 22:31:54 +02:00
gabriele.lana
8d52d87d72 Preserve operators promotion (single quote)
Fixes #222
2019-07-20 22:07:47 +02:00
sphaso
0065a9baf6 Add space after minus for ‘NegApp’ 2019-07-20 21:53:45 +02:00
waddlaw
68bbc647f7 Always surround the class to derive with parentheses 2019-07-20 21:34:50 +02:00
Daniel Krueger
2cae331d1b Insert space before double dot of arithmetic sequence
This style is arguably ugly, but solves the issue when the type signatures
mess with the double dot. Will do for now.
2019-07-20 20:42:41 +02:00
mrkkrp
63478a0ba4
Drop shebang from the ormolize.sh script
This one is likely to incorrect in the context of the build.
2019-07-15 11:41:45 +02:00
mrkkrp
c5b9fa1168 Add an option to tolerate CPP pragmas 2019-07-14 13:14:55 +02:00
mrkkrp
62cbd42ddd Improve error pretty printing 2019-07-14 13:14:55 +02:00
mrkkrp
78e8dd830a Make sure we always get both original and formatted files 2019-07-14 13:14:55 +02:00
mrkkrp
7a9aab77b3 Add nix expression for reformatting sources of arbitrary packages
See the description in readme.
2019-07-14 13:14:55 +02:00
mrkkrp
a444abc764 Update ‘CONTRIBUTING.md’ 2019-07-13 21:51:45 +02:00
mrkkrp
53c3044ffc
Add a note about ‘ApplicativeStmt’
[skip ci]
2019-07-13 21:48:44 +02:00