X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=Normalize.hs;h=9ee919ab524be8a211b99fe4b22bd7a03478079a;hb=969b7ddd86b69d2fc61b101961affcca0364749c;hp=747a95b0c6eccd898bfbd12e0bec80f33a0910ae;hpb=019e55a763768d778d0e62b4dc5e49f3c7e06a0f;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git diff --git a/Normalize.hs b/Normalize.hs index 747a95b..9ee919a 100644 --- a/Normalize.hs +++ b/Normalize.hs @@ -140,7 +140,7 @@ letflattop = everywhere ("letflat", letflat) -------------------------------- -- Remove a = b bindings from let expressions everywhere letremovetop :: Transform -letremovetop = everywhere ("letremove", inlinebind (\(b, e) -> case e of (Var v) -> True; otherwise -> False)) +letremovetop = everywhere ("letremove", inlinebind (\(b, e) -> case e of (Var v) | not $ Id.isDataConWorkId v -> True; otherwise -> False)) -------------------------------- -- Function inlining @@ -288,8 +288,9 @@ caseremovetop = everywhere ("caseremove", caseremove) -------------------------------- -- Make sure that all arguments in an application are simple variables. appsimpl, appsimpltop :: Transform --- Don't simplify arguments that are already simple -appsimpl expr@(App f (Var _)) = return expr +-- Don't simplify arguments that are already simple. Do simplify datacons, +-- however, since we can't portmap literals. +appsimpl expr@(App f (Var v)) | not $ Id.isDataConWorkId v = return expr -- Simplify all non-applicable (to prevent loops with inlinefun) arguments, -- except for type arguments (since a let can't bind type vars, only a lambda -- can). Do this by introducing a new Let that binds the argument and passing