@@ -73,6 +73,7 @@ import Packages
73
73
import Panic (handleGhcException )
74
74
import Module
75
75
import FastString
76
+ import Pipes
76
77
77
78
--------------------------------------------------------------------------------
78
79
-- * Exception handling
@@ -161,9 +162,9 @@ haddockWithGhc ghc args = handleTopExceptions $ do
161
162
forM_ (warnings args) $ \ warning -> do
162
163
hPutStrLn stderr warning
163
164
164
- ghc flags' $ do
165
+ ghc flags' $ runEffect $ do
165
166
166
- dflags <- getDynFlags
167
+ dflags <- lift getDynFlags
167
168
168
169
if not (null files) then do
169
170
(packages, ifaces, homeLinks) <- readPackagesAndProcessModules flags files
@@ -176,14 +177,15 @@ haddockWithGhc ghc args = handleTopExceptions $ do
176
177
}
177
178
178
179
-- Render the interfaces.
179
- liftIO $ renderStep dflags flags qual packages ifaces
180
+ lift $ liftIO $ renderStep dflags flags qual packages ifaces
180
181
181
182
else do
182
183
when (any (`elem` [Flag_Html , Flag_Hoogle , Flag_LaTeX ]) flags) $
183
184
throwE " No input file(s)."
184
185
185
186
-- Get packages supplied with --read-interface.
186
- packages <- liftIO $ readInterfaceFiles freshNameCache (readIfaceArgs flags)
187
+ readInterfaceFiles freshNameCache (readIfaceArgs flags)
188
+ let packages = undefined
187
189
188
190
-- Render even though there are no input files (usually contents/index).
189
191
liftIO $ renderStep dflags flags qual packages []
@@ -208,16 +210,12 @@ withGhc flags action = do
208
210
209
211
210
212
readPackagesAndProcessModules :: [Flag ] -> [String ]
211
- -> Ghc ([( DocPaths , InterfaceFile )], [ Interface ], LinkEnv )
213
+ -> Producer' Interface ( StateT LinkEnv Ghc ) ( )
212
214
readPackagesAndProcessModules flags files = do
213
215
-- Get packages supplied with --read-interface.
214
- packages <- readInterfaceFiles nameCacheFromGhc (readIfaceArgs flags)
215
-
216
- -- Create the interfaces -- this is the core part of Haddock.
217
- let ifaceFiles = map snd packages
218
- (ifaces, homeLinks) <- processModules (verbosity flags) files flags ifaceFiles
219
-
220
- return (packages, ifaces, homeLinks)
216
+ readInterfaceFiles nameCacheFromGhc (readIfaceArgs flags)
217
+ >-> map snd
218
+ >-> processModules (verbosity flags) files flags
221
219
222
220
223
221
renderStep :: DynFlags -> [Flag ] -> QualOption -> [(DocPaths , InterfaceFile )] -> [Interface ] -> IO ()
@@ -365,19 +363,18 @@ modulePackageInfo dflags flags modu =
365
363
readInterfaceFiles :: MonadIO m
366
364
=> NameCacheAccessor m
367
365
-> [(DocPaths , FilePath )]
368
- -> m [ (DocPaths , InterfaceFile )]
366
+ -> Producer' (DocPaths , InterfaceFile ) m ()
369
367
readInterfaceFiles name_cache_accessor pairs = do
370
- catMaybes `liftM` mapM tryReadIface pairs
368
+ mapM_ tryReadIface pairs
371
369
where
372
370
-- try to read an interface, warn if we can't
373
371
tryReadIface (paths, file) =
374
- readInterfaceFile name_cache_accessor file >>= \ case
372
+ lift ( readInterfaceFile name_cache_accessor file) >>= \ case
375
373
Left err -> liftIO $ do
376
374
putStrLn (" Warning: Cannot read " ++ file ++ " :" )
377
375
putStrLn (" " ++ err)
378
376
putStrLn " Skipping this interface."
379
- return Nothing
380
- Right f -> return $ Just (paths, f)
377
+ Right f -> yield (paths, f)
381
378
382
379
383
380
-------------------------------------------------------------------------------
0 commit comments