Turn off all context sensitive alignment in Brittany. #56

Closed
opened 2017-09-21 20:27:32 +02:00 by eborden · 6 comments
eborden commented 2017-09-21 20:27:32 +02:00 (Migrated from github.com)

Hey @lspitzner, I think brittany is a fantastic project, but I'm having trouble getting it to behave the way I'd like. I was able to disable most context sensitive alignment, but I can't seem to rid the world of it. My config is:

conf_debug:
  dconf_dump_bridoc_simpl_par: false
  dconf_dump_ast_unknown: false
  dconf_dump_bridoc_simpl_floating: false
  dconf_dump_config: false
  dconf_dump_bridoc_raw: false
  dconf_dump_bridoc_final: false
  dconf_dump_bridoc_simpl_alt: false
  dconf_dump_bridoc_simpl_indent: false
  dconf_dump_annotations: false
  dconf_dump_bridoc_simpl_columns: false
  dconf_dump_ast_full: false
conf_forward:
  options_ghc: []
conf_errorHandling:
  econf_ExactPrintFallback: ExactPrintFallbackModeInline
  econf_Werror: false
  econf_omit_output_valid_check: false
  econf_CPPMode: CPPModeAbort
  econf_produceOutputOnErrors: false
conf_layout:
  lconfig_altChooser:
    tag: AltChooserBoundedSearch
    contents: 3
  lconfig_importColumn: 60
  lconfig_alignmentLimit: 1
  lconfig_indentListSpecial: true
  lconfig_indentAmount: 2
  lconfig_alignmentBreakOnMultiline: false
  lconfig_cols: 120
  lconfig_indentPolicy: IndentPolicyLeft
  lconfig_indentWhereSpecial: true
  lconfig_columnAlignMode:
    tag: ColumnAlignModeDisabled
    contents: []

But I still get code like this:

+    socialStudiesReadingAssignmentSessions <- getEntities socialStudiesProducts
+                                                          SocialStudiesProductReading
+                                                          getSocialStudiesReadingAssignmentSessions
+    socialStudiesWritingAssignmentSessions <- getEntities socialStudiesProducts
+                                                          SocialStudiesProductWriting
+                                                          getSocialStudiesWritingAssignmentSessions

Is there any way to turn this off completely?

Hey @lspitzner, I think `brittany` is a fantastic project, but I'm having trouble getting it to behave the way I'd like. I was able to disable most context sensitive alignment, but I can't seem to rid the world of it. My config is: ``` conf_debug: dconf_dump_bridoc_simpl_par: false dconf_dump_ast_unknown: false dconf_dump_bridoc_simpl_floating: false dconf_dump_config: false dconf_dump_bridoc_raw: false dconf_dump_bridoc_final: false dconf_dump_bridoc_simpl_alt: false dconf_dump_bridoc_simpl_indent: false dconf_dump_annotations: false dconf_dump_bridoc_simpl_columns: false dconf_dump_ast_full: false conf_forward: options_ghc: [] conf_errorHandling: econf_ExactPrintFallback: ExactPrintFallbackModeInline econf_Werror: false econf_omit_output_valid_check: false econf_CPPMode: CPPModeAbort econf_produceOutputOnErrors: false conf_layout: lconfig_altChooser: tag: AltChooserBoundedSearch contents: 3 lconfig_importColumn: 60 lconfig_alignmentLimit: 1 lconfig_indentListSpecial: true lconfig_indentAmount: 2 lconfig_alignmentBreakOnMultiline: false lconfig_cols: 120 lconfig_indentPolicy: IndentPolicyLeft lconfig_indentWhereSpecial: true lconfig_columnAlignMode: tag: ColumnAlignModeDisabled contents: [] ``` But I still get code like this: ``` + socialStudiesReadingAssignmentSessions <- getEntities socialStudiesProducts + SocialStudiesProductReading + getSocialStudiesReadingAssignmentSessions + socialStudiesWritingAssignmentSessions <- getEntities socialStudiesProducts + SocialStudiesProductWriting + getSocialStudiesWritingAssignmentSessions ``` Is there any way to turn this off completely?
lspitzner commented 2017-09-21 20:59:54 +02:00 (Migrated from github.com)

