[commit: ghc] master: Minor refactor to use filterInScope (ab98860)

git at git.haskell.org git at git.haskell.org
Wed Aug 5 15:50:07 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/ab98860871cfac17417d5b55e590445064d21111/ghc

>---------------------------------------------------------------

commit ab98860871cfac17417d5b55e590445064d21111
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Wed Aug 5 14:03:34 2015 +0100

    Minor refactor to use filterInScope


>---------------------------------------------------------------

ab98860871cfac17417d5b55e590445064d21111
 compiler/rename/RnTypes.hs | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/compiler/rename/RnTypes.hs b/compiler/rename/RnTypes.hs
index 346d764..5dfd3fa 100644
--- a/compiler/rename/RnTypes.hs
+++ b/compiler/rename/RnTypes.hs
@@ -489,17 +489,18 @@ rnHsBndrSig :: HsDocContext
 rnHsBndrSig doc (HsWB { hswb_cts = ty@(L loc _) }) thing_inside
   = do { sig_ok <- xoptM Opt_ScopedTypeVariables
        ; unless sig_ok (badSigErr True doc ty)
-       ; let (kv_bndrs, tv_bndrs) = extractHsTyRdrTyVars ty
-       ; name_env <- getLocalRdrEnv
-       ; tv_names <- newLocalBndrsRn [L loc tv | tv <- tv_bndrs
-                                               , not (tv `elemLocalRdrEnv` name_env) ]
-       ; kv_names <- newLocalBndrsRn [L loc kv | kv <- kv_bndrs
-                                               , not (kv `elemLocalRdrEnv` name_env) ]
+       ; rdr_env <- getLocalRdrEnv
+       ; let (kv_bndrs, tv_bndrs) = filterInScope rdr_env $
+                                    extractHsTyRdrTyVars ty
+       ; kv_names <- newLocalBndrsRn (map (L loc) kv_bndrs)
+       ; tv_names <- newLocalBndrsRn (map (L loc) tv_bndrs)
        ; bindLocalNamesFV kv_names $
          bindLocalNamesFV tv_names $
     do { (ty', fvs1, wcs) <- rnLHsTypeWithWildCards doc ty
-       ; (res, fvs2) <- thing_inside (HsWB { hswb_cts = ty', hswb_kvs = kv_names,
-                                             hswb_tvs = tv_names, hswb_wcs = wcs })
+       ; (res, fvs2) <- thing_inside (HsWB { hswb_cts = ty'
+                                           , hswb_kvs = kv_names
+                                           , hswb_tvs = tv_names
+                                           , hswb_wcs = wcs })
        ; return (res, fvs1 `plusFV` fvs2) } }
 
 overlappingKindVars :: HsDocContext -> [RdrName] -> SDoc



More information about the ghc-commits mailing list