Cabal-1.24.2.0: A framework for packaging Haskell software

Copyright | Isaac Jones 2003-2004
License | BSD3
Maintainer | cabal-devel@haskell.org
Portability | portable
Safe Haskell | None
Language | Haskell98

Distribution.Simple.Compiler

Contents

- Haskell implementations
- Support for package databases
- Support for optimisation levels
- Support for debug info levels
- Support for language extensions
- Support for profiling detail levels

Description

This should be a much more sophisticated abstraction than it is. Currently it's just a bit of data about the compiler, like it's flavour and name and version. The reason it's just data is because currently it has to be in `Read` and `Show` so it can be saved along with the `LocalBuildInfo`. The only interesting bit of info it contains is a mapping between language extensions and compiler command line flags. This module also defines a `PackageDB` type which is used to refer to package databases. Most compilers only know about a single global package collection but GHC has a global and per-user one and it lets you create arbitrary other package databases. We do not yet fully support this latter feature.

Synopsis

- module Distribution.Compiler
- data Compiler = Compiler {
  - compilerId :: CompilerId
  - compilerAbiTag :: AbiTag
  - compilerCompat :: [CompilerId]
  - compilerLanguages :: [(Language, Flag)]
  - compilerExtensions :: [(Extension, Flag)]
  - compilerProperties :: Map String String
  }
- showCompilerId :: Compiler -> String
- showCompilerIdWithAbi :: Compiler -> String
- compilerFlavor :: Compiler -> CompilerFlavor
- compilerVersion :: Compiler -> Version
- compilerCompatVersion :: CompilerFlavor -> Compiler -> Maybe Version
- compilerInfo :: Compiler -> CompilerInfo
- data PackageDB
  - = GlobalPackageDB
  - | UserPackageDB
  - | SpecificPackageDB FilePath
- type PackageDBStack = [PackageDB]
- registrationPackageDB :: PackageDBStack -> PackageDB
- absolutePackageDBPaths :: PackageDBStack -> IO PackageDBStack
- absolutePackageDBPath :: PackageDB -> IO PackageDB
- data OptimisationLevel
  - = NoOptimisation
  - | NormalOptimisation
  - | MaximumOptimisation
- flagToOptimisationLevel :: Maybe String -> OptimisationLevel
- data DebugInfoLevel
  - = NoDebugInfo
  - | MinimalDebugInfo
  - | NormalDebugInfo
  - | MaximalDebugInfo
- flagToDebugInfoLevel :: Maybe String -> DebugInfoLevel
- type Flag = String
- languageToFlags :: Compiler -> Maybe Language -> [Flag]
- unsupportedLanguages :: Compiler -> [Language] -> [Language]
- extensionsToFlags :: Compiler -> [Extension] -> [Flag]
- unsupportedExtensions :: Compiler -> [Extension] -> [Extension]
- parmakeSupported :: Compiler -> Bool
- reexportedModulesSupported :: Compiler -> Bool
- renamingPackageFlagsSupported :: Compiler -> Bool
- unifiedIPIDRequired :: Compiler -> Bool
- packageKeySupported :: Compiler -> Bool
- unitIdSupported :: Compiler -> Bool
- libraryDynDirSupported :: Compiler -> Bool
- data ProfDetailLevel
  - = ProfDetailNone
  - | ProfDetailDefault
  - | ProfDetailExportedFunctions
  - | ProfDetailToplevelFunctions
  - | ProfDetailAllFunctions
  - | ProfDetailOther String
- knownProfDetailLevels :: [(String, [String], ProfDetailLevel)]
- flagToProfDetailLevel :: String -> ProfDetailLevel
- showProfDetailLevel :: ProfDetailLevel -> String

# Haskell implementations

module Distribution.Compiler

data Compiler Source #

Constructors

Compiler |
Fields compilerId :: CompilerId Compiler flavour and version. compilerAbiTag :: AbiTag Tag for distinguishing incompatible ABI's on the same architecture/os. compilerCompat :: [CompilerId] Other implementations that this compiler claims to be compatible with. compilerLanguages :: [(Language, Flag)] Supported language standards. compilerExtensions :: [(Extension, Flag)] Supported extensions. compilerProperties :: Map String String A key-value map for properties not covered by the above fields.

Instances

