Skip to content

Code action to anonymize/deanonymize a function #4614

@llakala

Description

@llakala

Playground link for reference. Whenever I use something like list.fold, list.map, or use any function that takes another function as an argument, I default to writing an anonymous function. However, if I'm only applying a single transformation to each element, I don't need the anonymous function logic - I can just pass the function I want to apply directly.

It would be nice if the LSP provided two code actions to switch between these styles - just like the convert to pipe and convert to function call actions. If you had a "useless" anonymous function that just called some other function, it could "de-anonymize" the anonymous function with the shorter form. And, if you passed an existing function as an argument to some other function, it could turn it into the anonymous form, for adding more intermediate transformations!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions