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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heuristic for placing fun decl body on separate line #82

Open
MatthewFluet opened this issue Mar 9, 2023 · 1 comment · May be fixed by #88
Open

Heuristic for placing fun decl body on separate line #82

MatthewFluet opened this issue Mar 9, 2023 · 1 comment · May be fixed by #88

Comments

@MatthewFluet
Copy link

The heuristic for determining whether the body of a function declaration is placed on a newline seems rather conservative and can lead to seemingly wasted horizontal space, especially when mixed with val declarations that do not seem to use the same heuristic.

❯ smlfmt -max-width 45 --preview-only z.sml 
---- z.sml ----
infixr 1 $

val f = fn (g, x) => x
val f = fn (g, x) => g x
val f = fn (g, x) => g $ x
val f = fn (g, x) => g $ g x
val f = fn (g, x) => g $ g $ x
val f = fn (g, x) => g $ g $ g x
val f = fn (g, x) => g $ g $ g $ x
val f = fn (g, x) => g $ g $ g $ g x
val f = fn (g, x) => g $ g $ g $ g $ x
val f = fn (g, x) => g $ g $ g $ g $ g x
val f = fn (g, x) => g $ g $ g $ g $ g $ x
val f = fn (g, x) => g $ g $ g $ g $ g $ g x
val f = fn (g, x) =>
  g $ g $ g $ g $ g $ g $ x

fun f (g, x) = x
fun f (g, x) = g x
fun f (g, x) = g $ x
fun f (g, x) = g $ g x
fun f (g, x) = g $ g $ x
fun f (g, x) =
  g $ g $ g x
fun f (g, x) =
  g $ g $ g $ x
fun f (g, x) =
  g $ g $ g $ g x
fun f (g, x) =
  g $ g $ g $ g $ x
fun f (g, x) =
  g $ g $ g $ g $ g x
fun f (g, x) =
  g $ g $ g $ g $ g $ x
fun f (g, x) =
  g $ g $ g $ g $ g $ g x
fun f (g, x) =
  g $ g $ g $ g $ g $ g $ x
--------
@shwestrick
Copy link
Owner

Ah good point -- I hadn't checked if these two heuristics are consistent with each other.

@MatthewFluet MatthewFluet linked a pull request May 17, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants