[project @ 2001-12-20 11:19:05 by simonpj]
[ghc-hetmet.git] / ghc / compiler / typecheck / TcIfaceSig.lhs
index 0d4824d..da180d8 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"
 
@@ -37,7 +37,7 @@ import Var            ( mkTyVar, tyVarKind )
 import Name            ( Name, nameIsLocalOrFrom )
 import ErrUtils                ( pprBagOfErrors )
 import Outputable      
-import Util            ( zipWithEqual )
+import Util            ( zipWithEqual, dropList, equalLength )
 import HscTypes                ( TyThing(..) )
 \end{code}
 
@@ -88,8 +88,7 @@ tcIdInfo unf_env in_scope_vars name ty info_ins
     tcPrag info (HsNoCafRefs)   = returnTc (info `setCafInfo`   NoCafRefs)
 
     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' ->
@@ -105,7 +104,7 @@ tcIdInfo unf_env in_scope_vars name ty info_ins
          returnTc info2
 
     tcPrag info (HsStrictness strict_info)
-       = returnTc (info `setNewStrictnessInfo` Just strict_info)
+       = returnTc (info `setAllStrictnessInfo` Just strict_info)
 
     tcPrag info (HsWorker nm arity)
        = tcWorkerInfo unf_env ty info nm arity
@@ -138,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 ->
+       getDOptsTc              `thenNF_Tc` \ 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
@@ -163,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}
 
 
@@ -339,10 +337,10 @@ tcCoreAlt scrut_ty alt@(con, names, rhs)
        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')
-       id_names            = drop (length ex_tyvars) names
+       id_names            = dropList ex_tyvars names
        arg_ids
 #ifdef DEBUG
-               | length id_names /= length arg_tys
+               | not (equalLength id_names arg_tys)
                = pprPanic "tcCoreAlts" (ppr (con, names, rhs) $$
                                         (ppr main_tyvars <+> ppr ex_tyvars) $$
                                         ppr arg_tys)
@@ -350,7 +348,7 @@ tcCoreAlt scrut_ty alt@(con, names, rhs)
 #endif
                = zipWithEqual "tcCoreAlts" mkLocalId id_names arg_tys
     in
-    ASSERT( con `elem` tyConDataCons tycon && length inst_tys == length main_tyvars )
+    ASSERT( con `elem` tyConDataCons tycon && equalLength inst_tys main_tyvars )
     tcExtendTyVarEnv ex_tyvars'                        $
     tcExtendGlobalValEnv arg_ids               $
     tcCoreExpr rhs                                     `thenTc` \ rhs' ->