finished product unboxing through newtypes and proper demand analysis of newtypes
[ghc-hetmet.git] / compiler / simplCore / SimplUtils.lhs
index 196efb6..235cdfe 100644 (file)
@@ -5,7 +5,7 @@
 
 \begin{code}
 module SimplUtils (
-       mkLam, mkCase, mkDataConAlt,
+       mkLam, mkCase, 
 
        -- Inlining,
        preInlineUnconditionally, postInlineUnconditionally, activeInline, activeRule,
@@ -246,7 +246,9 @@ getContArgs chkr fun orig_cont
        where
          args = reverse acc
          hole_ty = applyTypeToArgs (Var fun) (idType fun)
-                                   [substExpr se arg | (arg,se,_) <- args]
+                                   [substExpr_mb se arg | (arg,se,_) <- args]
+          substExpr_mb Nothing   arg = arg
+         substExpr_mb (Just se) arg = substExpr se arg
     
     ----------------------------
     vanilla_stricts, computed_stricts :: [Bool]
@@ -1142,7 +1144,8 @@ mkDataConAlt :: DataCon -> [OutType] -> InExpr -> SimplM InAlt
 -- Make a data-constructor alternative to replace the DEFAULT case
 -- NB: there's something a bit bogus here, because we put OutTypes into an InAlt
 mkDataConAlt con inst_tys rhs
-  = do         { tv_uniqs <- getUniquesSmpl 
+  = ASSERT(not (isNewTyCon (dataConTyCon con)))
+    do         { tv_uniqs <- getUniquesSmpl 
        ; arg_uniqs <- getUniquesSmpl
        ; let tv_bndrs  = zipWith mk_tv_bndr (dataConExTyVars con) tv_uniqs
              arg_tys   = dataConInstArgTys con (inst_tys ++ mkTyVarTys tv_bndrs)
@@ -1489,7 +1492,7 @@ mkCase1 scrut case_bndr ty alts   -- Identity case
       | isNewTyCon (dataConTyCon con) 
       = wrapNewTypeBody (dataConTyCon con) arg_tys (varToCoreExpr $ head args)
       | otherwise
-      = pprTrace "mkCase1" (ppr con) $ mkConApp con (arg_ty_exprs ++ varsToCoreExprs args)
+      = mkConApp con (arg_ty_exprs ++ varsToCoreExprs args)
     identity_rhs (LitAlt lit)  _    = Lit lit
     identity_rhs DEFAULT       _    = Var case_bndr