From 511be8bdbd4b1c5b1ed822b180a22dec8d6ca738 Mon Sep 17 00:00:00 2001 From: davve Date: Fri, 12 Jan 2007 18:32:41 +0000 Subject: Use exceptions instead of Either when loading package info --- src/Main.hs | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/Main.hs b/src/Main.hs index 1ff2ca01..cff23922 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -1247,9 +1247,7 @@ getIface pkgInfo = case haddockInterfaces pkgInfo of -- | Try to create a PackageData structure for a package getPackage :: Session -> InstalledPackageInfo -> IO PackageData getPackage session pkgInfo = do - - -- try to get the html path to the documentation - eHtml <- getHtml pkgInfo + html <- getHtml pkgInfo -- get a sorted list of the exposed modules let modules = packageModules pkgInfo @@ -1257,19 +1255,15 @@ getPackage session pkgInfo = do -- try to get a ModuleInfo struct for each module mbModInfo <- moduleInfo session modules' - let toEither err = maybe (Left err) Right - let eModInfo = toEither "Could not get ModuleInfo for all exposed modules." - mbModInfo - - -- build the PackageData structure in the Either monad - return $ do - html <- eHtml - modInfo <- eModInfo - return $ PackageData { - pdModules = modules', - pdDocEnv = packageDocEnv modules' modInfo, - pdHtmlPath = html - } + modInfo <- case mbModInfo of + Just x -> return x + Nothing -> throwE "Could not get ModuleInfo for all exposed modules." + + return $ PackageData { + pdModules = modules', + pdDocEnv = packageDocEnv modules' modInfo, + pdHtmlPath = html + } -- | Build a package doc env out of a topologically sorted list of modules packageDocEnv :: [Module] -> [ModuleInfo] -> [(Name, Name)] -- cgit v1.2.3