Commit Graph

141 Commits (231c2f5e94b2d242de9990f11673e466418a445c)

Author SHA1 Message Date
Lennart Spitzner 18704e403f Fix inline disabling of brittany 2018-04-19 17:09:10 +02:00
Lennart Spitzner b43ee43220 Fix/Implement empty type constraint handling (fixes #133) 2018-04-02 17:11:53 +02:00
Lennart Spitzner 0845142727 Fix let-in comment placement bug (fixes #110) 2018-03-23 17:34:36 +01:00
Lennart Spitzner bdd3b155f3 Fix HsPar comment placement bug (see #111) 2018-03-23 17:11:39 +01:00
Lennart Spitzner 3847325fd5 Omit single-line layout for OpApp with comments (fixes #111) 2018-03-23 17:02:58 +01:00
Lennart Spitzner a003b932a9 Fix comments in tuples being dropped (fixes #37) 2018-03-23 16:55:28 +01:00
Lennart Spitzner d634d34ff1 Fix module-import-hiding-items layout 2018-03-23 15:41:41 +01:00
Lennart Spitzner 90a2f65ba7 Align applications on for same function, plus minor fixup
Arguments of two function applications will only be aligned
if the same function is called in both cases.

The column transform was altered slightly to fix #65
properly as well.

fixes #65, #128
2018-03-22 01:19:56 +01:00
Lennart Spitzner 46de13256b Add one more testcase 2018-03-21 16:03:38 +01:00
Lennart Spitzner f1536b8966 Merge pull request #83/#124 from sniperrifle2004/import 2018-03-21 01:06:26 +01:00
Lennart Spitzner 8de56ba11d Support import column vs import-as column 2018-03-21 01:02:44 +01:00
Lennart Spitzner 1330aeb6b4 Fix ticked type operator losing tick (fixes #125) 2018-03-13 23:51:22 +01:00
Lennart Spitzner 833ac95fd7 Add two config options to control preamble layouting 2018-03-12 17:11:25 +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 19e31fdaf2 Improve layouting of RecordUpd, Fix minor issue for HsLet 2018-02-19 21:33:43 +01:00
Lennart Spitzner c124336738 Fix NOINLINE pragma layouting 2018-02-19 17:17:39 +01:00
Lennart Spitzner 55b1c71bf3 Fix a layouting mistake that went unnoticed so far 2018-02-14 01:00:01 +01:00
Lennart Spitzner 91de1ca08c Fix bang deletion on ghc-8.2, Add testcase (fixes #116) 2018-02-13 23:48:00 +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
Lennart Spitzner 25ff576dc3
Merge pull request #97 from eborden/let-in-on-single-lines
Format let and in on a single line if they fit
2018-01-13 21:39:11 +01:00
Evan Rutledge Borden f1b49b082f Format let and in on a single line if they fit
The following is wasteful of vertical space:

```
_ =
  let
    longIdentifierForShortValue = 1
  in
    longIdentifierForShortValue + longIdentifierForShortValue
```

We should format it on two lines if possible.

```
_ =
  let longIdentifierForShortValue = 1
  in longIdentifierForShortValue + longIdentifierForShortValue
```

This commit also allows for a mix of variations:

```
_ =
  let
    longIdentifierForShortValue = 1
  in longIdentifierForShortValue + longIdentifierForShortValue

_ =
  let longIdentifierForShortValue = 1
  in
    longIdentifierForShortValue + longIdentifierForShortValue
```
2017-12-31 00:04:53 -05:00
Lennart Spitzner 37e355fea5 Support hanging type signature config option 2017-12-28 21:38:31 +01:00
Lennart Spitzner 43abab2dd2 Remove space after opening parenthesis (fixes #87) 2017-12-28 20:46:03 +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 a72465ebef Add context-free tests 2017-12-17 13:13:19 +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
Lennart Spitzner 39c48b33f1 Fix error in Annotation filtering (fixes #70) 2017-12-08 19:57:16 +01:00
Lennart Spitzner 127299b442 Merge branch 'dev' into indentpolicyleft 2017-11-30 23:47:18 +01:00
Lennart Spitzner 882a3b1a7a Allow single-line after let with IndentPolicyLeft 2017-11-30 23:20:35 +01:00
Lennart Spitzner 8a401d291e Workaround for #68: trim exactprinted text for unknown nodes 2017-11-28 18:23:05 +01:00
Lennart Spitzner 6a97379b33 Add whitespace around operator in section, Fixes #67 2017-11-28 17:56:28 +01:00
Evan Rutledge Borden f6859d184f Fix tests after rebase. 2017-11-27 13:05:04 -05:00
Evan Rutledge Borden e9a2de7a85 Filter binders with docSetBaseAndIndent. 2017-11-27 18:12:19 +01:00
Evan Rutledge Borden ba3d9ad739 Add tests for record construction. 2017-11-27 18:12:19 +01:00
Evan Rutledge Borden d7ac478fc6 Update type operator pending tests to remove context. 2017-11-27 18:12:19 +01:00
Evan Rutledge Borden 44e95940c0 Change record update syntax for left indent policy 2017-11-27 18:12:19 +01:00
Evan Rutledge Borden a6bea7542b Update pending long operator use for left indent. 2017-11-27 18:12:19 +01:00
Evan Rutledge Borden d1e1984206 Update guard formatting for IndentPolicyLeft 2017-11-27 18:12:19 +01:00
Evan Rutledge Borden f3c37a6abf Update pending long argument test to context free. 2017-11-27 18:12:19 +01:00
Evan Rutledge Borden cd9f7de566 Update pending type operator test for context free. 2017-11-27 18:12:19 +01:00
Evan Rutledge Borden 3bbf81baab Add literate tests for context free formatting
Left indent combined with no columnized alignment represents a context
free formatting style for brittany. These tests allow this format to be
tested until inline formatting tools are available to make these files
less redundant.
2017-11-27 18:12:19 +01:00
Lennart Spitzner 26f8cdfb65 Support RecursiveDo/`rec` keyword 2017-10-24 00:25:59 +02:00
Lennart Spitzner 338beb8eea Move testcases for extensions in separate testfile 2017-10-24 00:15:53 +02:00
Lennart Spitzner b1c6be7acd Fix parentheses around kind signatures, fixes #64 2017-10-15 00:23:14 +02:00
Lennart Spitzner f86665a251 Fix promoted HsTyVars on ghc-8.2.1
This fix does not work on ghc-8.0, because I do not understand
the 8.0 API in this instance. Could be resolved by looking
at annotations, but that really should not be necessary.
2017-10-14 23:21:13 +02:00
Lennart Spitzner a0112524aa Split up littests input into multiple files
*.blt instead of just tests.blt

yay for unix-style for ordering the inputs "15-regression.blt"
2017-10-02 20:53:56 +02:00
Lennart Spitzner ccf2eb092f Support RecordWildCards, Add one-liner layouting for records
fixes #52
2017-10-01 17:24:13 +02:00
Lennart Spitzner ca13a1897f Fix type application layouting (fixes #48)
- one-line externals are not detected as multiline in backend
- layouting of EAsPat (when TypeApplications is disabled)
- layouting of HsTyLit (TypeApplications with literals)
2017-08-20 14:09:03 +02:00
Lennart Spitzner fba8ad1a99 Fix negative literals in patterns (fixes #49) 2017-08-20 00:34:13 +02:00
Lennart Spitzner 655074d1c0 Fix comment insertion error introduced in 91b9a240 2017-08-10 13:09:39 +02:00
Lennart Spitzner 91b9a240f1 Fix comment-before-BDCols issue; Relax alignmentBreakOnMultiline 2017-08-07 00:35:09 +02:00
Lennart Spitzner 00ad6c71b9 Impl. layouting of TypeApplication, fixes #38 2017-07-28 18:03:21 +02:00
Lennart Spitzner 6268b8075a Fix layouting bug for RecordUpd 2017-07-04 23:57:54 +02:00
Lennart Spitzner 5a82968a7b Add sub-config-alternative default to lib interface
i.e. `forwardOptionsSyntaxExtsEnabled`
2017-07-04 23:26:13 +02:00
Lennart Spitzner cece70380c Fix/Implement proper layouting of MultiWayIf 2017-06-28 23:35:02 +02:00
Lennart Spitzner 6d472315e3 Fix layouting special-case (getSpacing(s) internals) 2017-06-04 18:15:22 +02:00
Lennart Spitzner 5e3cc0a7c3 Fix OpApp layouting/indentation annoyance 2017-06-04 16:28:01 +02:00
Lennart Spitzner 3784a0123b Refactor exposed function (now parsePrintModule)
- Rename parsePrintModule -> parsePrintModuleTests
- Rename pureModuleTransform -> parsePrintModule
- Change argument type from (CConfig Option) to Config
- Expose CConfig type fully
2017-06-03 18:23:03 +02:00
Lennart Spitzner f350113f7f Refactor all modules: +Internal; Add public Brittany module 2017-05-22 21:25:08 +02:00
Lennart Spitzner 8f1e366f9c Change config file structure; Add config version tag 2017-05-21 16:48:05 +02:00
Lennart Spitzner 4ee44388f7 Improve layouting for OpApp (special-case for dollar/HsVar) 2017-05-21 13:43:39 +02:00
Lennart Spitzner 8b7b1334e2 Fix forall type signature layouting 2017-05-18 14:18:10 +02:00
Lennart Spitzner 83ba7803e6 Fix layouting issues in lists/listcomprehension 2017-05-17 23:31:20 +02:00
Lennart Spitzner 6448ee780a Restrict aggressive horizontal alignment (fixes #21)
- Add config values:
  _lconfig_alignmentLimit for roughly "max spaces inserted"
  _lconfig_alignmentBreakOnMultiline for stopping
  alignment after non-singleline-items
2017-05-17 21:34:49 +02:00
Lennart Spitzner c701e5d00b Fix #26: Fix comment glitch in patternbind layouting
Prevent single-line layout when it would not even be
a single line due to a comment.
This patch might be a bit over-eager in at least one
case (I think you'd get a two-line layout with a
multiway-if and a comment _after_ the where binding).
2017-05-02 17:10:04 +02:00
Lennart Spitzner c3dc3b6074 And one more touch to ExplicitList 2017-05-02 16:32:43 +02:00
Lennart Spitzner ca42178eff Improve tuple layouting (also fixes #18 for tuples) 2017-05-02 16:21:13 +02:00
Lennart Spitzner f6324da600 Fix ExplicitList comment insertion (fixes #18) 2017-05-02 14:20:58 +02:00
Lennart Spitzner 505ad99f35 Handle InlineSig construct (pragma), fixes #20 2017-04-12 21:47:59 +02:00
Lennart Spitzner acbaba0782 Omit output syntax test for fix-point tests 2017-04-12 14:53:47 +02:00
Lennart Spitzner a7e4bdc168 Fix #16; Improve layouting in two cases; Add comments
- the #16 fix is a one-liner:
  Throw `nub` at spacings before pruning.
- Expr/OpApp layouting: Force single-line for children in
  the params-in-multiple-lines-right-of-the-function case.
- Expr/HsIf layouting: Insert a SetBaseY to prevent
  "then"/"else" being placed left of "if".
2017-03-16 23:02:11 +01:00
Lennart Spitzner 7dc6c525eb Fix minor layouting issue with long guards
(see test multiple-clauses-4)
2017-03-07 21:44:28 +01:00
Lennart Spitzner cea81d5369 Add indentation to the paragraphs inserted in patterns
Ugly, but fixes #6. Ugly still better than non-valid-haskell result.
2017-03-06 16:56:38 +01:00
Lennart Spitzner 8d163eb099 Improve layouting for equations with multiple clauses
e.g.
func x | x         = simple expression
       | otherwise = 0

This fixes part of #7
2017-03-06 16:03:47 +01:00
Lennart Spitzner 0a907c5594 Add some pending issues testcases 2017-03-01 22:04:41 +01:00
Lennart Spitzner 93611b9a1c Apply brittany 2017-01-31 18:44:39 +01:00
Lennart Spitzner bc70eb07e8 Change config setup(!), Refactor, Update deps
- config now uses foo_bar instead of _foo_bar;
- config now will accept missing keys;
- use latest butcher version;
- improve identity testing by moving into separate file.
2017-01-31 18:43:16 +01:00