make eta_reduction less aggressive (#76)

Co-authored-by: Stephan Maka <stephan.maka@cyberus-technology.de>
This commit is contained in:
Astro 2023-07-05 13:47:24 +02:00 committed by GitHub
parent 3c7136a23f
commit bcb3d10f2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -15,4 +15,7 @@ in
# other non-free forms
(map (f: {inherit f;}.double f.val) [ f ])
# don't reduce on more complex lambda bodies
(map (x: builtins.div 3 x) xs)
]

View File

@ -56,10 +56,13 @@ impl Rule for EtaReduction {
if let Some(value_node) = body.value();
if let Some(value) = Ident::cast(value_node);
if arg.as_str() == value.as_str() ;
if arg.as_str() == value.as_str();
if let Some(lambda_node) = body.lambda();
if !mentions_ident(&arg, &lambda_node);
// lambda body should be no more than a single Ident to
// retain code readability
if let Some(_) = Ident::cast(lambda_node);
then {
let at = node.text_range();