- mb_modguts <- frontend
- case mb_modguts of
- Nothing
- -> return Nothing
- Just core
- -> do result <- backend core
- return (Just result)
- where
- frontend :: Comp (Maybe ModGuts) -- Front end
- -- backend :: (ModGuts -> Comp result) -- Backend.
- (frontend,backend)
- = case ms_hsc_src mod_summary of
- ExtCoreFile -> (hscCoreFrontEnd, nonBootComp)
- HsSrcFile -> (hscFileFrontEnd, nonBootComp)
- HsBootFile -> (hscFileFrontEnd, bootComp)
+ recomp
+
+-- the usual way to build the Comp (Maybe result) to pass to hscCompiler
+genComp :: (ModGuts -> Comp (Maybe a))
+ -> (TcGblEnv -> Comp (Maybe a))
+ -> Comp (Maybe a)
+genComp backend boot_backend = do
+ mod_summary <- gets compModSummary
+ case ms_hsc_src mod_summary of
+ ExtCoreFile -> do
+ mb_modguts <- hscCoreFrontEnd
+ case mb_modguts of
+ Nothing -> return Nothing
+ Just guts -> backend guts
+ _not_core -> do
+ mb_tc <- hscFileFrontEnd
+ case mb_tc of
+ Nothing -> return Nothing
+ Just tc_result ->
+ case ms_hsc_src mod_summary of
+ HsBootFile -> boot_backend tc_result
+ _other -> do
+ mb_guts <- hscDesugar tc_result
+ case mb_guts of
+ Nothing -> return Nothing
+ Just guts -> backend guts