Lennart Spitzner
9236673d66
Fix newtype indent in associated type family ( #207 )
2020-03-13 01:23:17 +01:00
Raoul Hidalgo Charman
dfa3fef56c
Add support for pattern synonyms
2020-03-08 19:30:23 +00:00
Lennart Spitzner
4b673d1d9d
Fix bug in record layouting causing overflows
2020-02-25 17:55:20 +01:00
Lennart Spitzner
a3b501051a
Add proper multiline layout for type-level-lists
2020-02-23 23:33:03 +01:00
Lennart Spitzner
38cdd15221
Fix moving comment in export list (haddock header) ( #281 )
2020-02-13 19:05:05 +01:00
Lennart Spitzner
825ec425d4
Improve comments-affecting-layout behaviour for tuples ( #231 )
2020-02-13 19:04:49 +01:00
Lennart Spitzner
0fdbd51de0
Revert embarrassing debugging leftover that breaks things badly
2020-02-06 20:28:53 +01:00
Lennart Spitzner
fad9db8fd8
Autoformat Config.hs
2020-01-23 13:56:25 +01:00
Lennart Spitzner
03e2b62c24
Introduce flag to disable formatting per-module
...
New inline config `-- brittany-disable` that parses but
ignores the current module. Useful if both brittany
and ghc-exactprint bug out for some syntax.
2020-01-23 13:56:25 +01:00
Lennart Spitzner
95686c20cd
Merge branch 'master' into error-handling
2020-01-22 22:58:40 +01:00
Lennart Spitzner
128dd828c2
Fix newline issue on comments before where
2020-01-11 23:19:04 +01:00
Lennart Spitzner
2b303b2a20
Fix additional indentation bug for let-in
2020-01-10 16:32:18 +01:00
Lennart Spitzner
d0256bb0db
Make unknown syntax errors non-fatal/Fall back on exactprint
2020-01-03 11:58:53 +01:00
Lennart Spitzner
342cf16c56
Improve error message printing
...
- Omit unnecessary show-invocation
- Use showOutputable for the error span (location)
before/after:
"RealSrcSpan SrcSpanPoint \"stdin\" 2 1: parse error (possibly incorrect indentation or mismatched brackets)"
stdin:2:1: parse error (possibly incorrect indentation or mismatched brackets)
2020-01-03 11:58:53 +01:00
Lennart Spitzner
af227a797d
Add a few code comments
2019-12-20 01:20:07 +01:00
Lennart Spitzner
6724760f40
Fix non-idempotent newlines with comment + where ( #263 )
2019-12-20 01:12:25 +01:00
Lennart Spitzner
00c6854887
Fix two minor data-decl layouting issues
2019-12-09 22:35:26 +01:00
Lennart Spitzner
3fbbf3d661
Fix one misplaced comment bug on data decls
2019-12-09 11:22:43 -07:00
Lennart Spitzner
6c3d9c57c5
Comment the single-line record decl config flag out
2019-12-09 11:22:43 -07:00
Lennart Spitzner
5a49277eba
Improve data decl layouting
...
- Fix bug in BackendUtil/lowest level of brittany about
alignment being ignored after a comment,
- Properly layout large (more than single-line) types in
record fields and in data decl rhs arguments,
- Properly layout data decl constructors with large "heads"
(forall, constraints),
- Add a config flag to control single-line layout of record
definition,
2019-12-09 11:20:28 -07:00
Evan Rutledge Borden
80f370a8e1
Support nullary data types
...
Add tests for nullary prefix data types and nullary record data types.
2019-12-09 11:17:32 -07:00
Lennart Spitzner
0381b9fe24
Fix record field comment indentation
2019-12-09 11:17:32 -07:00
Evan Rutledge Borden
9494d6203a
Allow multi line formatting of normal records
...
Only single line formatting of normal records was being supported. For
records with long names we need multi line formatting. This also needs
to support both multi and left indentation policies.
2019-12-09 11:17:32 -07:00
Lennart Spitzner
48490a7110
Fix handling of comment before data-decl
...
`docWrapNodePrior` caused duplication of offset of `data` keyword
and of comments connected to it.
2019-12-09 11:17:31 -07:00
Evan Rutledge Borden
aeaa043e99
Support building DataDecl with 8.0.2
2019-12-09 11:17:31 -07:00
Evan Rutledge Borden
9971e3905d
Support building DataDecl with 8.2.2
2019-12-09 11:17:31 -07:00
Lennart Spitzner
2f6967b7b8
Support comments in record data decls
2019-12-09 11:17:31 -07:00
Lennart Spitzner
d21ecf89e6
Fix a comment bug in tuple-type layouting
2019-12-09 11:17:31 -07:00
Lennart Spitzner
208a1ceadb
Start making datadecls work with ghc-8.4
2019-12-09 11:17:31 -07:00
Evan Rutledge Borden
57ba88a73c
Work-in-progress add record declaration layout
...
Simple records are supports. The tests cover:
- single records
- multi-field types
- columnized alignment
- basic deriving
- deriving strategies
- existential quanitification
A few items block merger
- retaining comments
A few items can be deferred:
- normal types
- sum types
2019-12-09 11:17:31 -07:00
Lennart Spitzner
4f827491da
Work-in-progress commit (deriving clause..)
2019-12-09 11:17:31 -07:00
Lennart Spitzner
172866755c
Start impl. layouting for datatypes ( #12 )
...
Only newtypes work for now; the "interesting" data records
are not touched yet.
Comment insertion not really considered yet; probably needs work.
2019-12-09 11:17:31 -07:00
Lennart Spitzner
e24271318d
Improve record-expression layouting
...
- Finish consolidation, clearing a TODO
- Fix two comment placement issues around record wildcards
- Fix regression in brittany-0.12 about layouting large
(multiline) record field updates
2019-12-05 14:30:50 +01:00
Lennart Spitzner
f87c0c64b8
Implement experimental semicolon-into-newlines feature
2019-12-04 13:55:41 +01:00
Lennart Spitzner
77d6d5b553
Fix roundtripping of (~) constraint/type
2019-11-27 22:21:16 +01:00
Lennart Spitzner
974826f98f
Fix whitespace regression on forall+constraint type sig
2019-11-08 12:11:35 +01:00
Lennart Spitzner
89b7655bac
Fix support for ghc-8.8
2019-09-29 21:45:46 +02:00
Lennart Spitzner
0795a39806
Fix infix matches with more than 2 args, fixes #219
2019-09-19 00:48:59 +02:00
Lennart Spitzner
6879436e67
Fix lambdas with lazy/bang pattern as first argument
2019-09-03 01:10:38 +02:00
Lennart Spitzner
702b993dab
Fix prefix operator pattern-match invalid result
2019-09-03 00:23:58 +02:00
Lennart Spitzner
8861f16624
Fix comment handling with let-in
2019-09-02 17:04:44 +02:00
Lennart Spitzner
91d6e18aba
Adapt to ghc-8.8 (deps are not ready though)
2019-09-02 17:04:44 +02:00
Lennart Spitzner
f289389879
Fix comment wandering left inside instance decls
2019-08-28 14:48:11 +02:00
Lennart Spitzner
6c69388d73
Make errors more descriptive
...
This is defensive against GHC API guarantees.
2019-07-19 00:12:04 +02:00
pepe iborra
a79b5e1a4b
Add support for Implicit Params
...
I don't know what I'm doing, but it type checks
Closes #246
2019-07-14 23:31:11 +01:00
Evan Borden
988d5b4353
Add support for OverloadedLabels
...
`OverloadedLabels` is a simple enough extension to parse and format. It
is becoming more common with use of `generic-lens`. Since it can be
treated as a `HsVar` its implementation only requires using `docLit`,
along with some marshalling for dealing with `FastString`.
2019-06-23 19:31:05 -05:00
Lennart Spitzner
3288ef3bd4
For funs with multiple matches, use the match id as id ( fixes #234 )
2019-06-16 22:51:18 +02:00
Lennart Spitzner
42f566b94a
Support QuasiQuotation-splices
2019-06-12 09:17:21 +02:00
Lennart Spitzner
517eda8526
Merge pull request #216 from matt-noonan/master
2019-06-05 22:41:22 +02:00
Lennart Spitzner
4f2673a2eb
Merge pull request #215 from matt-noonan/multiline-app-with-comments
...
Disable single-line HsApp with argument comments.
2019-06-05 21:06:02 +02:00
Lennart Spitzner
f9d70cf546
Refactor CPP slightly, Add test-cases
2019-06-05 21:05:27 +02:00
Lennart Spitzner
059bb9402e
Merge pull request #198 from ruhatch/type-synonyms
2019-06-05 15:56:50 +02:00
Lennart Spitzner
ca3c8b6f9e
Add one source doc
2019-06-05 15:56:32 +02:00
Lennart Spitzner
bd8b743e36
Document terminology "regular comments"
2019-06-05 15:42:47 +02:00
Matt Noonan
8551600377
Explicitly handle empty HsCase and HsLamCase.
2019-02-04 22:56:46 -05:00
Matt Noonan
6aa537089d
Disable single-line HsApp with argument comments.
2019-02-04 15:10:55 -05:00
Lennart Spitzner
621e00bf3f
Fix indentation (comments) after "if" ( Fixes #167 )
2018-11-14 14:53:08 +01:00
Rupert Horlick
01e31b4256
Add type fam instance formatting
2018-11-13 17:07:27 -04:00
Lennart Spitzner
e7d8f59e93
travis-ci: Add ghc-8.6, Clean up a bit
2018-11-04 22:14:02 +01:00
Lennart Spitzner
34735e27ef
Add compat with GHC-8.6 API
2018-11-04 22:14:00 +01:00
Lennart Spitzner
522e40c8ed
Retain empty lines before "where"
...
only applies to local "where"s (not module..where)
2018-11-04 18:13:37 +01:00
Lennart Spitzner
ad5868eb76
Fix spacing bugs, Clean up implemenation
...
- Normalize spaces on type alias lhs. unnecessary spaces were
retained previously, e.g.
"type ( ( a :%: b ) c ) = (a , c)"
had non-optimal output
- Clean up separator usage
- Remove backend hacks (to some degree)
- Minor reformatting and premature optimization
2018-10-27 16:15:28 +02:00
Rupert Horlick
e7d8b5f1ab
Fix type synonym comments
2018-10-19 15:55:29 -04:00
Rupert Horlick
b249c10054
Deal with parens inside comments on 8.4.3
2018-10-17 17:01:31 -04:00
Rupert Horlick
e1b43531a8
Add type synonym formatting
2018-10-16 19:28:30 -04:00
Lennart Spitzner
38216cdc02
Add longer doc/Refactor stripWhitespace'
2018-10-11 20:14:29 +02:00
Rupert Horlick
66fd44058d
Add instance formatting for simple case
2018-10-10 14:32:58 -04:00
Lennart Spitzner
6dc5561d08
Merge pull request #186 from sergv/unboxed-tuples
...
Unboxed tuples
2018-09-30 21:19:15 +02:00
Lennart Spitzner
71efa54954
Move tests, minor Refactoring, Add comments
2018-09-23 23:32:05 +02:00
Lennart Spitzner
460bd4dd2b
Merge pull request #185 from 5outh/benjamin/file-name-errors
...
Append input path name to UnknownNode errors
2018-09-23 22:29:42 +02:00
Sergey Vinokurov
9755db1d05
Unify "(#", "#)" under single name, docParenHashL and docParenHashR
2018-09-18 09:14:20 +01:00
Sergey Vinokurov
6898d3ef44
Lay out unboxed tuples in types
2018-09-18 09:07:15 +01:00
Sergey Vinokurov
281d7a2f81
Lay out unboxed tuples with spaces
...
This avoids clashes with names like foo#
2018-09-18 09:07:13 +01:00
Lennart Spitzner
37e4225c49
Include exact location when printing ErrorUnknownNode
2018-09-18 00:23:23 +02:00
Evan Rutledge Borden
92a1d89983
Consolidate record expression layouter
...
Both record construction and record layouting have very similar
constructions. These each had their own layouter with slightly different
variations. Variations here lead to subtley different bugs in layout for
nearly identicle syntactic forms.
The record update logic is more advanced and respects `IndentPolicyLeft`.
Instead of keeping these layouters distinct we can consolidate
construction logic into the update logic. This results in a smaller
volume of code and more uniform layouting of syntax for these simlilar
forms.
Record constructors with fields and wildcards are not included in this
consolidation. A TODO has been left to handle this consolidation later.
2018-09-16 15:47:04 -04:00
Lennart Spitzner
8c5cce5070
Prevent package environment file GHC API stupidities
...
This fixes the code-path for the commandline interface
(unfortunately not covered by our testsuite).
The other code-path should be covered by the changes in
https://github.com/alanz/ghc-exactprint/pull/68 .
2018-08-20 21:19:10 +02:00
Phil Hazelden
a5a24b4220
Fix imports of type operators.
...
Previously, we could only import a type operator with no subsequent
list, i.e.
import Foo ( (:.) )
was fine, but
import Foo ( (:.)(..) )
import Foo ( (:.)((:.) )
import Foo ( (:.)(A, b) )
would all break. Brittany would attempt to output them as
import Foo ( :.(..) )
import Foo ( :.((:.) )
import Foo ( :.(A, b) )
I believe the problem was that although `ieName <$> lie` was returning
an `IEWrappedName` with the same contents as used in `layoutWrapped`,
it had different location annotations; and the parentheses are
apparently saved in the location annotations.
2018-08-10 10:01:11 +01:00
Lennart Spitzner
4497fa927f
Add a comment about one superfluous docSetParSpacing
2018-07-06 22:57:33 +02:00
Lennart Spitzner
ab27825b7b
Core layouting algo improvement (non-bottom more effective)
...
During alt-transform, when gather spacings, previously
we tracked different non-bottom spacings separately even
though they would be treated in the same way during any
future transformations (apart from certain exceptions that
don't practically give better results). Instead we now
merge such spacings into one, giving more space for other
spacings when pruning to the spacings limit.
2018-07-06 22:41:31 +02:00
Lennart Spitzner
3c5670d5cd
Fix layouting for OpApps with comments (fixes 159)
2018-07-05 21:31:28 +02:00
Lennart Spitzner
95f42061d2
Fixup for the fix of ExplicitNames/PatternSynonyms for ghc-8.0
2018-07-04 22:42:20 +02:00
Lennart Spitzner
ab389fe66f
Support for -XExplicitNamespaces and -XPatternSynonyms
...
Properly round-trip export items of the forms "type OPERATOR"
or "pattern SYNONYM"
fixes #158
2018-07-04 21:42:46 +02:00
Lennart Spitzner
0b40dd7c32
Fix deprecation warnings with latest versions of yaml
2018-07-04 21:14:06 +02:00
Lennart Spitzner
cc0718e964
Add indentation to import-hiding-paragraph
2018-06-04 18:18:44 +02:00
Lennart Spitzner
5816704658
Fix import-hiding-paragraph with policy/=free ( fixes #150 )
2018-06-04 17:30:50 +02:00
Lennart Spitzner
6725d0e119
Refactor/Auto-format Main, Brittany.Internal
2018-06-04 17:10:10 +02:00
Lennart Spitzner
57c48f64c1
Apply inline config to module header ( fixes #151 )
2018-06-04 16:57:07 +02:00
Lennart Spitzner
bdee27cb59
Add spaces around record braces (single-line) ( fixes #126 )
2018-05-25 17:57:54 +02:00
Lennart Spitzner
f75127b3a5
Make non-bottom-spacing affect sameline, too ( fixes #144 )
2018-05-16 21:19:36 +02:00
Lennart Spitzner
4973298f30
Support same-line let decl when indentAmount>=4
2018-05-01 23:21:31 +02:00
Lennart Spitzner
dd53948a23
Fix IndentPolicyMultiple for indentAmount>4
2018-05-01 23:21:09 +02:00
Lennart Spitzner
e91bb6aec9
Clean up IndentPolicyMultiple
2018-05-01 23:19:44 +02:00
Bryan Richter
9ab17cc899
Implement IndentPolicyMultiple
2018-05-01 22:07:05 +02:00
Lennart Spitzner
929e465fd4
Refactor a bit (Internal.ppDecl -> Decl.layoutDecl)
2018-04-25 20:17:36 +02:00
Lennart Spitzner
e9aacb27ff
Implement hacky workaround for issue 89
2018-04-25 19:54:35 +02:00
Lennart Spitzner
a237e591b2
Implement `--obfuscate`
...
Support replacing all (non-keyword) identifiers with
randomly generated characters
2018-04-24 00:47:50 +02:00
Lennart Spitzner
696f72d336
Fixup last two commits (tests were effectively disabled
...
- re-enable tests
- un-break tests by fixing the alignment code behaviour
2018-04-24 00:38:40 +02:00
Lennart Spitzner
315a7e1ee1
Fix overflowing due to alignment; Add docs (alignment algorithm)
2018-04-23 19:33:04 +02:00
Lennart Spitzner
18704e403f
Fix inline disabling of brittany
2018-04-19 17:09:10 +02:00
Lennart Spitzner
17fb271694
Fix inlineconfig additions for ghc-8.4 + compat
...
The semigroup changes are a bit confusing when aiming
for backwards-compat.
2018-04-17 21:45:38 +02:00