2015-01-16 14:47:56 +00:00
|
|
|
{-# LANGUAGE CPP #-}
|
2014-06-29 08:28:28 +00:00
|
|
|
|
2015-01-16 14:47:56 +00:00
|
|
|
-- | This module abstracts extracting information from Cabal's on-disk
|
|
|
|
-- 'LocalBuildInfo' (@dist/setup-config@) for different version combinations of
|
|
|
|
-- Cabal and GHC.
|
2014-05-09 18:35:13 +00:00
|
|
|
module Language.Haskell.GhcMod.CabalConfig (
|
2015-02-07 22:55:57 +00:00
|
|
|
CabalConfig
|
|
|
|
, cabalGetConfig
|
|
|
|
, cabalConfigDependencies
|
2014-09-10 12:23:36 +00:00
|
|
|
, cabalConfigFlags
|
2014-05-09 18:35:13 +00:00
|
|
|
) where
|
|
|
|
|
2015-01-16 14:47:56 +00:00
|
|
|
import Distribution.Package (PackageIdentifier)
|
|
|
|
import Distribution.PackageDescription (FlagAssignment)
|
2014-05-09 18:35:13 +00:00
|
|
|
|
2015-01-16 14:47:56 +00:00
|
|
|
import Language.Haskell.GhcMod.Types
|
|
|
|
import Language.Haskell.GhcMod.Error
|
2014-07-17 08:16:44 +00:00
|
|
|
|
2015-02-07 22:55:57 +00:00
|
|
|
import Language.Haskell.GhcMod.CabalConfig.Extract
|
2014-05-09 18:35:13 +00:00
|
|
|
|
2015-02-07 22:55:57 +00:00
|
|
|
cabalGetConfig :: (IOish m, GmError m) => Cradle -> m CabalConfig
|
|
|
|
cabalGetConfig = getConfig
|
2014-05-09 18:35:13 +00:00
|
|
|
|
2014-08-11 21:45:33 +00:00
|
|
|
-- | Get list of 'Package's needed by all components of the current package
|
2015-02-07 22:55:57 +00:00
|
|
|
cabalConfigDependencies :: CabalConfig -> PackageIdentifier -> [Package]
|
|
|
|
cabalConfigDependencies config thisPkg =
|
|
|
|
configDependencies thisPkg config
|
2014-05-09 18:35:13 +00:00
|
|
|
|
|
|
|
|
2014-09-10 12:23:36 +00:00
|
|
|
-- | Get the flag assignment from the local build info of the given cradle
|
2015-02-07 22:55:57 +00:00
|
|
|
cabalConfigFlags :: (IOish m, GmError m) => CabalConfig -> m FlagAssignment
|
|
|
|
cabalConfigFlags config = do
|
2014-09-10 12:23:36 +00:00
|
|
|
case configFlags config of
|
|
|
|
Right x -> return x
|
|
|
|
Left msg -> throwError (GMECabalFlags (GMEString msg))
|