Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fantomas cuts a long line of code in the middle of a pattern match #884

Open
JackMatusiewicz opened this issue Jun 4, 2020 · 6 comments

Comments

@JackMatusiewicz
Copy link
Contributor

Issue created from fantomas-online

The long line of code for the lambda has multiple pattern matches in it. The default configuration settings of fantomas means that when it tries to shorten the length of the line it splits the pattern match over many lines, lead to invalid code

Code

module MyModule =

    let foo : Foo -> Foo =
        BigLongTypee.doStuff<aaaaaaaaaaaaa, bbbbbb, BigLongTypee>
            (fun aaa bbbbbb (CCC ccc) ddddddddddd (EEEE eee) (FFF fff) ggggg ->
                failwith "Not important"
            )

Error

Fantomas was able to format the code but the result appears to be invalid F# code.
Please open an issue.

Formatted result:

module MyModule =

    let foo: Foo -> Foo =
        BigLongTypee.doStuff<aaaaaaaaaaaaa, bbbbbb, BigLongTypee> (fun aaa bbbbbb (CCC ccc) ddddddddddd (EEEE eee) (FFF
                fff) ggggg -> failwith "Not important")

Options

Fantomas Master at 06/02/2020 18:39:46 - eee0f32

Name Value
IndentSpaceNum 4
PageWidth 120
SemicolonAtEndOfLine false
SpaceBeforeParameter true
SpaceBeforeLowercaseInvocation true
SpaceBeforeUppercaseInvocation false
SpaceBeforeClassConstructor false
SpaceBeforeMember false
SpaceBeforeColon false
SpaceAfterComma true
SpaceBeforeSemicolon false
SpaceAfterSemicolon true
IndentOnTryWith false
SpaceAroundDelimiter true
MaxIfThenElseShortWidth 40
MaxInfixOperatorExpression 50
MaxRecordWidth 40
MaxArrayOrListWidth 40
MaxLetBindingWidth 40
MultilineBlockBracketsOnSameColumn false
NewlineBetweenTypeDefinitionAndMembers false
KeepIfThenInSameLine false
StrictMode false
@deviousasti
Copy link
Member

Linking #842

@nojaf
Copy link
Contributor

nojaf commented Jul 15, 2020

Not sure if this is a bug anymore, looks ok now in online tool.

@deviousasti
Copy link
Member

That's true. It doesn't seem to be respecting MaxLineLength though.

@nojaf
Copy link
Contributor

nojaf commented Jul 15, 2020

True

@nojaf
Copy link
Contributor

nojaf commented Aug 14, 2020

Would

module MyModule =

    let foo : Foo -> Foo =
        BigLongTypee.doStuff<aaaaaaaaaaaaa, bbbbbb, BigLongTypee>
            (fun aaa 
                 bbbbbb 
                 (CCC ccc) 
                 ddddddddddd 
                 (EEEE eee) 
                 (FFF fff) 
                 ggggg ->
                failwith "Not important"
            )

be a solution to respect the max line length?

@deviousasti
Copy link
Member

This seems fairly readable.
It's more of a best-fit rather than absolute limit?

For e.g., I don't think we can make BigLongTypee.doStuff<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> (however unlikely) respect max line length.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants