From: Matthijs Kooijman Date: Wed, 31 Mar 2010 10:39:44 +0000 (+0200) Subject: Only apply eta expansion to expressions at the top level. X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fmaster-project%2Fc%CE%BBash.git;a=commitdiff_plain;h=b890268bf9e26904e659678944edf2cfa55f258d Only apply eta expansion to expressions at the top level. --- diff --git "a/c\316\273ash/CLasH/Normalize.hs" "b/c\316\273ash/CLasH/Normalize.hs" index cf33b7b..6ee0f0f 100644 --- "a/c\316\273ash/CLasH/Normalize.hs" +++ "b/c\316\273ash/CLasH/Normalize.hs" @@ -45,17 +45,16 @@ import CLasH.Utils.Pretty -------------------------------- -------------------------------- --- η abstraction --------------------------------- +-- η expansion +-------------------------------- +-- Make sure all parameters to the normalized functions are named by top +-- level lambda expressions. For this we apply η expansion to the +-- function body (possibly enclosed in some lambda abstractions) while +-- it has a function type. Eventually this will result in a function +-- body consisting of a bunch of nested lambdas containing a +-- non-function value (e.g., a complete application). eta, etatop :: Transform --- Don't apply to expressions that are applied, since that would cause --- us to apply to our own result indefinitely. -eta (AppFirst:_) expr = return expr --- Also don't apply to arguments, since this can cause loops with --- funextract. This isn't the proper solution, but due to an --- implementation bug in notappargs, this is how it used to work so far. -eta (AppSecond:_) expr = return expr -eta c expr | is_fun expr && not (is_lam expr) = do +eta c expr | is_fun expr && not (is_lam expr) && all (== LambdaBody) c = do let arg_ty = (fst . Type.splitFunTy . CoreUtils.exprType) expr id <- Trans.lift $ mkInternalVar "param" arg_ty change (Lam id (App expr (Var id)))