Eq Compiler # |
Methods (==) :: Compiler -> Compiler -> Bool # (/=) :: Compiler -> Compiler -> Bool #
Read Compiler # |
Methods readsPrec :: Int -> ReadS Compiler Source # readList :: ReadS [Compiler] Source # readPrec :: ReadPrec Compiler Source # readListPrec :: ReadPrec [Compiler] Source #
Show Compiler # |
Methods showsPrec :: Int -> Compiler -> ShowS Source # show :: Compiler -> String Source # showList :: [Compiler] -> ShowS Source #
Generic Compiler # |
Associated Types type Rep Compiler :: * -> * Source # Methods from :: Compiler -> Rep Compiler x Source # to :: Rep Compiler x -> Compiler Source #
Binary Compiler # |
Methods put :: Compiler -> Put Source # get :: Get Compiler Source # putList :: [Compiler] -> Put Source #
type Rep Compiler # |
type Rep Compiler = D1 (MetaData "Compiler" "Distribution.Simple.Compiler" "Cabal-1.24.2.0" False) (C1 (MetaCons "Compiler" PrefixI True) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "compilerId") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 CompilerId)) ((:*:) (S1 (MetaSel (Just Symbol "compilerAbiTag") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 AbiTag)) (S1 (MetaSel (Just Symbol "compilerCompat") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [CompilerId])))) ((:*:) (S1 (MetaSel (Just Symbol "compilerLanguages") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [(Language, Flag)])) ((:*:) (S1 (MetaSel (Just Symbol "compilerExtensions") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [(Extension, Flag)])) (S1 (MetaSel (Just Symbol "compilerProperties") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Map String String)))))))

showCompilerId :: Compiler -> String Source #

showCompilerIdWithAbi :: Compiler -> String Source #

compilerFlavor :: Compiler -> CompilerFlavor Source #

compilerVersion :: Compiler -> Version Source #

compilerCompatVersion :: CompilerFlavor -> Compiler -> Maybe Version Source #

compilerInfo :: Compiler -> CompilerInfo Source #

# Support for package databases

data PackageDB Source #

Some compilers have a notion of a database of available packages. For some there is just one global db of packages, other compilers support a per-user or an arbitrary db specified at some location in the file system. This can be used to build isloated environments of packages, for example to build a collection of related packages without installing them globally.

Constructors

GlobalPackageDB |
UserPackageDB |
SpecificPackageDB FilePath |

Instances

Eq PackageDB # |
Methods (==) :: PackageDB -> PackageDB -> Bool # (/=) :: PackageDB -> PackageDB -> Bool #
Ord PackageDB # |
Methods compare :: PackageDB -> PackageDB -> Ordering # (<) :: PackageDB -> PackageDB -> Bool # (<=) :: PackageDB -> PackageDB -> Bool # (>) :: PackageDB -> PackageDB -> Bool # (>=) :: PackageDB -> PackageDB -> Bool # max :: PackageDB -> PackageDB -> PackageDB # min :: PackageDB -> PackageDB -> PackageDB #
Read PackageDB # |
Methods readsPrec :: Int -> ReadS PackageDB Source # readList :: ReadS [PackageDB] Source # readPrec :: ReadPrec PackageDB Source # readListPrec :: ReadPrec [PackageDB] Source #
Show PackageDB # |
Methods showsPrec :: Int -> PackageDB -> ShowS Source # show :: PackageDB -> String Source # showList :: [PackageDB] -> ShowS Source #
Generic PackageDB # |
Associated Types type Rep PackageDB :: * -> * Source # Methods from :: PackageDB -> Rep PackageDB x Source # to :: Rep PackageDB x -> PackageDB Source #
Binary PackageDB # |
Methods put :: PackageDB -> Put Source # get :: Get PackageDB Source # putList :: [PackageDB] -> Put Source #
type Rep PackageDB # |
type Rep PackageDB = D1 (MetaData "PackageDB" "Distribution.Simple.Compiler" "Cabal-1.24.2.0" False) ((:+:) (C1 (MetaCons "GlobalPackageDB" PrefixI False) U1) ((:+:) (C1 (MetaCons "UserPackageDB" PrefixI False) U1) (C1 (MetaCons "SpecificPackageDB" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 FilePath)))))

type PackageDBStack = [PackageDB] Source #

We typically get packages from several databases, and stack them together. This type lets us be explicit about that stacking. For example typical stacks include:

    [GlobalPackageDB]
    [GlobalPackageDB, UserPackageDB]
    [GlobalPackageDB, SpecificPackageDB "package.conf.inplace"]

Note that the `GlobalPackageDB` is invariably at the bottom since it contains the rts, base and other special compiler-specific packages.

We are not restricted to using just the above combinations. In particular we can use several custom package dbs and the user package db together.

When it comes to writing, the top most (last) package is used.

registrationPackageDB :: PackageDBStack -> PackageDB Source #

Return the package that we should register into. This is the package db at the top of the stack.

absolutePackageDBPaths :: PackageDBStack -> IO PackageDBStack Source #

Make package paths absolute

absolutePackageDBPath :: PackageDB -> IO PackageDB Source #

# Support for optimisation levels

data OptimisationLevel Source #

Some compilers support optimising. Some have different levels. For compilers that do not the level is just capped to the level they do support.

