Commit Graph

55 Commits (8bd669f1456a1cf1c3a475af44480a1bd4c63b4f)

Author SHA1 Message Date
Lennart Spitzner 00c6854887 Fix two minor data-decl layouting issues 2019-12-09 22:35:26 +01:00
Lennart Spitzner a1282c3ac6 Add a testcase for the last commit 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 a23ef696e8 Fix test failure: DerivingStrategies exists since ghc-8.2 2019-12-09 11:17:32 -07:00
Lennart Spitzner 54f34344b3 Implement #min-ghc keyword for test script 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 b2f4262749 Isolate deriving via test 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
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 0795a39806 Fix infix matches with more than 2 args, fixes #219 2019-09-19 00:48:59 +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 517eda8526 Merge pull request #216 from matt-noonan/master 2019-06-05 22:41:22 +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 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 2eb22e730f Add tests for empty lines around where 2018-11-04 18:13:37 +01:00
Rupert Horlick e7d8b5f1ab
Fix type synonym comments 2018-10-19 15:55:29 -04:00
Rupert Horlick e1b43531a8
Add type synonym formatting 2018-10-16 19:28:30 -04:00
Rupert Horlick 66fd44058d
Add instance formatting for simple case 2018-10-10 14:32:58 -04: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 5816704658 Fix import-hiding-paragraph with policy/=free (fixes #150) 2018-06-04 17:30:50 +02:00
Lennart Spitzner d634d34ff1 Fix module-import-hiding-items layout 2018-03-23 15:41:41 +01:00
Lennart Spitzner 46de13256b Add one more testcase 2018-03-21 16:03:38 +01:00
Lennart Spitzner 9531edb2a7 Improve module layouting in two aspects
- IEThingWith in export list can now be single-line
- Now respect offset of the "module" keyword
  (retain empty lines after pragmas, for example)
2018-03-12 16:29:47 +01:00
Lennart Spitzner 20f9c009ee Stop hanging indent for IEThingWith
plus minor refactors/cleanups

this is more in line with IndentPolicyLeft and imo also looks
nicer in general
2018-03-11 22:49:20 +01:00
Lennart Spitzner 41a60ce60f Merge branch 'master' into import 2018-03-11 17:43:16 +01:00
Lennart Spitzner c124336738 Fix NOINLINE pragma layouting 2018-02-19 17:17:39 +01:00
Evan Rutledge Borden 019d47bf7e Change infix patterns to include spaces
This commit changes infix patterns to utilize `lrdrNameToTextAnn`. This
function allows the logic to avoid introspecting on the constructor
name.

Additionally this adds spaces to all infix operator pattern matches.
Previously infix symbols did not include spaces:

```
foo (x:xs) = _
```

Now they include a space

```
foo (x : xs) = _
```
2018-02-09 16:43:44 +01:00
Evan Rutledge Borden 18b3cfaf88 Fix infix constructor pattern matching for normal constructors
Brittany was previously only support symbol based infix constructors. It
is common in some libraries (for example Esqueleto) to pattern match on
normal constructors as infix. Brittany was failing in this case by not
wrapping the constructor name in back ticks/spaces. Backticks and spaces
have been added in the case where the constructor contains any alpha
characters.
2018-02-09 16:43:29 +01:00
sniperrifle2004 98c93f0d63 Move expanded binding list to standard indent level for compact layout 2017-12-22 16:35:39 +01:00
sniperrifle2004 ad34a8b9b9 Only expand empty binding list with comments 2017-12-22 10:18:09 +01:00
sniperrifle2004 3708838b6a Also handle comments inside ThingWith 2017-12-22 06:58:39 +01:00
sniperrifle2004 21c080572b Add compact version of import layout
Also let layoutLLIEs deal with comments
2017-12-21 23:51:27 +01:00
Lennart Spitzner f651d02898 Merge branch 'dev' into import 2017-12-19 22:27:37 +01:00
sniperrifle2004 162b6e6bfd Also fix export comments
Also refactored a little to improve reuse of the docWrapNode logic
2017-12-19 16:33:13 +01:00
sniperrifle2004 a59df1f391 Fix comments!! 🎉 2017-12-19 14:28:22 +01:00
sniperrifle2004 7c51a181c8 Fix operators for ThingWith 2017-12-19 01:17:19 +01:00
Lennart Spitzner 8c3a9bec25 Fix operators in import list 2017-12-18 18:56:50 +01:00
sniperrifle2004 c3b6e17261 Improve layout for imports 2017-12-18 13:17:24 +01:00
Lennart Spitzner 204f0aff08 import+module: Refactor and Simplify slightly 2017-12-17 21:14:46 +01:00
sniperrifle2004 ee9abff9e8 Add import and module support 2017-12-17 12:51:04 +01:00
Matthew Piziak 9704fc3490
add tuple section tests 2017-12-14 18:15:07 -05:00