diff options
author | Andreas Klebinger <klebinger.andreas@gmx.at> | 2022-01-17 19:37:29 +0100 |
---|---|---|
committer | Andreas Klebinger <klebinger.andreas@gmx.at> | 2022-01-18 13:58:20 +0100 |
commit | de3ac3220b11bee3413c4bc47b753ddd89516e36 (patch) | |
tree | 5accc4420d4b4544476921d0c781d65db464cbd2 /compiler/GHC/Core.hs | |
parent | a13aff98cfccddee285b6550dd08c6ec1a3c4e17 (diff) | |
download | haskell-wip/andreask/prep_depth.tar.gz |
CorePrep: Don't interleave collecting of args and counting argswip/andreask/prep_depth
Diffstat (limited to 'compiler/GHC/Core.hs')
-rw-r--r-- | compiler/GHC/Core.hs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/GHC/Core.hs b/compiler/GHC/Core.hs index cc7320f531..15a0674e38 100644 --- a/compiler/GHC/Core.hs +++ b/compiler/GHC/Core.hs @@ -47,7 +47,7 @@ module GHC.Core ( collectArgs, stripNArgs, collectArgsTicks, flattenBinds, exprToType, exprToCoercion_maybe, - applyTypeToArg, + applyTypeToArg, wrapLamBody, isValArg, isTypeArg, isCoArg, isTyCoArg, valArgCount, valBndrCount, isRuntimeArg, isRuntimeVar, @@ -1942,6 +1942,14 @@ collectArgs expr go (App f a) as = go f (a:as) go e as = (e, as) +-- | fmap on the body of a lambda. +-- wrapLamBody f (\x -> body) == (\x -> f body) +wrapLamBody :: (CoreExpr -> CoreExpr) -> CoreExpr -> CoreExpr +wrapLamBody f expr = go expr + where + go (Lam v body) = Lam v $ go body + go expr = f expr + -- | Attempt to remove the last N arguments of a function call. -- Strip off any ticks or coercions encountered along the way and any -- at the end. |