\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 TysWiredIn ( tupleCon )
import Var ( mkTyVar, tyVarKind )
import Name ( Name, nameIsLocalOrFrom )
-import Demand ( wwLazy )
import ErrUtils ( pprBagOfErrors )
import Outputable
import Util ( zipWithEqual )
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' ->
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
\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
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
\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
bad_value = getErrsTc `thenNF_Tc` \ (warns,errs) ->
returnNF_Tc (pprTrace "Failed:"
(hang doc 4 (pprBagOfErrors errs))
- Nothing)
+ bad_ans)
\end{code}