Fix `doc` command not using right ghc-pkg exe

This commit is contained in:
Daniel Gröber 2015-09-02 07:19:11 +02:00
parent 86c157d1d2
commit 8fea4ac426
2 changed files with 18 additions and 3 deletions

View File

@ -6,6 +6,7 @@ module Language.Haskell.GhcMod.GhcPkg (
, ghcDbOpt
, getPackageDbStack
, getPackageCachePaths
, getGhcPkgProgram
) where
import Config (cProjectVersion, cTargetPlatformString, cProjectVersionInt)
@ -59,6 +60,18 @@ ghcDbOpt (PackageDb pkgDb)
----------------------------------------------------------------
getGhcPkgProgram :: IOish m => GhcModT m FilePath
getGhcPkgProgram = do
crdl <- cradle
progs <- optPrograms <$> options
case cradleProjectType crdl of
StackProject -> do
Just ghcPkg <- getStackGhcPkgPath (cradleRootDir crdl)
return ghcPkg
_ ->
return $ ghcPkgProgram progs
getPackageDbStack :: IOish m => GhcModT m [GhcPkgDb]
getPackageDbStack = do
crdl <- cradle

View File

@ -3,7 +3,7 @@ module Language.Haskell.GhcMod.PkgDoc (pkgDoc) where
import Language.Haskell.GhcMod.Types
import Language.Haskell.GhcMod.GhcPkg
import Language.Haskell.GhcMod.Monad
import Language.Haskell.GhcMod.Utils
import Language.Haskell.GhcMod.Output
import Control.Applicative
import Prelude
@ -11,12 +11,14 @@ import Prelude
-- | Obtaining the package name and the doc path of a module.
pkgDoc :: IOish m => String -> GhcModT m String
pkgDoc mdl = do
ghcPkg <- getGhcPkgProgram
readProc <- gmReadProcess
pkgDbStack <- getPackageDbStack
pkg <- liftIO $ trim <$> readProcess "ghc-pkg" (toModuleOpts pkgDbStack) ""
pkg <- liftIO $ trim <$> readProc ghcPkg (toModuleOpts pkgDbStack) ""
if pkg == "" then
return "\n"
else do
htmlpath <- liftIO $ readProcess "ghc-pkg" (toDocDirOpts pkg pkgDbStack) ""
htmlpath <- liftIO $ readProc ghcPkg (toDocDirOpts pkg pkgDbStack) ""
let ret = pkg ++ " " ++ drop 14 htmlpath
return ret
where