import HsTypes ( getTyVarName, pprClassAssertion, cmpHsTypes )
import RdrName ( RdrName, isRdrDataCon, rdrNameOcc, isRdrTyVar )
import RdrHsSyn ( RdrNameContext, RdrNameHsType, RdrNameConDecl,
- extractHsTyRdrNames, extractRuleBndrsTyVars
+ extractRuleBndrsTyVars, extractHsTyRdrTyVars
)
import RnHsSyn
import HsCore
| otherwise = addErrRn (ctxtErr explicit_forall doc forall_tyvars ct ty)
`thenRn_` returnRn Nothing
where
- forall_mentioned = foldr ((||) . any (`elem` forall_tyvars) . extractHsTyRdrNames)
+ forall_mentioned = foldr ((||) . any (`elem` forall_tyvars) . extractHsTyRdrTyVars)
False
tys
-freeRdrTyVars :: RdrNameHsType -> [RdrName]
-freeRdrTyVars ty = filter isRdrTyVar (extractHsTyRdrNames ty)
-
rnHsType :: SDoc -> RdrNameHsType -> RnMS (RenamedHsType, FreeVars)
rnHsType doc (HsForAllTy Nothing ctxt ty)
-- over FV(T) \ {in-scope-tyvars}
= getLocalNameEnv `thenRn` \ name_env ->
let
- mentioned_in_tau = freeRdrTyVars ty
+ mentioned_in_tau = extractHsTyRdrTyVars ty
forall_tyvars = filter (not . (`elemFM` name_env)) mentioned_in_tau
in
checkConstraints False doc forall_tyvars ctxt ty `thenRn` \ ctxt' ->
-- That's only a warning... unless the tyvar is constrained by a
-- context in which case it's an error
= let
- mentioned_in_tau = freeRdrTyVars tau
+ mentioned_in_tau = extractHsTyRdrTyVars tau
mentioned_in_ctxt = nub [tv | (_,tys) <- ctxt,
ty <- tys,
- tv <- freeRdrTyVars ty]
+ tv <- extractHsTyRdrTyVars ty]
dubious_guys = filter (`notElem` mentioned_in_tau) forall_tyvar_names
-- dubious = explicitly quantified but not mentioned in tau type