#Auto Format - Can

1 messages Β· Page 1 of 1 (latest)

cerulean barn
#

Is there a way to disable the Gleam VsCode extension from automatically formatting newlines? I want all the other features (adjust indents, spaces, labeling types, etc) but I want to it leave my newlines alone. (There's value to consistent formatters. Is there an alternate formatter if there's no easy toggle?)

In the example (from Advent of Code) the top function is clear at a glance: it does something to the text, and then something similar to each line. The bottom function -- arranged by the formatter and no longer balanced across lines -- takes me about 3x longer to read.

fringe trail
#

no, to both questions

robust valley
#
fn parse(text) {
  use line <- list.map(string.split(text, on: "\n"))
  use col <- list.map(string.split(line, on: "  "))
  int.parse(col)
}

the answer is always to add more newlines, not less

autumn tusk
#

bleh use and list.map /j

foggy barn
#

use here is fine imo but i always feel bad when the last thing is just one function call

robust valley
#

I mean if you look at the types I'm pretty sure this won't be the final version anyways ^.^

autumn tusk
#

i think my preferred format would actually be

fn parse(text) {
  text
  |> string.split("\n")
  |> list.map(fn(line) {
    line
    |> string.split("   ")
    |> list.map(int.parse)
  })
}
```tbh
robust valley
#

fight me use with lists is good

charred adder
robust valley
fringe trail
#

yeah, I think the general idea is that either everything should be on one line or everything should be on separate lines, mixing and matching ends up looking weird

charred adder
autumn tusk
#

it's because of the anonymous function - them being on one line has higher precedence than splitting pipe operators from my experience

charred adder
autumn tusk
#

that's fine as well

autumn tusk
#

i find that equally as readable as mine, i just prefer piping everywhere because it's more consistent on my eyes πŸ€·β€β™€οΈ

#

not everywhere*

#

sometimes it doesn't make sense lmao

charred adder
#

I'm just not a huge fan of "variable |> piped call"

#

We'll ignore the README of glexer for this point

robust valley
#

HAH I WIN

autumn tusk
#

😭

robust valley
#

πŸ’•

charred adder
cerulean barn
charred adder
#

I guess I win TPF_Raphi_Wink

bleak crescent
charred adder
robust valley
#

tbh that was expected πŸ˜‚

bleak crescent
#

AoC and stuff, yeah sure.

autumn tusk
#

list.map(int.parse) |> result.values() <3

proud goblet
#
  • Beginner: Pipes? πŸ‘Ά
  • Intermediate: str |> string.length() |> int.add(5) |> case(... 😭
  • Advanced: Pipes? 😐
foggy barn
#

that way you save the extra iterating to collect all the okays

autumn tusk
#

true!

#

there's so many cool functions that i forget about half of them πŸ˜…

foggy barn
#

i find i don't use try_map or try_fold very often but they come in handy whenever im messing with results

foggy barn
autumn tusk
#

i've only been here since march πŸ˜„

robust valley
autumn tusk
#

πŸ’€

#

indeed

#

just a few deprecations recently

robust valley
#

TIL you can do o+e instead of ambersand file descriptor number

autumn tusk
#

it's nushell

robust valley
#

. 😦

hybrid cave
bleak crescent
#

Can we stop saying this over and over please