fsprojects / fantomas

FSharp source code formatter
https://fsprojects.github.io/fantomas
Other
772 stars 194 forks source link

"Better" support for nesting complex expressions in async { } blocks #386

Closed isaacabraham closed 4 years ago

isaacabraham commented 5 years ago

let! bindings don't indent the same as non-let! ones:

let x data =
    async { 
        let bar =
            data
            |> Array.map id
            |> Array.filter ((=) 1)
            |> Array.countBy id
            |> async.Return
        return bar
    }

But if you change the let to a let!:

let x data =
    async { 
        let! bar = data
                   |> Array.map id
                   |> Array.filter ((=) 1)
                   |> Array.countBy id
                   |> async.Return
        return bar
    }

This uses up lots of horizontal space and doesn't scale well if the expression is larger.

nojaf commented 5 years ago

Please mention your configuration. What is the value of PreserveEndOfLine?

isaacabraham commented 5 years ago

Just using the default settings e.g. create an empty fsx file, put in the code above and use fantomas foo.fsx.

zakaluka commented 5 years ago

Re-create:

let: http://ratatosk.dynu.net/fantomas/#?code=DYUwLgBAHhAmCGZ4QLwFgBQFsXgZwE8A7AYwgG8JMcaJRIAjeAJ1Wto4SXY5oB8AfBACCzZvAIA6ALbwADhACWsHr2yCRYiZIBmi4GBCsAFMZQBKCAEZzqtRtHipJAPYBXImABCBJSqxqOBr4xCSSAErgbsxEdjjMUTEQTMyqAL5AA&config=N4IgkgdgJgphAuBlADgQwMYwHIFcC2IAXACwA0IACqgOYwDqAllPABZEAcADORQE4wBnGLwBuMAKLQA8gDMAMgwgwiM1ABsh5RDDwN0AezX6IAQXiSoshUpXrNIFBhgAhGDP38Tvavjjwi8Lw4MFpomK7u-ADChsYBQSEOYTAmMvDCMXh4qPHBoU6p6bzaugZGELmJkLAIUhAAKrwAnoysthqJAEowHrC8UshwACIw6GqovKjwDHGEqh35mF76ONAjagy6RZVagXrwALL6sO1CAL5AA

let!: http://ratatosk.dynu.net/fantomas/#?code=DYUwLgBAHhAmCGZ4QLwFgBQFsXgZwE8A7AYwgG8JMcaJQwBCCAI3gCdU5F5ra-+APgD4IAQTZt4BAHQBbeAAcIAS1i9+G7MLESp0gGbLgYEBwAUZlAEoIARivrNgkeMkySAewCuRMACECFTUsJw1tfGISaQAlcC82IkcaNjiElnZHAF8gA&config=N4IgkgdgJgphAuBlADgQwMYwHIFcC2IAXACwA0IACqgOYwDqAllPABZEAcADORQE4wBnGLwBuMAKLQA8gDMAMgwgwiM1ABsh5RDDwN0AezX6IAQXiSoshUpXrNIFBhgAhGDP38Tvavjjwi8Lw4MFpomK7u-ADChsYBQSEOYTAmMvDCMXh4qPHBoU6p6bzaugZGELmJkLAIUhAAKrwAnoysthqJAEowHrC8UshwACIw6GqovKjwDHGEqh35mF76ONAjagy6RZVagXrwALL6sO1CAL5AA

isaacabraham commented 5 years ago

I think the second one should be http://ratatosk.dynu.net/fantomas/#?code=DYUwLgBAHhAmCGZ4QLwFgBQFsXgZwE8A7AYwgG8JMcaJQwBCCAI3gCdVrbuEkvuaAHwB8EAIJs28AgDoAtvAAOEAJax+A7CPGTpMgGYrgYEBwAUZlAEoIARisbN2iVNkkA9gFciYAEIFVdSxNHG18YhIZACVwTzYiRxw2WPiWdg0AXyA&config=N4IgkgdgJgphAuBlADgQwMYwHIFcC2IAXACwA0IACqgOYwDqAllPABZEAcADORQE4wBnGLwBuMAKLQA8gDMAMgwgwiM1ABsh5RDDwN0AezX6IAQXiSoshUpXrNIFBhgAhGDP38Tvavjjwi8Lw4MFpomK7u-ADChsYBQSEOYTAmMvDCMXh4qPHBoU6p6bzaugZGELmJkLAIUhAAKrwAnoysthqJAEowHrC8UshwACIw6GqovKjwDHGEqh35mF76ONAjagy6RZVagXrwALL6sO1CAL5AA

nojaf commented 4 years ago

This behaviour has been improved by now. I did encounter one minor related bug.