Change the way cabal-helper is built a bit

This commit is contained in:
Daniel Gröber
2015-03-04 16:45:26 +01:00
parent 82bb0090c0
commit bc71877dcf
9 changed files with 314 additions and 173 deletions

View File

@@ -23,6 +23,7 @@ module Language.Haskell.GhcMod.CabalHelper (
) where
import Control.Applicative
import Control.Arrow
import Control.Monad
import Data.Monoid
import Data.List
@@ -100,5 +101,9 @@ cabalHelper = withCabal $ do
Just (GmCabalHelperStrings ghcOpts),
Just (GmCabalHelperStrings ghcSrcOpts),
Just (GmCabalHelperStrings ghcPkgOpts) ] = res
eps' = map (second $ fmap $ map md) eps
return $ CabalHelper eps srcDirs ghcOpts ghcSrcOpts ghcPkgOpts
return $ CabalHelper eps' srcDirs ghcOpts ghcSrcOpts ghcPkgOpts
where
md (GmModuleName mn) = mkModuleName mn

View File

@@ -24,7 +24,6 @@ import Data.List
import Data.Char
import Data.Maybe
import Data.Traversable (traverse)
import Types
import System.Directory
import System.FilePath
import System.IO.Unsafe

View File

@@ -2,7 +2,7 @@
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Language.Haskell.GhcMod.Types (
module Language.Haskell.GhcMod.Types
, module Types
, module CabalHelper.Types
, ModuleName
, mkModuleName
, moduleNameString
@@ -11,6 +11,7 @@ module Language.Haskell.GhcMod.Types (
import Control.Monad.Trans.Control (MonadBaseControl)
import Control.Monad.Error (Error(..))
import Control.Exception (Exception)
import Data.List (intercalate)
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Set (Set)
@@ -22,7 +23,7 @@ import MonadUtils (MonadIO)
import GHC (ModuleName, moduleNameString, mkModuleName)
import PackageConfig (PackageConfig)
import Types
import CabalHelper.Types
-- | A constraint alias (-XConstraintKinds) to make functions dealing with
-- 'GhcModT' somewhat cleaner.
@@ -95,6 +96,52 @@ data Cradle = Cradle {
----------------------------------------------------------------
-- | GHC package database flags.
data GhcPkgDb = GlobalDb | UserDb | PackageDb String deriving (Eq, Show)
-- | A single GHC command line option.
type GHCOption = String
-- | An include directory for modules.
type IncludeDir = FilePath
-- | A package name.
type PackageBaseName = String
-- | A package version.
type PackageVersion = String
-- | A package id.
type PackageId = String
-- | A package's name, verson and id.
type Package = (PackageBaseName, PackageVersion, PackageId)
pkgName :: Package -> PackageBaseName
pkgName (n,_,_) = n
pkgVer :: Package -> PackageVersion
pkgVer (_,v,_) = v
pkgId :: Package -> PackageId
pkgId (_,_,i) = i
showPkg :: Package -> String
showPkg (n,v,_) = intercalate "-" [n,v]
showPkgId :: Package -> String
showPkgId (n,v,i) = intercalate "-" [n,v,i]
-- | Haskell expression.
type Expression = String
-- | Module name.
type ModuleString = String
-- | A Module
type Module = [String]
data GmLogLevel = GmPanic
| GmException
| GmError
@@ -140,21 +187,6 @@ instance Read ModuleName where
(m,t) <- readsPrec (app_prec+1) s]) r
where app_prec = 10
--- \ / These types MUST be in sync with the copies in cabal-helper/Main.hs
data GmComponentName = GmSetupHsName
| GmLibName
| GmExeName String
| GmTestName String
| GmBenchName String
deriving (Eq, Ord, Read, Show)
data GmCabalHelperResponse
= GmCabalHelperStrings [(GmComponentName, [String])]
| GmCabalHelperEntrypoints [(GmComponentName, Either FilePath [ModuleName])]
| GmCabalHelperLbi String
deriving (Read, Show)
--- ^ These types MUST be in sync with the copies in cabal-helper/Main.hs
data GhcModError
= GMENoMsg
-- ^ Unknown error