Constructors

NoOptimisation |
NormalOptimisation |
MaximumOptimisation |

Instances

Bounded OptimisationLevel # |
Methods minBound :: OptimisationLevel Source # maxBound :: OptimisationLevel Source #
Enum OptimisationLevel # |
Methods succ :: OptimisationLevel -> OptimisationLevel Source # pred :: OptimisationLevel -> OptimisationLevel Source # toEnum :: Int -> OptimisationLevel Source # fromEnum :: OptimisationLevel -> Int Source # enumFrom :: OptimisationLevel -> [OptimisationLevel] Source # enumFromThen :: OptimisationLevel -> OptimisationLevel -> [OptimisationLevel] Source # enumFromTo :: OptimisationLevel -> OptimisationLevel -> [OptimisationLevel] Source # enumFromThenTo :: OptimisationLevel -> OptimisationLevel -> OptimisationLevel -> [OptimisationLevel] Source #
Eq OptimisationLevel # |
Methods (==) :: OptimisationLevel -> OptimisationLevel -> Bool # (/=) :: OptimisationLevel -> OptimisationLevel -> Bool #
Read OptimisationLevel # |
Methods readsPrec :: Int -> ReadS OptimisationLevel Source # readList :: ReadS [OptimisationLevel] Source # readPrec :: ReadPrec OptimisationLevel Source # readListPrec :: ReadPrec [OptimisationLevel] Source #
Show OptimisationLevel # |
Methods showsPrec :: Int -> OptimisationLevel -> ShowS Source # show :: OptimisationLevel -> String Source # showList :: [OptimisationLevel] -> ShowS Source #
Generic OptimisationLevel # |
Associated Types type Rep OptimisationLevel :: * -> * Source # Methods from :: OptimisationLevel -> Rep OptimisationLevel x Source # to :: Rep OptimisationLevel x -> OptimisationLevel Source #
Binary OptimisationLevel # |
Methods put :: OptimisationLevel -> Put Source # get :: Get OptimisationLevel Source # putList :: [OptimisationLevel] -> Put Source #
type Rep OptimisationLevel # |
type Rep OptimisationLevel = D1 (MetaData "OptimisationLevel" "Distribution.Simple.Compiler" "Cabal-1.24.2.0" False) ((:+:) (C1 (MetaCons "NoOptimisation" PrefixI False) U1) ((:+:) (C1 (MetaCons "NormalOptimisation" PrefixI False) U1) (C1 (MetaCons "MaximumOptimisation" PrefixI False) U1)))

flagToOptimisationLevel :: Maybe String -> OptimisationLevel Source #

# Support for debug info levels

data DebugInfoLevel Source #

Some compilers support emitting debug info. Some have different levels. For compilers that do not the level is just capped to the level they do support.

Constructors

NoDebugInfo |
MinimalDebugInfo |
NormalDebugInfo |
MaximalDebugInfo |

Instances

Bounded DebugInfoLevel # |
Methods minBound :: DebugInfoLevel Source # maxBound :: DebugInfoLevel Source #
Enum DebugInfoLevel # |
Methods succ :: DebugInfoLevel -> DebugInfoLevel Source # pred :: DebugInfoLevel -> DebugInfoLevel Source # toEnum :: Int -> DebugInfoLevel Source # fromEnum :: DebugInfoLevel -> Int Source # enumFrom :: DebugInfoLevel -> [DebugInfoLevel] Source # enumFromThen :: DebugInfoLevel -> DebugInfoLevel -> [DebugInfoLevel] Source # enumFromTo :: DebugInfoLevel -> DebugInfoLevel -> [DebugInfoLevel] Source # enumFromThenTo :: DebugInfoLevel -> DebugInfoLevel -> DebugInfoLevel -> [DebugInfoLevel] Source #
Eq DebugInfoLevel # |
Methods (==) :: DebugInfoLevel -> DebugInfoLevel -> Bool # (/=) :: DebugInfoLevel -> DebugInfoLevel -> Bool #
Read DebugInfoLevel # |
Methods readsPrec :: Int -> ReadS DebugInfoLevel Source # readList :: ReadS [DebugInfoLevel] Source # readPrec :: ReadPrec DebugInfoLevel Source # readListPrec :: ReadPrec [DebugInfoLevel] Source #
Show DebugInfoLevel # |
Methods showsPrec :: Int -> DebugInfoLevel -> ShowS Source # show :: DebugInfoLevel -> String Source # showList :: [DebugInfoLevel] -> ShowS Source #
Generic DebugInfoLevel # |
Associated Types type Rep DebugInfoLevel :: * -> * Source # Methods from :: DebugInfoLevel -> Rep DebugInfoLevel x Source # to :: Rep DebugInfoLevel x -> DebugInfoLevel Source #
Binary DebugInfoLevel # |
Methods put :: DebugInfoLevel -> Put Source # get :: Get DebugInfoLevel Source # putList :: [DebugInfoLevel] -> Put Source #
type Rep DebugInfoLevel # |
type Rep DebugInfoLevel = D1 (MetaData "DebugInfoLevel" "Distribution.Simple.Compiler" "Cabal-1.24.2.0" False) ((:+:) ((:+:) (C1 (MetaCons "NoDebugInfo" PrefixI False) U1) (C1 (MetaCons "MinimalDebugInfo" PrefixI False) U1)) ((:+:) (C1 (MetaCons "NormalDebugInfo" PrefixI False) U1) (C1 (MetaCons "MaximalDebugInfo" PrefixI False) U1)))

