1
1
mirror of https://github.com/google/ormolu.git synced 2024-09-11 08:05:24 +03:00
Commit Graph

140 Commits

Author SHA1 Message Date
mrkkrp
05e420159a
Replace current year with the word "present"
[skip ci]

Saves a lot of effort updating all those thingies every year.
2019-07-02 21:27:45 +02:00
mrkkrp
f8bad3a855 Only drop indentation present for every line in multiline comments 2019-07-01 00:07:54 +02:00
Basile Henry
faf3d86f14 Recognize gaps between comment blocks 2019-06-30 22:59:21 +02:00
mrkkrp
733e8086d4 Fix comparison of prelude imports 2019-06-30 22:42:32 +02:00
mrkkrp
8c27549532 Fix rendering of type equalities
Please see the comment in the diff.
2019-06-28 23:41:37 +02:00
mrkkrp
057977d60c Insert newlines after annotations in certain cases
Just like other pragmas annotations will now “stick” to the definitions they
pertain to. If it's not possible, there will be a newline separating them
from other declarations in the module.
2019-06-28 21:37:38 +02:00
yumiova
ba64967c03 Implement properly indented constraint contexts
Essentially, it simply indents the constraints one layer, instead of hanging the constraints off of `class` or `instance`.
2019-06-28 21:09:15 +02:00
Dmitry Ivanov
c5ed521e35 Add more function guards tests 2019-06-27 21:14:22 +02:00
Dmitry Ivanov
db8c179187 Allegedly fix function guards 2019-06-27 21:14:22 +02:00
yumiova
1654ac10a1 Implement all facets of arrow notation
Most syntactic constructs reuse pretty printing specified previously, such as arrow cases, if-expressions and lambdas. Relevant operators (such as arrow argument passing) and brackets are also formatted as operators and brackets typically are.
2019-06-27 20:49:24 +02:00
yumiova
f9842f5942 Add newlines between most declarations in a type class instance
Certain other kinds of declarations, such as instance signatures (e.g., from `InstanceSigs`) and bindings, are grouped together without newlines. The process for determining which declarations are grouped reuses the same logic as for modules and type classes.
2019-06-27 20:32:49 +02:00
Rupert Horlick
3c506ecf2b Implement printer for ‘WarningD’ 2019-06-26 22:26:31 +02:00
yumiova
bdc8738fa8 Add newlines between most declarations in a type class
Certain other kinds of declarations (such as associated type signatures and
bindings) are grouped together without newlines. The process for determining
which declarations are grouped reuses the same logic as for modules.
2019-06-25 23:26:43 +02:00
mrkkrp
ca49003d41
Drop redundant trailing newlines in nix files 2019-06-24 20:14:49 +02:00
mrkkrp
7524d6fd78
Add a couple of comments in ‘p_pat’
[skip ci]
2019-06-23 20:31:04 +02:00
sphaso
b3ebe87bf3 Support empty data declarations 2019-06-23 20:30:46 +02:00
sphaso
4f6b6171ba Implement specialize instance pragma 2019-06-23 20:16:53 +02:00
sphaso
430e0a3620 Implemented set cost centre pragma 2019-06-23 20:03:14 +02:00
Utku Demir
5565311264 Correctly print lambda case with guards 2019-06-23 19:31:16 +02:00
Luc Tielen
6b73283246 Clean nix configuration
* Point to more recent nixpkgs commit. This fixes build issue with python
  3.7.3 (only on darwin?).

* Separate shell.nix and default.nix. This is so that lorri can be used for
  development.

* Add nix output to .gitignore.

* Format *.nix using nixfmt.

* Use gitignore for filtering files in nix derivation.
2019-06-23 19:17:05 +02:00
yumiova
c13a515b28 Implement pretty printing of normal & parallel list comprehensions
There are no real problems to speak of, as the formatting is obvious and consistent with what the Haskell community already does.See the tests for an example.

