aboutsummaryrefslogtreecommitdiff
path: root/Distribution
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2015-11-25 23:51:55 +0100
committerDaniel Gröber <dxld@darkboxed.org>2015-11-25 23:56:56 +0100
commit2a429d58f50e7436c9f9ee94cfc399f82355f839 (patch)
tree3e491d72bb2b0990c991549bd3ea25d4ed3676bf /Distribution
parentd4db18cfdffdd82ba19a087b15680c2756b258f6 (diff)
Expose compiler-version command in library
Diffstat (limited to 'Distribution')
-rw-r--r--Distribution/Helper.hs17
1 files changed, 14 insertions, 3 deletions
diff --git a/Distribution/Helper.hs b/Distribution/Helper.hs
index 4a4bfde..256fb4d 100644
--- a/Distribution/Helper.hs
+++ b/Distribution/Helper.hs
@@ -48,6 +48,7 @@ module Distribution.Helper (
, configFlags
, nonDefaultConfigFlags
, packageId
+ , compilerVersion
-- * Result types
, ChModuleName(..)
@@ -154,7 +155,8 @@ data SomeLocalBuildInfo = SomeLocalBuildInfo {
slbiPkgLicenses :: [(String, [(String, Version)])],
slbiFlags :: [(String, Bool)],
slbiConfigFlags :: [(String, Bool)],
- slbiNonDefaultConfigFlags :: [(String, Bool)]
+ slbiNonDefaultConfigFlags :: [(String, Bool)],
+ slbiCompilerVersion :: (String, Version)
} deriving (Eq, Ord, Read, Show)
-- | Caches helper executable result so it doesn't have to be run more than once
@@ -164,6 +166,9 @@ newtype Query m a = Query { unQuery :: StateT (Maybe SomeLocalBuildInfo)
(ReaderT QueryEnv m) a }
deriving (Functor, Applicative, Monad, MonadIO)
+instance MonadTrans Query where
+ lift = Query . lift . lift
+
type MonadQuery m = ( MonadIO m
, MonadState (Maybe SomeLocalBuildInfo) m
, MonadReader QueryEnv m)
@@ -230,6 +235,9 @@ configFlags :: MonadIO m => Query m [(String, Bool)]
-- i.e. don't rely on these being the flags set by the user directly.
nonDefaultConfigFlags :: MonadIO m => Query m [(String, Bool)]
+-- | The version of GHC the project is configured to use
+compilerVersion :: MonadIO m => Query m (String, Version)
+
-- | Package identifier, i.e. package name and version
packageId :: MonadIO m => Query m (String, Version)
@@ -246,6 +254,7 @@ pkgLicenses = Query $ slbiPkgLicenses `liftM` getSlbi
flags = Query $ slbiFlags `liftM` getSlbi
configFlags = Query $ slbiConfigFlags `liftM` getSlbi
nonDefaultConfigFlags = Query $ slbiNonDefaultConfigFlags `liftM` getSlbi
+compilerVersion = Query $ slbiCompilerVersion `liftM` getSlbi
packageId = Query $ getPackageId
-- | Run @cabal configure@
@@ -309,6 +318,7 @@ getSomeConfigState = ask >>= \QueryEnv {..} -> do
, "flags"
, "config-flags"
, "non-default-config-flags"
+ , "compiler-version"
]
let [ Just (ChResponsePkgDbs pkgDbs),
Just (ChResponseEntrypoints eps),
@@ -321,11 +331,12 @@ getSomeConfigState = ask >>= \QueryEnv {..} -> do
Just (ChResponseLicenses pkgLics),
Just (ChResponseFlags fls),
Just (ChResponseFlags cfls),
- Just (ChResponseFlags ndcfls)
+ Just (ChResponseFlags ndcfls),
+ Just (ChResponseVersion comp compVer)
] = res
return $ SomeLocalBuildInfo
- pkgDbs eps srcDirs ghcOpts ghcSrcOpts ghcPkgOpts ghcMergedPkgOpts ghcLangOpts pkgLics fls cfls ndcfls
+ pkgDbs eps srcDirs ghcOpts ghcSrcOpts ghcPkgOpts ghcMergedPkgOpts ghcLangOpts pkgLics fls cfls ndcfls (comp, compVer)
-- | Make sure the appropriate helper executable for the given project is
-- installed and ready to run queries.