diff options
author | Ben Gamari <ben@smart-cactus.org> | 2015-07-21 22:27:18 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-07-23 16:04:19 +0200 |
commit | 5ff4daddd9bc8f424d8f71fb01ebbbae9d608cdf (patch) | |
tree | 79405592b4e18398dde9563a1eef9a0fd1406b1e /compiler/main/HscMain.hs | |
parent | e809ef57d841695f76ab9b2758f7aeb774d6b223 (diff) | |
download | haskell-5ff4daddd9bc8f424d8f71fb01ebbbae9d608cdf.tar.gz |
Add a few comments from SPJ on fixity declarations
Diffstat (limited to 'compiler/main/HscMain.hs')
-rw-r--r-- | compiler/main/HscMain.hs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/compiler/main/HscMain.hs b/compiler/main/HscMain.hs index 3c4b92b3de..328655c6d0 100644 --- a/compiler/main/HscMain.hs +++ b/compiler/main/HscMain.hs @@ -1467,7 +1467,6 @@ hscDeclsWithLocation hsc_env0 str source linenumber = -- been done. See the notes at the definition of InteractiveContext -- (ic_instances) for more details. let defaults = tcg_default tc_gblenv - let fix_env = tcg_fix_env tc_gblenv {- Desugar it -} -- We use a basically null location for iNTERACTIVE @@ -1521,10 +1520,29 @@ hscDeclsWithLocation hsc_env0 str source linenumber = new_tythings = map AnId ext_ids ++ map ATyCon tcs ++ map (AConLike . PatSynCon) patsyns ictxt = hsc_IC hsc_env + -- See Note [Fixity declarations in GHCi] + fix_env = tcg_fix_env tc_gblenv new_ictxt = extendInteractiveContext ictxt new_tythings cls_insts fam_insts defaults fix_env return (new_tythings, new_ictxt) + +{- + Note [Fixity declarations in GHCi] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + To support fixity declarations on types defined within GHCi (as requested + in #10018) we record the fixity environment in InteractiveContext. + When we want to evaluate something TcRnDriver.runTcInteractive pulls out this + fixity environment and uses it to initialize the global typechecker environment. + After the typechecker has finished its business, an updated fixity environment + (reflecting whatever fixity declarations were present in the statements we + passed it) will be returned from hscParsedStmt. This is passed to + updateFixityEnv, which will stuff it back into InteractiveContext, to be + used in evaluating the next statement. + +-} + hscImport :: HscEnv -> String -> IO (ImportDecl RdrName) hscImport hsc_env str = runInteractiveHsc hsc_env $ do (L _ (HsModule{hsmodImports=is})) <- |