See: https://stil4m.github.io/elm-analyse/#/messages/FunctionInLet
What the rule should do:
Forbid the declaration of functions in let
expressions.
What problems does it solve:
In a let statement you can define variables and functions in their own scope. But you are already in the scope of a module. Just define the functions you want on a top-level. There is no not much need to define functions in let statements.
This will also stop you from mixing values into the local function from the scope (which can cause unexpected performance reductions).
Example of things the rule would report:
foo : Int -> Int
foo x =
let
somethingIShouldDefineOnTopLevel : Int -> Int
somethingIShouldDefineOnTopLevel y =
y + 1
in
somethingIShouldDefineOnTopLevel x
Example of things the rule would not report:
- Anything without a function signature type annotation or an argument (where it's not clear whether it's a constant or a function).
When (not) to enable this rule:
Just don't enable this - whilst it's a good basic rule of thumb, there often needs to be much more to this review than this simple rule can account for.
I am looking for:
- Good reasons not to use this rule.