aboutsummaryrefslogtreecommitdiff
path: root/lib/src/lints/eta_reduction.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-10-31 16:01:04 +0000
committerAkshay <[email protected]>2021-10-31 16:01:04 +0000
commit15ccd864c8869f87a564e5ab7e923dcc2bb54340 (patch)
tree9d47b230d5d4ad1b0f40ba88f097418b981805a4 /lib/src/lints/eta_reduction.rs
parent4567a246a0b63418f17ead4adc81f5ebab8bdd81 (diff)
add explainations to each lint
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",