The reason transform list comprehensions are not implemented yet is because the GHC AST for representing list comprehensions is ahorrible mess, where slightly different list comprehensions end upcausing massively different syntax trees. The simplest way of solving this would likely be a preprocessing step that reads the syntaxtrees and produces a simple, linear list of bindings. I decided not to implement this yet to avoid delaying this commit further.
2019-06-23 18:58:20 +02:00
sphaso
3cc902102b Remove trailing whitespace from empty export list 2019-06-23 18:38:46 +02:00
Basile Henry
2fd53f6af2 Support typed and untyped splices 2019-06-23 17:59:47 +02:00
Rupert Horlick
4a0e5d4e42 [#94] Improve handling of newline before match group bodies
The PR changes the body layouting to use a span that includes the last point in
the name/pattern part of a match. This forces the layout to be multiline iff the
body starts on a newline.
2019-06-19 21:38:53 +02:00
Basile Henry
42c91987bf Use explicit error code in check mode 2019-06-19 21:28:22 +02:00
Basile Henry
b2024bfc3d Use different exit codes for different exceptions
We map every Ormulu exception to a different exit code so that they can
easily be differentiated from a shell script.
2019-06-19 21:28:22 +02:00
Rupert Horlick
c460bfa346 [#53] Implement rendering for foreign declarations
Closes #53
2019-06-19 21:20:19 +02:00
yumiova
515251c7a5 Support infix operator & multi-line class names 2019-06-19 21:09:34 +02:00
Basile Henry
73cc30c5d1 Add AnnD printer 2019-06-19 20:50:24 +02:00
waddlaw
f9c58af594 Implement rendering of ‘HsTypedSplice’ and ‘HsUntypedSplice’ 2019-06-19 20:30:55 +02:00
Basile Henry
2c6a9829ab Add CompleteMatchSig printer 2019-06-19 19:58:46 +02:00
Basile Henry
1753c7d647 Add Default declaration printer
Co-authored-by: Rupert Horlick <ruhatch@me.com>
2019-06-19 17:53:42 +02:00
Basile Henry
4955cdc4bc Add MinimalSig printer 2019-06-19 17:35:45 +02:00
Rupert Horlick
7307b6debd [#52] Implement WARNING/DEPRECATED in module header 2019-06-19 17:35:45 +02:00
Rupert Horlick
f8b920767c [#98] Fix where blocks with do notation
Closes #98
2019-06-17 10:49:58 +02:00
PanAeon
a325cd6cdf Support rendering of role annotation declarations 2019-06-16 14:49:56 +02:00
sphaso
5570439bb4 Implemenet rendering of standalone deriving 2019-06-16 14:25:57 +02:00
yumiova
7e31ae7407 Implement rendering of type class declarations 2019-06-16 13:59:10 +02:00
waddlaw
4442039c65 Implement n+k pattern 2019-06-16 08:49:55 +02:00
Rupert Horlick
cd8302a6c3 [#70] Format Pattern Synonym Signatures
This is a simple addition, adding `pattern ` in front of normal type signature
formatting
2019-06-16 08:48:28 +02:00
Domen Kožar
8f44d98b84 Expand all constructor that are missing (no Show instance) 2019-06-15 17:50:03 +02:00
mrkkrp
244144d6f4 Fix rendering of infix constructions in lhs of definitions
Also includes a minor refactoring of how type families are rendered.
2019-06-15 09:43:42 +02:00
mrkkrp
695842ec26 Make record constructors hang 2019-06-12 21:41:34 +02:00
mrkkrp
0d4da7f4eb
Refactor detection of things that do not require extra parentheses 2019-06-12 20:10:06 +02:00
waddlaw
057a3cf2ca Implement ‘HsSpliceE’ and ‘SplicePat’ 2019-06-12 18:11:09 +02:00
mrkkrp
e00bd3e72a Fix extra layer of parentheses around operator sections 2019-06-12 17:21:31 +02:00
mrkkrp
1e6f4cdc95 Fix type signature declarations for multiple values
Maybe the style is debatable, but I don't know a better way to format it in
multi-line.
2019-06-12 16:16:14 +02:00
mrkkrp
803f76aab9 Fix Haddock placement for function arguments
I'm not sure it's perfect, but it fixes the original issue and all the tests
pass.

The problem was in entering with locate (or some version of it) the same
span twice. So the algorithm saw an element with identical enclosing element
and the ‘commentFollowsElt’ function got confused.

The solution is two first augment registration of enclosing spans to allow
us to keep more than one item there. Then we can filter out spans which are
just copies of current reference span to get to the “real” enclosing span.

It seems to make sense to attach comments to child element if it starts
exactly at the same position of parent element, hence the distance between
start of enclosing/reference span and start of comment is the same, thus
changing ‘>’ to ‘>=’ in ‘commentFollowsElt’.
2019-06-11 22:21:41 +02:00
mrkkrp
5165003149 Fix rendering of implicit parameter variables 2019-06-10 22:43:37 +02:00
mrkkrp
be0ce29744 Fix rendering of case alternatives with guards
Also rolls back handing things in if branches, because it doesn't look so
good?
2019-06-10 22:34:12 +02:00