aboutsummaryrefslogtreecommitdiff
path: root/lib/src/lints/eta_reduction.rs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/src/lints/eta_reduction.rs')
-rw-r--r--lib/src/lints/eta_reduction.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/src/lints/eta_reduction.rs b/lib/src/lints/eta_reduction.rs
index b329ae8..3a483d0 100644
--- a/lib/src/lints/eta_reduction.rs
+++ b/lib/src/lints/eta_reduction.rs
@@ -7,6 +7,32 @@ use rnix::{
7 NodeOrToken, SyntaxElement, SyntaxKind, SyntaxNode, 7 NodeOrToken, SyntaxElement, SyntaxKind, SyntaxNode,
8}; 8};
9 9
10/// ## What it does
11/// Checks for eta-reducible functions, i.e.: converts lambda
12/// expressions into free standing functions where applicable.
13///
14/// ## Why is this bad?
15/// Oftentimes, eta-reduction results in code that is more natural
16/// to read.
17///
18/// ## Example
19///
20/// ```
21/// let
22/// double = i: 2 * i;
23/// in
24/// map (x: double x) [ 1 2 3 ]
25/// ```
26///
27/// The lambda passed to the `map` function is eta-reducible, and the
28/// result reads more naturally:
29///
30/// ```
31/// let
32/// double = i: 2 * i;
33/// in
34/// map double [ 1 2 3 ]
35/// ```
10#[lint( 36#[lint(
11 name = "eta reduction", 37 name = "eta reduction",
12 note = "This function expression is eta reducible", 38 note = "This function expression is eta reducible",