module SimplUtils (
simplBinder, simplBinders, simplIds,
tryRhsTyLam, tryEtaExpansion,
- mkCase, findAlt, findDefault,
+ mkCase,
-- The continuation type
SimplCont(..), DupFlag(..), contIsDupable, contResultType,
)
import CoreSyn
import CoreUtils ( exprIsTrivial, cheapEqExpr, exprType, exprIsCheap,
- etaExpand, exprEtaExpandArity, bindNonRec, mkCoerce )
+ etaExpand, exprEtaExpandArity, bindNonRec, mkCoerce,
+ findDefault, findAlt
+ )
import Subst ( InScopeSet, mkSubst, substBndrs, substBndr, substIds, substExpr )
import Id ( idType, idName,
idUnfolding, idStrictness,
\end{code}
-\begin{code}
-findDefault :: [CoreAlt] -> ([CoreAlt], Maybe CoreExpr)
-findDefault [] = ([], Nothing)
-findDefault ((DEFAULT,args,rhs) : alts) = ASSERT( null alts && null args )
- ([], Just rhs)
-findDefault (alt : alts) = case findDefault alts of
- (alts', deflt) -> (alt : alts', deflt)
-
-findAlt :: AltCon -> [CoreAlt] -> CoreAlt
-findAlt con alts
- = go alts
- where
- go [] = pprPanic "Missing alternative" (ppr con $$ vcat (map ppr alts))
- go (alt : alts) | matches alt = alt
- | otherwise = go alts
-
- matches (DEFAULT, _, _) = True
- matches (con1, _, _) = con == con1
-\end{code}