Strange hiding formatting #150

Closed
opened 2018-06-03 16:57:45 +02:00 by pbrisbin · 3 comments
pbrisbin commented 2018-06-03 16:57:45 +02:00 (Migrated from github.com)

With brittany-0.11.0.0, I'm getting the following for a long hiding import, is it intentional?

import Prelude as X
    hiding ( head
    , init
    , last
    , maximum
    , minimum
    , pred
    , read
    , readFile
    , succ
    , tail
    )

It looks quite weird to me, I would've expected this:

import Prelude as X hiding
    ( head
    , init
    , last
    , maximum
    , minimum
    , pred
    , read
    , readFile
    , succ
    , tail
    )

Or maybe this:

import Prelude as X
    hiding
        ( head
        , init
        , last
        , maximum
        , minimum
        , pred
        , read
        , readFile
        , succ
        , tail
        )

I'm using this configuration:

---
conf_debug:
  dconf_roundtrip_exactprint_only: false
  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_produceOutputOnErrors: false
conf_preprocessor:
  ppconf_CPPMode: CPPModeAbort
  ppconf_hackAroundIncludes: false
conf_version: 1
conf_layout:
  lconfig_altChooser:
    tag: AltChooserBoundedSearch
    contents: 3
  lconfig_importColumn: 60
  lconfig_alignmentLimit: 1
  lconfig_indentListSpecial: true
  lconfig_indentAmount: 4
  lconfig_alignmentBreakOnMultiline: true
  lconfig_cols: 80
  lconfig_indentPolicy: IndentPolicyLeft
  lconfig_indentWhereSpecial: true
  lconfig_columnAlignMode:
    tag: ColumnAlignModeDisabled
    contents: 0.7
With `brittany-0.11.0.0`, I'm getting the following for a long `hiding` import, is it intentional? ```hs import Prelude as X hiding ( head , init , last , maximum , minimum , pred , read , readFile , succ , tail ) ``` It looks quite weird to me, I would've expected this: ```hs import Prelude as X hiding ( head , init , last , maximum , minimum , pred , read , readFile , succ , tail ) ``` Or maybe this: ```hs import Prelude as X hiding ( head , init , last , maximum , minimum , pred , read , readFile , succ , tail ) ``` I'm using this configuration: ```yaml --- conf_debug: dconf_roundtrip_exactprint_only: false 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_produceOutputOnErrors: false conf_preprocessor: ppconf_CPPMode: CPPModeAbort ppconf_hackAroundIncludes: false conf_version: 1 conf_layout: lconfig_altChooser: tag: AltChooserBoundedSearch contents: 3 lconfig_importColumn: 60 lconfig_alignmentLimit: 1 lconfig_indentListSpecial: true lconfig_indentAmount: 4 lconfig_alignmentBreakOnMultiline: true lconfig_cols: 80 lconfig_indentPolicy: IndentPolicyLeft lconfig_indentWhereSpecial: true lconfig_columnAlignMode: tag: ColumnAlignModeDisabled contents: 0.7 ```
pbrisbin commented 2018-06-03 17:02:09 +02:00 (Migrated from github.com)

Oh, I'm sorry! I don't know for sure if this is caused by brittany, stylish-haskell, or the fact that I'm using both in the same project. I'm going to close and may re-open if I can suss that out.

EDIT: This is indeed Brittany. Using only stylish-haskell, I get:

import Prelude as X hiding
    (head, init, last, maximum, minimum, pred, read, readFile, succ, tail)

And I get a correct vertical alignment when I go past 80 columns.

~~Oh, I'm sorry! I don't know for sure if this is caused by brittany, stylish-haskell, or the fact that I'm using both in the same project. I'm going to close and may re-open if I can suss that out.~~ EDIT: This is indeed Brittany. Using only stylish-haskell, I get: ```hs import Prelude as X hiding (head, init, last, maximum, minimum, pred, read, readFile, succ, tail) ``` And I get a correct vertical alignment when I go past 80 columns.
lspitzner commented 2018-06-04 18:13:37 +02:00 (Migrated from github.com)

@pbrisbin this fix produces the very basic

-- brittany { lconfig_indentPolicy: IndentPolicyLeft, lconfig_indentAmount: 4 }

import Prelude as X
    hiding
    ( head
    , init
    , last
    , maximum
    , minimum
    , pred
    , read
    , readFile
    , succ
    , tail
    , undefined
    )

I can change this to one of your proposed versions. I think I'd rather go with the second one, as the reader might overlook the "hiding" in the first version? What is your preference?

@pbrisbin this fix produces the very basic ~~~~ -- brittany { lconfig_indentPolicy: IndentPolicyLeft, lconfig_indentAmount: 4 } import Prelude as X hiding ( head , init , last , maximum , minimum , pred , read , readFile , succ , tail , undefined ) ~~~~ I can change this to one of your proposed versions. I think I'd rather go with the second one, as the reader might overlook the "hiding" in the first version? What is your preference?
pbrisbin commented 2018-06-04 18:28:57 +02:00 (Migrated from github.com)

Thanks for such a quick turn around! It's totally up to you if you want to change things further, but if you're asking for my own total ideal, it would be this:

(indent 4, columns 80)

import {module} (as {alias}) hiding
    ( ...
    )

But, if "import {module} (as {alias})" cross 80-columns, then

import qualified {super duper long module name} as {also super duper long alias name}
    hiding
        ( ...
        )

Or maybe this?

import qualified {super duper long module name}
    as {also super duper long alias name}
    hiding
        ( ...
        )
Thanks for such a quick turn around! It's totally up to you if you want to change things further, but if you're asking for my own total ideal, it would be this: (indent 4, columns 80) ```hs import {module} (as {alias}) hiding ( ... ) ``` But, if "import {module} (as {alias})" cross 80-columns, then ```hs import qualified {super duper long module name} as {also super duper long alias name} hiding ( ... ) ``` Or maybe this? ```hs import qualified {super duper long module name} as {also super duper long alias name} hiding ( ... ) ```
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#150
There is no content yet.