\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"
import Name ( Name, nameIsLocalOrFrom )
import ErrUtils ( pprBagOfErrors )
import Outputable
-import Util ( zipWithEqual )
+import Util ( zipWithEqual, dropList, equalLength )
import HscTypes ( TyThing(..) )
\end{code}
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' ->
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
\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
bad_value = getErrsTc `thenNF_Tc` \ (warns,errs) ->
returnNF_Tc (pprTrace "Failed:"
(hang doc 4 (pprBagOfErrors errs))
- Nothing)
+ bad_ans)
\end{code}
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)
#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' ->