Commit Graph

11 Commits

Author SHA1 Message Date
Utku Demir
9a1f5ebd87 Split large examples
There has been a lot of good intense work lately and as a result of that
some examples have grown considerably. The problem is that we do not show
diffs when something is not formatted as expected, we show entire
"expected/got" files. It works well when files are small, but not so well
where they are huge (some of our examples are well beyond 100 lines). It can
be hard to understand where the problem is.

This commit split long examples into smaller ones to make it easier to see
what went wrong when a test fails.
2019-08-25 12:35:31 +02:00
Utku Demir
e598b72be5 Preserve the name of the expression bracket
Both `[e|...|]` and `[||]` mean the same thing, and instead of sticking to a
single style, we can just preserve what user wrote.
2019-08-16 22:17:53 +02:00
Utku Demir
0cf6d654eb Fix TH quoting of operators 2019-08-14 21:23:21 +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
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
mrkkrp
004c8d0256 Adjust when we put parentheses around TH-quoted names 2019-07-29 22:27:06 +02:00
mrkkrp
46a1c221ab
Also add parentheses around TH-quoted qualified operators 2019-07-21 12:36:30 +02:00
mrkkrp
de1b33788d Fix parentheses around TH-quoted operators 2019-07-21 12:14:32 +02:00
mrkkrp
d82d607b3a Implement ‘VarBr’ 2019-07-07 13:40:48 +02:00
waddlaw
ae40a33507 Sort language pragmas and fix their placement in modules
The approach we take here is parsing of language pragmas on creation of
comment stream and then pretty-printing them in a separate block.
2019-07-05 20:03:31 +02:00
Basile Henry
2fd53f6af2 Support typed and untyped splices 2019-06-23 17:59:47 +02:00