# Elm-format alternative

**URL:** <https://discourse.elm-lang.org/t/elm-format-alternative/1973>\
**Category:** Learn\
**Created:** [September 15, 2018, 7:40pm UTC](https://discourse.elm-lang.org/t/elm-format-alternative/1973 "2018-09-15T19:40:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Biggar](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/paul_biggar/32/1054_2.png) [@Paul\_Biggar](https://discourse.elm-lang.org/u/Paul_Biggar)\
**Post date:** [September 15, 2018, 7:40pm UTC](https://discourse.elm-lang.org/t/elm-format-alternative/1973/1 "2018-09-15T19:40:06Z")

</div>

I’m interested in getting the advantages of elm-format (no discussion of formatting etc), but the specific choices in elm-format don’t work for my team (in particular, we prefer a concise codebase, and we want to be consistent with our non-Elm code rather than consistent with other programs written in Elm).

Elm-format itself has chosen not to be configurable, so I’m looking for an alternative. There are 99 forks, and I worry about falling behind elm-format which seems to be blessed at this point.

Is there one partiuclar fork (or other tool) that the non-elm-format community has rallied around?

---

<div class="post-metadata">

**Author:** ![andys8](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/andys8/32/280_2.png) [@andys8](https://discourse.elm-lang.org/u/andys8)\
**Post date:** [September 15, 2018, 8:20pm UTC](https://discourse.elm-lang.org/t/elm-format-alternative/1973/2 "2018-09-15T20:20:49Z")

</div>

I’m not aware of a maintained alternative. What are the differences your team is looking for? In case those are simple and only a small amount, one solution I could think of, is calling elm-format, and calling a custom script for the changes in addition afterwards (e.g. correcting the indentation). Although this will get errorprone and hard to maintain easily as soon as there is a bunch of changes that should be done.

---

<div class="post-metadata">

**Author:** ![Paul\_Biggar](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/paul_biggar/32/1054_2.png) [@Paul\_Biggar](https://discourse.elm-lang.org/u/Paul_Biggar)\
**Post date:** [September 15, 2018, 8:34pm UTC](https://discourse.elm-lang.org/t/elm-format-alternative/1973/3 "2018-09-15T20:34:44Z")

</div>

Yes, I thought about this. Not a bad idea for some of the changes (eg lining up `|>` with the first letter on it’s lhs).

So what I’m looking for is avoiding extra spacing and lines. The compact branch of timjs/elm-format does a lot of this, especially removing extra lines between case conditions and between functions. Some extra that I’m looking for:

- dont go to newlines quite so quickly in `if`s and `case`s (use line-length to decide)
- dont add a newline before the first let-def in a `let`
- lets with one def that fit on a line should stay on that line, including the `in` at the end
- dont indent before `|>`

Ideally I’d also get to split imports into groups (core, libs, and our stuff) but I won’t die on that hill.

---

<div class="post-metadata">

**Author:** ![billstclair](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/billstclair/32/260_2.png) [@billstclair](https://discourse.elm-lang.org/u/billstclair)\
**Post date:** [September 16, 2018, 9:59am UTC](https://discourse.elm-lang.org/t/elm-format-alternative/1973/4 "2018-09-16T09:59:07Z")

</div>

I used to style my Elm that way, until I hooked up `elm-format` to my Emacs and “Learned to Stop Worrying and Love the Bomb” (to quote [_Dr. Strangelove_](https://www.imdb.com/title/tt0057012/)). I decided that one consistent Elm community style was more important than my personal preferences. Your mileage may vary (YMMV).

I am reminded of my short stay at the end of life of the Atari Cambridge Research Lab, in Kendall Square, Cambridge, Massachusetts, January through March of 1984. We programmed Symbolics Lisp Machines there. One of our researchers used the biggest font available on the Lisp Machine, and had a rule that a function definition had to fit on one screen at that font size. Another built his own 7-pixel-high font (five pixels above the baseline and two for descenders, leaving very little room for style decisions), and filled HIS screen with little tiny text. Different strokes. (this was before the time of scalable fonts, when the font designer specified every pixel).

---

<div class="post-metadata">

**Author:** ![avh4](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/avh4/32/97_2.png) [@avh4](https://discourse.elm-lang.org/u/avh4)\
**Post date:** [September 16, 2018, 6:15pm UTC](https://discourse.elm-lang.org/t/elm-format-alternative/1973/5 "2018-09-16T18:15:45Z")

</div>

> [@Paul\_Biggar](#):
>
> dont go to newlines quite so quickly in `if` s and `case` s (use line-length to decide)

These two are likely to change (at least to provide a single-line option), see [elm-format#507](https://github.com/avh4/elm-format/issues/507) (`case`), and [elm-format#209](https://github.com/avh4/elm-format/issues/209) (`if`).

* * *

Also, `elm-format` is getting close to having an AST mode which will parse and provide an AST of a given source file; possibly that would be useful for the parsing half of an alternate formatter?

I’m also open to PRs to elm-format that refactor the code in ways that will make future changes less likely to break forks.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [September 26, 2018, 6:15pm UTC](https://discourse.elm-lang.org/t/elm-format-alternative/1973/6 "2018-09-26T18:15:47Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
