hoogle-index 0.4.2 → 0.4.3
raw patch · 2 files changed
+20/−20 lines, 2 filesdep ~errors
Dependency ranges changed: errors
Files
- Main.hs +18/−18
- hoogle-index.cabal +2/−2
Main.hs view
@@ -89,7 +89,7 @@ deriving (Show) -- | Call a process-callProcessE :: Config -> FilePath -> [String] -> EitherT String IO ()+callProcessE :: Config -> FilePath -> [String] -> ExceptT String IO () callProcessE ver = callProcessIn ver "." -- | Call a process from the given directory@@ -97,7 +97,7 @@ -> FilePath -- ^ directory -> FilePath -- ^ executable -> [String] -- ^ arguments- -> EitherT String IO ()+ -> ExceptT String IO () callProcessIn cfg dir exec args = do let ver = verbosity cfg stream@@ -116,10 +116,10 @@ code <- liftIO $ waitForProcess ph case code of ExitSuccess -> return ()- ExitFailure e -> left $ "Process "++exec++" failed with error "++show e+ ExitFailure e -> throwE $ "Process "++exec++" failed with error "++show e -- | Unpack a package-unpack :: Config -> PackageId -> EitherT String IO PackageTree+unpack :: Config -> PackageId -> ExceptT String IO PackageTree unpack cfg (PackageIdentifier (PackageName pkg) ver) = do tmpDir <- liftIO getTemporaryDirectory dir <- liftIO $ createTempDirectory tmpDir "hoogle-index.pkg"@@ -135,7 +135,7 @@ newtype TextBase = TextBase BS.ByteString -- | Write a Haddock textbase to a file-writeTextBase :: TextBase -> FilePath -> EitherT String IO ()+writeTextBase :: TextBase -> FilePath -> ExceptT String IO () writeTextBase (TextBase content) path = liftIO $ BS.writeFile path content -- | A file containing a Haddock textbase@@ -156,14 +156,14 @@ else return Nothing -- | Build a textbase from source-buildTextBase :: Config -> PackageName -> PackageTree -> EitherT String IO TextBase+buildTextBase :: Config -> PackageName -> PackageTree -> ExceptT String IO TextBase buildTextBase cfg (PackageName pkg) (PkgTree dir) = do callProcessIn cfg dir "cabal" ["configure"] callProcessIn cfg dir "cabal" ["haddock", "--hoogle"] let path = dir </> "dist" </> "doc" </> "html" </> pkg </> (pkg++".txt") TextBase <$> liftIO (BS.readFile path) -placeTextBase :: Config -> InstalledPackageInfo -> TextBase -> EitherT String IO ()+placeTextBase :: Config -> InstalledPackageInfo -> TextBase -> ExceptT String IO () placeTextBase cfg ipkg tb | Just docRoot <- listToMaybe $ haddockHTMLs ipkg = tryIO' $ do let TextBase content = tb@@ -178,7 +178,7 @@ pkg = sourcePackageId ipkg PackageName name = pkgName pkg -getTextBase :: Config -> InstalledPackageInfo -> EitherT String IO TextBase+getTextBase :: Config -> InstalledPackageInfo -> ExceptT String IO TextBase getTextBase cfg ipkg = do existing <- if ignoreExistingTextBases cfg then return Nothing@@ -192,7 +192,7 @@ when (installTextBase cfg) $ do -- It's not the end of the world if this fails- result <- liftIO $ runEitherT $ placeTextBase cfg ipkg tb+ result <- liftIO $ runExceptT $ placeTextBase cfg ipkg tb case result of Left e -> liftIO $ putStrLn $ name++": Failed to install textbase: "++e Right _ -> return ()@@ -213,7 +213,7 @@ convert :: Config -> TextBaseFile -> Maybe FilePath -- ^ documentation root -> [Database]- -> EitherT String IO Database+ -> ExceptT String IO Database convert cfg tbf docRoot merge = do let docRoot' = maybe [] (\d->["--haddock", "--doc="++d]) docRoot (tb,h) <- liftIO $ openTempFile "/tmp" "db.hoo"@@ -225,7 +225,7 @@ return $ DB tb -- | Generate a Hoogle database for an installed package-indexPackage :: Config -> InstalledPackageInfo -> EitherT String IO Database+indexPackage :: Config -> InstalledPackageInfo -> ExceptT String IO Database indexPackage cfg ipkg | pkgName pkg `S.member` downloadPackages = do tmpDir <- liftIO getTemporaryDirectory@@ -233,7 +233,7 @@ return $ DB $ tmpDir </> name++".hoo" | pkgName pkg `S.member` ignorePackages =- left $ "Can't build documentation for "++name+ throwE $ "Can't build documentation for "++name | otherwise = do tb <- getTextBase cfg ipkg@@ -259,7 +259,7 @@ PackageName name = pkgName pkg -- | Combine Hoogle databases-combineDBs :: Config -> [Database] -> EitherT String IO Database+combineDBs :: Config -> [Database] -> ExceptT String IO Database combineDBs cfg dbs = do tmpDir <- tryIO' $ getTemporaryDirectory (out, h) <- tryIO' $ openTempFile tmpDir "combined.hoo"@@ -269,7 +269,7 @@ return (DB out) -- | Install a database in Hoogle's database directory-installDB :: Database -> SandboxPath -> EitherT String IO ()+installDB :: Database -> SandboxPath -> ExceptT String IO () installDB (DB db) sp = do dbDir <- liftIO $ getDatabaseLocation sp let destDir = dbDir </> "databases"@@ -299,7 +299,7 @@ maybeIndex :: InstalledPackageInfo -> IO (Either (PackageId, String) Database) maybeIndex pkg = do putStrLn ""- result <- runEitherT $ indexPackage cfg pkg+ result <- runExceptT $ indexPackage cfg pkg case result of Left e -> do let pkgId = sourcePackageId pkg@@ -314,7 +314,7 @@ let failedMsg (pkgId, reason) = " "++show (pkgName pkgId)++"\t"++reason putStrLn $ unlines $ map failedMsg failed - res <- runEitherT $ do+ res <- runExceptT $ do combined <- fmapLT ("Error while combining databases: "++) $ combineDBs cfg idxs installDB combined sandboxPath@@ -322,11 +322,11 @@ mapM_ removeDB idxs Just (HoogleCall args) -> do- res <- runEitherT $+ res <- runExceptT $ callProcessE cfg "hoogle" $ getHoogleArgs sandboxPath args either putStrLn return res -tryIO' :: IO a -> EitherT String IO a+tryIO' :: IO a -> ExceptT String IO a tryIO' = fmapLT show . tryIO
hoogle-index.cabal view
@@ -1,5 +1,5 @@ name: hoogle-index-version: 0.4.2+version: 0.4.3 synopsis: Easily generate Hoogle indices for installed packages description: 'hoogle-index' is a small utility for generating indicies for local@@ -32,7 +32,7 @@ directory >=1.2 && <1.3, process >=1.2 && <1.3, filepath >=1.3 && <1.5,- errors >=1.4 && <1.5,+ errors >=2.0 && <3.0, bytestring >=0.9 && <1.11, temporary >=1.2 && <1.3, Cabal >=1.20 && <1.23,