ghc-mod root.

This commit is contained in:
Kazu Yamamoto
2014-03-20 16:21:48 +09:00
parent 1a1ee0f3ae
commit ee6dc2fc47
5 changed files with 30 additions and 5 deletions

View File

@@ -22,6 +22,7 @@ module Language.Haskell.GhcMod (
, listLanguages
, listFlags
, debugInfo
, rootInfo
-- * Converting the 'Ghc' monad to the 'IO' monad
, withGHC
, withGHCDummyFile

View File

@@ -1,4 +1,4 @@
module Language.Haskell.GhcMod.Debug (debugInfo, debug) where
module Language.Haskell.GhcMod.Debug (debugInfo, debug, rootInfo, root) where
import Control.Applicative
import Control.Exception.IOChoice
@@ -54,3 +54,24 @@ debug opt cradle fileName = do
fromCabalFile = parseCabalFile file >>= getCompilerOptions origGopts cradle
where
file = fromJust mCabalFile
----------------------------------------------------------------
-- | Obtaining root information.
rootInfo :: Options
-> Cradle
-> FilePath -- ^ A target file.
-> IO String
rootInfo opt cradle fileName = withGHC fileName (root opt cradle fileName)
-- | Obtaining root information.
root :: Options
-> Cradle
-> FilePath -- ^ A target file.
-> Ghc String
root _ cradle _ = do
return $ rootDir ++ "\n"
where
currentDir = cradleCurrentDir cradle
mCabalDir = cradleCabalDir cradle
rootDir = fromMaybe currentDir mCabalDir