import RnBinds ( rnTopBinds, rnMethodBinds )
import RnEnv ( bindTyVarsRn, lookupBndrRn, lookupOccRn, lookupImplicitOccRn, bindLocalsRn,
- lookupOptionalOccRn, newSysName, newDfunName, checkDupOrQualNames, checkDupNames,
+ newSysName, newDfunName, checkDupOrQualNames, checkDupNames,
listType_RDR, tupleType_RDR )
import RnMonad
import ListSetOps ( unionLists, minusList )
import Maybes ( maybeToBool, catMaybes )
import Bag ( emptyBag, unitBag, consBag, unionManyBags, unionBags, listToBag, bagToList )
-import Outputable ( Outputable(..){-instances-} )
-import PprStyle
+import Outputable ( PprStyle(..), Outputable(..){-instances-} )
import Pretty
import SrcLoc ( SrcLoc )
--- import TyCon ( TyCon{-instance NamedThing-} )
import Unique ( Unique )
import UniqSet ( SYN_IE(UniqSet) )
import UniqFM ( UniqFM, lookupUFM )
(if opt_IgnoreIfacePragmas then
returnRn []
else
+ setModeRn (InterfaceMode Optional) $
+ -- In all the rest of the signature we read in optional mode,
+ -- so that (a) we don't die
mapRn rnIdInfo id_infos
) `thenRn` \ id_infos' ->
-- Call up interface info for default method, if such info exists
let
- dm_occ = prefixOccName SLIT("$m") (rdrNameOcc op)
+ dm_occ = prefixOccName SLIT("$m") (rdrNameOcc op)
in
- newSysName dm_occ Exported locn `thenRn` \ dm_name ->
- addOccurrenceName Optional dm_name `thenRn_`
-
+ newSysName dm_occ Exported locn `thenRn` \ dm_name ->
+ setModeRn (InterfaceMode Optional) (
+ addOccurrenceName dm_name
+ ) `thenRn_`
-- Checks.....
let
mapRn rn_uprag uprags `thenRn` \ new_uprags ->
newDfunName maybe_dfun src_loc `thenRn` \ dfun_name ->
- addOccurrenceName Compulsory dfun_name `thenRn_`
+ addOccurrenceName dfun_name `thenRn_`
-- The dfun is not optional, because we use its version number
-- to identify the version of the instance declaration
not (tv `elem` forall_tyvars)
]
in
--- checkRn (null non_foralld_constrained)
--- (ctxtErr sig_doc non_foralld_constrained) `thenRn_`
+ checkRn (null non_foralld_constrained)
+ (ctxtErr sig_doc non_foralld_constrained) `thenRn_`
(bindTyVarsRn sig_doc (map UserTyVar forall_tyvars) $ \ new_tyvars ->
rnContext ctxt `thenRn` \ new_ctxt ->
-- Easiest thing is simply not to put it in the occurrence set.
lookupBndrRn clas `thenRn` \ clas_name ->
(if clas_name /= allClass_NAME then
- addOccurrenceName Compulsory clas_name
+ addOccurrenceName clas_name
else
returnRn clas_name
) `thenRn_`
= rnStrict strict `thenRn` \ strict' ->
returnRn (HsStrictness strict')
-rnIdInfo (HsUnfold expr) = rnCoreExpr expr `thenRn` \ expr' ->
- returnRn (HsUnfold expr')
+rnIdInfo (HsUnfold inline expr) = rnCoreExpr expr `thenRn` \ expr' ->
+ returnRn (HsUnfold inline expr')
rnIdInfo (HsArity arity) = returnRn (HsArity arity)
rnIdInfo (HsUpdate update) = returnRn (HsUpdate update)
rnIdInfo (HsFBType fb) = returnRn (HsFBType fb)
rnIdInfo (HsArgUsage au) = returnRn (HsArgUsage au)
rnIdInfo (HsDeforest df) = returnRn (HsDeforest df)
-rnStrict (StrictnessInfo demands (Just worker))
- = lookupOptionalOccRn worker `thenRn` \ worker' ->
- returnRn (StrictnessInfo demands (Just worker'))
+rnStrict (StrictnessInfo demands (Just (worker,cons)))
+ -- The sole purpose of the "cons" field is so that we can mark the constructors
+ -- needed to build the wrapper as "needed", so that their data type decl will be
+ -- slurped in. After that their usefulness is o'er, so we just put in the empty list.
+ = lookupOccRn worker `thenRn` \ worker' ->
+ mapRn lookupOccRn cons `thenRn_`
+ returnRn (StrictnessInfo demands (Just (worker',[])))
-- Boring, but necessary for the type checker.
rnStrict (StrictnessInfo demands Nothing) = returnRn (StrictnessInfo demands Nothing)
\begin{code}
rnCoreExpr (UfVar v)
- = lookupOptionalOccRn v `thenRn` \ v' ->
+ = lookupOccRn v `thenRn` \ v' ->
returnRn (UfVar v')
rnCoreExpr (UfLit lit) = returnRn (UfLit lit)
rnCoreExpr (UfCon con args)
- = lookupOptionalOccRn con `thenRn` \ con' ->
+ = lookupOccRn con `thenRn` \ con' ->
mapRn rnCoreArg args `thenRn` \ args' ->
returnRn (UfCon con' args')
\end{code}
\begin{code}
-rnCoreArg (UfVarArg v) = lookupOptionalOccRn v `thenRn` \ v' -> returnRn (UfVarArg v')
-rnCoreArg (UfUsageArg u) = lookupOptionalOccRn u `thenRn` \ u' -> returnRn (UfUsageArg u')
+rnCoreArg (UfVarArg v) = lookupOccRn v `thenRn` \ v' -> returnRn (UfVarArg v')
+rnCoreArg (UfUsageArg u) = lookupOccRn u `thenRn` \ u' -> returnRn (UfUsageArg u')
rnCoreArg (UfTyArg ty) = rnHsType ty `thenRn` \ ty' -> returnRn (UfTyArg ty')
rnCoreArg (UfLitArg lit) = returnRn (UfLitArg lit)
rnCoreDefault deflt `thenRn` \ deflt' ->
returnRn (UfAlgAlts alts' deflt')
where
- rn_alt (con, bndrs, rhs) = lookupOptionalOccRn con `thenRn` \ con' ->
+ rn_alt (con, bndrs, rhs) = lookupOccRn con `thenRn` \ con' ->
bindLocalsRn "unfolding alt" bndrs $ \ bndrs' ->
rnCoreExpr rhs `thenRn` \ rhs' ->
returnRn (con', bndrs', rhs')
rnCoreExpr rhs `thenRn` \ rhs' ->
returnRn (UfBindDefault bndr' rhs')
-rnCoercion (UfIn n) = lookupOptionalOccRn n `thenRn` \ n' -> returnRn (UfIn n')
-rnCoercion (UfOut n) = lookupOptionalOccRn n `thenRn` \ n' -> returnRn (UfOut n')
+rnCoercion (UfIn n) = lookupOccRn n `thenRn` \ n' -> returnRn (UfIn n')
+rnCoercion (UfOut n) = lookupOccRn n `thenRn` \ n' -> returnRn (UfOut n')
rnCorePrim (UfOtherOp op)
- = lookupOptionalOccRn op `thenRn` \ op' ->
+ = lookupOccRn op `thenRn` \ op' ->
returnRn (UfOtherOp op')
rnCorePrim (UfCCallOp str casm gc arg_tys res_ty)