I published a rule that can be used to enforce varying levels of function simplification
elm-review-reducible-lambdas. The default settings are probably a little more aggressive than most in the community would prefer. However, you may be able to tinker with the settings to find a useful sweet spot for your project and so I decided to share in case anyone finds this useful.
Conservative Settings
This example config will only reduce single argument lambdas that have single letter argument names (thanks to @Arkham for the argument name predicate suggestion).
Error
\a -> someFunction awill reduce tosomeFunction
Not Error
\apples -> someFunction applesdue to argument name length\a b -> someFunction a bdue to multiple arguments.
config : List Rule
config =
[ NoEtaReducibleLambdas.rule
{ lambdaReduceStrategy = NoEtaReducibleLambdas.OnlyWhenSingleArgument
, argumentNamePredicate = \argumentName -> String.length argumentName == 1
}
]
More Aggressive
These are the default settings. These may reduce a little too aggressively for most.
Error
\apples -> someFunction applesreduces tosomeFunction\apples bananas -> someFunction apples bananasreduces tosomeFunction\apples bananas -> someFunction milk apples bananasreduces tosomeFunction milk\apples bananas -> fn (apples 15) bananasreduces to\apples -> fn (apples 15)
Not Error
\bananas -> fn (apples 15) bananasbecause removing the lambda would change performance attributes by immediately evaluating(apples 15).
config : List Rule
config =
[ NoEtaReducibleLambdas.rule
{ lambdaReduceStrategy = NoEtaReducibleLambdas.RemoveLambdaWhenNoCallsInApplication
, argumentNamePredicate = always True
}
]