Cabal-1.22.5.0: A framework for packaging Haskell software

Copyright | Isaac Jones 2003-2004
License | BSD3
Maintainer | cabal-devel@haskell.org
Portability | portable
Safe Haskell | Safe
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

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
- packageKeySupported :: Compiler -> Bool

# Haskell implementations

module Distribution.Compiler

data Compiler

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

Read Compiler |
Show Compiler |
Generic Compiler |
Binary Compiler |
type Rep Compiler |

showCompilerId :: Compiler -> String

showCompilerIdWithAbi :: Compiler -> String

compilerFlavor :: Compiler -> CompilerFlavor

compilerVersion :: Compiler -> Version

compilerCompatVersion :: CompilerFlavor -> Compiler -> Maybe Version

compilerInfo :: Compiler -> CompilerInfo

# Support for package databases

data PackageDB

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 |
Ord PackageDB |
Read PackageDB |
Show PackageDB |
Generic PackageDB |
Binary PackageDB |
type Rep PackageDB |

type PackageDBStack = [PackageDB]

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

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

absolutePackageDBPaths :: PackageDBStack -> IO PackageDBStack

Make package paths absolute

absolutePackageDBPath :: PackageDB -> IO PackageDB

# Support for optimisation levels

data OptimisationLevel

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 |
Enum OptimisationLevel |
Eq OptimisationLevel |
Read OptimisationLevel |
Show OptimisationLevel |
Generic OptimisationLevel |
Binary OptimisationLevel |
type Rep OptimisationLevel |

flagToOptimisationLevel :: Maybe String -> OptimisationLevel

# Support for debug info levels

data DebugInfoLevel

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 |
Enum DebugInfoLevel |
Eq DebugInfoLevel |
Read DebugInfoLevel |
Show DebugInfoLevel |
Generic DebugInfoLevel |
Binary DebugInfoLevel |
type Rep DebugInfoLevel |

flagToDebugInfoLevel :: Maybe String -> DebugInfoLevel

# Support for language extensions

type Flag = String

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

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

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

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

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

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

parmakeSupported :: Compiler -> Bool

Does this compiler support parallel --make mode?

reexportedModulesSupported :: Compiler -> Bool

Does this compiler support reexported-modules?

renamingPackageFlagsSupported :: Compiler -> Bool

Does this compiler support thinning/renaming on package flags?

packageKeySupported :: Compiler -> Bool

Does this compiler support package keys?