From d54117f6de8d00fe0ce7552c905cf197678d7ed7 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 30 Mar 2010 14:59:43 +0200 Subject: [PATCH] Let eta expansion use the passed context instead of using notappargs. --- "c\316\273ash/CLasH/Normalize.hs" | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git "a/c\316\273ash/CLasH/Normalize.hs" "b/c\316\273ash/CLasH/Normalize.hs" index fa6ae8c..a5b2a94 100644 --- "a/c\316\273ash/CLasH/Normalize.hs" +++ "b/c\316\273ash/CLasH/Normalize.hs" @@ -48,13 +48,20 @@ import CLasH.Utils.Pretty -- η abstraction -------------------------------- 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 let arg_ty = (fst . Type.splitFunTy . CoreUtils.exprType) expr id <- Trans.lift $ mkInternalVar "param" arg_ty change (Lam id (App expr (Var id))) -- Leave all other expressions unchanged eta c e = return e -etatop = notappargs ("eta", eta) +etatop = everywhere ("eta", eta) -------------------------------- -- β-reduction -- 2.30.2