typeEnvClasses, typeEnvTyCons, emptyIfaceTable )
import FiniteMap ( FiniteMap, plusFM, emptyFM, addToFM )
import OccName ( OccName )
-import Name ( Name, nameModule, nameOccName, getName )
-import Name ( emptyNameEnv )
+import Name ( Name, nameModule, nameOccName, getName, isGlobalName,
+ emptyNameEnv )
import Module ( Module, lookupModuleEnvByName )
import Monad ( when )
Nothing -> return (HscFail pcs_rn);
Just (print_unqualified, (is_exported, new_iface, rn_hs_decls)) -> do {
+ -- In interactive mode, we don't want to discard any top-level entities at
+ -- all (eg. do not inline them away during simplification), and retain them
+ -- all in the TypeEnv so they are available from the command line.
+ --
+ -- isGlobalName separates the user-defined top-level names from those
+ -- introduced by the type checker.
+ ; let dont_discard | ghci_mode == Interactive = isGlobalName
+ | otherwise = is_exported
+
-------------------
-- TYPECHECK
-------------------
-------------------
-- We grab the the unfoldings at this point.
; (pcs_simpl, tidy_binds, orphan_rules)
- <- simplThenTidy dflags pcs_tc hst this_mod is_exported ds_binds ds_rules
+ <- simplThenTidy dflags pcs_tc hst this_mod dont_discard ds_binds ds_rules
-------------------
-- BUILD THE NEW ModDetails AND ModIface
}}
-simplThenTidy dflags pcs hst this_mod is_exported binds rules
+simplThenTidy dflags pcs hst this_mod dont_discard binds rules
= do -- Do main Core-language transformations ---------
-- _scc_ "Core2Core"
(simplified, orphan_rules)
- <- core2core dflags pcs hst is_exported binds rules
+ <- core2core dflags pcs hst dont_discard binds rules
-- Do saturation and convert to A-normal form
-- NOTE: subsequent passes may not transform the syntax, only annotate it