1
1
mirror of https://github.com/google/ormolu.git synced 2024-12-06 03:01:59 +03:00
Commit Graph

56 Commits

Author SHA1 Message Date
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
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
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
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
mrkkrp
656d0369d4 Output multiple specialize pragmas in a row nicer
We should not insert newlines between them.
2019-06-10 21:34:49 +02:00
mrkkrp
e98df37597 Fix rendering of value-level units 2019-06-10 21:24:12 +02:00
Mitchell Rosen
4b1d31e4ea Implement rendering of ‘SigPat’s 2019-06-10 21:24:00 +02:00
mrkkrp
fab9f15ad6 Implement specialize pragma 2019-06-09 15:03:55 +02:00
mrkkrp
046f14e7e5 Implement support for inline signatures 2019-06-09 15:03:55 +02:00
mrkkrp
a8235f7164 Implement fixity signatures, plus some refactoring 2019-06-09 15:03:55 +02:00
yumiova
c05d9d62e0 Support associated data types and open data family instances 2019-06-08 22:28:25 +02:00
mrkkrp
2dfd181c2f Avoid comparing ‘SourceText’ when comparing ASTs 2019-06-08 22:28:25 +02:00
yumiova
5f5f9227aa Implement rendering of instance declarations
This pull request implements half of #49. Specifically, it deals with pretty printing instance declarations and most structures needed to support that. This includes pretty printing of associated types (and therefore also type family instances.) However, this _does not_ include pretty printing of associated data types.

Pretty printing of type class declarations is to be dealt with at a later time.

Instances are formatted such that indentation hangs after the `instance`. Namely,

```haskell
instance Eq a
         => Eq [a] where
```

To support pretty printing associated types, the function `p_tyFamInstEqn` was exported from the appropriate module. This was done to avoid redundant code duplication.
2019-06-08 22:28:25 +02:00
waddlaw
59bc871d1a Implement view patterns 2019-06-08 20:31:08 +02:00
mrkkrp
fda95194f6 Fix rendering of hanging constructions 2019-06-08 19:29:23 +02:00
mrkkrp
46d175c89d Make case expressions hanging 2019-06-06 22:35:53 +02:00
mrkkrp
f937aa7aaf Handle “prefixed blocks” when they go after an operator
The change is obvious from the examples.
2019-06-06 22:35:53 +02:00
Utku Demir
99a345b919 Initial support for do notation 2019-06-06 20:50:52 +02:00
mrkkrp
6bc7333a6d Fix rendering of certain record patterns 2019-06-05 21:17:22 +02:00
mrkkrp
1b287b3b0d Change formatting of operators and infix constructors
This formatting scheme is more appropriate if you think of chaining multiple
infix expressions and combining it with do-blocks. The operator should hang
on previous line instead going first on the next line, e.g.:

foo +
  bar

instead of

foo
  + bar
2019-06-05 20:36:04 +02:00
mrkkrp
777524b6de Various adjustments
The main point of this commit is perhaps that certain constructions are rare
and unnatural in multi-line form, so we could print them always in
single-line form however putting parentheses still in multi-line fashion so
the properly of idempotency is satisfied.
2019-06-04 22:45:16 +02:00
yumiova
45e25a1146 Implement rendering of most types of expressions
This pull request implements most of currently missing types of expressions,
with the exception of:

* Do notation
* List comprehensions (list comprehensions are considered a kind of do
  notation in GHC)
* Arrow notation
* Template Haskell

Most expressions are pretty printed in an uncontroversial manner, preferably
similar to existing syntax.
2019-06-04 22:45:16 +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
34b9b71601 Build the project with Nix and switct to GHC 8.6.4
It was decided that we're going to make the project compatible with just one
GHC version at a time. Right now this version is going to be 8.6.4.

A small refactoring included, plus support for the “deriving via” feature.
2019-05-31 14:43:15 +02:00
Utku Demir
06e4f1d5ad Implement TypeApplications and StaticPointers support 2019-05-28 12:18:32 +02:00
mrkkrp
b129979516 Fix guards 2019-05-23 15:30:55 +02:00
mrkkrp
61f49600f8 Adjust if formatting
This includes a refactoring which changes the default strategy for
indentation level bumping. I think it's an improvement overall.
2019-05-23 15:30:55 +02:00
mrkkrp
09afebbd9c Implement rendering of simplest value-level constructs 2019-05-18 18:47:53 +02:00
mrkkrp
3553fc35d0 Implement signature declarations
This implements not everything, but the most common case: simple top-level
declarations for functions.
2019-05-16 19:03:14 +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