fantomas icon indicating copy to clipboard operation
fantomas copied to clipboard

Vanity alignment inside indexing expression

Open knocte opened this issue 2 years ago • 2 comments

Issue created from fantomas-online

Code


module Test =
    let parsePacket() =
        match Foo.bar() with
        | false -> failwith "NIE"
        | true ->
            match Foo.baz() with
            | true ->
                let perHopPayloadLength = 1
                let MacLength = 1
                let bin = Array.zeroCreate 0

                let hmac =
                    bin.[perHopPayloadLength - MacLength .. perHopPayloadLength - 1]

                hmac
            | false -> failwith "NIE"

Result

module Test =
    let parsePacket () =
        match Foo.bar () with
        | false -> failwith "NIE"
        | true ->
            match Foo.baz () with
            | true ->
                let perHopPayloadLength = 1
                let MacLength = 1
                let bin = Array.zeroCreate 0

                let hmac =
                    bin.[perHopPayloadLength - MacLength .. perHopPayloadLength
                                                            - 1]

                hmac
            | false -> failwith "NIE"

Problem description

Vanity alignment used. Any hints on expected results? if provided, my team will work on this issue. Thanks!

Extra information

  • [ ] The formatted result breaks my code.
  • [ ] The formatted result gives compiler warnings.
  • [x] I or my company would be willing to help fix this.

Options

Fantomas master branch at 2022-07-01T17:23:51Z - e59f7df65757f637b753c7d3f5bd788c18145518

    { config with
                MaxLineLength = 80 }

knocte avatar Jul 04 '22 06:07 knocte

Any hints on expected results?

Hmm, not really, could you please raise this with the style guide? Whatever we settle on will probably look weird to the next user, so I want to have the discussion in the right place.

if provided, my team will work on this issue.

Thank you.

nojaf avatar Jul 04 '22 06:07 nojaf

@knocte I am interested in your opinion about "max line length": https://github.com/fsharp/fslang-design/discussions/692

Also, I feel calling "verticalhorizontal alignment" "vanity alignment" skews things.

VerticalHorizontal alignment is very common concept related to code while "vanity alignment" seems to be a special term specific to you, based on googling.

In any case, the formatting here is a bit problematic, but I assume it stems from concept of max line length, and fact that indenting code one block farther will rejig or not things, unless max line length is set to very high value.

smoothdeveloper avatar Jul 06 '22 18:07 smoothdeveloper