Skip to content

Configuration for styling let #202

@brandonchinn178

Description

@brandonchinn178

Describe the option you'd like to add

  • name: let-style
    • inline: first definition is on the same line as let; subsequent definitions are aligned to this definition. If there's an in clause, in is aligned with start of let column, in contents is aligned with let definitions (i.e. 2 spaces after in)
    • inline-ormolu: Same as inline, except if there's an in clause, in is aligned with end of let column (i.e. 1 space before and after in)
    • auto-newline: inline when there's only one let binding, otherwise newline
    • newline: first definition is on the line after let, indented once, with subsequent definitions aligned to this definition. If there's an in clause, in is aligned with start of let column, and the in contents start on the next line, indented once
  • Ormolu configured with inline-ormolu
  • I think default behavior should be auto-newline, but open to suggestions.

Show a code example exemplifying the different option settings

-- inline
-- note that the space before the `in` is moved to after, not just removed
let a = 1
    b = 2
in  a + b

-- inline-ormolu
let a = 1
    b = 2
 in a + b

-- auto-newline (indent=2)
let a = 1
in  a + 2

-- newline (indent=2)
let
  a = 1
in
  a + 2

-- auto-newline + newline (indent=2)
let
  a = 1
  b = 2
in
  a + b

-- auto-newline + newline (indent=4)
let
    a = 1
    b = 2
in
    a + b

Notes:

  • With newline, we won't support aligning in with the end of let; it just doesn't really look good. Originally, I wrote this issue where there were multiple independent toggles, but pretty much nothing else looked good. Happy to hear other suggestions as well.
  • If someone adds the in clause in a do-block, we'll change "in " to " in" for everything, since keeping it on the same level as let is invalid do-syntax

Metadata

Metadata

Assignees

No one assigned

    Labels

    new config optionAdds or would add new configuration option

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions