Commit Graph

95 Commits

Author SHA1 Message Date
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
Basile Henry
b2f49a7693 Support single line where clauses 2019-07-13 19:57:10 +02:00
Basile Henry
0baa898f30 Add tests for let/where interaction #177 2019-07-13 19:57:10 +02:00
Vladislav Zavialov
fd4fa7f33e Comma-separated SPECIALIZE types 2019-07-13 19:56:59 +02:00
Vladislav Zavialov
984e4b674f Keep FunBind strictness 2019-07-13 19:38:46 +02:00
Vladislav Zavialov
b03f989f36 Bang patterns and splices in lambdas 2019-07-13 17:45:52 +02:00
waddlaw
a7265df09e Fix printing of backticks around wildcards in operator position 2019-07-12 18:06:21 +02:00
yumiova
9e880c5299 Support transform list comprehensions 2019-07-12 17:49:16 +02:00
yumiova
069ae69a5b Support data types with infix & multi-line declarations
Fix the bug where data types with infix names & names layed out over multiple lines get incorrectly formatted. Specifically, reuse `p_infixDefHelper` to easily take care of this behavior.
2019-07-12 17:19:05 +02:00
PanAeon
c2dd159c9c Implement rendering of rewrite rule declarations 2019-07-12 17:07:54 +02:00
mrkkrp
a2b75213b3 Adjust rendering of kind signatures and implicit parameters
Previously there was no space between type variable and ‘::’, which is why I
started digging this in the first place.
2019-07-08 22:22:51 +02:00
mrkkrp
99619d681c Fix rendering of implicit bidirectional pattern synonyms
Previously we forgot to enable the extension, and apparently we were just
defining a function called ‘pattern’.
2019-07-08 21:46:24 +02:00
mrkkrp
3d74f2fb53 Shift ‘in’ in ‘let’ to the right to allow placing it in do blocks
It is a bit uncommon to format it like this, but this way it can be placed
without changes in do blocks as well. I think it's the right way go about
that bug.
2019-07-07 14:13:40 +02:00
mrkkrp
01486edadb Enable some non-conflicting language extensions by default 2019-07-07 13:53:59 +02:00
mrkkrp
d82d607b3a Implement ‘VarBr’ 2019-07-07 13:40:48 +02:00
mrkkrp
3be1adbfc7
Add an example for case expression with preceding comment (now fixed) 2019-07-07 00:13:59 +02:00
mrkkrp
d7d4592b8e Improve handling of newlines
Now the printing code can correctly detect when hanging constructions should
be placed in non-hanging fashion from the way they are placed in input
source code.
2019-07-07 00:04:33 +02:00
mrkkrp
875c79d88d Implement dropping of trailing whitespace in comments 2019-07-05 21:01:45 +02:00
Dominik Kellner
6583ecb3f0 Keep space in lambdas with lazyness annotation
Fixes #144
2019-07-05 20:14:16 +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
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
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
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
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
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