[project @ 2001-08-22 12:24:41 by simonmar]
[ghc-hetmet.git] / ghc / compiler / typecheck / TcIfaceSig.lhs
index b922e62..0d4824d 100644 (file)
@@ -27,14 +27,14 @@ import WorkWrap             ( mkWrapper )
 
 import Id              ( Id, mkVanillaGlobal, mkLocalId, idName, isDataConWrapId_maybe )
 import Module          ( Module )
-import MkId            ( mkCCallOpId )
+import MkId            ( mkFCallId )
 import IdInfo
+import TyCon           ( tyConDataCons )
 import DataCon         ( DataCon, dataConId, dataConSig, dataConArgTys )
-import Type            ( mkTyVarTys, splitAlgTyConApp_maybe )
+import Type            ( mkTyVarTys, splitTyConApp )
 import TysWiredIn      ( tupleCon )
 import Var             ( mkTyVar, tyVarKind )
 import Name            ( Name, nameIsLocalOrFrom )
-import Demand          ( wwLazy )
 import ErrUtils                ( pprBagOfErrors )
 import Outputable      
 import Util            ( zipWithEqual )
@@ -86,10 +86,9 @@ tcIdInfo unf_env in_scope_vars name ty info_ins
     init_info = vanillaIdInfo `setCgInfo` vanillaCgInfo
 
     tcPrag info (HsNoCafRefs)   = returnTc (info `setCafInfo`   NoCafRefs)
-    tcPrag info HsCprInfo       = returnTc (info `setCprInfo`   ReturnsCPR)
 
     tcPrag info (HsArity arity) = 
-       returnTc (info `setArityInfo` (ArityExactly arity)
+       returnTc (info `setArityInfo` arity
                       `setCgArity`   arity)
 
     tcPrag info (HsUnfold inline_prag expr)
@@ -106,7 +105,7 @@ tcIdInfo unf_env in_scope_vars name ty info_ins
          returnTc info2
 
     tcPrag info (HsStrictness strict_info)
-       = returnTc (info `setStrictnessInfo` strict_info)
+       = returnTc (info `setNewStrictnessInfo` Just strict_info)
 
     tcPrag info (HsWorker nm arity)
        = tcWorkerInfo unf_env ty info nm arity
@@ -114,7 +113,7 @@ tcIdInfo unf_env in_scope_vars name ty info_ins
 
 \begin{code}
 tcWorkerInfo unf_env ty info worker_name arity
-  = uniqSMToTcM (mkWrapper ty arity demands res_bot cpr_info) `thenNF_Tc` \ wrap_fn ->
+  = uniqSMToTcM (mkWrapper ty strict_sig) `thenNF_Tc` \ wrap_fn ->
     let
        -- Watch out! We can't pull on unf_env too eagerly!
        info' = case tcLookupRecId_maybe unf_env worker_name of
@@ -127,15 +126,11 @@ tcWorkerInfo unf_env ty info worker_name arity
     in
     returnTc info'
   where
-       -- We are relying here on cpr and strictness info always appearing 
+       -- We are relying here on strictness info always appearing 
        -- before worker info,  fingers crossed ....
-      cpr_info   = cprInfo info
-
-      (demands, res_bot)
-       = case strictnessInfo info of
-               StrictnessInfo d r -> (d,r)
-               _                  -> (take arity (repeat wwLazy),False)
-                                       -- Noncommittal
+      strict_sig = case newStrictnessInfo info of
+                       Just sig -> sig
+                       Nothing  -> pprPanic "Worker info but no strictness for" (ppr worker_name)
 \end{code}
 
 For unfoldings we try to do the job lazily, so that we never type check
@@ -212,10 +207,10 @@ tcCoreExpr (UfLitLit lit ty)
   = tcIfaceType ty             `thenTc` \ ty' ->
     returnTc (Lit (MachLitLit lit ty'))
 
-tcCoreExpr (UfCCall cc ty)
+tcCoreExpr (UfFCall cc ty)
   = tcIfaceType ty     `thenTc` \ ty' ->
     tcGetUnique                `thenNF_Tc` \ u ->
-    returnTc (Var (mkCCallOpId u cc ty'))
+    returnTc (Var (mkFCallId u cc ty'))
 
 tcCoreExpr (UfTuple (HsTupCon _ boxity arity) args) 
   = mapTc tcCoreExpr args      `thenTc` \ args' ->
@@ -339,9 +334,8 @@ tcCoreAlt scrut_ty alt@(con, names, rhs)
     let
        (main_tyvars, _, ex_tyvars, _, _, _) = dataConSig con
 
-       (_, inst_tys, cons) = case splitAlgTyConApp_maybe scrut_ty of
-                                   Just stuff -> stuff
-                                   Nothing -> pprPanic "tcCoreAlt" (ppr alt)
+       (tycon, inst_tys)   = splitTyConApp scrut_ty    -- NB: not tcSplitTyConApp
+                                                       -- We are looking at Core here
        ex_tyvars'          = [mkTyVar name (tyVarKind tv) | (name,tv) <- names `zip` ex_tyvars] 
        ex_tys'             = mkTyVarTys ex_tyvars'
        arg_tys             = dataConArgTys con (inst_tys ++ ex_tys')
@@ -356,7 +350,7 @@ tcCoreAlt scrut_ty alt@(con, names, rhs)
 #endif
                = zipWithEqual "tcCoreAlts" mkLocalId id_names arg_tys
     in
-    ASSERT( con `elem` cons && length inst_tys == length main_tyvars )
+    ASSERT( con `elem` tyConDataCons tycon && length inst_tys == length main_tyvars )
     tcExtendTyVarEnv ex_tyvars'                        $
     tcExtendGlobalValEnv arg_ids               $
     tcCoreExpr rhs                                     `thenTc` \ rhs' ->