Without -fglasow-exts, quantify over all mentioned type vars in type sigs
import NameSet ( FreeVars )
import Unique ( Uniquable(..) )
import NameSet ( FreeVars )
import Unique ( Uniquable(..) )
+import CmdLineOpts ( DynFlag(Opt_GlasgowExts) )
import List ( nub )
import ListSetOps ( removeDupsEq )
import Outputable
import List ( nub )
import ListSetOps ( removeDupsEq )
import Outputable
-- Given the signature C => T we universally quantify
-- over FV(T) \ {in-scope-tyvars}
= getLocalNameEnv `thenRn` \ name_env ->
-- Given the signature C => T we universally quantify
-- over FV(T) \ {in-scope-tyvars}
= getLocalNameEnv `thenRn` \ name_env ->
+ doptRn Opt_GlasgowExts `thenRn` \ opt_GlasgowExts ->
let
mentioned_in_tau = extractHsTyRdrTyVars ty
mentioned_in_ctxt = extractHsCtxtRdrTyVars ctxt
mentioned = nub (mentioned_in_tau ++ mentioned_in_ctxt)
let
mentioned_in_tau = extractHsTyRdrTyVars ty
mentioned_in_ctxt = extractHsCtxtRdrTyVars ctxt
mentioned = nub (mentioned_in_tau ++ mentioned_in_ctxt)
- forall_tyvars = filter (not . (`elemRdrEnv` name_env)) mentioned
+
+ -- Don't quantify over type variables that are in scope,
+ -- when GlasgowExts is on
+ forall_tyvars
+ | opt_GlasgowExts = filter (not . (`elemRdrEnv` name_env)) mentioned
+ | otherwise = mentioned
in
rnForAll doc (map UserTyVar forall_tyvars) ctxt ty
in
rnForAll doc (map UserTyVar forall_tyvars) ctxt ty