-compile :: HscEnv
- -> ModSummary
- -> Maybe Linkable -- Just linkable <=> source unchanged
- -> Maybe ModIface -- Old interface, if available
- -> Int -> Int
- -> IO CompResult
-
-data CompResult
- = CompOK ModDetails -- New details
- ModIface -- New iface
- (Maybe Linkable) -- a Maybe, for the same reasons as hm_linkable
-
- | CompErrs
-
-
-compile hsc_env mod_summary maybe_old_linkable old_iface mod_index nmods = do
-
- let dflags0 = ms_hspp_opts mod_summary
- this_mod = ms_mod mod_summary
- src_flavour = ms_hsc_src mod_summary
-
- have_object
- | Just l <- maybe_old_linkable, isObjectLinkable l = True
- | otherwise = False
-
- -- FIXME: We need to know whether or not we're recompiling the file. Move this to HscMain?
- --showPass dflags0 ("Compiling " ++ showModMsg have_object mod_summary)
-
- let location = ms_location mod_summary
- let input_fn = expectJust "compile:hs" (ml_hs_file location)
- let input_fnpp = ms_hspp_file mod_summary
-
- debugTraceMsg dflags0 2 (text "compile: input file" <+> text input_fnpp)
-
- let (basename, _) = splitFilename input_fn
+compile :: GhcMonad m =>
+ HscEnv
+ -> ModSummary -- ^ summary for module being compiled
+ -> Int -- ^ module N ...
+ -> Int -- ^ ... of M
+ -> Maybe ModIface -- ^ old interface, if we have one
+ -> Maybe Linkable -- ^ old linkable, if we have one
+ -> m HomeModInfo -- ^ the complete HomeModInfo, if successful
+
+compile = compile' (hscCompileNothing, hscCompileInteractive, hscCompileBatch)
+
+type Compiler m a = HscEnv -> ModSummary -> Bool
+ -> Maybe ModIface -> Maybe (Int, Int)
+ -> m a
+
+compile' :: GhcMonad m =>
+ (Compiler m (HscStatus, ModIface, ModDetails),
+ Compiler m (InteractiveStatus, ModIface, ModDetails),
+ Compiler m (HscStatus, ModIface, ModDetails))
+ -> HscEnv
+ -> ModSummary -- ^ summary for module being compiled
+ -> Int -- ^ module N ...
+ -> Int -- ^ ... of M
+ -> Maybe ModIface -- ^ old interface, if we have one
+ -> Maybe Linkable -- ^ old linkable, if we have one
+ -> m HomeModInfo -- ^ the complete HomeModInfo, if successful
+
+compile' (nothingCompiler, interactiveCompiler, batchCompiler)
+ hsc_env0 summary mod_index nmods mb_old_iface maybe_old_linkable
+ = do
+ let dflags0 = ms_hspp_opts summary
+ this_mod = ms_mod summary
+ src_flavour = ms_hsc_src summary
+ location = ms_location summary
+ input_fn = expectJust "compile:hs" (ml_hs_file location)
+ input_fnpp = ms_hspp_file summary
+
+ liftIO $ debugTraceMsg dflags0 2 (text "compile: input file" <+> text input_fnpp)
+
+ let basename = dropExtension input_fn