From: Matthijs Kooijman Date: Thu, 6 Aug 2009 13:56:04 +0000 (+0200) Subject: Add expr_uses_binders predicate. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=6bd3f1fdc9c2d618576bbd0885aa2b30692445f4;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Add expr_uses_binders predicate. --- diff --git "a/c\316\273ash/CLasH/Utils/Core/CoreTools.hs" "b/c\316\273ash/CLasH/Utils/Core/CoreTools.hs" index 7a82505..05366fc 100644 --- "a/c\316\273ash/CLasH/Utils/Core/CoreTools.hs" +++ "b/c\316\273ash/CLasH/Utils/Core/CoreTools.hs" @@ -186,6 +186,10 @@ has_free_tyvars = not . VarSet.isEmptyVarSet . (CoreFVs.exprSomeFreeVars Var.isT has_free_vars :: CoreSyn.CoreExpr -> Bool has_free_vars = not . VarSet.isEmptyVarSet . CoreFVs.exprFreeVars +-- Does the given expression use any of the given binders? +expr_uses_binders :: [CoreSyn.CoreBndr] -> CoreSyn.CoreExpr -> Bool +expr_uses_binders bndrs = not . VarSet.isEmptyVarSet . (CoreFVs.exprSomeFreeVars (`elem` bndrs)) + -- Turns a Var CoreExpr into the Id inside it. Will of course only work for -- simple Var CoreExprs, not complexer ones. exprToVar :: CoreSyn.CoreExpr -> Var.Id