I added a fix to the elm-review NoMissingTypeConstructor rule. I’m looking for folks to try this and provide feedback on how it works for you.
elm-review --template Arkham/elm-review-no-missing-type-constructor/example --fix
Example
Before fix
module Fruit exposing (Fruit, all)
type Fruit
= Apple
| Banana
| Kiwi
| Pineapple
all : List Fruit
all =
[ Banana
, Apple
]
After fix
module Fruit exposing (Fruit, all)
type Fruit
= Apple
| Banana
| Kiwi
| Pineapple
all : List Fruit
all =
[ Banana
, Apple
, Kiwi
, Pineapple
]
The missing type constructors Kiwi
and Pineapple
were added in alphabetical order.
Feedback request
Is this fix acceptable? Do you rely on the order?
When I use an all
value I usually have toString : Fruit -> String
that returns the display name. Then I sort by that:
Fruit.all
|> List.map Fruit.toString
|> List.sort
Using this technique, the order of the variants in all
is irrelevant.
Maybe you have a different concern. Or maybe this fix is just fine. Please let me know your thoughts.