Skip to content

Add explicit section in regards to multiline expressions in let bindings #23

@nojaf

Description

@nojaf

Following up on the previous issue, I'd like to see a small section about what to do with multiline body expressions in let and member bindings.
Example:

let functionName x y = a

if a is long or multiline it should be placed on the next line with an indent.

let functionName x y = 
    a

regardless of what SynExpr a ends up being.

Some examples I consider bad:

let a = """
foobar, long string
"""

let b = async {
    return () // not following the other CE samples
}

let c = {
    Name = "Bilbo"
    Age = 112
}

let d = while f do
    printfn "%A" x

From my (technical) point of view, the only a few SynExpr that can start right after the = sign and it strikes me as inconsistent to have these.
The only one I could find in the current guide is:

let rec sizeLambda acc = function
    | Abs(x, body) -> sizeLambda (succ acc) body
    | App(lam1, lam2) -> sizeLambda (sizeLambda acc lam1) lam2
    | Var v -> succ acc

As MatchLambda is only 1 of 63 SynExpr cases, this just seems like not worth having.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions