Commit 5ff4dadd authored by Ben Gamari's avatar Ben Gamari 🐢

Add a few comments from SPJ on fixity declarations

parent e809ef57
......@@ -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})) <-
......
......@@ -1436,7 +1436,7 @@ extendInteractiveContext ictxt new_tythings new_cls_insts new_fam_insts defaults
, ic_instances = ( new_cls_insts ++ old_cls_insts
, new_fam_insts ++ old_fam_insts )
, ic_default = defaults
, ic_fix_env = fix_env -- # 10018
, ic_fix_env = fix_env -- See Note [Fixity declarations in GHCi]
}
where
new_ids = [id | AnId id <- new_tythings]
......
Markdown is supported
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