diff options
author | davve <davve@dtek.chalmers.se> | 2007-01-12 18:32:41 +0000 |
---|---|---|
committer | davve <davve@dtek.chalmers.se> | 2007-01-12 18:32:41 +0000 |
commit | 511be8bdbd4b1c5b1ed822b180a22dec8d6ca738 (patch) | |
tree | 428765d313f938b7a8fdc83b7f4341b404bab8fc | |
parent | f4ba2b390aa8e75b8154685e05d55ff3f7aa4130 (diff) |
Use exceptions instead of Either when loading package info
-rw-r--r-- | src/Main.hs | 26 |
1 files changed, 10 insertions, 16 deletions
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)] |