Docs: F# style guidelines: no advice given for reverse pipeline operator

Created on 10 Nov 2020  Â·  5Comments  Â·  Source: dotnet/docs

Issue description

Advice is given about how to use forward pipeline operators |> (chaining them by putting an EOL character next to them on the left side), e.g.

|> someFunc
|> otherFunc

However, what to do with reverse pipeline operators? Splitting them in the same way looks odd, e.g.:

failwith <| sprintf "foo: %s - bar: %s" foo bar

failwith
<| sprintf "foobar: %s - foobarbaz: %s" foobar foobarbaz

So I recommend that an example is given which looks like the following:

failwith <| sprintf "foo: %s - bar: %s" foo bar

failwith <| sprintf "foobar: %s - foobarbaz: %s"
                    foobar
                    foobarbaz

_Document details added by adegeo_


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Area - F# Guide Pri2 doc-enhancement dotnet-fsharprod

Most helpful comment

I would like to point out that the recommendation has a 'vanity' indentation problem I believe.
foobar and foorbarbaz are indented with 20 spaces in the example and I think that is determined by the length of the word failwith.

If it were failwithSuperLongBananas, the indentation would increase because of the function name.

failwithSuperLongBananas <| sprintf "foobar: %s - foobarbaz: %s"
                                foobar
                                foobarbaz

where

failwithSuperLongBananas 
<| sprintf "foobar: %s - foobarbaz: %s" foobar foobarbaz

does not have this problem.

@cmeeren, @pragmatrix, @lydell this is the place do discuss these things ;)

All 5 comments

I would like to point out that the recommendation has a 'vanity' indentation problem I believe.
foobar and foorbarbaz are indented with 20 spaces in the example and I think that is determined by the length of the word failwith.

If it were failwithSuperLongBananas, the indentation would increase because of the function name.

failwithSuperLongBananas <| sprintf "foobar: %s - foobarbaz: %s"
                                foobar
                                foobarbaz

where

failwithSuperLongBananas 
<| sprintf "foobar: %s - foobarbaz: %s" foobar foobarbaz

does not have this problem.

@cmeeren, @pragmatrix, @lydell this is the place do discuss these things ;)

For reference, the Fantomas issue mentioning vanity indentation: https://github.com/fsprojects/fantomas/issues/659

@nojaf What do you mean by

this is the place do discuss these things ;)

Are you saying that the Fantomas repo is not the place to discuss the issue @lydell linked to above, and that unless this is rectified in the official style guidelines, vanity indentation won't be changed in Fantomas?

If so, remember, the guidelines are just that, guidelines :)

(Mandatory Captain Barbossa meme)

In any case, I think the linked issue pretty much sums up why vanity indentation might not be a good idea.

<| sprintf "foobar: %s - foobarbaz: %s" foobar foobarbaz

Makes me giggle but I suppose it's the least friction. Happy to accept a PR!

@cmeeren, style needs to discussed over here and what gets in this style guide gets in Fantomas.
Sorry for the burden Phillip ;)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ygoe picture ygoe  Â·  3Comments

svick picture svick  Â·  3Comments

LJ9999 picture LJ9999  Â·  3Comments

stanuku picture stanuku  Â·  3Comments

JagathPrasad picture JagathPrasad  Â·  3Comments