mkLets, mkLams,
mkApps, mkTyApps, mkValApps, mkVarApps,
mkLit, mkIntLitInt, mkIntLit,
- mkConApp,
- varToCoreExpr,
+ mkConApp, mkCast,
+ varToCoreExpr, varsToCoreExprs,
isTyVar, isId, cmpAltCon, cmpAlt, ltAlt,
bindersOf, bindersOfBinds, rhssOfBind, rhssOfAlts,
import CostCentre ( CostCentre, noCostCentre )
import Var ( Var, Id, TyVar, isTyVar, isId )
import Type ( Type, mkTyVarTy, seqType )
+import TyCon ( isNewTyCon )
+import Coercion ( Coercion )
import Name ( Name )
import OccName ( OccName )
import Literal ( Literal, mkMachInt )
-import DataCon ( DataCon, dataConWorkId, dataConTag )
+import DataCon ( DataCon, dataConWorkId, dataConTag, dataConTyCon,
+ dataConWrapId )
import BasicTypes ( Activation )
import FastString
import Outputable
-- lit (for LitAlts)
-- This makes finding the relevant constructor easy,
-- and makes comparison easier too
+ | Cast (Expr b) Coercion
| Note Note (Expr b)
| Type Type -- This should only show up at the top
-- level of an Arg
type Alt b = (AltCon, [b], Expr b) -- (DEFAULT, [], rhs) is the default alternative
-data AltCon = DataAlt DataCon
+data AltCon = DataAlt DataCon -- Invariant: the DataCon is always from
+ -- a *data* type, and never from a *newtype*
| LitAlt Literal
| DEFAULT
deriving (Eq, Ord)
data Note
= SCC CostCentre
- | Coerce
- Type -- The to-type: type of whole coerce expression
- Type -- The from-type: type of enclosed expression
-
| InlineMe -- Instructs simplifer to treat the enclosed expression
-- as very small, and inline it at its call sites
varToCoreExpr :: CoreBndr -> Expr b
varToCoreExpr v | isId v = Var v
| otherwise = Type (mkTyVarTy v)
+
+varsToCoreExprs :: [CoreBndr] -> [Expr b]
+varsToCoreExprs vs = map varToCoreExpr vs
+
+mkCast :: Expr b -> Coercion -> Expr b
+mkCast e co = Cast e co
\end{code}
seqExpr (Let b e) = seqBind b `seq` seqExpr e
-- gaw 2004
seqExpr (Case e b t as) = seqExpr e `seq` seqBndr b `seq` seqType t `seq` seqAlts as
+seqExpr (Cast e co) = seqExpr e `seq` seqType co
seqExpr (Note n e) = seqNote n `seq` seqExpr e
seqExpr (Type t) = seqType t
seqExprs [] = ()
seqExprs (e:es) = seqExpr e `seq` seqExprs es
-seqNote (Coerce t1 t2) = seqType t1 `seq` seqType t2
seqNote (CoreNote s) = s `seq` ()
seqNote other = ()
-- gaw 2004
| AnnCase (AnnExpr bndr annot) bndr Type [AnnAlt bndr annot]
| AnnLet (AnnBind bndr annot) (AnnExpr bndr annot)
+ | AnnCast (AnnExpr bndr annot) Coercion
| AnnNote Note (AnnExpr bndr annot)
| AnnType Type
deAnnotate' (AnnLit lit) = Lit lit
deAnnotate' (AnnLam binder body) = Lam binder (deAnnotate body)
deAnnotate' (AnnApp fun arg) = App (deAnnotate fun) (deAnnotate arg)
+deAnnotate' (AnnCast e co) = Cast (deAnnotate e) co
deAnnotate' (AnnNote note body) = Note note (deAnnotate body)
deAnnotate' (AnnLet bind body)