Provides elm-review rules to detect reducible lambda expressions using different techniques.
Use these to control how aggressively lambda expressions are reduced.
OnlyWhenSingleArgument has the least impact on performance and will reduce the least.
\a -> f a to f.\a b -> f a b because there are two arguments.\a -> (getFunction 10) a because there is a function application to get the function.RemoveLambdaWhenNoCallsInApplication should have minimal impact on performance and reduces most of the functions you would want to reduce.
\a -> f a to f.\a b -> f a b to f.\a b -> f [1, 2, 3] a b to f [1, 2, 3]\a b -> f (g 10) a b to \a -> f (g 10) a but it will not remove the lambda outright because of the (g 10) call.\a b c -> a b c to identity.\a -> f (g 10) a due to the (g 10) call.AlwaysRemoveLambdaWhenPossible is the most aggressive.
\a -> f a to f.\a b -> f a b to f.\a b -> f [1, 2, 3] a b to f [1, 2, 3]\a b -> f (g 10) a b to f (g 10).\a b c -> a b c to identity.\a -> (getFunction 10) a to (getFunction 10).See the module documentation.
Error message when the lambda can be removed (for unit testing only).
Error message when arguments can be removed (for unit testing only).
Error message when the lambda reduces to identity (for unit testing only).
This rule detect reducible lambda expressions using different techniques.
Fail
Success
When (not) to enable this rule
This rule can change the performance characteristics of your program which is why LambdaReduceStrategy offers different levels of reduction.
Reducing
\\a b -> f a btoffdoes work on first argumentReducing
\\a b -> f g a btof gfdoes work on first argumentfdoes work on second argumentgandatofwould wait untilbhad been applied.Reducing
\\a b -> f (g 10) a btof (g 10)g 10to evaluate immediately which could be costlyConfiguration
Try it out
You can try this rule out by running the following command: