aboutsummaryrefslogtreecommitdiff
path: root/src/CabalHelper/Compiletime/Types.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/CabalHelper/Compiletime/Types.hs')
-rw-r--r--src/CabalHelper/Compiletime/Types.hs56
1 files changed, 43 insertions, 13 deletions
diff --git a/src/CabalHelper/Compiletime/Types.hs b/src/CabalHelper/Compiletime/Types.hs
index 77c3255..10fe916 100644
--- a/src/CabalHelper/Compiletime/Types.hs
+++ b/src/CabalHelper/Compiletime/Types.hs
@@ -14,7 +14,8 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
-{-# LANGUAGE DeriveGeneric, DeriveDataTypeable, DefaultSignatures #-}
+{-# LANGUAGE DeriveGeneric, DeriveDataTypeable, DefaultSignatures,
+ KindSignatures, ImplicitParams, ConstraintKinds #-}
{-|
Module : CabalHelper.Compiletime.Types
@@ -25,18 +26,47 @@ License : GPL-3
module CabalHelper.Compiletime.Types where
import Data.Version
+import Data.Typeable
+import GHC.Generics
-data Options = Options {
- oHelp :: Bool
- , oVerbose :: Bool
- , oGhcProgram :: FilePath
- , oGhcPkgProgram :: FilePath
- , oCabalProgram :: FilePath
- , oCabalVersion :: Maybe Version
- , oCabalPkgDb :: Maybe PackageDbDir
-}
+type Env = (?opts :: CompileOptions)
-newtype PackageDbDir = PackageDbDir { unPackageDbDir :: FilePath }
+-- | Paths or names of various programs we need.
+data Programs = Programs {
+ -- | The path to the @cabal@ program.
+ cabalProgram :: FilePath,
+
+ -- | The path to the @ghc@ program.
+ ghcProgram :: FilePath,
+
+ -- | The path to the @ghc-pkg@ program. If
+ -- not changed it will be derived from the path to 'ghcProgram'.
+ ghcPkgProgram :: FilePath
+ } deriving (Eq, Ord, Show, Read, Generic, Typeable)
+
+-- | Default all programs to their unqualified names, i.e. they will be searched
+-- for on @PATH@.
+defaultPrograms :: Programs
+defaultPrograms = Programs "cabal" "ghc" "ghc-pkg"
+
+data CompileOptions = CompileOptions
+ { oVerbose :: Bool
+ , oCabalPkgDb :: Maybe PackageDbDir
+ , oCabalVersion :: Maybe Version
+ , oPrograms :: Programs
+ }
-defaultOptions :: Options
-defaultOptions = Options False False "ghc" "ghc-pkg" "cabal" Nothing Nothing
+oCabalProgram :: Env => FilePath
+oCabalProgram = cabalProgram $ oPrograms ?opts
+
+oGhcProgram :: Env => FilePath
+oGhcProgram = ghcProgram $ oPrograms ?opts
+
+oGhcPkgProgram :: Env => FilePath
+oGhcPkgProgram = ghcPkgProgram $ oPrograms ?opts
+
+defaultCompileOptions :: CompileOptions
+defaultCompileOptions =
+ CompileOptions False Nothing Nothing defaultPrograms
+
+newtype PackageDbDir = PackageDbDir { unPackageDbDir :: FilePath }