mkConApp, mkTyBind,
varToCoreExpr, varsToCoreExprs,
- isTyVar, isId, cmpAltCon, cmpAlt, ltAlt,
+ isTyVar, isIdVar, cmpAltCon, cmpAlt, ltAlt,
-- ** Simple 'Expr' access functions and predicates
bindersOf, bindersOfBinds, rhssOfBind, rhssOfAlts,
import CostCentre
import Var
-import Id
import Type
import Coercion
import Name
--
-- @
-- data Foo = Red | Green | Blue
- --
-- ... case x of
-- Red -> True
-- other -> f (case x of
-- | Convert a binder into either a 'Var' or 'Type' 'Expr' appropriately
varToCoreExpr :: CoreBndr -> Expr b
-varToCoreExpr v | isId v = Var v
+varToCoreExpr v | isIdVar v = Var v
| otherwise = Type (mkTyVarTy v)
varsToCoreExprs :: [CoreBndr] -> [Expr b]
rhssOfAlts alts = [e | (_,_,e) <- alts]
-- | Collapse all the bindings in the supplied groups into a single
--- list of lhs/rhs pairs suitable for binding in a 'Rec' binding group
+-- list of lhs\/rhs pairs suitable for binding in a 'Rec' binding group
flattenBinds :: [Bind b] -> [(b, Expr b)]
flattenBinds (NonRec b r : binds) = (b,r) : flattenBinds binds
flattenBinds (Rec prs1 : binds) = prs1 ++ flattenBinds binds
collectValBinders expr
= go [] expr
where
- go ids (Lam b e) | isId b = go (b:ids) e
- go ids body = (reverse ids, body)
+ go ids (Lam b e) | isIdVar b = go (b:ids) e
+ go ids body = (reverse ids, body)
\end{code}
\begin{code}
\begin{code}
-- | Will this variable exist at runtime?
isRuntimeVar :: Var -> Bool
-isRuntimeVar = isId
+isRuntimeVar = isIdVar
-- | Will this argument expression exist at runtime?
isRuntimeArg :: CoreExpr -> Bool
-- | The number of binders that bind values rather than types
valBndrCount :: [CoreBndr] -> Int
-valBndrCount = count isId
+valBndrCount = count isIdVar
-- | The number of argument expressions that are values rather than types at their top level
valArgCount :: [Arg b] -> Int