flagToDebugInfoLevel :: Maybe String -> DebugInfoLevel Source #

# Support for language extensions

type Flag = String Source #

languageToFlags :: Compiler -> Maybe Language -> [Flag] Source #

unsupportedLanguages :: Compiler -> [Language] -> [Language] Source #

extensionsToFlags :: Compiler -> [Extension] -> [Flag] Source #

For the given compiler, return the flags for the supported extensions.

unsupportedExtensions :: Compiler -> [Extension] -> [Extension] Source #

For the given compiler, return the extensions it does not support.

parmakeSupported :: Compiler -> Bool Source #

Does this compiler support parallel --make mode?

reexportedModulesSupported :: Compiler -> Bool Source #

Does this compiler support reexported-modules?

renamingPackageFlagsSupported :: Compiler -> Bool Source #

Does this compiler support thinning/renaming on package flags?

unifiedIPIDRequired :: Compiler -> Bool Source #

Does this compiler have unified IPIDs (so no package keys)

packageKeySupported :: Compiler -> Bool Source #

Does this compiler support package keys?

unitIdSupported :: Compiler -> Bool Source #

Does this compiler support unit IDs?

libraryDynDirSupported :: Compiler -> Bool Source #

Does this compiler support a package database entry with: "dynamic-library-dirs"?

# Support for profiling detail levels

data ProfDetailLevel Source #

Some compilers (notably GHC) support profiling and can instrument programs so the system can account costs to different functions. There are different levels of detail that can be used for this accounting. For compilers that do not support this notion or the particular detail levels, this is either ignored or just capped to some similar level they do support.

Constructors

ProfDetailNone |
ProfDetailDefault |
ProfDetailExportedFunctions |
ProfDetailToplevelFunctions |
ProfDetailAllFunctions |
ProfDetailOther String |

Instances

Eq ProfDetailLevel # |
Methods (==) :: ProfDetailLevel -> ProfDetailLevel -> Bool # (/=) :: ProfDetailLevel -> ProfDetailLevel -> Bool #
Read ProfDetailLevel # |
Methods readsPrec :: Int -> ReadS ProfDetailLevel Source # readList :: ReadS [ProfDetailLevel] Source # readPrec :: ReadPrec ProfDetailLevel Source # readListPrec :: ReadPrec [ProfDetailLevel] Source #
Show ProfDetailLevel # |
Methods showsPrec :: Int -> ProfDetailLevel -> ShowS Source # show :: ProfDetailLevel -> String Source # showList :: [ProfDetailLevel] -> ShowS Source #
Generic ProfDetailLevel # |
Associated Types type Rep ProfDetailLevel :: * -> * Source # Methods from :: ProfDetailLevel -> Rep ProfDetailLevel x Source # to :: Rep ProfDetailLevel x -> ProfDetailLevel Source #
Binary ProfDetailLevel # |
Methods put :: ProfDetailLevel -> Put Source # get :: Get ProfDetailLevel Source # putList :: [ProfDetailLevel] -> Put Source #
type Rep ProfDetailLevel # |
type Rep ProfDetailLevel = D1 (MetaData "ProfDetailLevel" "Distribution.Simple.Compiler" "Cabal-1.24.2.0" False) ((:+:) ((:+:) (C1 (MetaCons "ProfDetailNone" PrefixI False) U1) ((:+:) (C1 (MetaCons "ProfDetailDefault" PrefixI False) U1) (C1 (MetaCons "ProfDetailExportedFunctions" PrefixI False) U1))) ((:+:) (C1 (MetaCons "ProfDetailToplevelFunctions" PrefixI False) U1) ((:+:) (C1 (MetaCons "ProfDetailAllFunctions" PrefixI False) U1) (C1 (MetaCons "ProfDetailOther" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String))))))

knownProfDetailLevels :: [(String, [String], ProfDetailLevel)] Source #

flagToProfDetailLevel :: String -> ProfDetailLevel Source #

showProfDetailLevel :: ProfDetailLevel -> String Source #