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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃帹 Format tuples with the same rules as function calls. #2507

Closed
hayleigh-dot-dev opened this issue Dec 30, 2023 · 0 comments 路 Fixed by #2513
Closed

馃帹 Format tuples with the same rules as function calls. #2507

hayleigh-dot-dev opened this issue Dec 30, 2023 · 0 comments 路 Fixed by #2513
Labels
help wanted Contributions encouraged priority:medium

Comments

@hayleigh-dot-dev
Copy link
Member

Background

Currently a function call with a callback as the final argument will be formatted neatly with all args on one line save for the function body, thanks to @giacomocavalieri's great work:

wibble("value", fn(attr) {
  attr
  |> ...
})

Request

I'd like this formatting applied consistently to tuple construction also:

#("value", fn(attr) {
  attr
  |> ...
})

鈽濓笍 currently the above formats like this 馃憞

#(
  "value",
  fn(attr) {
    attr
    |> ...
  },
)

Context

In lustre component definitions must supply a dictionary of attribute names to listen to and a decoder to run when those attributes change:

fn on_attribute_change() -> Dict(String, Decoder(Msg)) {
  dict.from_list([
    #(
      "value",
      fn(attr) {
        attr
        |> dynamic.int
        |> result.map(Value)
        |> result.map(AttributeChanged)
      },
    ),
  ])
}

The recent formatter changes have made lots of common lustre code much more legible but this particular aspect produces quite a lot of vertical noise. For non-trivial components that may want to listen to more than one or two attributes this can end up occupying a lot of space in a module.

@lpil lpil added help wanted Contributions encouraged priority:medium labels Dec 30, 2023
giacomocavalieri added a commit to giacomocavalieri/gleam that referenced this issue Dec 31, 2023
giacomocavalieri added a commit to giacomocavalieri/gleam that referenced this issue Dec 31, 2023
@lpil lpil closed this as completed in #2513 Jan 4, 2024
lpil pushed a commit that referenced this issue Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Contributions encouraged priority:medium
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants