1
1
mirror of https://github.com/tweag/ormolu.git synced 2024-10-05 17:37:11 +03:00
Commit Graph

68 Commits

Author SHA1 Message Date
mrkkrp
a3a93ebfef Refactor the comment rendering code and ‘newline’
This removes (or rather puts it to a lower level) logic around “modifying
newline” because it was very hard to reason about and almost blocked my work
on fixing issue #337.

I also dropped debugging output because it's too verbose and I'm not using
it anyway.

As part of these changes I also changed now the ‘newline’ combinator works.
Now, similar to ‘space’, the second ‘newline’ in a row just tells the
rendering engine to prefix next thing with a newline, using the ‘newline’
combinator more than twice in a row has no effect.

To take full advantage of the new feature I also went through the code and
simplified some logic around outputting exact amount of newlines because now
it's harder to get things wrong, so we can be less careful with counting
newlines.
2019-09-05 16:56:43 +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
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
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
mrkkrp
c421b22832 Make test suite failures a bit more readable 2019-06-09 15:03:55 +02:00
mrkkrp
9a0276b36d Implement the rest of binding types
This includes pattern binds, pattern synonyms, and a refactoring around
printing ‘RdrName’s.
2019-06-04 00:49:33 +02:00
mrkkrp
09afebbd9c Implement rendering of simplest value-level constructs 2019-05-18 18:47:53 +02:00
mrkkrp
b9c8b64947 Implement more precise comment placement without ‘ghc-exactprint’
‘ghc-exactprint’ (or perhaps lexer of GHC itself) does a fairly poor job at
associating comments with elements of AST. In many cases the result is not
what you'd expect. We ran into insuperable problems with that to the effect
that correct comment placement were impossible.

The new approach is to exploit the raw position information provided by the
GHC lexer, that is, spans attached to AST elements and comments. This
allowed us to place comments in output in a very precise and satisfactory
fashion.
2019-05-08 22:03:21 +02:00
mrkkrp
00b08eeaff Implement rendering of data type declarations 2019-05-08 22:03:21 +02:00
mrkkrp
576f943e7f Implement rendering of types and type families declarations 2019-04-07 19:33:28 +02:00
mrkkrp
b6d49bb625 Implement pretty-printing of imports 2019-03-21 14:45:06 +01:00
mrkkrp
6f169f2969 Include debugging option in ‘Config’ 2019-02-28 22:22:10 +01:00
mrkkrp
2f73bae977 Implement CLI for the application 2019-02-28 22:22:10 +01:00
mrkkrp
120b4caefc Implement handling of comments and printing of module headers 2019-02-21 18:15:27 +01:00
mrkkrp
fcd35a1faa Implement pretty printing combinators 2019-01-28 19:26:13 +01:00
mrkkrp
dc6605107a
Initial commit 2018-11-25 20:51:22 +07:00