From: Matthijs Kooijman Date: Thu, 18 Jun 2009 12:55:14 +0000 (+0200) Subject: Add is_lam and is_fun predicates. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=a89f11ef881be9280586aa92abc91639fd8cb9c5;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Add is_lam and is_fun predicates. --- diff --git a/CoreTools.hs b/CoreTools.hs index 63bca94..3dfaf50 100644 --- a/CoreTools.hs +++ b/CoreTools.hs @@ -20,6 +20,7 @@ import qualified SrcLoc import qualified CoreSyn import qualified Var import qualified Unique +import qualified CoreUtils import GhcTools import HsTools @@ -89,3 +90,12 @@ is_wild :: CoreSyn.CoreBndr -> Bool -- occstring for now... TODO --(Var.varUnique bndr) == (Unique.mkBuiltinUnique 1) is_wild bndr = "wild" == (OccName.occNameString . Name.nameOccName . Var.varName) bndr + +-- Is the given core expression a lambda abstraction? +is_lam :: CoreSyn.CoreExpr -> Bool +is_lam (CoreSyn.Lam _ _) = True +is_lam _ = False + +-- Is the given core expression of a function type? +is_fun :: CoreSyn.CoreExpr -> Bool +is_fun = Type.isFunTy . CoreUtils.exprType