jfmengels / elm-review-simplify

Provides elm-review rules to simplify your Elm code
https://package.elm-lang.org/packages/jfmengels/elm-review-simplify/latest/
BSD 3-Clause "New" or "Revised" License
19 stars 9 forks source link

Map checks preserve wrap style of non-branching wrapped #247

Closed lue-bird closed 1 year ago

lue-bird commented 1 year ago

Previously, "map on wrap call" fixes did not try to preserve the "style" of wrap:

a |> List.singleton |> List.map f |> g
--> [ a |> f ] |> g

We now keep the existing style for non-branching cases:

a |> List.singleton |> List.map f |> g
--> (a |> f) |> List.singleton |> g

while branching styles are still over-written by using [ ... ] for list singletons

(if c then List.singleton a else List.singleton b) |> List.map f |> g
--> [ (if c then a else b) |> f) ] |> g

Not sure I'm super happy with the results but it's a bit nicer than before for sure.

Do you think we should also try to recover something like "the commonly used wrap style in all branches" or is that overkill?

github-actions[bot] commented 1 year ago

The branch can be tried out by running:

elm-review --template jfmengels/elm-review-simplify/preview