No, this is not implemented (yet). I see you set lconfig_indentPolicy = IndentPolicyLeft already, and that setting is planned to do exactly what you want, but I fear the field is currently ignored entirely.

(This is related to #54, the implementation of which similarly would disable certain layouting alternatives based on config.)

In a way, implementing this depends on #30 because otherwise we cannot easily write tests for this.

I make no promises as to when I will find time to work on this.

No, this is not implemented (yet). I see you set `lconfig_indentPolicy = IndentPolicyLeft` already, and that setting is planned to do exactly what you want, but I fear the field is currently ignored entirely. (This is related to #54, the implementation of which similarly would disable certain layouting alternatives based on config.) In a way, implementing this depends on #30 because otherwise we cannot easily write tests for this. I make no promises as to when I will find time to work on this.
eborden commented 2017-09-21 22:47:50 +02:00 (Migrated from github.com)

@lspitzner Are you open to pull requests? Is there an easy way to contribute to this project?

@lspitzner Are you open to pull requests? Is there an easy way to contribute to this project?
lspitzner commented 2017-09-21 23:14:33 +02:00 (Migrated from github.com)

Certainly, PR is welcome. Not sure how hard the DSL is to understand, although "conditionally disabling" is on the easier side..

Any necessary changes should be in the Language.Haskell.Brittany.Internal.Layouters.* modules.

  • Perhaps start with Layouters.Expr, because that contains the code for the example you mentioned.
  • Replace docAlt [x, y] with docAltFilter [(,) _ x, (,) _ y] where the holes depend on stuff read from the config.
  • The relevant case for the example is HsApp, where the comments should clearly point out the different layouts, so you should see which one to disable.

Unfortunately not all stuff is documented that clearly yet.. another indicator is the usage of docSetBaseY, which roughly expresses "take the current column, and use it as base indentation for every syntax node below" - the thing you do not want.

Maybe it is best if I implement the HsApp case, and you can see which other cases require attention and apply the same treatment to those? The main work for this really is finding the right places to disable, not the disabling itself.. Give me a sec.

Certainly, PR is welcome. Not sure how hard the DSL is to understand, although "conditionally disabling" is on the easier side.. Any necessary changes should be in the `Language.Haskell.Brittany.Internal.Layouters.*` modules. - Perhaps start with `Layouters.Expr`, because that contains the code for the example you mentioned. - Replace `docAlt [x, y]` with `docAltFilter [(,) _ x, (,) _ y]` where the holes depend on stuff read from the config. - The relevant case for the example is `HsApp`, where the comments should clearly point out the different layouts, so you should see which one to disable. Unfortunately not all stuff is documented that clearly yet.. another indicator is the usage of `docSetBaseY`, which roughly expresses "take the current column, and use it as base indentation for every syntax node below" - the thing you do not want. Maybe it is best if I implement the HsApp case, and you can see which other cases require attention and apply the same treatment to those? The main work for this really is finding the right places to disable, not the disabling itself.. Give me a sec.
lspitzner commented 2017-09-21 23:31:58 +02:00 (Migrated from github.com)

@eborden I have pushed a start to the indentpolicyleft branch. Commit d019c044197fad9bf2a3e91eed4b36ec17e6771f is the important bit. The other commit just indents the whole thing a bit.. the diff probably looks scarier than necessary :-)

@eborden I have pushed a start to the `indentpolicyleft` branch. Commit d019c044197fad9bf2a3e91eed4b36ec17e6771f is the important bit. The other commit just indents the whole thing a bit.. the diff probably looks scarier than necessary :-)
lspitzner commented 2017-09-21 23:51:19 +02:00 (Migrated from github.com)

(And forgive me if the layouting of the brittany source itself is not very consistent there - I have gotten lazy when it comes to formatting manually, and brittany cannot cope with the CPP bits required for ghc-8.0/8.2 support..)

(And forgive me if the layouting of the `brittany` source itself is not very consistent there - I have gotten lazy when it comes to formatting manually, and `brittany` cannot cope with the CPP bits required for ghc-8.0/8.2 support..)
eborden commented 2017-09-22 00:05:57 +02:00 (Migrated from github.com)

Awesome, I'll take a look. Hopefully I can be helpful.

Awesome, I'll take a look. Hopefully I can be helpful.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: hexagoxel/brittany#56
There is no content yet.