Format let and in on a single line if they fit #73

Closed
opened 2017-12-04 00:14:08 +01:00 by tfausak · 3 comments
tfausak commented 2017-12-04 00:14:08 +01:00 (Migrated from github.com)

https://github.com/lspitzner/brittany/pull/66#issuecomment-348820992

Using the currently unreleased IndentPolicyLeft/ColumnAlignModeDisabled config, Brittany formats let ... in ... like this:

_ =
  let
    longIdentifierForShortValue = 1
  in
    longIdentifierForShortValue + longIdentifierForShortValue

I expected both let and in to be on a single line, like this:

_ =
  let longIdentifierForShortValue = 1
  in longIdentifierForShortValue + longIdentifierForShortValue
https://github.com/lspitzner/brittany/pull/66#issuecomment-348820992 Using the currently unreleased `IndentPolicyLeft`/`ColumnAlignModeDisabled` config, Brittany formats `let ... in ...` like this: ``` hs _ = let longIdentifierForShortValue = 1 in longIdentifierForShortValue + longIdentifierForShortValue ``` I expected both `let` and `in` to be on a single line, like this: ``` hs _ = let longIdentifierForShortValue = 1 in longIdentifierForShortValue + longIdentifierForShortValue ```
lspitzner commented 2017-12-08 23:00:22 +01:00 (Migrated from github.com)

Indeed, the approach from 882a3b1a7a can be applied to the relevant layouter in Expr.hs too. I am a bit unsure though which combinations should be accepted, i.e. should the following layouts be possible:

_ =
  let singlelinebinder = 1
  in
    some
      multiline
      expression
-- and
_ =
  let
    some long stuff = do
      blah
      blub
  in singleline expression

this boils down to permitting layouters
"let (single|multiline) in (single|multiline)" vs
"(let singleline in singleline | let multiline in multiline)"

Indeed, the approach from 882a3b1a7a7851b36fb147580ad36eda2d28abc6 can be applied to the relevant layouter in `Expr.hs` too. I am a bit unsure though which combinations should be accepted, i.e. should the following layouts be possible: ~~~~.hs _ = let singlelinebinder = 1 in some multiline expression -- and _ = let some long stuff = do blah blub in singleline expression ~~~~ this boils down to permitting layouters "let (single|multiline) in (single|multiline)" vs "(let singleline in singleline | let multiline in multiline)"
tfausak commented 2017-12-08 23:41:17 +01:00 (Migrated from github.com)

I would prefer "let (single|multiline) in (single|multiline)". I don't particularly care about them matching; I want them to avoid wasting vertical space.

a =
  let it = foo
  in it
-- maybe even `a = let it = foo in it` if everything fits
-- not sure if it's like that already
b =
  let
    it = do
      foo
      bar
  in it
c =
  let it = foo
  in -- maybe start long expression here instead of next line
    do
      it
      bar
d =
  let
    it = do
      foo
      bar
  in
    do
      it
      baz
I would prefer "let (single|multiline) in (single|multiline)". I don't particularly care about them matching; I want them to avoid wasting vertical space. ``` hs a = let it = foo in it -- maybe even `a = let it = foo in it` if everything fits -- not sure if it's like that already b = let it = do foo bar in it c = let it = foo in -- maybe start long expression here instead of next line do it bar d = let it = do foo bar in do it baz
eborden commented 2018-01-13 22:38:26 +01:00 (Migrated from github.com)

@lspitzner I believe you can close this with the merger of #97

@lspitzner I believe you can close this with the merger of #97
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#73
There is no content yet.