elm-format icon indicating copy to clipboard operation
elm-format copied to clipboard

Convert lambdas assigned directly to names to functions.

Open Lattyware opened this issue 5 years ago • 2 comments

I did a few searches and couldn't find any previous discussion of this—apologies if I missed something.

I think it would be a good feature to rewrite lambdas assigned directly to names into normal function definitions.

E.g:

let
    a =
        (\b -> 1)
in
...

To:

let
    a b =
        1
in
...

I commonly find myself refactoring out lambdas from inline to names, and forgetting to make this change, which feels like it is always the preferable way to do this.

Lattyware avatar Feb 05 '20 22:02 Lattyware

Something similar I see a fair bit is:

(\b -> someFunction b)

which could be replaced with

someFunction

I guess I'd wonder if this is likely to be an intermediate state for code that the developer might want to save without a reformat, so they can then make further changes to it.

sentience avatar Apr 17 '20 11:04 sentience

Maybe this sort of changes is more suitable for elm-analyzer which would give users the choice

harrysarson avatar Apr 17 '20 12:04 harrysarson