-%************************************************************************
-%* *
-\subsection{Core arguments (atoms)}
-%* *
-%************************************************************************
-
-\begin{code}
-data GenCoreArg val_occ flexi
- = LitArg Literal
- | VarArg val_occ
- | TyArg (GenType flexi)
-\end{code}
-
-General and specific forms:
-\begin{code}
-mkGenApp :: GenCoreExpr val_bdr val_occ flexi
- -> [GenCoreArg val_occ flexi]
- -> GenCoreExpr val_bdr val_occ flexi
-mkTyApp :: GenCoreExpr val_bdr val_occ flexi
- -> [GenType flexi]
- -> GenCoreExpr val_bdr val_occ flexi
-mkValApp :: GenCoreExpr val_bdr val_occ flexi
- -> [GenCoreArg val_occ flexi] -- but we ASSERT they are LitArg or VarArg
- -> GenCoreExpr val_bdr val_occ flexi
-
-mkGenApp f args = foldl App f args
-mkTyApp f args = foldl (\ e a -> App e (TyArg a)) f args
-mkValApp f args = foldl (\ e a -> App e (is_Lit_or_Var a)) f args
-
-#ifndef DEBUG
-is_Lit_or_Var a = a
-#else
-is_Lit_or_Var a
- = if isValArg a then a else panic "CoreSyn.mkValApps:not LitArg or VarArg"
-#endif
-
-isValArg (LitArg _) = True -- often used for sanity-checking
-isValArg (VarArg _) = True
-isValArg _ = False
-
-notValArg = not . isValArg -- exists only because it's a common use of isValArg
-
-numValArgs as = length [ a | a <- as, isValArg a ] -- again, convenience
-\end{code}
-
-\begin{code}
-mkApp fun = mk_thing (mkGenApp fun)
-mkCon con = mk_thing (Con con)
-mkPrim op = mk_thing (Prim op)
-
-mk_thing :: ([GenCoreArg val_occ flexi] -> GenCoreExpr val_bdr val_occ flexi)
- -> [GenType flexi]
- -> [GenCoreArg val_occ flexi]
- -> GenCoreExpr val_bdr val_occ flexi
-mk_thing thing tys vals
- = ASSERT( all isValArg vals )
- thing (map TyArg tys ++ vals)
-\end{code}