avh4 / avh4/elm-format

Rewrite `[ foo ] ++ bar` to `foo :: bar`?

Open
#405 4 comments 0 reactions 0 assignees View on GitHub
discussion
Dominant language
Haskell
Stars
1.3k
Forks
148
PR merge metrics
No merged PRs in 30d

Description

[`elm-analyse`](https://github.com/stil4m/elm-analyse) gives a warning for this situation:

> If you concatenate two lists, but the [left hand side is a single element list literal], then you should use the cons operator.

This seems like not only a stylistic concern, but a performance optimization!

I can't think of any situations where it would be better to write e.g. `[ foo ] ++ anyOtherList` than `foo :: anyOtherList`. Should `elm-format` automatically perform this rewrite?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the linked elm-analyse warning and elm-format's existing Elm rewrite behavior; the issue names no source file or test. Decide whether rewriting `[ foo ] ++ bar` to `foo :: bar` belongs in elm-format, then confirm the chosen behavior against the Elm Style Guide and formatter output.

Written by the indexing model from the issue text.

Assessment

Tech stack
elm, haskell
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.