Commit c97ea0ce authored by simonpj's avatar simonpj
Browse files

[project @ 2004-12-23 11:50:55 by simonpj]

Enable scoped type variables only where there is an explicit forall
parent e12e0bb7
...@@ -506,7 +506,7 @@ reservedWordsFM = listToUFM $ ...@@ -506,7 +506,7 @@ reservedWordsFM = listToUFM $
( "where", ITwhere, 0 ), ( "where", ITwhere, 0 ),
( "_scc_", ITscc, 0 ), -- ToDo: remove ( "_scc_", ITscc, 0 ), -- ToDo: remove
( "forall", ITforall, bit glaExtsBit), ( "forall", ITforall, bit tvBit),
( "mdo", ITmdo, bit glaExtsBit), ( "mdo", ITmdo, bit glaExtsBit),
( "foreign", ITforeign, bit ffiBit), ( "foreign", ITforeign, bit ffiBit),
...@@ -542,7 +542,7 @@ reservedSymsFM = listToUFM $ ...@@ -542,7 +542,7 @@ reservedSymsFM = listToUFM $
,("!", ITbang, 0) ,("!", ITbang, 0)
,("*", ITstar, bit glaExtsBit) -- For data T (a::*) = MkT ,("*", ITstar, bit glaExtsBit) -- For data T (a::*) = MkT
,(".", ITdot, bit glaExtsBit) -- For 'forall a . t' ,(".", ITdot, bit tvBit) -- For 'forall a . t'
,("-<", ITlarrowtail, bit arrowsBit) ,("-<", ITlarrowtail, bit arrowsBit)
,(">-", ITrarrowtail, bit arrowsBit) ,(">-", ITrarrowtail, bit arrowsBit)
...@@ -1160,6 +1160,7 @@ parrBit = 2 ...@@ -1160,6 +1160,7 @@ parrBit = 2
arrowsBit = 4 arrowsBit = 4
thBit = 5 thBit = 5
ipBit = 6 ipBit = 6
tvBit = 7 -- Scoped type variables enables 'forall' keyword
glaExtsEnabled, ffiEnabled, parrEnabled :: Int -> Bool glaExtsEnabled, ffiEnabled, parrEnabled :: Int -> Bool
glaExtsEnabled flags = testBit flags glaExtsBit glaExtsEnabled flags = testBit flags glaExtsBit
...@@ -1168,6 +1169,7 @@ parrEnabled flags = testBit flags parrBit ...@@ -1168,6 +1169,7 @@ parrEnabled flags = testBit flags parrBit
arrowsEnabled flags = testBit flags arrowsBit arrowsEnabled flags = testBit flags arrowsBit
thEnabled flags = testBit flags thBit thEnabled flags = testBit flags thBit
ipEnabled flags = testBit flags ipBit ipEnabled flags = testBit flags ipBit
tvEnabled flags = testBit flags tvBit
-- create a parse state -- create a parse state
-- --
...@@ -1190,6 +1192,7 @@ mkPState buf loc flags = ...@@ -1190,6 +1192,7 @@ mkPState buf loc flags =
.|. arrowsBit `setBitIf` dopt Opt_Arrows flags .|. arrowsBit `setBitIf` dopt Opt_Arrows flags
.|. thBit `setBitIf` dopt Opt_TH flags .|. thBit `setBitIf` dopt Opt_TH flags
.|. ipBit `setBitIf` dopt Opt_ImplicitParams flags .|. ipBit `setBitIf` dopt Opt_ImplicitParams flags
.|. tvBit `setBitIf` dopt Opt_ScopedTypeVariables flags
-- --
setBitIf :: Int -> Bool -> Int setBitIf :: Int -> Bool -> Int
b `setBitIf` cond | cond = bit b b `setBitIf` cond | cond = bit b
......
...@@ -644,7 +644,9 @@ bindSigTyVarsFV sigs thing_inside ...@@ -644,7 +644,9 @@ bindSigTyVarsFV sigs thing_inside
bindLocalNamesFV tvs thing_inside } bindLocalNamesFV tvs thing_inside }
where where
tvs = [ hsLTyVarName ltv tvs = [ hsLTyVarName ltv
| L _ (Sig _ (L _ (HsForAllTy _ ltvs _ _))) <- sigs, ltv <- ltvs ] | L _ (Sig _ (L _ (HsForAllTy Explicit ltvs _ _))) <- sigs, ltv <- ltvs ]
-- Note the pattern-match on "Explicit"; we only bind
-- type variables from signatures with an explicit top-level for-all
extendTyVarEnvFVRn :: [Name] -> RnM (a, FreeVars) -> RnM (a, FreeVars) extendTyVarEnvFVRn :: [Name] -> RnM (a, FreeVars) -> RnM (a, FreeVars)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment