[project @ 2001-10-19 10:04:37 by sewardj]
[ghc-hetmet.git] / ghc / compiler / typecheck / TcIfaceSig.lhs
index 8b255e4..cc7d9b6 100644 (file)
@@ -4,7 +4,7 @@
 \section[TcIfaceSig]{Type checking of type signatures in interface files}
 
 \begin{code}
-module TcIfaceSig ( tcInterfaceSigs, tcVar, tcCoreExpr, tcCoreLamBndrs ) where
+module TcIfaceSig ( tcInterfaceSigs, tcDelay, tcVar, tcCoreExpr, tcCoreLamBndrs ) where
 
 #include "HsVersions.h"
 
@@ -35,7 +35,6 @@ 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 )
@@ -87,11 +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` arity
-                      `setCgArity`   arity)
+       returnTc (info `setArityInfo` arity)
 
     tcPrag info (HsUnfold inline_prag expr)
        = tcPragExpr unf_env name in_scope_vars expr    `thenNF_Tc` \ maybe_expr' ->
@@ -107,7 +104,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
@@ -115,7 +112,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
@@ -128,15 +125,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
@@ -144,24 +137,23 @@ an unfolding that isn't going to be looked at.
 
 \begin{code}
 tcPragExpr unf_env name in_scope_vars expr
-  = tcDelay unf_env doc $
+  = tcDelay unf_env doc Nothing $
        tcCoreExpr expr         `thenTc` \ core_expr' ->
 
                -- Check for type consistency in the unfolding
        tcGetSrcLoc             `thenNF_Tc` \ src_loc -> 
        getDOptsTc              `thenTc` \ dflags ->
        case lintUnfolding dflags src_loc in_scope_vars core_expr' of
-         (Nothing,_)       -> returnTc core_expr'  -- ignore warnings
+         (Nothing,_)       -> returnTc (Just core_expr')  -- ignore warnings
          (Just fail_msg,_) -> failWithTc ((doc <+> text "failed Lint") $$ fail_msg)
   where
     doc = text "unfolding of" <+> ppr name
 
-tcDelay :: RecTcEnv -> SDoc -> TcM a -> NF_TcM (Maybe a)
-tcDelay unf_env doc thing_inside
+tcDelay :: RecTcEnv -> SDoc -> a -> TcM a -> NF_TcM a
+tcDelay unf_env doc bad_ans thing_inside
   = forkNF_Tc (
        recoverNF_Tc bad_value (
-               tcSetEnv unf_env thing_inside   `thenTc` \ r ->
-               returnTc (Just r)
+               tcSetEnv unf_env thing_inside
     ))                 
   where
        -- The trace tells what wasn't available, for the benefit of
@@ -169,7 +161,7 @@ tcDelay unf_env doc thing_inside
     bad_value = getErrsTc              `thenNF_Tc` \ (warns,errs) ->
                returnNF_Tc (pprTrace "Failed:" 
                                         (hang doc 4 (pprBagOfErrors errs))
-                                        Nothing)
+                                        bad_ans)
 \end{code}