-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | A framework for packaging Haskell software
--   
--   The Haskell Common Architecture for Building Applications and
--   Libraries: a framework defining a common interface for authors to more
--   easily build their Haskell applications in a portable way.
--   
--   The Haskell Cabal is part of a larger infrastructure for distributing,
--   organizing, and cataloging Haskell libraries and tools.
@package Cabal
@version 1.16.0


-- | This module defines the detailed test suite interface which makes it
--   possible to expose individual tests to Cabal or other test agents.
module Distribution.TestSuite
data TestInstance
TestInstance :: IO Progress -> String -> [String] -> [OptionDescr] -> (String -> String -> Either String TestInstance) -> TestInstance

-- | Perform the test.
run :: TestInstance -> IO Progress

-- | A name for the test, unique within a test suite.
name :: TestInstance -> String

-- | Users can select groups of tests by their tags.
tags :: TestInstance -> [String]

-- | Descriptions of the options recognized by this test.
options :: TestInstance -> [OptionDescr]

-- | Try to set the named option to the given value. Returns an error
--   message if the option is not supported or the value could not be
--   correctly parsed; otherwise, a <a>TestInstance</a> with the option set
--   to the given value is returned.
setOption :: TestInstance -> String -> String -> Either String TestInstance
data OptionDescr
OptionDescr :: String -> String -> OptionType -> Maybe String -> OptionDescr
optionName :: OptionDescr -> String

-- | A human-readable description of the option to guide the user setting
--   it.
optionDescription :: OptionDescr -> String
optionType :: OptionDescr -> OptionType
optionDefault :: OptionDescr -> Maybe String
data OptionType
OptionFile :: Bool -> Bool -> [String] -> OptionType
optionFileMustExist :: OptionType -> Bool
optionFileIsDir :: OptionType -> Bool
optionFileExtensions :: OptionType -> [String]
OptionString :: Bool -> OptionType
optionStringMultiline :: OptionType -> Bool
OptionNumber :: Bool -> (Maybe String, Maybe String) -> OptionType
optionNumberIsInt :: OptionType -> Bool
optionNumberBounds :: OptionType -> (Maybe String, Maybe String)
OptionBool :: OptionType
OptionEnum :: [String] -> OptionType
OptionSet :: [String] -> OptionType
OptionRngSeed :: OptionType
data Test
Test :: TestInstance -> Test
Group :: String -> Bool -> [Test] -> Test
groupName :: Test -> String

-- | If true, then children of this group may be run in parallel. Note that
--   this setting is not inherited by children. In particular, consider a
--   group F with <a>concurrently = False</a> that has some children,
--   including a group T with <a>concurrently = True</a>. The children of
--   group T may be run concurrently with each other, as long as none are
--   run at the same time as any of the direct children of group F.
concurrently :: Test -> Bool
groupTests :: Test -> [Test]
ExtraOptions :: [OptionDescr] -> Test -> Test
type Options = [(String, String)]
data Progress
Finished :: Result -> Progress
Progress :: String -> (IO Progress) -> Progress
data Result
Pass :: Result
Fail :: String -> Result
Error :: String -> Result

-- | Create a named group of tests, which are assumed to be safe to run in
--   parallel.
testGroup :: String -> [Test] -> Test
instance Eq OptionType
instance Read OptionType
instance Show OptionType
instance Eq OptionDescr
instance Read OptionDescr
instance Show OptionDescr
instance Eq Result
instance Read Result
instance Show Result


-- | Remove the "literal" markups from a Haskell source file, including
--   "<tt>&gt;</tt>", "<tt>\begin{code}</tt>", "<tt>\end{code}</tt>", and
--   "<tt>#</tt>"
module Distribution.Simple.PreProcess.Unlit

-- | <a>unlit</a> takes a filename (for error reports), and transforms the
--   given string, to eliminate the literate comments from the program
--   text.
unlit :: FilePath -> String -> Either String String

-- | No unliteration.
plain :: String -> String -> String


-- | This is a library of parser combinators, originally written by Koen
--   Claessen. It parses all alternatives in parallel, so it never keeps
--   hold of the beginning of the input string, a common source of space
--   leaks with other parsers. The '(+++)' choice combinator is genuinely
--   commutative; it makes no difference which branch is "shorter".
--   
--   See also Koen's paper <i>Parallel Parsing Processes</i>
--   (<a>http://www.cs.chalmers.se/~koen/publications.html</a>).
--   
--   This version of ReadP has been locally hacked to make it H98, by
--   Martin Sjögren <a>mailto:msjogren@gmail.com</a>
module Distribution.Compat.ReadP
type ReadP r a = Parser r Char a

-- | Consumes and returns the next character. Fails if there is no input
--   left.
get :: ReadP r Char

-- | Look-ahead: returns the part of the input that is left, without
--   consuming it.
look :: ReadP r String

-- | Symmetric choice.
(+++) :: ReadP r a -> ReadP r a -> ReadP r a

-- | Local, exclusive, left-biased choice: If left parser locally produces
--   any result at all, then right parser is not used.
(<++) :: ReadP a a -> ReadP r a -> ReadP r a

-- | Transforms a parser into one that does the same, but in addition
--   returns the exact characters read. IMPORTANT NOTE: <a>gather</a> gives
--   a runtime error if its first argument is built using any occurrences
--   of readS_to_P.
gather :: ReadP (String -> P Char r) a -> ReadP r (String, a)

-- | Always fails.
pfail :: ReadP r a

-- | Consumes and returns the next character, if it satisfies the specified
--   predicate.
satisfy :: (Char -> Bool) -> ReadP r Char

-- | Parses and returns the specified character.
char :: Char -> ReadP r Char

-- | Parses and returns the specified string.
string :: String -> ReadP r String

-- | Parses the first zero or more characters satisfying the predicate.
munch :: (Char -> Bool) -> ReadP r String

-- | Parses the first one or more characters satisfying the predicate.
munch1 :: (Char -> Bool) -> ReadP r String

-- | Skips all whitespace.
skipSpaces :: ReadP r ()

-- | Combines all parsers in the specified list.
choice :: [ReadP r a] -> ReadP r a

-- | <tt> count n p </tt> parses <tt>n</tt> occurrences of <tt>p</tt> in
--   sequence. A list of results is returned.
count :: Int -> ReadP r a -> ReadP r [a]

-- | <tt> between open close p </tt> parses <tt>open</tt>, followed by
--   <tt>p</tt> and finally <tt>close</tt>. Only the value of <tt>p</tt> is
--   returned.
between :: ReadP r open -> ReadP r close -> ReadP r a -> ReadP r a

-- | <tt>option x p</tt> will either parse <tt>p</tt> or return <tt>x</tt>
--   without consuming any input.
option :: a -> ReadP r a -> ReadP r a

-- | <tt>optional p</tt> optionally parses <tt>p</tt> and always returns
--   <tt>()</tt>.
optional :: ReadP r a -> ReadP r ()

-- | Parses zero or more occurrences of the given parser.
many :: ReadP r a -> ReadP r [a]

-- | Parses one or more occurrences of the given parser.
many1 :: ReadP r a -> ReadP r [a]

-- | Like <a>many</a>, but discards the result.
skipMany :: ReadP r a -> ReadP r ()

-- | Like <a>many1</a>, but discards the result.
skipMany1 :: ReadP r a -> ReadP r ()

-- | <tt>sepBy p sep</tt> parses zero or more occurrences of <tt>p</tt>,
--   separated by <tt>sep</tt>. Returns a list of values returned by
--   <tt>p</tt>.
sepBy :: ReadP r a -> ReadP r sep -> ReadP r [a]

-- | <tt>sepBy1 p sep</tt> parses one or more occurrences of <tt>p</tt>,
--   separated by <tt>sep</tt>. Returns a list of values returned by
--   <tt>p</tt>.
sepBy1 :: ReadP r a -> ReadP r sep -> ReadP r [a]

-- | <tt>endBy p sep</tt> parses zero or more occurrences of <tt>p</tt>,
--   separated and ended by <tt>sep</tt>.
endBy :: ReadP r a -> ReadP r sep -> ReadP r [a]

-- | <tt>endBy p sep</tt> parses one or more occurrences of <tt>p</tt>,
--   separated and ended by <tt>sep</tt>.
endBy1 :: ReadP r a -> ReadP r sep -> ReadP r [a]

-- | <tt>chainr p op x</tt> parses zero or more occurrences of <tt>p</tt>,
--   separated by <tt>op</tt>. Returns a value produced by a <i>right</i>
--   associative application of all functions returned by <tt>op</tt>. If
--   there are no occurrences of <tt>p</tt>, <tt>x</tt> is returned.
chainr :: ReadP r a -> ReadP r (a -> a -> a) -> a -> ReadP r a

-- | <tt>chainl p op x</tt> parses zero or more occurrences of <tt>p</tt>,
--   separated by <tt>op</tt>. Returns a value produced by a <i>left</i>
--   associative application of all functions returned by <tt>op</tt>. If
--   there are no occurrences of <tt>p</tt>, <tt>x</tt> is returned.
chainl :: ReadP r a -> ReadP r (a -> a -> a) -> a -> ReadP r a

-- | Like <a>chainl</a>, but parses one or more occurrences of <tt>p</tt>.
chainl1 :: ReadP r a -> ReadP r (a -> a -> a) -> ReadP r a

-- | Like <a>chainr</a>, but parses one or more occurrences of <tt>p</tt>.
chainr1 :: ReadP r a -> ReadP r (a -> a -> a) -> ReadP r a

-- | <tt>manyTill p end</tt> parses zero or more occurrences of <tt>p</tt>,
--   until <tt>end</tt> succeeds. Returns a list of values returned by
--   <tt>p</tt>.
manyTill :: ReadP r a -> ReadP [a] end -> ReadP r [a]

-- | A parser for a type <tt>a</tt>, represented as a function that takes a
--   <a>String</a> and returns a list of possible parses as
--   <tt>(a,<a>String</a>)</tt> pairs.
--   
--   Note that this kind of backtracking parser is very inefficient;
--   reading a large structure may be quite slow (cf <a>ReadP</a>).
type ReadS a = String -> [(a, String)]

-- | Converts a parser into a Haskell ReadS-style function. This is the
--   main way in which you can "run" a <a>ReadP</a> parser: the expanded
--   type is <tt> readP_to_S :: ReadP a -&gt; String -&gt; [(a,String)]
--   </tt>
readP_to_S :: ReadP a a -> ReadS a

-- | Converts a Haskell ReadS-style function into a parser. Warning: This
--   introduces local backtracking in the resulting parser, and therefore a
--   possible inefficiency.
readS_to_P :: ReadS a -> ReadP r a
instance Monad (Parser r s)
instance Functor (Parser r s)
instance MonadPlus (P s)
instance Monad (P s)


-- | Simple parsing with failure
module Distribution.ReadE

-- | Parser with simple error reporting
newtype ReadE a
ReadE :: (String -> Either ErrorMsg a) -> ReadE a
runReadE :: ReadE a -> String -> Either ErrorMsg a
succeedReadE :: (String -> a) -> ReadE a
failReadE :: ErrorMsg -> ReadE a
parseReadE :: ReadE a -> ReadP r a
readEOrFail :: ReadE a -> (String -> a)
readP_to_E :: (String -> ErrorMsg) -> ReadP a a -> ReadE a
instance Functor ReadE


-- | A simple <a>Verbosity</a> type with associated utilities. There are 4
--   standard verbosity levels from <a>silent</a>, <a>normal</a>,
--   <a>verbose</a> up to <a>deafening</a>. This is used for deciding what
--   logging messages to print.
module Distribution.Verbosity
data Verbosity
silent :: Verbosity
normal :: Verbosity
verbose :: Verbosity
deafening :: Verbosity
moreVerbose :: Verbosity -> Verbosity
lessVerbose :: Verbosity -> Verbosity
intToVerbosity :: Int -> Maybe Verbosity
flagToVerbosity :: ReadE Verbosity
showForCabal :: Verbosity -> String
showForGHC :: Verbosity -> String
instance Show Verbosity
instance Read Verbosity
instance Eq Verbosity
instance Ord Verbosity
instance Enum Verbosity
instance Bounded Verbosity


-- | This defines a <a>Text</a> class which is a bit like the <a>Read</a>
--   and <a>Show</a> classes. The difference is that is uses a modern
--   pretty printer and parser system and the format is not expected to be
--   Haskell concrete syntax but rather the external human readable
--   representation used by Cabal.
module Distribution.Text
class Text a
disp :: Text a => a -> Doc
parse :: Text a => ReadP r a
display :: Text a => a -> String
simpleParse :: Text a => String -> Maybe a
instance Text Version
instance Text Bool


-- | Data type for Haskell module names.
module Distribution.ModuleName

-- | A valid Haskell module name.
data ModuleName

-- | Construct a <a>ModuleName</a> from a valid module name <a>String</a>.
--   
--   This is just a convenience function intended for valid module strings.
--   It is an error if it is used with a string that is not a valid module
--   name. If you are parsing user input then use <a>simpleParse</a>
--   instead.
fromString :: String -> ModuleName

-- | The individual components of a hierarchical module name. For example
--   
--   <pre>
--   components (fromString "A.B.C") = ["A", "B", "C"]
--   </pre>
components :: ModuleName -> [String]

-- | Convert a module name to a file path, but without any file extension.
--   For example:
--   
--   <pre>
--   toFilePath (fromString "A.B.C") = "A/B/C"
--   </pre>
toFilePath :: ModuleName -> FilePath

-- | The module name <tt>Main</tt>.
main :: ModuleName

-- | <i>Deprecated: use ModuleName.fromString instead </i>
simple :: String -> ModuleName
instance Eq ModuleName
instance Ord ModuleName
instance Read ModuleName
instance Show ModuleName
instance Text ModuleName


-- | Cabal often needs to do slightly different things on specific
--   platforms. You probably know about the <a>os</a> however using that is
--   very inconvenient because it is a string and different Haskell
--   implementations do not agree on using the same strings for the same
--   platforms! (In particular see the controversy over "windows" vs
--   "ming32"). So to make it more consistent and easy to use we have an
--   <a>OS</a> enumeration.
module Distribution.System
data OS
Linux :: OS
Windows :: OS
OSX :: OS
FreeBSD :: OS
OpenBSD :: OS
NetBSD :: OS
Solaris :: OS
AIX :: OS
HPUX :: OS
IRIX :: OS
HaLVM :: OS
OtherOS :: String -> OS
buildOS :: OS
data Arch
I386 :: Arch
X86_64 :: Arch
PPC :: Arch
PPC64 :: Arch
Sparc :: Arch
Arm :: Arch
Mips :: Arch
SH :: Arch
IA64 :: Arch
S390 :: Arch
Alpha :: Arch
Hppa :: Arch
Rs6000 :: Arch
M68k :: Arch
Vax :: Arch
OtherArch :: String -> Arch
buildArch :: Arch
data Platform
Platform :: Arch -> OS -> Platform
buildPlatform :: Platform
instance Eq OS
instance Ord OS
instance Show OS
instance Read OS
instance Eq Arch
instance Ord Arch
instance Show Arch
instance Read Arch
instance Eq Platform
instance Ord Platform
instance Show Platform
instance Read Platform
instance Text Platform
instance Text Arch
instance Text OS


-- | Haskell language dialects and extensions
module Language.Haskell.Extension

-- | This represents a Haskell language dialect.
--   
--   Language <a>Extension</a>s are interpreted relative to one of these
--   base languages.
data Language

-- | The Haskell 98 language as defined by the Haskell 98 report.
--   <a>http://haskell.org/onlinereport/</a>
Haskell98 :: Language

-- | The Haskell 2010 language as defined by the Haskell 2010 report.
--   <a>http://www.haskell.org/onlinereport/haskell2010</a>
Haskell2010 :: Language

-- | An unknown language, identified by its name.
UnknownLanguage :: String -> Language
knownLanguages :: [Language]

-- | This represents language extensions beyond a base <a>Language</a>
--   definition (such as <a>Haskell98</a>) that are supported by some
--   implementations, usually in some special mode.
--   
--   Where applicable, references are given to an implementation's official
--   documentation, e.g. "GHC § 7.2.1" for an extension documented in
--   section 7.2.1 of the GHC User's Guide.
data Extension

-- | Enable a known extension
EnableExtension :: KnownExtension -> Extension

-- | Disable a known extension
DisableExtension :: KnownExtension -> Extension

-- | An unknown extension, identified by the name of its <tt>LANGUAGE</tt>
--   pragma.
UnknownExtension :: String -> Extension
data KnownExtension

-- | <ul>
--   <li><i>GHC § 7.6.3.4</i> Allow overlapping class instances, provided
--   there is a unique most specific instance for each use.</li>
--   </ul>
OverlappingInstances :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.6.3.3</i> Ignore structural rules guaranteeing the
--   termination of class instance resolution. Termination is guaranteed by
--   a fixed-depth recursion stack, and compilation may fail if this depth
--   is exceeded.</li>
--   </ul>
UndecidableInstances :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.6.3.4</i> Implies <a>OverlappingInstances</a>. Allow
--   the implementation to choose an instance even when it is possible that
--   further instantiation of types will lead to a more specific instance
--   being applicable.</li>
--   </ul>
IncoherentInstances :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.3.8</i> Allows recursive bindings in <tt>do</tt>
--   blocks, using the <tt>rec</tt> keyword.</li>
--   </ul>
DoRec :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.3.8.2</i> Deprecated in GHC. Allows recursive bindings
--   using <tt>mdo</tt>, a variant of <tt>do</tt>. <tt>DoRec</tt> provides
--   a different, preferred syntax.</li>
--   </ul>
RecursiveDo :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.3.9</i> Provide syntax for writing list comprehensions
--   which iterate over several lists together, like the <a>zipWith</a>
--   family of functions.</li>
--   </ul>
ParallelListComp :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.6.1.1</i> Allow multiple parameters in a type
--   class.</li>
--   </ul>
MultiParamTypeClasses :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.17</i> Enable the dreaded monomorphism
--   restriction.</li>
--   </ul>
MonomorphismRestriction :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.6.2</i> Allow a specification attached to a
--   multi-parameter type class which indicates that some parameters are
--   entirely determined by others. The implementation will check that this
--   property holds for the declared instances, and will use this property
--   to reduce ambiguity in instance resolution.</li>
--   </ul>
FunctionalDependencies :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.8.5</i> Like <a>RankNTypes</a> but does not allow a
--   higher-rank type to itself appear on the left of a function
--   arrow.</li>
--   </ul>
Rank2Types :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.8.5</i> Allow a universally-quantified type to occur on
--   the left of a function arrow.</li>
--   </ul>
RankNTypes :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.8.5</i> Allow data constructors to have polymorphic
--   arguments. Unlike <a>RankNTypes</a>, does not allow this for ordinary
--   functions.</li>
--   </ul>
PolymorphicComponents :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.4.4</i> Allow existentially-quantified data
--   constructors.</li>
--   </ul>
ExistentialQuantification :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.8.7</i> Cause a type variable in a signature, which has
--   an explicit <tt>forall</tt> quantifier, to scope over the definition
--   of the accompanying value declaration.</li>
--   </ul>
ScopedTypeVariables :: KnownExtension

-- | Deprecated, use <a>ScopedTypeVariables</a> instead.
PatternSignatures :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.8.3</i> Enable implicit function parameters with
--   dynamic scope.</li>
--   </ul>
ImplicitParams :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.8.2</i> Relax some restrictions on the form of the
--   context of a type signature.</li>
--   </ul>
FlexibleContexts :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.6.3.2</i> Relax some restrictions on the form of the
--   context of an instance declaration.</li>
--   </ul>
FlexibleInstances :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.4.1</i> Allow data type declarations with no
--   constructors.</li>
--   </ul>
EmptyDataDecls :: KnownExtension

-- | <ul>
--   <li><i>GHC § 4.10.3</i> Run the C preprocessor on Haskell source
--   code.</li>
--   </ul>
CPP :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.8.4</i> Allow an explicit kind signature giving the
--   kind of types over which a type variable ranges.</li>
--   </ul>
KindSignatures :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.11</i> Enable a form of pattern which forces evaluation
--   before an attempted match, and a form of strict
--   <tt>let</tt>/<tt>where</tt> binding.</li>
--   </ul>
BangPatterns :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.6.3.1</i> Allow type synonyms in instance heads.</li>
--   </ul>
TypeSynonymInstances :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.9</i> Enable Template Haskell, a system for
--   compile-time metaprogramming.</li>
--   </ul>
TemplateHaskell :: KnownExtension

-- | <ul>
--   <li><i>GHC § 8</i> Enable the Foreign Function Interface. In GHC,
--   implements the standard Haskell 98 Foreign Function Interface
--   Addendum, plus some GHC-specific extensions.</li>
--   </ul>
ForeignFunctionInterface :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.10</i> Enable arrow notation.</li>
--   </ul>
Arrows :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.16</i> Enable generic type classes, with default
--   instances defined in terms of the algebraic structure of a type.</li>
--   </ul>
Generics :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.3.11</i> Enable the implicit importing of the module
--   <tt>Prelude</tt>. When disabled, when desugaring certain built-in
--   syntax into ordinary identifiers, use whatever is in scope rather than
--   the <tt>Prelude</tt> -- version.</li>
--   </ul>
ImplicitPrelude :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.3.15</i> Enable syntax for implicitly binding local
--   names corresponding to the field names of a record. Puns bind specific
--   names, unlike <a>RecordWildCards</a>.</li>
--   </ul>
NamedFieldPuns :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.3.5</i> Enable a form of guard which matches a pattern
--   and binds variables.</li>
--   </ul>
PatternGuards :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.5.4</i> Allow a type declared with <tt>newtype</tt> to
--   use <tt>deriving</tt> for any class with an instance for the
--   underlying type.</li>
--   </ul>
GeneralizedNewtypeDeriving :: KnownExtension

-- | <ul>
--   <li><i>Hugs § 7.1</i> Enable the "Trex" extensible records
--   system.</li>
--   </ul>
ExtensibleRecords :: KnownExtension

-- | <ul>
--   <li><i>Hugs § 7.2</i> Enable type synonyms which are transparent in
--   some definitions and opaque elsewhere, as a way of implementing
--   abstract datatypes.</li>
--   </ul>
RestrictedTypeSynonyms :: KnownExtension

-- | <ul>
--   <li><i>Hugs § 7.3</i> Enable an alternate syntax for string literals,
--   with string templating.</li>
--   </ul>
HereDocuments :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.3.2</i> Allow the character <tt>#</tt> as a postfix
--   modifier on identifiers. Also enables literal syntax for unboxed
--   values.</li>
--   </ul>
MagicHash :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.7</i> Allow data types and type synonyms which are
--   indexed by types, i.e. ad-hoc polymorphism for types.</li>
--   </ul>
TypeFamilies :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.5.2</i> Allow a standalone declaration which invokes
--   the type class <tt>deriving</tt> mechanism.</li>
--   </ul>
StandaloneDeriving :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.3.1</i> Allow certain Unicode characters to stand for
--   certain ASCII character sequences, e.g. keywords and punctuation.</li>
--   </ul>
UnicodeSyntax :: KnownExtension

-- | <ul>
--   <li><i>GHC § 8.1.1</i> Allow the use of unboxed types as foreign
--   types, e.g. in <tt>foreign import</tt> and <tt>foreign
--   export</tt>.</li>
--   </ul>
UnliftedFFITypes :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.4.3</i> Defer validity checking of types until after
--   expanding type synonyms, relaxing the constraints on how synonyms may
--   be used.</li>
--   </ul>
LiberalTypeSynonyms :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.4.2</i> Allow the name of a type constructor, type
--   class, or type variable to be an infix operator.</li>
--   </ul>
TypeOperators :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.3.16</i> Enable syntax for implicitly binding local
--   names corresponding to the field names of a record. A wildcard binds
--   all unmentioned names, unlike <a>NamedFieldPuns</a>.</li>
--   </ul>
RecordWildCards :: KnownExtension

-- | Deprecated, use <a>NamedFieldPuns</a> instead.
RecordPuns :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.3.14</i> Allow a record field name to be disambiguated
--   by the type of the record it's in.</li>
--   </ul>
DisambiguateRecordFields :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.6.4</i> Enable overloading of string literals using a
--   type class, much like integer literals.</li>
--   </ul>
OverloadedStrings :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.4.6</i> Enable generalized algebraic data types, in
--   which type variables may be instantiated on a per-constructor basis.
--   Implies GADTSyntax.</li>
--   </ul>
GADTs :: KnownExtension

-- | Enable GADT syntax for declaring ordinary algebraic datatypes.
GADTSyntax :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.17.2</i> Make pattern bindings monomorphic.</li>
--   </ul>
MonoPatBinds :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.8.8</i> Relax the requirements on mutually-recursive
--   polymorphic functions.</li>
--   </ul>
RelaxedPolyRec :: KnownExtension

-- | <ul>
--   <li><i>GHC § 2.4.5</i> Allow default instantiation of polymorphic
--   types in more situations.</li>
--   </ul>
ExtendedDefaultRules :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.2.2</i> Enable unboxed tuples.</li>
--   </ul>
UnboxedTuples :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.5.3</i> Enable <tt>deriving</tt> for classes
--   <tt>Data.Typeable.Typeable</tt> and <tt>Data.Generics.Data</tt>.</li>
--   </ul>
DeriveDataTypeable :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.6.1.3</i> Allow a class method's type to place
--   additional constraints on a class type variable.</li>
--   </ul>
ConstrainedClassMethods :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.3.18</i> Allow imports to be qualified by the package
--   name the module is intended to be imported from, e.g.</li>
--   </ul>
--   
--   <pre>
--   import "network" Network.Socket
--   </pre>
PackageImports :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.8.6</i> Deprecated in GHC 6.12 and will be removed in
--   GHC 7. Allow a type variable to be instantiated at a polymorphic
--   type.</li>
--   </ul>
ImpredicativeTypes :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.3.3</i> Change the syntax for qualified infix
--   operators.</li>
--   </ul>
NewQualifiedOperators :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.3.12</i> Relax the interpretation of left operator
--   sections to allow unary postfix operators.</li>
--   </ul>
PostfixOperators :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.9.5</i> Enable quasi-quotation, a mechanism for
--   defining new concrete syntax for expressions and patterns.</li>
--   </ul>
QuasiQuotes :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.3.10</i> Enable generalized list comprehensions,
--   supporting operations such as sorting and grouping.</li>
--   </ul>
TransformListComp :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.3.6</i> Enable view patterns, which match a value by
--   applying a function and matching on the result.</li>
--   </ul>
ViewPatterns :: KnownExtension

-- | Allow concrete XML syntax to be used in expressions and patterns, as
--   per the Haskell Server Pages extension language:
--   <a>http://www.haskell.org/haskellwiki/HSP</a>. The ideas behind it are
--   discussed in the paper "Haskell Server Pages through Dynamic Loading"
--   by Niklas Broberg, from Haskell Workshop '05.
XmlSyntax :: KnownExtension

-- | Allow regular pattern matching over lists, as discussed in the paper
--   "Regular Expression Patterns" by Niklas Broberg, Andreas Farre and
--   Josef Svenningsson, from ICFP '04.
RegularPatterns :: KnownExtension

-- | Enables the use of tuple sections, e.g. <tt>(, True)</tt> desugars
--   into <tt>x -&gt; (x, True)</tt>.
TupleSections :: KnownExtension

-- | Allows GHC primops, written in C--, to be imported into a Haskell
--   file.
GHCForeignImportPrim :: KnownExtension

-- | Support for patterns of the form <tt>n + k</tt>, where <tt>k</tt> is
--   an integer literal.
NPlusKPatterns :: KnownExtension

-- | Improve the layout rule when <tt>if</tt> expressions are used in a
--   <tt>do</tt> block.
DoAndIfThenElse :: KnownExtension

-- | Makes much of the Haskell sugar be desugared into calls to the
--   function with a particular name that is in scope.
RebindableSyntax :: KnownExtension

-- | Make <tt>forall</tt> a keyword in types, which can be used to give the
--   generalisation explicitly.
ExplicitForAll :: KnownExtension

-- | Allow contexts to be put on datatypes, e.g. the <tt>Eq a</tt> in
--   <tt>data Eq a =&gt; Set a = NilSet | ConsSet a (Set a)</tt>.
DatatypeContexts :: KnownExtension

-- | Local (<tt>let</tt> and <tt>where</tt>) bindings are monomorphic.
MonoLocalBinds :: KnownExtension

-- | Enable <tt>deriving</tt> for the <tt>Data.Functor.Functor</tt> class.
DeriveFunctor :: KnownExtension

-- | Enable <tt>deriving</tt> for the <tt>Data.Traversable.Traversable</tt>
--   class.
DeriveTraversable :: KnownExtension

-- | Enable <tt>deriving</tt> for the <tt>Data.Foldable.Foldable</tt>
--   class.
DeriveFoldable :: KnownExtension

-- | Enable non-decreasing indentation for 'do' blocks.
NondecreasingIndentation :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.20.3</i> Allow imports to be qualified with a safe
--   keyword that requires the imported module be trusted as according to
--   the Safe Haskell definition of trust.</li>
--   </ul>
--   
--   <pre>
--   import safe Network.Socket
--   </pre>
SafeImports :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.20</i> Compile a module in the Safe, Safe Haskell mode
--   -- a restricted form of the Haskell language to ensure type
--   safety.</li>
--   </ul>
Safe :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.20</i> Compile a module in the Trustworthy, Safe
--   Haskell mode -- no restrictions apply but the module is marked as
--   trusted as long as the package the module resides in is trusted.</li>
--   </ul>
Trustworthy :: KnownExtension

-- | <ul>
--   <li><i>GHC § 7.40</i> Allow type class<i>implicit
--   parameter</i>equality constraints to be used as types with the special
--   kind Constraint. Also generalise the (ctxt =&gt; ty) syntax so that
--   any type of kind Constraint can occur before the arrow.</li>
--   </ul>
ConstraintKinds :: KnownExtension

-- | <i>Deprecated: KnownExtension is an instance of Enum and Bounded, use
--   those instead. </i>
knownExtensions :: [KnownExtension]

-- | Extensions that have been deprecated, possibly paired with another
--   extension that replaces it.
deprecatedExtensions :: [(Extension, Maybe Extension)]
instance Show Language
instance Read Language
instance Eq Language
instance Show KnownExtension
instance Read KnownExtension
instance Eq KnownExtension
instance Enum KnownExtension
instance Bounded KnownExtension
instance Show Extension
instance Read Extension
instance Eq Extension
instance Text KnownExtension
instance Text Extension
instance Text Language


-- | Exports the <a>Version</a> type along with a parser and pretty
--   printer. A version is something like <tt>"1.3.3"</tt>. It also defines
--   the <a>VersionRange</a> data types. Version ranges are like <tt>"&gt;=
--   1.2 &amp;&amp; &lt; 2"</tt>.
module Distribution.Version

-- | A <a>Version</a> represents the version of a software entity.
--   
--   An instance of <a>Eq</a> is provided, which implements exact equality
--   modulo reordering of the tags in the <a>versionTags</a> field.
--   
--   An instance of <a>Ord</a> is also provided, which gives lexicographic
--   ordering on the <a>versionBranch</a> fields (i.e. 2.1 &gt; 2.0, 1.2.3
--   &gt; 1.2.2, etc.). This is expected to be sufficient for many uses,
--   but note that you may need to use a more specific ordering for your
--   versioning scheme. For example, some versioning schemes may include
--   pre-releases which have tags <tt>"pre1"</tt>, <tt>"pre2"</tt>, and so
--   on, and these would need to be taken into account when determining
--   ordering. In some cases, date ordering may be more appropriate, so the
--   application would have to look for <tt>date</tt> tags in the
--   <a>versionTags</a> field and compare those. The bottom line is, don't
--   always assume that <a>compare</a> and other <a>Ord</a> operations are
--   the right thing for every <a>Version</a>.
--   
--   Similarly, concrete representations of versions may differ. One
--   possible concrete representation is provided (see <a>showVersion</a>
--   and <a>parseVersion</a>), but depending on the application a different
--   concrete representation may be more appropriate.
data Version :: *
Version :: [Int] -> [String] -> Version

-- | The numeric branch for this version. This reflects the fact that most
--   software versions are tree-structured; there is a main trunk which is
--   tagged with versions at various points (1,2,3...), and the first
--   branch off the trunk after version 3 is 3.1, the second branch off the
--   trunk after version 3 is 3.2, and so on. The tree can be branched
--   arbitrarily, just by adding more digits.
--   
--   We represent the branch as a list of <a>Int</a>, so version 3.2.1
--   becomes [3,2,1]. Lexicographic ordering (i.e. the default instance of
--   <a>Ord</a> for <tt>[Int]</tt>) gives the natural ordering of branches.
versionBranch :: Version -> [Int]

-- | A version can be tagged with an arbitrary list of strings. The
--   interpretation of the list of tags is entirely dependent on the entity
--   that this version applies to.
versionTags :: Version -> [String]
data VersionRange

-- | <i>Deprecated: Use <a>anyVersion</a>, <a>foldVersionRange</a> or
--   <a>asVersionIntervals</a> </i>
AnyVersion :: VersionRange

-- | <i>Deprecated: use <a>thisVersion</a>, <a>foldVersionRange</a> or
--   <a>asVersionIntervals</a> </i>
ThisVersion :: Version -> VersionRange

-- | <i>Deprecated: use <a>laterVersion</a>, <a>foldVersionRange</a> or
--   <a>asVersionIntervals</a> </i>
LaterVersion :: Version -> VersionRange

-- | <i>Deprecated: use <a>earlierVersion</a>, <a>foldVersionRange</a> or
--   <a>asVersionIntervals</a> </i>
EarlierVersion :: Version -> VersionRange

-- | <i>Deprecated: use <a>anyVersion</a>, <a>foldVersionRange</a> or
--   <a>asVersionIntervals</a> </i>
WildcardVersion :: Version -> VersionRange

-- | <i>Deprecated: use <a>unionVersionRanges</a>, <a>foldVersionRange</a>
--   or <a>asVersionIntervals</a> </i>
UnionVersionRanges :: VersionRange -> VersionRange -> VersionRange

-- | <i>Deprecated: use <a>intersectVersionRanges</a>,
--   <a>foldVersionRange</a> or <a>asVersionIntervals</a> </i>
IntersectVersionRanges :: VersionRange -> VersionRange -> VersionRange
VersionRangeParens :: VersionRange -> VersionRange

-- | The version range <tt>-any</tt>. That is, a version range containing
--   all versions.
--   
--   <pre>
--   withinRange v anyVersion = True
--   </pre>
anyVersion :: VersionRange

-- | The empty version range, that is a version range containing no
--   versions.
--   
--   This can be constructed using any unsatisfiable version range
--   expression, for example <tt>&gt; 1 &amp;&amp; &lt; 1</tt>.
--   
--   <pre>
--   withinRange v anyVersion = False
--   </pre>
noVersion :: VersionRange

-- | The version range <tt>== v</tt>
--   
--   <pre>
--   withinRange v' (thisVersion v) = v' == v
--   </pre>
thisVersion :: Version -> VersionRange

-- | The version range <tt><a>||</a> v</tt>
--   
--   <pre>
--   withinRange v' (notThisVersion v) = v' /= v
--   </pre>
notThisVersion :: Version -> VersionRange

-- | The version range <tt>&gt; v</tt>
--   
--   <pre>
--   withinRange v' (laterVersion v) = v' &gt; v
--   </pre>
laterVersion :: Version -> VersionRange

-- | The version range <tt>&lt; v</tt>
--   
--   <pre>
--   withinRange v' (earlierVersion v) = v' &lt; v
--   </pre>
earlierVersion :: Version -> VersionRange

-- | The version range <tt>&gt;= v</tt>
--   
--   <pre>
--   withinRange v' (orLaterVersion v) = v' &gt;= v
--   </pre>
orLaterVersion :: Version -> VersionRange

-- | The version range <tt>&lt;= v</tt>
--   
--   <pre>
--   withinRange v' (orEarlierVersion v) = v' &lt;= v
--   </pre>
orEarlierVersion :: Version -> VersionRange

-- | The version range <tt>vr1 || vr2</tt>
--   
--   <pre>
--     withinRange v' (unionVersionRanges vr1 vr2)
--   = withinRange v' vr1 || withinRange v' vr2
--   </pre>
unionVersionRanges :: VersionRange -> VersionRange -> VersionRange

-- | The version range <tt>vr1 &amp;&amp; vr2</tt>
--   
--   <pre>
--     withinRange v' (intersectVersionRanges vr1 vr2)
--   = withinRange v' vr1 &amp;&amp; withinRange v' vr2
--   </pre>
intersectVersionRanges :: VersionRange -> VersionRange -> VersionRange

-- | The version range <tt>== v.*</tt>.
--   
--   For example, for version <tt>1.2</tt>, the version range <tt>==
--   1.2.*</tt> is the same as <tt>&gt;= 1.2 &amp;&amp; &lt; 1.3</tt>
--   
--   <pre>
--   withinRange v' (laterVersion v) = v' &gt;= v &amp;&amp; v' &lt; upper v
--     where
--       upper (Version lower t) = Version (init lower ++ [last lower + 1]) t
--   </pre>
withinVersion :: Version -> VersionRange

-- | The version range <tt>&gt;= v1 &amp;&amp; &lt;= v2</tt>.
--   
--   In practice this is not very useful because we normally use inclusive
--   lower bounds and exclusive upper bounds.
--   
--   <pre>
--   withinRange v' (laterVersion v) = v' &gt; v
--   </pre>

-- | <i>Deprecated: In practice this is not very useful because we normally
--   use inclusive lower bounds and exclusive upper bounds </i>
betweenVersionsInclusive :: Version -> Version -> VersionRange

-- | Does this version fall within the given range?
--   
--   This is the evaluation function for the <a>VersionRange</a> type.
withinRange :: Version -> VersionRange -> Bool

-- | Does this <a>VersionRange</a> place any restriction on the
--   <a>Version</a> or is it in fact equivalent to <a>AnyVersion</a>.
--   
--   Note this is a semantic check, not simply a syntactic check. So for
--   example the following is <tt>True</tt> (for all <tt>v</tt>).
--   
--   <pre>
--   isAnyVersion (EarlierVersion v `UnionVersionRanges` orLaterVersion v)
--   </pre>
isAnyVersion :: VersionRange -> Bool

-- | This is the converse of <a>isAnyVersion</a>. It check if the version
--   range is empty, if there is no possible version that satisfies the
--   version range.
--   
--   For example this is <tt>True</tt> (for all <tt>v</tt>):
--   
--   <pre>
--   isNoVersion (EarlierVersion v `IntersectVersionRanges` LaterVersion v)
--   </pre>
isNoVersion :: VersionRange -> Bool

-- | Is this version range in fact just a specific version?
--   
--   For example the version range <tt>"&gt;= 3 &amp;&amp; &lt;= 3"</tt>
--   contains only the version <tt>3</tt>.
isSpecificVersion :: VersionRange -> Maybe Version

-- | Simplify a <a>VersionRange</a> expression. For non-empty version
--   ranges this produces a canonical form. Empty or inconsistent version
--   ranges are left as-is because that provides more information.
--   
--   If you need a canonical form use <tt>fromVersionIntervals .
--   toVersionIntervals</tt>
--   
--   It satisfies the following properties:
--   
--   <pre>
--   withinRange v (simplifyVersionRange r) = withinRange v r
--   </pre>
--   
--   <pre>
--       withinRange v r = withinRange v r'
--   ==&gt; simplifyVersionRange r = simplifyVersionRange r'
--    || isNoVersion r
--    || isNoVersion r'
--   </pre>
simplifyVersionRange :: VersionRange -> VersionRange

-- | Fold over the basic syntactic structure of a <a>VersionRange</a>.
--   
--   This provides a syntacic view of the expression defining the version
--   range. The syntactic sugar <tt>"&gt;= v"</tt>, <tt>"&lt;= v"</tt> and
--   <tt>"== v.*"</tt> is presented in terms of the other basic syntax.
--   
--   For a semantic view use <a>asVersionIntervals</a>.
foldVersionRange :: a -> (Version -> a) -> (Version -> a) -> (Version -> a) -> (a -> a -> a) -> (a -> a -> a) -> VersionRange -> a

-- | An extended variant of <a>foldVersionRange</a> that also provides a
--   view of in which the syntactic sugar <tt>"&gt;= v"</tt>, <tt>"&lt;=
--   v"</tt> and <tt>"== v.*"</tt> is presented explicitly rather than in
--   terms of the other basic syntax.
foldVersionRange' :: a -> (Version -> a) -> (Version -> a) -> (Version -> a) -> (Version -> a) -> (Version -> a) -> (Version -> Version -> a) -> (a -> a -> a) -> (a -> a -> a) -> (a -> a) -> VersionRange -> a

-- | View a <a>VersionRange</a> as a union of intervals.
--   
--   This provides a canonical view of the semantics of a
--   <a>VersionRange</a> as opposed to the syntax of the expression used to
--   define it. For the syntactic view use <a>foldVersionRange</a>.
--   
--   Each interval is non-empty. The sequence is in increasing order and no
--   intervals overlap or touch. Therefore only the first and last can be
--   unbounded. The sequence can be empty if the range is empty (e.g. a
--   range expression like <tt><a>&amp;&amp;</a> 2</tt>).
--   
--   Other checks are trivial to implement using this view. For example:
--   
--   <pre>
--   isNoVersion vr | [] &lt;- asVersionIntervals vr = True
--                  | otherwise                   = False
--   </pre>
--   
--   <pre>
--   isSpecificVersion vr
--      | [(LowerBound v  InclusiveBound
--         ,UpperBound v' InclusiveBound)] &lt;- asVersionIntervals vr
--      , v == v'   = Just v
--      | otherwise = Nothing
--   </pre>
asVersionIntervals :: VersionRange -> [VersionInterval]
type VersionInterval = (LowerBound, UpperBound)
data LowerBound
LowerBound :: Version -> !Bound -> LowerBound
data UpperBound
NoUpperBound :: UpperBound
UpperBound :: Version -> !Bound -> UpperBound
data Bound
ExclusiveBound :: Bound
InclusiveBound :: Bound

-- | A complementary representation of a <a>VersionRange</a>. Instead of a
--   boolean version predicate it uses an increasing sequence of
--   non-overlapping, non-empty intervals.
--   
--   The key point is that this representation gives a canonical
--   representation for the semantics of <a>VersionRange</a>s. This makes
--   it easier to check things like whether a version range is empty,
--   covers all versions, or requires a certain minimum or maximum version.
--   It also makes it easy to check equality or containment. It also makes
--   it easier to identify 'simple' version predicates for translation into
--   foreign packaging systems that do not support complex version range
--   expressions.
data VersionIntervals

-- | Convert a <a>VersionRange</a> to a sequence of version intervals.
toVersionIntervals :: VersionRange -> VersionIntervals

-- | Convert a <a>VersionIntervals</a> value back into a
--   <a>VersionRange</a> expression representing the version intervals.
fromVersionIntervals :: VersionIntervals -> VersionRange

-- | Test if a version falls within the version intervals.
--   
--   It exists mostly for completeness and testing. It satisfies the
--   following properties:
--   
--   <pre>
--   withinIntervals v (toVersionIntervals vr) = withinRange v vr
--   withinIntervals v ivs = withinRange v (fromVersionIntervals ivs)
--   </pre>
withinIntervals :: Version -> VersionIntervals -> Bool

-- | Inspect the list of version intervals.
versionIntervals :: VersionIntervals -> [VersionInterval]

-- | Directly construct a <a>VersionIntervals</a> from a list of intervals.
--   
--   Each interval must be non-empty. The sequence must be in increasing
--   order and no invervals may overlap or touch. If any of these
--   conditions are not satisfied the function returns <tt>Nothing</tt>.
mkVersionIntervals :: [VersionInterval] -> Maybe VersionIntervals
unionVersionIntervals :: VersionIntervals -> VersionIntervals -> VersionIntervals
intersectVersionIntervals :: VersionIntervals -> VersionIntervals -> VersionIntervals
instance Show VersionRange
instance Read VersionRange
instance Eq VersionRange
instance Eq Bound
instance Show Bound
instance Eq UpperBound
instance Show UpperBound
instance Eq LowerBound
instance Show LowerBound
instance Eq VersionIntervals
instance Show VersionIntervals
instance Text VersionRange
instance Ord UpperBound
instance Ord LowerBound


-- | The License datatype. For more information about these and other
--   open-source licenses, you may visit <a>http://www.opensource.org/</a>.
--   
--   The <tt>.cabal</tt> file allows you to specify a license file. Of
--   course you can use any license you like but people often pick common
--   open source licenses and it's useful if we can automatically recognise
--   that (eg so we can display it on the hackage web pages). So you can
--   also specify the license itself in the <tt>.cabal</tt> file from a
--   short enumeration defined in this module. It includes <a>GPL</a>,
--   <a>LGPL</a> and <a>BSD3</a> licenses.
module Distribution.License

-- | This datatype indicates the license under which your package is
--   released. It is also wise to add your license to each source file
--   using the license-file field. The <a>AllRightsReserved</a> constructor
--   is not actually a license, but states that you are not giving anyone
--   else a license to use or distribute your work. The comments below are
--   general guidelines. Please read the licenses themselves and consult a
--   lawyer if you are unsure of your rights to release the software.
data License

-- | GNU Public License. Source code must accompany alterations.
GPL :: (Maybe Version) -> License

-- | Lesser GPL, Less restrictive than GPL, useful for libraries.
LGPL :: (Maybe Version) -> License

-- | 3-clause BSD license, newer, no advertising clause. Very free license.
BSD3 :: License

-- | 4-clause BSD license, older, with advertising clause. You almost
--   certainly want to use the BSD3 license instead.
BSD4 :: License

-- | The MIT license, similar to the BSD3. Very free license.
MIT :: License

-- | The Apache License. Version 2.0 is the current version, previous
--   versions are considered historical.
Apache :: (Maybe Version) -> License

-- | Holder makes no claim to ownership, least restrictive license.
PublicDomain :: License

-- | No rights are granted to others. Undistributable. Most restrictive.
AllRightsReserved :: License

-- | Some other license.
OtherLicense :: License

-- | Not a recognised license. Allows us to deal with future extensions
--   more gracefully.
UnknownLicense :: String -> License
knownLicenses :: [License]
instance Read License
instance Show License
instance Eq License
instance Text License


-- | Defines a package identifier along with a parser and pretty printer
--   for it. <a>PackageIdentifier</a>s consist of a name and an exact
--   version. It also defines a <a>Dependency</a> data type. A dependency
--   is a package name and a version range, like <tt>"foo &gt;= 1.2
--   &amp;&amp; &lt; 2"</tt>.
module Distribution.Package
newtype PackageName
PackageName :: String -> PackageName

-- | The name and version of a package.
data PackageIdentifier
PackageIdentifier :: PackageName -> Version -> PackageIdentifier

-- | The name of this package, eg. foo
pkgName :: PackageIdentifier -> PackageName

-- | the version of this package, eg 1.2
pkgVersion :: PackageIdentifier -> Version

-- | Type alias so we can use the shorter name PackageId.
type PackageId = PackageIdentifier

-- | An InstalledPackageId uniquely identifies an instance of an installed
--   package. There can be at most one package with a given
--   <a>InstalledPackageId</a> in a package database, or overlay of
--   databases.
newtype InstalledPackageId
InstalledPackageId :: String -> InstalledPackageId

-- | Describes a dependency on a source package (API)
data Dependency
Dependency :: PackageName -> VersionRange -> Dependency
thisPackageVersion :: PackageIdentifier -> Dependency
notThisPackageVersion :: PackageIdentifier -> Dependency

-- | Simplify the <a>VersionRange</a> expression in a <a>Dependency</a>.
--   See <a>simplifyVersionRange</a>.
simplifyDependency :: Dependency -> Dependency

-- | Class of things that have a <a>PackageIdentifier</a>
--   
--   Types in this class are all notions of a package. This allows us to
--   have different types for the different phases that packages go though,
--   from simple name/id, package description, configured or installed
--   packages.
--   
--   Not all kinds of packages can be uniquely identified by a
--   <a>PackageIdentifier</a>. In particular, installed packages cannot,
--   there may be many installed instances of the same source package.
class Package pkg
packageId :: Package pkg => pkg -> PackageIdentifier
packageName :: Package pkg => pkg -> PackageName
packageVersion :: Package pkg => pkg -> Version

-- | Subclass of packages that have specific versioned dependencies.
--   
--   So for example a not-yet-configured package has dependencies on
--   version ranges, not specific versions. A configured or an already
--   installed package depends on exact versions. Some operations or data
--   structures (like dependency graphs) only make sense on this subclass
--   of package types.
class Package pkg => PackageFixedDeps pkg
depends :: PackageFixedDeps pkg => pkg -> [PackageIdentifier]
instance Read PackageName
instance Show PackageName
instance Eq PackageName
instance Ord PackageName
instance Read PackageIdentifier
instance Show PackageIdentifier
instance Eq PackageIdentifier
instance Ord PackageIdentifier
instance Read InstalledPackageId
instance Show InstalledPackageId
instance Eq InstalledPackageId
instance Ord InstalledPackageId
instance Read Dependency
instance Show Dependency
instance Eq Dependency
instance Package PackageIdentifier
instance Text Dependency
instance Text InstalledPackageId
instance Text PackageIdentifier
instance Text PackageName


-- | A large and somewhat miscellaneous collection of utility functions
--   used throughout the rest of the Cabal lib and in other tools that use
--   the Cabal lib like <tt>cabal-install</tt>. It has a very simple set of
--   logging actions. It has low level functions for running programs, a
--   bunch of wrappers for various directory and file functions that do
--   extra logging.
module Distribution.Simple.Utils
cabalVersion :: Version
die :: String -> IO a
dieWithLocation :: FilePath -> Maybe Int -> String -> IO a
topHandler :: IO a -> IO a

-- | Non fatal conditions that may be indicative of an error or problem.
--   
--   We display these at the <a>normal</a> verbosity level.
warn :: Verbosity -> String -> IO ()

-- | Useful status messages.
--   
--   We display these at the <a>normal</a> verbosity level.
--   
--   This is for the ordinary helpful status messages that users see. Just
--   enough information to know that things are working but not floods of
--   detail.
notice :: Verbosity -> String -> IO ()
setupMessage :: Verbosity -> String -> PackageIdentifier -> IO ()

-- | More detail on the operation of some action.
--   
--   We display these messages when the verbosity level is <a>verbose</a>
info :: Verbosity -> String -> IO ()

-- | Detailed internal debugging information
--   
--   We display these messages when the verbosity level is <a>deafening</a>
debug :: Verbosity -> String -> IO ()

-- | Perform an IO action, catching any IO exceptions and printing an error
--   if one occurs.
chattyTry :: String -> IO () -> IO ()
rawSystemExit :: Verbosity -> FilePath -> [String] -> IO ()
rawSystemExitCode :: Verbosity -> FilePath -> [String] -> IO ExitCode
rawSystemExitWithEnv :: Verbosity -> FilePath -> [String] -> [(String, String)] -> IO ()

-- | Run a command and return its output.
--   
--   The output is assumed to be text in the locale encoding.
rawSystemStdout :: Verbosity -> FilePath -> [String] -> IO String

-- | Run a command and return its output, errors and exit status.
--   Optionally also supply some input. Also provides control over whether
--   the binary/text mode of the input and output.
rawSystemStdInOut :: Verbosity -> FilePath -> [String] -> Maybe (String, Bool) -> Bool -> IO (String, String, ExitCode)
maybeExit :: IO ExitCode -> IO ()

-- | Like the unix xargs program. Useful for when we've got very long
--   command lines that might overflow an OS limit on command line length
--   and so you need to invoke a command multiple times to get all the args
--   in.
--   
--   Use it with either of the rawSystem variants above. For example:
--   
--   <pre>
--   xargs (32*1024) (rawSystemExit verbosity) prog fixedArgs bigArgs
--   </pre>
xargs :: Int -> ([String] -> IO ()) -> [String] -> [String] -> IO ()

-- | Look for a program on the path.
findProgramLocation :: Verbosity -> FilePath -> IO (Maybe FilePath)

-- | Look for a program and try to find it's version number. It can accept
--   either an absolute path or the name of a program binary, in which case
--   we will look for the program on the path.
findProgramVersion :: String -> (String -> String) -> Verbosity -> FilePath -> IO (Maybe Version)

-- | <i>Deprecated: Use findModuleFiles and copyFiles or
--   installOrdinaryFiles </i>
smartCopySources :: Verbosity -> [FilePath] -> FilePath -> [ModuleName] -> [String] -> IO ()

-- | Same as <tt>createDirectoryIfMissing</tt> but logs at higher verbosity
--   levels.
createDirectoryIfMissingVerbose :: Verbosity -> Bool -> FilePath -> IO ()

-- | Copies a file without copying file permissions. The target file is
--   created with default permissions. Any existing target file is
--   replaced.
--   
--   At higher verbosity levels it logs an info message.
copyFileVerbose :: Verbosity -> FilePath -> FilePath -> IO ()

-- | <i>Deprecated: You probably want installDirectoryContents instead </i>
copyDirectoryRecursiveVerbose :: Verbosity -> FilePath -> FilePath -> IO ()

-- | Copies a bunch of files to a target directory, preserving the
--   directory structure in the target location. The target directories are
--   created if they do not exist.
--   
--   The files are identified by a pair of base directory and a path
--   relative to that base. It is only the relative part that is preserved
--   in the destination.
--   
--   For example:
--   
--   <pre>
--   copyFiles normal "dist/src"
--      [("", "src/Foo.hs"), ("dist/build/", "src/Bar.hs")]
--   </pre>
--   
--   This would copy "src/Foo.hs" to "dist/src/src/Foo.hs" and copy
--   "dist/build/src/Bar.hs" to "dist/src/src/Bar.hs".
--   
--   This operation is not atomic. Any IO failure during the copy
--   (including any missing source files) leaves the target in an unknown
--   state so it is best to use it with a freshly created directory so that
--   it can be simply deleted if anything goes wrong.
copyFiles :: Verbosity -> FilePath -> [(FilePath, FilePath)] -> IO ()

-- | Install an ordinary file. This is like a file copy but the permissions
--   are set appropriately for an installed file. On Unix it is
--   "-rw-r--r--" while on Windows it uses the default permissions for the
--   target directory.
installOrdinaryFile :: Verbosity -> FilePath -> FilePath -> IO ()

-- | Install an executable file. This is like a file copy but the
--   permissions are set appropriately for an installed file. On Unix it is
--   "-rwxr-xr-x" while on Windows it uses the default permissions for the
--   target directory.
installExecutableFile :: Verbosity -> FilePath -> FilePath -> IO ()

-- | This is like <a>copyFiles</a> but uses <a>installOrdinaryFile</a>.
installOrdinaryFiles :: Verbosity -> FilePath -> [(FilePath, FilePath)] -> IO ()

-- | This installs all the files in a directory to a target location,
--   preserving the directory layout. All the files are assumed to be
--   ordinary rather than executable files.
installDirectoryContents :: Verbosity -> FilePath -> FilePath -> IO ()
setFileOrdinary :: FilePath -> IO ()
setFileExecutable :: FilePath -> IO ()

-- | The path name that represents the current directory. In Unix, it's
--   <tt>"."</tt>, but this is system-specific. (E.g. AmigaOS uses the
--   empty string <tt>""</tt> for the current directory.)
currentDir :: FilePath

-- | Find a file by looking in a search path. The file path must match
--   exactly.
findFile :: [FilePath] -> FilePath -> IO FilePath
findFirstFile :: (a -> FilePath) -> [a] -> IO (Maybe a)

-- | Find a file by looking in a search path with one of a list of possible
--   file extensions. The file base name should be given and it will be
--   tried with each of the extensions in each element of the search path.
findFileWithExtension :: [String] -> [FilePath] -> FilePath -> IO (Maybe FilePath)

-- | Like <a>findFileWithExtension</a> but returns which element of the
--   search path the file was found in, and the file path relative to that
--   base directory.
findFileWithExtension' :: [String] -> [FilePath] -> FilePath -> IO (Maybe (FilePath, FilePath))

-- | Find the file corresponding to a Haskell module name.
--   
--   This is similar to <a>findFileWithExtension'</a> but specialised to a
--   module name. The function fails if the file corresponding to the
--   module is missing.
findModuleFile :: [FilePath] -> [String] -> ModuleName -> IO (FilePath, FilePath)

-- | Finds the files corresponding to a list of Haskell module names.
--   
--   As <a>findModuleFile</a> but for a list of module names.
findModuleFiles :: [FilePath] -> [String] -> [ModuleName] -> IO [(FilePath, FilePath)]

-- | List all the files in a directory and all subdirectories.
--   
--   The order places files in sub-directories after all the files in their
--   parent directories. The list is generated lazily so is not well
--   defined if the source directory structure changes before the list is
--   used.
getDirectoryContentsRecursive :: FilePath -> IO [FilePath]
matchFileGlob :: FilePath -> IO [FilePath]
matchDirFileGlob :: FilePath -> FilePath -> IO [FilePath]
parseFileGlob :: FilePath -> Maybe FileGlob
data FileGlob

-- | No glob at all, just an ordinary file
NoGlob :: FilePath -> FileGlob

-- | dir prefix and extension, like <tt>"foo/bar/*.baz"</tt> corresponds to
--   <tt>FileGlob "foo/bar" ".baz"</tt>
FileGlob :: FilePath -> String -> FileGlob

-- | Use a temporary filename that doesn't already exist.
withTempFile :: FilePath -> String -> (FilePath -> Handle -> IO a) -> IO a

-- | Create and use a temporary directory.
--   
--   Creates a new temporary directory inside the given directory, making
--   use of the template. The temp directory is deleted after use. For
--   example:
--   
--   <pre>
--   withTempDirectory verbosity "src" "sdist." $ \tmpDir -&gt; do ...
--   </pre>
--   
--   The <tt>tmpDir</tt> will be a new subdirectory of the given directory,
--   e.g. <tt>src/sdist.342</tt>.
withTempDirectory :: Verbosity -> FilePath -> String -> (FilePath -> IO a) -> IO a

-- | Package description file (<i>pkgname</i><tt>.cabal</tt>)
defaultPackageDesc :: Verbosity -> IO FilePath

-- | Find a package description file in the given directory. Looks for
--   <tt>.cabal</tt> files.
findPackageDesc :: FilePath -> IO FilePath

-- | Optional auxiliary package information file
--   (<i>pkgname</i><tt>.buildinfo</tt>)
defaultHookedPackageDesc :: IO (Maybe FilePath)

-- | Find auxiliary package information in the given directory. Looks for
--   <tt>.buildinfo</tt> files.
findHookedPackageDesc :: FilePath -> IO (Maybe FilePath)

-- | Gets the contents of a file, but guarantee that it gets closed.
--   
--   The file is read lazily but if it is not fully consumed by the action
--   then the remaining input is truncated and the file is closed.
withFileContents :: FilePath -> (String -> IO a) -> IO a

-- | Writes a file atomically.
--   
--   The file is either written sucessfully or an IO exception is raised
--   and the original file is left unchanged.
--   
--   On windows it is not possible to delete a file that is open by a
--   process. This case will give an IO exception but the atomic property
--   is not affected.
writeFileAtomic :: FilePath -> String -> IO ()

-- | Write a file but only if it would have new content. If we would be
--   writing the same as the existing content then leave the file as is so
--   that we do not update the file's modification time.
rewriteFile :: FilePath -> String -> IO ()
fromUTF8 :: String -> String
toUTF8 :: String -> String

-- | Reads a UTF8 encoded text file as a Unicode String
--   
--   Reads lazily using ordinary <a>readFile</a>.
readUTF8File :: FilePath -> IO String

-- | Reads a UTF8 encoded text file as a Unicode String
--   
--   Same behaviour as <a>withFileContents</a>.
withUTF8FileContents :: FilePath -> (String -> IO a) -> IO a

-- | Writes a Unicode String as a UTF8 encoded text file.
--   
--   Uses <a>writeFileAtomic</a>, so provides the same guarantees.
writeUTF8File :: FilePath -> String -> IO ()

-- | Fix different systems silly line ending conventions
normaliseLineEndings :: String -> String
equating :: Eq a => (b -> a) -> b -> b -> Bool
comparing :: Ord a => (b -> a) -> b -> b -> Ordering
isInfixOf :: String -> String -> Bool
intercalate :: [a] -> [[a]] -> [a]
lowercase :: String -> String

-- | Wraps text to the default line width. Existing newlines are preserved.
wrapText :: String -> String

-- | Wraps a list of words to a list of lines of words of a particular
--   width.
wrapLine :: Int -> [String] -> [[String]]


-- | This provides an abstraction which deals with configuring and running
--   programs. A <a>Program</a> is a static notion of a known program. A
--   <a>ConfiguredProgram</a> is a <a>Program</a> that has been found on
--   the current machine and is ready to be run (possibly with some
--   user-supplied default args). Configuring a program involves finding
--   its location and if necessary finding its version. There's reasonable
--   default behavior for trying to find "foo" in PATH, being able to
--   override its location, etc.
module Distribution.Simple.Program.Types

-- | Represents a program which can be configured.
--   
--   Note: rather than constructing this directly, start with
--   <a>simpleProgram</a> and override any extra fields.
data Program
Program :: String -> (Verbosity -> IO (Maybe FilePath)) -> (Verbosity -> FilePath -> IO (Maybe Version)) -> (Verbosity -> ConfiguredProgram -> IO [ProgArg]) -> Program

-- | The simple name of the program, eg. ghc
programName :: Program -> String

-- | A function to search for the program if it's location was not
--   specified by the user. Usually this will just be a
programFindLocation :: Program -> Verbosity -> IO (Maybe FilePath)

-- | Try to find the version of the program. For many programs this is not
--   possible or is not necessary so it's ok to return Nothing.
programFindVersion :: Program -> Verbosity -> FilePath -> IO (Maybe Version)

-- | A function to do any additional configuration after we have located
--   the program (and perhaps identified its version). It is allowed to
--   return additional flags that will be passed to the program on every
--   invocation.
programPostConf :: Program -> Verbosity -> ConfiguredProgram -> IO [ProgArg]

-- | Make a simple named program.
--   
--   By default we'll just search for it in the path and not try to find
--   the version name. You can override these behaviours if necessary, eg:
--   
--   <pre>
--   simpleProgram "foo" { programFindLocation = ... , programFindVersion ... }
--   </pre>
simpleProgram :: String -> Program

-- | Represents a program which has been configured and is thus ready to be
--   run.
--   
--   These are usually made by configuring a <a>Program</a>, but if you
--   have to construct one directly then start with
--   <a>simpleConfiguredProgram</a> and override any extra fields.
data ConfiguredProgram
ConfiguredProgram :: String -> Maybe Version -> [String] -> [String] -> ProgramLocation -> ConfiguredProgram

-- | Just the name again
programId :: ConfiguredProgram -> String

-- | The version of this program, if it is known.
programVersion :: ConfiguredProgram -> Maybe Version

-- | Default command-line args for this program. These flags will appear
--   first on the command line, so they can be overridden by subsequent
--   flags.
programDefaultArgs :: ConfiguredProgram -> [String]

-- | Override command-line args for this program. These flags will appear
--   last on the command line, so they override all earlier flags.
programOverrideArgs :: ConfiguredProgram -> [String]

-- | Location of the program. eg. <tt>/usr/bin/ghc-6.4</tt>
programLocation :: ConfiguredProgram -> ProgramLocation

-- | The full path of a configured program.
programPath :: ConfiguredProgram -> FilePath
type ProgArg = String

-- | Where a program was found. Also tells us whether it's specifed by user
--   or not. This includes not just the path, but the program as well.
data ProgramLocation

-- | The user gave the path to this program, eg.
--   --ghc-path=/usr/bin/ghc-6.6
UserSpecified :: FilePath -> ProgramLocation
locationPath :: ProgramLocation -> FilePath

-- | The program was found automatically.
FoundOnSystem :: FilePath -> ProgramLocation
locationPath :: ProgramLocation -> FilePath

-- | Make a simple <a>ConfiguredProgram</a>.
--   
--   <pre>
--   simpleConfiguredProgram "foo" (FoundOnSystem path)
--   </pre>
simpleConfiguredProgram :: String -> ProgramLocation -> ConfiguredProgram
instance Read ProgramLocation
instance Show ProgramLocation
instance Eq ProgramLocation
instance Read ConfiguredProgram
instance Show ConfiguredProgram
instance Eq ConfiguredProgram


-- | This module provides a data type for program invocations and functions
--   to run them.
module Distribution.Simple.Program.Run

-- | Represents a specific invocation of a specific program.
--   
--   This is used as an intermediate type between deciding how to call a
--   program and actually doing it. This provides the opportunity to the
--   caller to adjust how the program will be called. These invocations can
--   either be run directly or turned into shell or batch scripts.
data ProgramInvocation
ProgramInvocation :: FilePath -> [String] -> [(String, String)] -> Maybe FilePath -> Maybe String -> IOEncoding -> IOEncoding -> ProgramInvocation
progInvokePath :: ProgramInvocation -> FilePath
progInvokeArgs :: ProgramInvocation -> [String]
progInvokeEnv :: ProgramInvocation -> [(String, String)]
progInvokeCwd :: ProgramInvocation -> Maybe FilePath
progInvokeInput :: ProgramInvocation -> Maybe String
progInvokeInputEncoding :: ProgramInvocation -> IOEncoding
progInvokeOutputEncoding :: ProgramInvocation -> IOEncoding
data IOEncoding
IOEncodingText :: IOEncoding
IOEncodingUTF8 :: IOEncoding
emptyProgramInvocation :: ProgramInvocation
simpleProgramInvocation :: FilePath -> [String] -> ProgramInvocation
programInvocation :: ConfiguredProgram -> [String] -> ProgramInvocation

-- | Like the unix xargs program. Useful for when we've got very long
--   command lines that might overflow an OS limit on command line length
--   and so you need to invoke a command multiple times to get all the args
--   in.
--   
--   It takes four template invocations corresponding to the simple,
--   initial, middle and last invocations. If the number of args given is
--   small enough that we can get away with just a single invocation then
--   the simple one is used:
--   
--   <pre>
--   $ simple args
--   </pre>
--   
--   If the number of args given means that we need to use multiple
--   invocations then the templates for the initial, middle and last
--   invocations are used:
--   
--   <pre>
--   $ initial args_0
--   $ middle  args_1
--   $ middle  args_2
--     ...
--   $ final   args_n
--   </pre>
multiStageProgramInvocation :: ProgramInvocation -> (ProgramInvocation, ProgramInvocation, ProgramInvocation) -> [String] -> [ProgramInvocation]
runProgramInvocation :: Verbosity -> ProgramInvocation -> IO ()
getProgramInvocationOutput :: Verbosity -> ProgramInvocation -> IO String


-- | This module provides an library interface to the <tt>ar</tt> program.
module Distribution.Simple.Program.Ar

-- | Call <tt>ar</tt> to create a library archive from a bunch of object
--   files.
createArLibArchive :: Verbosity -> ConfiguredProgram -> FilePath -> [FilePath] -> IO ()

-- | Like the unix xargs program. Useful for when we've got very long
--   command lines that might overflow an OS limit on command line length
--   and so you need to invoke a command multiple times to get all the args
--   in.
--   
--   It takes four template invocations corresponding to the simple,
--   initial, middle and last invocations. If the number of args given is
--   small enough that we can get away with just a single invocation then
--   the simple one is used:
--   
--   <pre>
--   $ simple args
--   </pre>
--   
--   If the number of args given means that we need to use multiple
--   invocations then the templates for the initial, middle and last
--   invocations are used:
--   
--   <pre>
--   $ initial args_0
--   $ middle  args_1
--   $ middle  args_2
--     ...
--   $ final   args_n
--   </pre>
multiStageProgramInvocation :: ProgramInvocation -> (ProgramInvocation, ProgramInvocation, ProgramInvocation) -> [String] -> [ProgramInvocation]


-- | This module provides an library interface to the <tt>ld</tt> linker
--   program.
module Distribution.Simple.Program.Ld

-- | Call <tt>ld -r</tt> to link a bunch of object files together.
combineObjectFiles :: Verbosity -> ConfiguredProgram -> FilePath -> [FilePath] -> IO ()


-- | This module provides an library interface to the <tt>hpc</tt> program.
module Distribution.Simple.Program.Hpc
markup :: ConfiguredProgram -> Verbosity -> FilePath -> FilePath -> FilePath -> [ModuleName] -> IO ()
union :: ConfiguredProgram -> Verbosity -> [FilePath] -> FilePath -> [ModuleName] -> IO ()


-- | This module provides an library interface to the <tt>hc-pkg</tt>
--   program. Currently only GHC and LHC have hc-pkg programs.
module Distribution.Simple.Program.Script

-- | Generate a system script, either POSIX shell script or Windows batch
--   file as appropriate for the given system.
invocationAsSystemScript :: OS -> ProgramInvocation -> String

-- | Generate a POSIX shell script that invokes a program.
invocationAsShellScript :: ProgramInvocation -> String

-- | Generate a Windows batch file that invokes a program.
invocationAsBatchFile :: ProgramInvocation -> String


-- | The module defines all the known built-in <a>Program</a>s.
--   
--   Where possible we try to find their version numbers.
module Distribution.Simple.Program.Builtin

-- | The default list of programs. These programs are typically used
--   internally to Cabal.
builtinPrograms :: [Program]
ghcProgram :: Program
ghcPkgProgram :: Program
lhcProgram :: Program
lhcPkgProgram :: Program
nhcProgram :: Program
hmakeProgram :: Program
jhcProgram :: Program
hugsProgram :: Program
ffihugsProgram :: Program
uhcProgram :: Program
gccProgram :: Program
ranlibProgram :: Program
arProgram :: Program
stripProgram :: Program
happyProgram :: Program
alexProgram :: Program
hsc2hsProgram :: Program
c2hsProgram :: Program
cpphsProgram :: Program
hscolourProgram :: Program
haddockProgram :: Program
greencardProgram :: Program
ldProgram :: Program
tarProgram :: Program
cppProgram :: Program
pkgConfigProgram :: Program
hpcProgram :: Program


-- | This provides a <a>ProgramDb</a> type which holds configured and
--   not-yet configured programs. It is the parameter to lots of actions
--   elsewhere in Cabal that need to look up and run programs. If we had a
--   Cabal monad, the <a>ProgramDb</a> would probably be a reader or state
--   component of it.
--   
--   One nice thing about using it is that any program that is registered
--   with Cabal will get some "configure" and ".cabal" helpers like
--   --with-foo-args --foo-path= and extra-foo-args.
--   
--   There's also a hook for adding programs in a Setup.lhs script. See
--   hookedPrograms in <a>UserHooks</a>. This gives a hook user the ability
--   to get the above flags and such so that they don't have to write all
--   the PATH logic inside Setup.lhs.
module Distribution.Simple.Program.Db

-- | The configuration is a collection of information about programs. It
--   contains information both about configured programs and also about
--   programs that we are yet to configure.
--   
--   The idea is that we start from a collection of unconfigured programs
--   and one by one we try to configure them at which point we move them
--   into the configured collection. For unconfigured programs we record
--   not just the <a>Program</a> but also any user-provided arguments and
--   location for the program.
data ProgramDb
emptyProgramDb :: ProgramDb
defaultProgramDb :: ProgramDb

-- | The Read/Show instance does not preserve all the unconfigured
--   <tt>Programs</tt> because <a>Program</a> is not in Read/Show because
--   it contains functions. So to fully restore a deserialised
--   <a>ProgramDb</a> use this function to add back all the known
--   <a>Program</a>s.
--   
--   <ul>
--   <li>It does not add the default programs, but you probably want them,
--   use <a>builtinPrograms</a> in addition to any extra you might
--   need.</li>
--   </ul>
restoreProgramDb :: [Program] -> ProgramDb -> ProgramDb

-- | Add a known program that we may configure later
addKnownProgram :: Program -> ProgramDb -> ProgramDb
addKnownPrograms :: [Program] -> ProgramDb -> ProgramDb
lookupKnownProgram :: String -> ProgramDb -> Maybe Program
knownPrograms :: ProgramDb -> [(Program, Maybe ConfiguredProgram)]

-- | User-specify this path. Basically override any path information for
--   this program in the configuration. If it's not a known program ignore
--   it.
userSpecifyPath :: String -> FilePath -> ProgramDb -> ProgramDb

-- | Like <a>userSpecifyPath</a> but for a list of progs and their paths.
userSpecifyPaths :: [(String, FilePath)] -> ProgramDb -> ProgramDb
userMaybeSpecifyPath :: String -> Maybe FilePath -> ProgramDb -> ProgramDb

-- | User-specify the arguments for this program. Basically override any
--   args information for this program in the configuration. If it's not a
--   known program, ignore it..
userSpecifyArgs :: String -> [ProgArg] -> ProgramDb -> ProgramDb

-- | Like <a>userSpecifyPath</a> but for a list of progs and their args.
userSpecifyArgss :: [(String, [ProgArg])] -> ProgramDb -> ProgramDb

-- | Get any extra args that have been previously specified for a program.
userSpecifiedArgs :: Program -> ProgramDb -> [ProgArg]

-- | Try to find a configured program
lookupProgram :: Program -> ProgramDb -> Maybe ConfiguredProgram

-- | Update a configured program in the database.
updateProgram :: ConfiguredProgram -> ProgramDb -> ProgramDb

-- | Try to configure a specific program. If the program is already
--   included in the colleciton of unconfigured programs then we use any
--   user-supplied location and arguments. If the program gets configured
--   sucessfully it gets added to the configured collection.
--   
--   Note that it is not a failure if the program cannot be configured.
--   It's only a failure if the user supplied a location and the program
--   could not be found at that location.
--   
--   The reason for it not being a failure at this stage is that we don't
--   know up front all the programs we will need, so we try to configure
--   them all. To verify that a program was actually sucessfully configured
--   use <a>requireProgram</a>.
configureProgram :: Verbosity -> Program -> ProgramDb -> IO ProgramDb

-- | Try to configure all the known programs that have not yet been
--   configured.
configureAllKnownPrograms :: Verbosity -> ProgramDb -> IO ProgramDb

-- | reconfigure a bunch of programs given new user-specified args. It
--   takes the same inputs as <a>userSpecifyPath</a> and
--   <a>userSpecifyArgs</a> and for all progs with a new path it calls
--   <a>configureProgram</a>.
reconfigurePrograms :: Verbosity -> [(String, FilePath)] -> [(String, [ProgArg])] -> ProgramDb -> IO ProgramDb

-- | Check that a program is configured and available to be run.
--   
--   It raises an exception if the program could not be configured,
--   otherwise it returns the configured program.
requireProgram :: Verbosity -> Program -> ProgramDb -> IO (ConfiguredProgram, ProgramDb)

-- | Check that a program is configured and available to be run.
--   
--   Additionally check that the version of the program number is suitable
--   and return it. For example you could require <tt>AnyVersion</tt> or
--   <tt><tt>orLaterVersion</tt> (<a>Version</a> [1,0] [])</tt>
--   
--   It raises an exception if the program could not be configured or the
--   version is unsuitable, otherwise it returns the configured program and
--   its version number.
requireProgramVersion :: Verbosity -> Program -> VersionRange -> ProgramDb -> IO (ConfiguredProgram, Version, ProgramDb)
instance Read ProgramDb
instance Show ProgramDb


-- | This provides an abstraction which deals with configuring and running
--   programs. A <a>Program</a> is a static notion of a known program. A
--   <a>ConfiguredProgram</a> is a <a>Program</a> that has been found on
--   the current machine and is ready to be run (possibly with some
--   user-supplied default args). Configuring a program involves finding
--   its location and if necessary finding its version. There is also a
--   <a>ProgramConfiguration</a> type which holds configured and not-yet
--   configured programs. It is the parameter to lots of actions elsewhere
--   in Cabal that need to look up and run programs. If we had a Cabal
--   monad, the <a>ProgramConfiguration</a> would probably be a reader or
--   state component of it.
--   
--   The module also defines all the known built-in <a>Program</a>s and the
--   <a>defaultProgramConfiguration</a> which contains them all.
--   
--   One nice thing about using it is that any program that is registered
--   with Cabal will get some "configure" and ".cabal" helpers like
--   --with-foo-args --foo-path= and extra-foo-args.
--   
--   There's also good default behavior for trying to find "foo" in PATH,
--   being able to override its location, etc.
--   
--   There's also a hook for adding programs in a Setup.lhs script. See
--   hookedPrograms in <a>UserHooks</a>. This gives a hook user the ability
--   to get the above flags and such so that they don't have to write all
--   the PATH logic inside Setup.lhs.
module Distribution.Simple.Program

-- | Represents a program which can be configured.
--   
--   Note: rather than constructing this directly, start with
--   <a>simpleProgram</a> and override any extra fields.
data Program
Program :: String -> (Verbosity -> IO (Maybe FilePath)) -> (Verbosity -> FilePath -> IO (Maybe Version)) -> (Verbosity -> ConfiguredProgram -> IO [ProgArg]) -> Program

-- | The simple name of the program, eg. ghc
programName :: Program -> String

-- | A function to search for the program if it's location was not
--   specified by the user. Usually this will just be a
programFindLocation :: Program -> Verbosity -> IO (Maybe FilePath)

-- | Try to find the version of the program. For many programs this is not
--   possible or is not necessary so it's ok to return Nothing.
programFindVersion :: Program -> Verbosity -> FilePath -> IO (Maybe Version)

-- | A function to do any additional configuration after we have located
--   the program (and perhaps identified its version). It is allowed to
--   return additional flags that will be passed to the program on every
--   invocation.
programPostConf :: Program -> Verbosity -> ConfiguredProgram -> IO [ProgArg]

-- | Make a simple named program.
--   
--   By default we'll just search for it in the path and not try to find
--   the version name. You can override these behaviours if necessary, eg:
--   
--   <pre>
--   simpleProgram "foo" { programFindLocation = ... , programFindVersion ... }
--   </pre>
simpleProgram :: String -> Program

-- | Look for a program on the path.
findProgramLocation :: Verbosity -> FilePath -> IO (Maybe FilePath)

-- | Look for a program and try to find it's version number. It can accept
--   either an absolute path or the name of a program binary, in which case
--   we will look for the program on the path.
findProgramVersion :: String -> (String -> String) -> Verbosity -> FilePath -> IO (Maybe Version)

-- | Represents a program which has been configured and is thus ready to be
--   run.
--   
--   These are usually made by configuring a <a>Program</a>, but if you
--   have to construct one directly then start with
--   <a>simpleConfiguredProgram</a> and override any extra fields.
data ConfiguredProgram
ConfiguredProgram :: String -> Maybe Version -> [String] -> [String] -> ProgramLocation -> ConfiguredProgram

-- | Just the name again
programId :: ConfiguredProgram -> String

-- | The version of this program, if it is known.
programVersion :: ConfiguredProgram -> Maybe Version

-- | Default command-line args for this program. These flags will appear
--   first on the command line, so they can be overridden by subsequent
--   flags.
programDefaultArgs :: ConfiguredProgram -> [String]

-- | Override command-line args for this program. These flags will appear
--   last on the command line, so they override all earlier flags.
programOverrideArgs :: ConfiguredProgram -> [String]

-- | Location of the program. eg. <tt>/usr/bin/ghc-6.4</tt>
programLocation :: ConfiguredProgram -> ProgramLocation

-- | The full path of a configured program.
programPath :: ConfiguredProgram -> FilePath
type ProgArg = String

-- | Where a program was found. Also tells us whether it's specifed by user
--   or not. This includes not just the path, but the program as well.
data ProgramLocation

-- | The user gave the path to this program, eg.
--   --ghc-path=/usr/bin/ghc-6.6
UserSpecified :: FilePath -> ProgramLocation
locationPath :: ProgramLocation -> FilePath

-- | The program was found automatically.
FoundOnSystem :: FilePath -> ProgramLocation
locationPath :: ProgramLocation -> FilePath

-- | Runs the given configured program.
runProgram :: Verbosity -> ConfiguredProgram -> [ProgArg] -> IO ()

-- | Runs the given configured program and gets the output.
getProgramOutput :: Verbosity -> ConfiguredProgram -> [ProgArg] -> IO String

-- | Represents a specific invocation of a specific program.
--   
--   This is used as an intermediate type between deciding how to call a
--   program and actually doing it. This provides the opportunity to the
--   caller to adjust how the program will be called. These invocations can
--   either be run directly or turned into shell or batch scripts.
data ProgramInvocation
ProgramInvocation :: FilePath -> [String] -> [(String, String)] -> Maybe FilePath -> Maybe String -> IOEncoding -> IOEncoding -> ProgramInvocation
progInvokePath :: ProgramInvocation -> FilePath
progInvokeArgs :: ProgramInvocation -> [String]
progInvokeEnv :: ProgramInvocation -> [(String, String)]
progInvokeCwd :: ProgramInvocation -> Maybe FilePath
progInvokeInput :: ProgramInvocation -> Maybe String
progInvokeInputEncoding :: ProgramInvocation -> IOEncoding
progInvokeOutputEncoding :: ProgramInvocation -> IOEncoding
emptyProgramInvocation :: ProgramInvocation
simpleProgramInvocation :: FilePath -> [String] -> ProgramInvocation
programInvocation :: ConfiguredProgram -> [String] -> ProgramInvocation
runProgramInvocation :: Verbosity -> ProgramInvocation -> IO ()
getProgramInvocationOutput :: Verbosity -> ProgramInvocation -> IO String

-- | The default list of programs. These programs are typically used
--   internally to Cabal.
builtinPrograms :: [Program]
type ProgramConfiguration = ProgramDb
emptyProgramConfiguration :: ProgramConfiguration
defaultProgramConfiguration :: ProgramConfiguration
restoreProgramConfiguration :: [Program] -> ProgramConfiguration -> ProgramConfiguration

-- | Add a known program that we may configure later
addKnownProgram :: Program -> ProgramDb -> ProgramDb
addKnownPrograms :: [Program] -> ProgramDb -> ProgramDb
lookupKnownProgram :: String -> ProgramDb -> Maybe Program
knownPrograms :: ProgramDb -> [(Program, Maybe ConfiguredProgram)]

-- | User-specify this path. Basically override any path information for
--   this program in the configuration. If it's not a known program ignore
--   it.
userSpecifyPath :: String -> FilePath -> ProgramDb -> ProgramDb

-- | Like <a>userSpecifyPath</a> but for a list of progs and their paths.
userSpecifyPaths :: [(String, FilePath)] -> ProgramDb -> ProgramDb
userMaybeSpecifyPath :: String -> Maybe FilePath -> ProgramDb -> ProgramDb

-- | User-specify the arguments for this program. Basically override any
--   args information for this program in the configuration. If it's not a
--   known program, ignore it..
userSpecifyArgs :: String -> [ProgArg] -> ProgramDb -> ProgramDb

-- | Like <a>userSpecifyPath</a> but for a list of progs and their args.
userSpecifyArgss :: [(String, [ProgArg])] -> ProgramDb -> ProgramDb

-- | Get any extra args that have been previously specified for a program.
userSpecifiedArgs :: Program -> ProgramDb -> [ProgArg]

-- | Try to find a configured program
lookupProgram :: Program -> ProgramDb -> Maybe ConfiguredProgram

-- | Update a configured program in the database.
updateProgram :: ConfiguredProgram -> ProgramDb -> ProgramDb

-- | Try to configure a specific program. If the program is already
--   included in the colleciton of unconfigured programs then we use any
--   user-supplied location and arguments. If the program gets configured
--   sucessfully it gets added to the configured collection.
--   
--   Note that it is not a failure if the program cannot be configured.
--   It's only a failure if the user supplied a location and the program
--   could not be found at that location.
--   
--   The reason for it not being a failure at this stage is that we don't
--   know up front all the programs we will need, so we try to configure
--   them all. To verify that a program was actually sucessfully configured
--   use <a>requireProgram</a>.
configureProgram :: Verbosity -> Program -> ProgramDb -> IO ProgramDb

-- | Try to configure all the known programs that have not yet been
--   configured.
configureAllKnownPrograms :: Verbosity -> ProgramDb -> IO ProgramDb

-- | reconfigure a bunch of programs given new user-specified args. It
--   takes the same inputs as <a>userSpecifyPath</a> and
--   <a>userSpecifyArgs</a> and for all progs with a new path it calls
--   <a>configureProgram</a>.
reconfigurePrograms :: Verbosity -> [(String, FilePath)] -> [(String, [ProgArg])] -> ProgramDb -> IO ProgramDb

-- | Check that a program is configured and available to be run.
--   
--   It raises an exception if the program could not be configured,
--   otherwise it returns the configured program.
requireProgram :: Verbosity -> Program -> ProgramDb -> IO (ConfiguredProgram, ProgramDb)

-- | Check that a program is configured and available to be run.
--   
--   Additionally check that the version of the program number is suitable
--   and return it. For example you could require <tt>AnyVersion</tt> or
--   <tt><tt>orLaterVersion</tt> (<a>Version</a> [1,0] [])</tt>
--   
--   It raises an exception if the program could not be configured or the
--   version is unsuitable, otherwise it returns the configured program and
--   its version number.
requireProgramVersion :: Verbosity -> Program -> VersionRange -> ProgramDb -> IO (ConfiguredProgram, Version, ProgramDb)

-- | Looks up the given program in the program database and runs it.
runDbProgram :: Verbosity -> Program -> ProgramDb -> [ProgArg] -> IO ()

-- | Looks up the given program in the program database and runs it.
getDbProgramOutput :: Verbosity -> Program -> ProgramDb -> [ProgArg] -> IO String
ghcProgram :: Program
ghcPkgProgram :: Program
lhcProgram :: Program
lhcPkgProgram :: Program
nhcProgram :: Program
hmakeProgram :: Program
jhcProgram :: Program
hugsProgram :: Program
ffihugsProgram :: Program
uhcProgram :: Program
gccProgram :: Program
ranlibProgram :: Program
arProgram :: Program
stripProgram :: Program
happyProgram :: Program
alexProgram :: Program
hsc2hsProgram :: Program
c2hsProgram :: Program
cpphsProgram :: Program
hscolourProgram :: Program
haddockProgram :: Program
greencardProgram :: Program
ldProgram :: Program
tarProgram :: Program
cppProgram :: Program
pkgConfigProgram :: Program
hpcProgram :: Program
rawSystemProgram :: Verbosity -> ConfiguredProgram -> [ProgArg] -> IO ()
rawSystemProgramStdout :: Verbosity -> ConfiguredProgram -> [ProgArg] -> IO String
rawSystemProgramConf :: Verbosity -> Program -> ProgramConfiguration -> [ProgArg] -> IO ()
rawSystemProgramStdoutConf :: Verbosity -> Program -> ProgramConfiguration -> [ProgArg] -> IO String

-- | <i>Deprecated: use findProgramLocation instead </i>
findProgramOnPath :: String -> Verbosity -> IO (Maybe FilePath)


-- | This has an enumeration of the various compilers that Cabal knows
--   about. It also specifies the default compiler. Sadly you'll often see
--   code that does case analysis on this compiler flavour enumeration
--   like:
--   
--   <pre>
--   case compilerFlavor comp of
--     GHC -&gt; GHC.getInstalledPackages verbosity packageDb progconf
--     JHC -&gt; JHC.getInstalledPackages verbosity packageDb progconf
--   </pre>
--   
--   Obviously it would be better to use the proper <tt>Compiler</tt>
--   abstraction because that would keep all the compiler-specific code
--   together. Unfortunately we cannot make this change yet without
--   breaking the <tt>UserHooks</tt> api, which would break all custom
--   <tt>Setup.hs</tt> files, so for the moment we just have to live with
--   this deficiency. If you're interested, see ticket #50.
module Distribution.Compiler
data CompilerFlavor
GHC :: CompilerFlavor
NHC :: CompilerFlavor
YHC :: CompilerFlavor
Hugs :: CompilerFlavor
HBC :: CompilerFlavor
Helium :: CompilerFlavor
JHC :: CompilerFlavor
LHC :: CompilerFlavor
UHC :: CompilerFlavor
OtherCompiler :: String -> CompilerFlavor
buildCompilerFlavor :: CompilerFlavor

-- | The default compiler flavour to pick when compiling stuff. This
--   defaults to the compiler used to build the Cabal lib.
--   
--   However if it's not a recognised compiler then it's <a>Nothing</a> and
--   the user will have to specify which compiler they want.
defaultCompilerFlavor :: Maybe CompilerFlavor

-- | Like <a>classifyCompilerFlavor</a> but compatible with the old ReadS
--   parser.
--   
--   It is compatible in the sense that it accepts only the same strings,
--   eg <a>GHC</a> but not <a>ghc</a>. However other strings get mapped to
--   <a>OtherCompiler</a>. The point of this is that we do not allow extra
--   valid values that would upset older Cabal versions that had a stricter
--   parser however we cope with new values more gracefully so that we'll
--   be able to introduce new value in future without breaking things so
--   much.
parseCompilerFlavorCompat :: ReadP r CompilerFlavor
data CompilerId
CompilerId :: CompilerFlavor -> Version -> CompilerId
instance Show CompilerFlavor
instance Read CompilerFlavor
instance Eq CompilerFlavor
instance Ord CompilerFlavor
instance Eq CompilerId
instance Ord CompilerId
instance Read CompilerId
instance Show CompilerId
instance Text CompilerId
instance Text CompilerFlavor


-- | Utilities for parsing <tt>PackageDescription</tt> and
--   <tt>InstalledPackageInfo</tt>.
--   
--   The <tt>.cabal</tt> file format is not trivial, especially with the
--   introduction of configurations and the section syntax that goes with
--   that. This module has a bunch of parsing functions that is used by the
--   <tt>.cabal</tt> parser and a couple others. It has the parsing
--   framework code and also little parsers for many of the formats we get
--   in various <tt>.cabal</tt> file fields, like module names, comma
--   separated lists etc.
module Distribution.ParseUtils
type LineNo = Int
data PError
AmbigousParse :: String -> LineNo -> PError
NoParse :: String -> LineNo -> PError
TabsError :: LineNo -> PError
FromString :: String -> (Maybe LineNo) -> PError
data PWarning
PWarning :: String -> PWarning
UTFWarning :: LineNo -> String -> PWarning
locatedErrorMsg :: PError -> (Maybe LineNo, String)
syntaxError :: LineNo -> String -> ParseResult a
warning :: String -> ParseResult ()
runP :: LineNo -> String -> ReadP a a -> String -> ParseResult a
runE :: LineNo -> String -> ReadE a -> String -> ParseResult a
data ParseResult a
ParseFailed :: PError -> ParseResult a
ParseOk :: [PWarning] -> a -> ParseResult a
catchParseError :: ParseResult a -> (PError -> ParseResult a) -> ParseResult a
parseFail :: PError -> ParseResult a
showPWarning :: FilePath -> PWarning -> String
data Field

-- | A regular <tt><a>property</a>: <a>value</a></tt> field
F :: LineNo -> String -> String -> Field

-- | A section with a name and possible parameter. The syntactic structure
--   is:
--   
--   <pre>
--   <a>sectionname</a> <a>arg</a> {
--     <a>field</a>*
--   }
--   </pre>
Section :: LineNo -> String -> String -> [Field] -> Field

-- | A conditional block with an optional else branch:
--   
--   <pre>
--   if <a>condition</a> {
--     <a>field</a>*
--   } else {
--     <a>field</a>*
--   }
--   </pre>
IfBlock :: LineNo -> String -> [Field] -> [Field] -> Field
fName :: Field -> String
lineNo :: Field -> LineNo

-- | Field descriptor. The parameter <tt>a</tt> parameterizes over where
--   the field's value is stored in.
data FieldDescr a
FieldDescr :: String -> (a -> Doc) -> (LineNo -> String -> a -> ParseResult a) -> FieldDescr a
fieldName :: FieldDescr a -> String
fieldGet :: FieldDescr a -> a -> Doc

-- | <tt>fieldSet n str x</tt> Parses the field value from the given input
--   string <tt>str</tt> and stores the result in <tt>x</tt> if the parse
--   was successful. Otherwise, reports an error on line number <tt>n</tt>.
fieldSet :: FieldDescr a -> LineNo -> String -> a -> ParseResult a
ppField :: String -> Doc -> Doc
ppFields :: [FieldDescr a] -> a -> Doc
readFields :: String -> ParseResult [Field]
readFieldsFlat :: String -> ParseResult [Field]
showFields :: [FieldDescr a] -> a -> String
showSingleNamedField :: [FieldDescr a] -> String -> Maybe (a -> String)
parseFields :: [FieldDescr a] -> a -> String -> ParseResult a
parseFieldsFlat :: [FieldDescr a] -> a -> String -> ParseResult a
parseFilePathQ :: ReadP r FilePath
parseTokenQ :: ReadP r String
parseTokenQ' :: ReadP r String

-- | parse a module name
parseModuleNameQ :: ReadP r ModuleName
parseBuildTool :: ReadP r Dependency
parsePkgconfigDependency :: ReadP r Dependency
parseOptVersion :: ReadP r Version
parsePackageNameQ :: ReadP r PackageName
parseVersionRangeQ :: ReadP r VersionRange
parseTestedWithQ :: ReadP r (CompilerFlavor, VersionRange)
parseLicenseQ :: ReadP r License
parseLanguageQ :: ReadP r Language
parseExtensionQ :: ReadP r Extension
parseSepList :: ReadP r b -> ReadP r a -> ReadP r [a]
parseCommaList :: ReadP r a -> ReadP r [a]
parseOptCommaList :: ReadP r a -> ReadP r [a]
showFilePath :: FilePath -> Doc
showToken :: String -> Doc
showTestedWith :: (CompilerFlavor, VersionRange) -> Doc

-- | Pretty-print free-format text, ensuring that it is vertically aligned,
--   and with blank lines replaced by dots for correct re-parsing.
showFreeText :: String -> Doc
parseFreeText :: ReadP s String
field :: String -> (a -> Doc) -> (ReadP a a) -> FieldDescr a
simpleField :: String -> (a -> Doc) -> (ReadP a a) -> (b -> a) -> (a -> b -> b) -> FieldDescr b
listField :: String -> (a -> Doc) -> (ReadP [a] a) -> (b -> [a]) -> ([a] -> b -> b) -> FieldDescr b
spaceListField :: String -> (a -> Doc) -> (ReadP [a] a) -> (b -> [a]) -> ([a] -> b -> b) -> FieldDescr b
commaListField :: String -> (a -> Doc) -> (ReadP [a] a) -> (b -> [a]) -> ([a] -> b -> b) -> FieldDescr b
optsField :: String -> CompilerFlavor -> (b -> [(CompilerFlavor, [String])]) -> ([(CompilerFlavor, [String])] -> b -> b) -> FieldDescr b
liftField :: (b -> a) -> (a -> b -> b) -> FieldDescr a -> FieldDescr b
boolField :: String -> (b -> Bool) -> (Bool -> b -> b) -> FieldDescr b
parseQuoted :: ReadP r a -> ReadP r a

-- | The type of a function which, given a name-value pair of an
--   unrecognized field, and the current structure being built, decides
--   whether to incorporate the unrecognized field (by returning Just x,
--   where x is a possibly modified version of the structure being built),
--   or not (by returning Nothing).
type UnrecFieldParser a = (String, String) -> a -> Maybe a

-- | A default unrecognized field parser which simply returns Nothing, i.e.
--   ignores all unrecognized fields, so warnings will be generated.
warnUnrec :: UnrecFieldParser a

-- | A default unrecognized field parser which silently (i.e. no warnings
--   will be generated) ignores unrecognized fields, by returning the
--   structure being built unmodified.
ignoreUnrec :: UnrecFieldParser a
instance Show PError
instance Show PWarning
instance Show a => Show (ParseResult a)
instance Show Field
instance Eq Field
instance Monad ParseResult


-- | This is the information about an <i>installed</i> package that is
--   communicated to the <tt>ghc-pkg</tt> program in order to register a
--   package. <tt>ghc-pkg</tt> now consumes this package format (as of
--   version 6.4). This is specific to GHC at the moment.
--   
--   The <tt>.cabal</tt> file format is for describing a package that is
--   not yet installed. It has a lot of flexibility, like conditionals and
--   dependency ranges. As such, that format is not at all suitable for
--   describing a package that has already been built and installed. By the
--   time we get to that stage, we have resolved all conditionals and
--   resolved dependency version constraints to exact versions of dependent
--   packages. So, this module defines the <a>InstalledPackageInfo</a> data
--   structure that contains all the info we keep about an installed
--   package. There is a parser and pretty printer. The textual format is
--   rather simpler than the <tt>.cabal</tt> format: there are no sections,
--   for example.
module Distribution.InstalledPackageInfo
data InstalledPackageInfo_ m
InstalledPackageInfo :: InstalledPackageId -> PackageId -> License -> String -> String -> String -> String -> String -> String -> String -> String -> String -> Bool -> [m] -> [m] -> Bool -> [FilePath] -> [FilePath] -> [String] -> [String] -> [String] -> [FilePath] -> [String] -> [InstalledPackageId] -> [String] -> [String] -> [String] -> [FilePath] -> [String] -> [FilePath] -> [FilePath] -> InstalledPackageInfo_ m
installedPackageId :: InstalledPackageInfo_ m -> InstalledPackageId
sourcePackageId :: InstalledPackageInfo_ m -> PackageId
license :: InstalledPackageInfo_ m -> License
copyright :: InstalledPackageInfo_ m -> String
maintainer :: InstalledPackageInfo_ m -> String
author :: InstalledPackageInfo_ m -> String
stability :: InstalledPackageInfo_ m -> String
homepage :: InstalledPackageInfo_ m -> String
pkgUrl :: InstalledPackageInfo_ m -> String
synopsis :: InstalledPackageInfo_ m -> String
description :: InstalledPackageInfo_ m -> String
category :: InstalledPackageInfo_ m -> String
exposed :: InstalledPackageInfo_ m -> Bool
exposedModules :: InstalledPackageInfo_ m -> [m]
hiddenModules :: InstalledPackageInfo_ m -> [m]
trusted :: InstalledPackageInfo_ m -> Bool
importDirs :: InstalledPackageInfo_ m -> [FilePath]
libraryDirs :: InstalledPackageInfo_ m -> [FilePath]
hsLibraries :: InstalledPackageInfo_ m -> [String]
extraLibraries :: InstalledPackageInfo_ m -> [String]
extraGHCiLibraries :: InstalledPackageInfo_ m -> [String]
includeDirs :: InstalledPackageInfo_ m -> [FilePath]
includes :: InstalledPackageInfo_ m -> [String]
depends :: InstalledPackageInfo_ m -> [InstalledPackageId]
hugsOptions :: InstalledPackageInfo_ m -> [String]
ccOptions :: InstalledPackageInfo_ m -> [String]
ldOptions :: InstalledPackageInfo_ m -> [String]
frameworkDirs :: InstalledPackageInfo_ m -> [FilePath]
frameworks :: InstalledPackageInfo_ m -> [String]
haddockInterfaces :: InstalledPackageInfo_ m -> [FilePath]
haddockHTMLs :: InstalledPackageInfo_ m -> [FilePath]
type InstalledPackageInfo = InstalledPackageInfo_ ModuleName
data ParseResult a
ParseFailed :: PError -> ParseResult a
ParseOk :: [PWarning] -> a -> ParseResult a
data PError
AmbigousParse :: String -> LineNo -> PError
NoParse :: String -> LineNo -> PError
TabsError :: LineNo -> PError
FromString :: String -> (Maybe LineNo) -> PError
data PWarning
emptyInstalledPackageInfo :: InstalledPackageInfo_ m
parseInstalledPackageInfo :: String -> ParseResult InstalledPackageInfo
showInstalledPackageInfo :: InstalledPackageInfo -> String
showInstalledPackageInfoField :: String -> Maybe (InstalledPackageInfo -> String)
fieldsInstalledPackageInfo :: [FieldDescr InstalledPackageInfo]
instance Read m => Read (InstalledPackageInfo_ m)
instance Show m => Show (InstalledPackageInfo_ m)
instance Package (InstalledPackageInfo_ str)


-- | An index of packages.
module Distribution.Simple.PackageIndex

-- | The collection of information about packages from one or more
--   <tt>PackageDB</tt>s.
--   
--   Packages are uniquely identified in by their
--   <a>InstalledPackageId</a>, they can also be effeciently looked up by
--   package name or by name and version.
data PackageIndex

-- | Build an index out of a bunch of packages.
--   
--   If there are duplicates by <a>InstalledPackageId</a> then later ones
--   mask earlier ones.
fromList :: [InstalledPackageInfo] -> PackageIndex

-- | Merge two indexes.
--   
--   Packages from the second mask packages from the first if they have the
--   exact same <a>InstalledPackageId</a>.
--   
--   For packages with the same source <a>PackageId</a>, packages from the
--   second are "preferred" over those from the first. Being preferred
--   means they are top result when we do a lookup by source
--   <a>PackageId</a>. This is the mechanism we use to prefer user packages
--   over global packages.
merge :: PackageIndex -> PackageIndex -> PackageIndex

-- | Inserts a single package into the index.
--   
--   This is equivalent to (but slightly quicker than) using <a>mappend</a>
--   or <a>merge</a> with a singleton index.
insert :: InstalledPackageInfo -> PackageIndex -> PackageIndex

-- | Removes a single installed package from the index.
deleteInstalledPackageId :: InstalledPackageId -> PackageIndex -> PackageIndex

-- | Removes all packages with this source <a>PackageId</a> from the index.
deleteSourcePackageId :: PackageId -> PackageIndex -> PackageIndex

-- | Removes all packages with this (case-sensitive) name from the index.
deletePackageName :: PackageName -> PackageIndex -> PackageIndex

-- | Does a lookup by source package id (name &amp; version).
--   
--   Since multiple package DBs mask each other by
--   <a>InstalledPackageId</a>, then we get back at most one package.
lookupInstalledPackageId :: PackageIndex -> InstalledPackageId -> Maybe InstalledPackageInfo

-- | Does a lookup by source package id (name &amp; version).
--   
--   There can be multiple installed packages with the same source
--   <a>PackageId</a> but different <a>InstalledPackageId</a>. They are
--   returned in order of preference, with the most preferred first.
lookupSourcePackageId :: PackageIndex -> PackageId -> [InstalledPackageInfo]

-- | Does a lookup by source package name.
lookupPackageName :: PackageIndex -> PackageName -> [(Version, [InstalledPackageInfo])]

-- | Does a lookup by source package name and a range of versions.
--   
--   We get back any number of versions of the specified package name, all
--   satisfying the version range constraint.
lookupDependency :: PackageIndex -> Dependency -> [(Version, [InstalledPackageInfo])]

-- | Does a case-insensitive search by package name.
--   
--   If there is only one package that compares case-insentiviely to this
--   name then the search is unambiguous and we get back all versions of
--   that package. If several match case-insentiviely but one matches
--   exactly then it is also unambiguous.
--   
--   If however several match case-insentiviely and none match exactly then
--   we have an ambiguous result, and we get back all the versions of all
--   the packages. The list of ambiguous results is split by exact package
--   name. So it is a non-empty list of non-empty lists.
searchByName :: PackageIndex -> String -> SearchResult [InstalledPackageInfo]
data SearchResult a
None :: SearchResult a
Unambiguous :: a -> SearchResult a
Ambiguous :: [a] -> SearchResult a

-- | Does a case-insensitive substring search by package name.
--   
--   That is, all packages that contain the given string in their name.
searchByNameSubstring :: PackageIndex -> String -> [InstalledPackageInfo]

-- | Get all the packages from the index.
allPackages :: PackageIndex -> [InstalledPackageInfo]

-- | Get all the packages from the index.
--   
--   They are grouped by package name (case-sensitively).
allPackagesByName :: PackageIndex -> [(PackageName, [InstalledPackageInfo])]

-- | Get all the packages from the index.
--   
--   They are grouped by source package id (package name and version).
allPackagesBySourcePackageId :: PackageIndex -> [(PackageId, [InstalledPackageInfo])]

-- | All packages that have immediate dependencies that are not in the
--   index.
--   
--   Returns such packages along with the dependencies that they're
--   missing.
brokenPackages :: PackageIndex -> [(InstalledPackageInfo, [InstalledPackageId])]

-- | Tries to take the transitive closure of the package dependencies.
--   
--   If the transitive closure is complete then it returns that subset of
--   the index. Otherwise it returns the broken packages as in
--   <a>brokenPackages</a>.
--   
--   <ul>
--   <li>Note that if the result is <tt>Right []</tt> it is because at
--   least one of the original given <a>PackageId</a>s do not occur in the
--   index.</li>
--   </ul>
dependencyClosure :: PackageIndex -> [InstalledPackageId] -> Either PackageIndex [(InstalledPackageInfo, [InstalledPackageId])]

-- | Takes the transitive closure of the packages reverse dependencies.
--   
--   <ul>
--   <li>The given <a>PackageId</a>s must be in the index.</li>
--   </ul>
reverseDependencyClosure :: PackageIndex -> [InstalledPackageId] -> [InstalledPackageInfo]
topologicalOrder :: PackageIndex -> [InstalledPackageInfo]
reverseTopologicalOrder :: PackageIndex -> [InstalledPackageInfo]

-- | Given a package index where we assume we want to use all the packages
--   (use <a>dependencyClosure</a> if you need to get such a index subset)
--   find out if the dependencies within it use consistent versions of each
--   package. Return all cases where multiple packages depend on different
--   versions of some other package.
--   
--   Each element in the result is a package name along with the packages
--   that depend on it and the versions they require. These are guaranteed
--   to be distinct.
dependencyInconsistencies :: PackageIndex -> [(PackageName, [(PackageId, Version)])]

-- | Find if there are any cycles in the dependency graph. If there are no
--   cycles the result is <tt>[]</tt>.
--   
--   This actually computes the strongly connected components. So it gives
--   us a list of groups of packages where within each group they all
--   depend on each other, directly or indirectly.
dependencyCycles :: PackageIndex -> [[InstalledPackageInfo]]

-- | Builds a graph of the package dependencies.
--   
--   Dependencies on other packages that are not in the index are
--   discarded. You can check if there are any such dependencies with
--   <a>brokenPackages</a>.
dependencyGraph :: PackageIndex -> (Graph, Vertex -> InstalledPackageInfo, InstalledPackageId -> Maybe Vertex)
moduleNameIndex :: PackageIndex -> Map ModuleName [InstalledPackageInfo]
instance Show PackageIndex
instance Read PackageIndex
instance Monoid PackageIndex


-- | This is to do with command line handling. The Cabal command line is
--   organised into a number of named sub-commands (much like darcs). The
--   <a>CommandUI</a> abstraction represents one of these sub-commands,
--   with a name, description, a set of flags. Commands can be associated
--   with actions and run. It handles some common stuff automatically, like
--   the <tt>--help</tt> and command line completion flags. It is designed
--   to allow other tools make derived commands. This feature is used
--   heavily in <tt>cabal-install</tt>.
module Distribution.Simple.Command
data CommandUI flags
CommandUI :: String -> String -> (String -> String) -> Maybe (String -> String) -> flags -> (ShowOrParseArgs -> [OptionField flags]) -> CommandUI flags

-- | The name of the command as it would be entered on the command line.
--   For example <tt>"build"</tt>.
commandName :: CommandUI flags -> String

-- | A short, one line description of the command to use in help texts.
commandSynopsis :: CommandUI flags -> String

-- | The useage line summary for this command
commandUsage :: CommandUI flags -> String -> String

-- | Additional explanation of the command to use in help texts.
commandDescription :: CommandUI flags -> Maybe (String -> String)

-- | Initial / empty flags
commandDefaultFlags :: CommandUI flags -> flags

-- | All the Option fields for this command
commandOptions :: CommandUI flags -> ShowOrParseArgs -> [OptionField flags]

-- | Show flags in the standard long option command line format
commandShowOptions :: CommandUI flags -> flags -> [String]
data CommandParse flags
CommandHelp :: (String -> String) -> CommandParse flags
CommandList :: [String] -> CommandParse flags
CommandErrors :: [String] -> CommandParse flags
CommandReadyToGo :: flags -> CommandParse flags

-- | Parse a bunch of command line arguments
commandParseArgs :: CommandUI flags -> Bool -> [String] -> CommandParse (flags -> flags, [String])
data ShowOrParseArgs
ShowArgs :: ShowOrParseArgs
ParseArgs :: ShowOrParseArgs

-- | Make a Command from standard <tt>GetOpt</tt> options.
makeCommand :: String -> String -> Maybe (String -> String) -> flags -> (ShowOrParseArgs -> [OptionField flags]) -> CommandUI flags
data Command action
commandAddAction :: CommandUI flags -> (flags -> [String] -> action) -> Command action

-- | Utility function, many commands do not accept additional flags. This
--   action fails with a helpful error message if the user supplies any
--   extra.
noExtraFlags :: [String] -> IO ()
commandsRun :: CommandUI a -> [Command action] -> [String] -> CommandParse (a, CommandParse action)

-- | We usually have a datatype for storing configuration values, where
--   every field stores a configuration option, and the user sets the value
--   either via command line flags or a configuration file. An individual
--   OptionField models such a field, and we usually build a list of
--   options associated to a configuration datatype.
data OptionField a
OptionField :: Name -> [OptDescr a] -> OptionField a
optionName :: OptionField a -> Name
optionDescr :: OptionField a -> [OptDescr a]
type Name = String

-- | Create an option taking a single OptDescr. No explicit Name is given
--   for the Option, the name is the first LFlag given.
option :: SFlags -> LFlags -> Description -> get -> set -> MkOptDescr get set a -> OptionField a

-- | Create an option taking several OptDescrs. You will have to give the
--   flags and description individually to the OptDescr constructor.
multiOption :: Name -> get -> set -> [get -> set -> OptDescr a] -> OptionField a
liftOption :: (b -> a) -> (a -> (b -> b)) -> OptionField a -> OptionField b

-- | to view as a FieldDescr, we sort the list of interfaces (Req &gt; Bool
--   &gt; Choice &gt; Opt) and consider only the first one.
viewAsFieldDescr :: OptionField a -> FieldDescr a

-- | An OptionField takes one or more OptDescrs, describing the command
--   line interface for the field.
data OptDescr a
ReqArg :: Description -> OptFlags -> ArgPlaceHolder -> (ReadE (a -> a)) -> (a -> [String]) -> OptDescr a
OptArg :: Description -> OptFlags -> ArgPlaceHolder -> (ReadE (a -> a)) -> (a -> a) -> (a -> [Maybe String]) -> OptDescr a
ChoiceOpt :: [(Description, OptFlags, a -> a, a -> Bool)] -> OptDescr a
BoolOpt :: Description -> OptFlags -> OptFlags -> (Bool -> a -> a) -> (a -> Maybe Bool) -> OptDescr a
type Description = String

-- | Short command line option strings
type SFlags = [Char]

-- | Long command line option strings
type LFlags = [String]
type OptFlags = (SFlags, LFlags)
type ArgPlaceHolder = String
type MkOptDescr get set a = SFlags -> LFlags -> Description -> get -> set -> OptDescr a

-- | Create a string-valued command line interface.
reqArg :: Monoid b => ArgPlaceHolder -> ReadE b -> (b -> [String]) -> MkOptDescr (a -> b) (b -> a -> a) a

-- | (String -&gt; a) variant of <a>reqArg</a>
reqArg' :: Monoid b => ArgPlaceHolder -> (String -> b) -> (b -> [String]) -> MkOptDescr (a -> b) (b -> a -> a) a

-- | Create a string-valued command line interface with a default value.
optArg :: Monoid b => ArgPlaceHolder -> ReadE b -> b -> (b -> [Maybe String]) -> MkOptDescr (a -> b) (b -> a -> a) a

-- | (String -&gt; a) variant of <a>optArg</a>
optArg' :: Monoid b => ArgPlaceHolder -> (Maybe String -> b) -> (b -> [Maybe String]) -> MkOptDescr (a -> b) (b -> a -> a) a
noArg :: (Eq b, Monoid b) => b -> MkOptDescr (a -> b) (b -> a -> a) a
boolOpt :: (b -> Maybe Bool) -> (Bool -> b) -> SFlags -> SFlags -> MkOptDescr (a -> b) (b -> a -> a) a
boolOpt' :: (b -> Maybe Bool) -> (Bool -> b) -> OptFlags -> OptFlags -> MkOptDescr (a -> b) (b -> a -> a) a

-- | create a Choice option
choiceOpt :: Eq b => [(b, OptFlags, Description)] -> MkOptDescr (a -> b) (b -> a -> a) a

-- | create a Choice option out of an enumeration type. As long flags, the
--   Show output is used. As short flags, the first character which does
--   not conflict with a previous one is used.
choiceOptFromEnum :: (Bounded b, Enum b, Show b, Eq b) => MkOptDescr (a -> b) (b -> a -> a) a
instance Functor CommandParse


-- | This defines the data structure for the <tt>.cabal</tt> file format.
--   There are several parts to this structure. It has top level info and
--   then <a>Library</a>, <a>Executable</a>, <a>TestSuite</a>, and
--   <a>Benchmark</a> sections each of which have associated
--   <a>BuildInfo</a> data that's used to build the library, exe, test, or
--   benchmark. To further complicate things there is both a
--   <a>PackageDescription</a> and a <a>GenericPackageDescription</a>. This
--   distinction relates to cabal configurations. When we initially read a
--   <tt>.cabal</tt> file we get a <a>GenericPackageDescription</a> which
--   has all the conditional sections. Before actually building a package
--   we have to decide on each conditional. Once we've done that we get a
--   <a>PackageDescription</a>. It was done this way initially to avoid
--   breaking too much stuff when the feature was introduced. It could
--   probably do with being rationalised at some point to make it simpler.
module Distribution.PackageDescription

-- | This data type is the internal representation of the file
--   <tt>pkg.cabal</tt>. It contains two kinds of information about the
--   package: information which is needed for all packages, such as the
--   package name and version, and information which is needed for the
--   simple build system only, such as the compiler options and library
--   name.
data PackageDescription
PackageDescription :: PackageIdentifier -> License -> FilePath -> String -> String -> String -> String -> [(CompilerFlavor, VersionRange)] -> String -> String -> String -> [SourceRepo] -> String -> String -> String -> [(String, String)] -> [Dependency] -> Either Version VersionRange -> Maybe BuildType -> Maybe Library -> [Executable] -> [TestSuite] -> [Benchmark] -> [FilePath] -> FilePath -> [FilePath] -> [FilePath] -> PackageDescription
package :: PackageDescription -> PackageIdentifier
license :: PackageDescription -> License
licenseFile :: PackageDescription -> FilePath
copyright :: PackageDescription -> String
maintainer :: PackageDescription -> String
author :: PackageDescription -> String
stability :: PackageDescription -> String
testedWith :: PackageDescription -> [(CompilerFlavor, VersionRange)]
homepage :: PackageDescription -> String
pkgUrl :: PackageDescription -> String
bugReports :: PackageDescription -> String
sourceRepos :: PackageDescription -> [SourceRepo]

-- | A one-line summary of this package
synopsis :: PackageDescription -> String

-- | A more verbose description of this package
description :: PackageDescription -> String
category :: PackageDescription -> String

-- | Custom fields starting with x-, stored in a simple assoc-list.
customFieldsPD :: PackageDescription -> [(String, String)]
buildDepends :: PackageDescription -> [Dependency]

-- | The version of the Cabal spec that this package description uses. For
--   historical reasons this is specified with a version range but only
--   ranges of the form <tt>&gt;= v</tt> make sense. We are in the process
--   of transitioning to specifying just a single version, not a range.
specVersionRaw :: PackageDescription -> Either Version VersionRange
buildType :: PackageDescription -> Maybe BuildType
library :: PackageDescription -> Maybe Library
executables :: PackageDescription -> [Executable]
testSuites :: PackageDescription -> [TestSuite]
benchmarks :: PackageDescription -> [Benchmark]
dataFiles :: PackageDescription -> [FilePath]
dataDir :: PackageDescription -> FilePath
extraSrcFiles :: PackageDescription -> [FilePath]
extraTmpFiles :: PackageDescription -> [FilePath]
emptyPackageDescription :: PackageDescription

-- | The version of the Cabal spec that this package should be interpreted
--   against.
--   
--   Historically we used a version range but we are switching to using a
--   single version. Currently we accept either. This function converts
--   into a single version by ignoring upper bounds in the version range.
specVersion :: PackageDescription -> Version

-- | The range of versions of the Cabal tools that this package is intended
--   to work with.
--   
--   This function is deprecated and should not be used for new purposes,
--   only to support old packages that rely on the old interpretation.

-- | <i>Deprecated: Use specVersion instead </i>
descCabalVersion :: PackageDescription -> VersionRange

-- | The type of build system used by this package.
data BuildType

-- | calls <tt>Distribution.Simple.defaultMain</tt>
Simple :: BuildType

-- | calls <tt>Distribution.Simple.defaultMainWithHooks
--   defaultUserHooks</tt>, which invokes <tt>configure</tt> to generate
--   additional build information used by later phases.
Configure :: BuildType

-- | calls <tt>Distribution.Make.defaultMain</tt>
Make :: BuildType

-- | uses user-supplied <tt>Setup.hs</tt> or <tt>Setup.lhs</tt> (default)
Custom :: BuildType

-- | a package that uses an unknown build type cannot actually be built.
--   Doing it this way rather than just giving a parse error means we get
--   better error messages and allows you to inspect the rest of the
--   package description.
UnknownBuildType :: String -> BuildType
knownBuildTypes :: [BuildType]
data Library
Library :: [ModuleName] -> Bool -> BuildInfo -> Library
exposedModules :: Library -> [ModuleName]

-- | Is the lib to be exposed by default?
libExposed :: Library -> Bool
libBuildInfo :: Library -> BuildInfo
emptyLibrary :: Library

-- | If the package description has a library section, call the given
--   function with the library build info as argument.
withLib :: PackageDescription -> (Library -> IO ()) -> IO ()

-- | does this package have any libraries?
hasLibs :: PackageDescription -> Bool

-- | Get all the module names from the library (exposed and internal
--   modules)
libModules :: Library -> [ModuleName]
data Executable
Executable :: String -> FilePath -> BuildInfo -> Executable
exeName :: Executable -> String
modulePath :: Executable -> FilePath
buildInfo :: Executable -> BuildInfo
emptyExecutable :: Executable

-- | Perform the action on each buildable <a>Executable</a> in the package
--   description.
withExe :: PackageDescription -> (Executable -> IO ()) -> IO ()

-- | does this package have any executables?
hasExes :: PackageDescription -> Bool

-- | Get all the module names from an exe
exeModules :: Executable -> [ModuleName]

-- | A "test-suite" stanza in a cabal file.
data TestSuite
TestSuite :: String -> TestSuiteInterface -> BuildInfo -> Bool -> TestSuite
testName :: TestSuite -> String
testInterface :: TestSuite -> TestSuiteInterface
testBuildInfo :: TestSuite -> BuildInfo
testEnabled :: TestSuite -> Bool

-- | The test suite interfaces that are currently defined. Each test suite
--   must specify which interface it supports.
--   
--   More interfaces may be defined in future, either new revisions or
--   totally new interfaces.
data TestSuiteInterface

-- | Test interface "exitcode-stdio-1.0". The test-suite takes the form of
--   an executable. It returns a zero exit code for success, non-zero for
--   failure. The stdout and stderr channels may be logged. It takes no
--   command line parameters and nothing on stdin.
TestSuiteExeV10 :: Version -> FilePath -> TestSuiteInterface

-- | Test interface "detailed-0.9". The test-suite takes the form of a
--   library containing a designated module that exports "tests :: [Test]".
TestSuiteLibV09 :: Version -> ModuleName -> TestSuiteInterface

-- | A test suite that does not conform to one of the above interfaces for
--   the given reason (e.g. unknown test type).
TestSuiteUnsupported :: TestType -> TestSuiteInterface

-- | The "test-type" field in the test suite stanza.
data TestType

-- | "type: exitcode-stdio-x.y"
TestTypeExe :: Version -> TestType

-- | "type: detailed-x.y"
TestTypeLib :: Version -> TestType

-- | Some unknown test type e.g. "type: foo"
TestTypeUnknown :: String -> Version -> TestType
testType :: TestSuite -> TestType
knownTestTypes :: [TestType]
emptyTestSuite :: TestSuite

-- | Does this package have any test suites?
hasTests :: PackageDescription -> Bool

-- | Perform an action on each buildable <a>TestSuite</a> in a package.
withTest :: PackageDescription -> (TestSuite -> IO ()) -> IO ()

-- | Get all the module names from a test suite.
testModules :: TestSuite -> [ModuleName]

-- | Get all the enabled test suites from a package.
enabledTests :: PackageDescription -> [TestSuite]

-- | A "benchmark" stanza in a cabal file.
data Benchmark
Benchmark :: String -> BenchmarkInterface -> BuildInfo -> Bool -> Benchmark
benchmarkName :: Benchmark -> String
benchmarkInterface :: Benchmark -> BenchmarkInterface
benchmarkBuildInfo :: Benchmark -> BuildInfo
benchmarkEnabled :: Benchmark -> Bool

-- | The benchmark interfaces that are currently defined. Each benchmark
--   must specify which interface it supports.
--   
--   More interfaces may be defined in future, either new revisions or
--   totally new interfaces.
data BenchmarkInterface

-- | Benchmark interface "exitcode-stdio-1.0". The benchmark takes the form
--   of an executable. It returns a zero exit code for success, non-zero
--   for failure. The stdout and stderr channels may be logged. It takes no
--   command line parameters and nothing on stdin.
BenchmarkExeV10 :: Version -> FilePath -> BenchmarkInterface

-- | A benchmark that does not conform to one of the above interfaces for
--   the given reason (e.g. unknown benchmark type).
BenchmarkUnsupported :: BenchmarkType -> BenchmarkInterface

-- | The "benchmark-type" field in the benchmark stanza.
data BenchmarkType

-- | "type: exitcode-stdio-x.y"
BenchmarkTypeExe :: Version -> BenchmarkType

-- | Some unknown benchmark type e.g. "type: foo"
BenchmarkTypeUnknown :: String -> Version -> BenchmarkType
benchmarkType :: Benchmark -> BenchmarkType
knownBenchmarkTypes :: [BenchmarkType]
emptyBenchmark :: Benchmark

-- | Does this package have any benchmarks?
hasBenchmarks :: PackageDescription -> Bool

-- | Perform an action on each buildable <a>Benchmark</a> in a package.
withBenchmark :: PackageDescription -> (Benchmark -> IO ()) -> IO ()

-- | Get all the module names from a benchmark.
benchmarkModules :: Benchmark -> [ModuleName]

-- | Get all the enabled benchmarks from a package.
enabledBenchmarks :: PackageDescription -> [Benchmark]
data BuildInfo
BuildInfo :: Bool -> [Dependency] -> [String] -> [String] -> [String] -> [Dependency] -> [String] -> [FilePath] -> [FilePath] -> [ModuleName] -> Maybe Language -> [Language] -> [Extension] -> [Extension] -> [Extension] -> [String] -> [String] -> [FilePath] -> [FilePath] -> [FilePath] -> [(CompilerFlavor, [String])] -> [String] -> [String] -> [(String, String)] -> [Dependency] -> BuildInfo

-- | component is buildable here
buildable :: BuildInfo -> Bool

-- | tools needed to build this bit
buildTools :: BuildInfo -> [Dependency]

-- | options for pre-processing Haskell code
cppOptions :: BuildInfo -> [String]

-- | options for C compiler
ccOptions :: BuildInfo -> [String]

-- | options for linker
ldOptions :: BuildInfo -> [String]

-- | pkg-config packages that are used
pkgconfigDepends :: BuildInfo -> [Dependency]

-- | support frameworks for Mac OS X
frameworks :: BuildInfo -> [String]
cSources :: BuildInfo -> [FilePath]

-- | where to look for the haskell module hierarchy
hsSourceDirs :: BuildInfo -> [FilePath]

-- | non-exposed or non-main modules
otherModules :: BuildInfo -> [ModuleName]

-- | language used when not explicitly specified
defaultLanguage :: BuildInfo -> Maybe Language

-- | other languages used within the package
otherLanguages :: BuildInfo -> [Language]

-- | language extensions used by all modules
defaultExtensions :: BuildInfo -> [Extension]

-- | other language extensions used within the package
otherExtensions :: BuildInfo -> [Extension]

-- | the old extensions field, treated same as <a>defaultExtensions</a>
oldExtensions :: BuildInfo -> [Extension]

-- | what libraries to link with when compiling a program that uses your
--   package
extraLibs :: BuildInfo -> [String]
extraLibDirs :: BuildInfo -> [String]

-- | directories to find .h files
includeDirs :: BuildInfo -> [FilePath]

-- | The .h files to be found in includeDirs
includes :: BuildInfo -> [FilePath]

-- | .h files to install with the package
installIncludes :: BuildInfo -> [FilePath]
options :: BuildInfo -> [(CompilerFlavor, [String])]
ghcProfOptions :: BuildInfo -> [String]
ghcSharedOptions :: BuildInfo -> [String]

-- | Custom fields starting with x-, stored in a simple assoc-list.
customFieldsBI :: BuildInfo -> [(String, String)]

-- | Dependencies specific to a library or executable target
targetBuildDepends :: BuildInfo -> [Dependency]
emptyBuildInfo :: BuildInfo

-- | The <a>BuildInfo</a> for the library (if there is one and it's
--   buildable), and all buildable executables, test suites and benchmarks.
--   Useful for gathering dependencies.
allBuildInfo :: PackageDescription -> [BuildInfo]

-- | The <a>Language</a>s used by this component
allLanguages :: BuildInfo -> [Language]

-- | The <a>Extension</a>s that are used somewhere by this component
allExtensions :: BuildInfo -> [Extension]

-- | The <tt>Extensions</tt> that are used by all modules in this component
usedExtensions :: BuildInfo -> [Extension]

-- | Select options for a particular Haskell compiler.
hcOptions :: CompilerFlavor -> BuildInfo -> [String]
type HookedBuildInfo = (Maybe BuildInfo, [(String, BuildInfo)])
emptyHookedBuildInfo :: HookedBuildInfo
updatePackageDescription :: HookedBuildInfo -> PackageDescription -> PackageDescription
data GenericPackageDescription
GenericPackageDescription :: PackageDescription -> [Flag] -> Maybe (CondTree ConfVar [Dependency] Library) -> [(String, CondTree ConfVar [Dependency] Executable)] -> [(String, CondTree ConfVar [Dependency] TestSuite)] -> [(String, CondTree ConfVar [Dependency] Benchmark)] -> GenericPackageDescription
packageDescription :: GenericPackageDescription -> PackageDescription
genPackageFlags :: GenericPackageDescription -> [Flag]
condLibrary :: GenericPackageDescription -> Maybe (CondTree ConfVar [Dependency] Library)
condExecutables :: GenericPackageDescription -> [(String, CondTree ConfVar [Dependency] Executable)]
condTestSuites :: GenericPackageDescription -> [(String, CondTree ConfVar [Dependency] TestSuite)]
condBenchmarks :: GenericPackageDescription -> [(String, CondTree ConfVar [Dependency] Benchmark)]

-- | A flag can represent a feature to be included, or a way of linking a
--   target against its dependencies, or in fact whatever you can think of.
data Flag
MkFlag :: FlagName -> String -> Bool -> Bool -> Flag
flagName :: Flag -> FlagName
flagDescription :: Flag -> String
flagDefault :: Flag -> Bool
flagManual :: Flag -> Bool

-- | A <a>FlagName</a> is the name of a user-defined configuration flag
newtype FlagName
FlagName :: String -> FlagName

-- | A <a>FlagAssignment</a> is a total or partial mapping of
--   <a>FlagName</a>s to <a>Bool</a> flag values. It represents the flags
--   chosen by the user or discovered during configuration. For example
--   <tt>--flags=foo --flags=-bar</tt> becomes <tt>[(<a>foo</a>, True),
--   (<a>bar</a>, False)]</tt>
type FlagAssignment = [(FlagName, Bool)]
data CondTree v c a
CondNode :: a -> c -> [(Condition v, CondTree v c a, Maybe (CondTree v c a))] -> CondTree v c a
condTreeData :: CondTree v c a -> a
condTreeConstraints :: CondTree v c a -> c
condTreeComponents :: CondTree v c a -> [(Condition v, CondTree v c a, Maybe (CondTree v c a))]

-- | A <tt>ConfVar</tt> represents the variable type used.
data ConfVar
OS :: OS -> ConfVar
Arch :: Arch -> ConfVar
Flag :: FlagName -> ConfVar
Impl :: CompilerFlavor -> VersionRange -> ConfVar

-- | A boolean expression parameterized over the variable type used.
data Condition c
Var :: c -> Condition c
Lit :: Bool -> Condition c
CNot :: (Condition c) -> Condition c
COr :: (Condition c) -> (Condition c) -> Condition c
CAnd :: (Condition c) -> (Condition c) -> Condition c

-- | Information about the source revision control system for a package.
--   
--   When specifying a repo it is useful to know the meaning or intention
--   of the information as doing so enables automation. There are two
--   obvious common purposes: one is to find the repo for the latest
--   development version, the other is to find the repo for this specific
--   release. The <tt>ReopKind</tt> specifies which one we mean (or another
--   custom one).
--   
--   A package can specify one or the other kind or both. Most will specify
--   just a head repo but some may want to specify a repo to reconstruct
--   the sources for this package release.
--   
--   The required information is the <a>RepoType</a> which tells us if it's
--   using <a>Darcs</a>, <a>Git</a> for example. The <a>repoLocation</a>
--   and other details are interpreted according to the repo type.
data SourceRepo
SourceRepo :: RepoKind -> Maybe RepoType -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe FilePath -> SourceRepo

-- | The kind of repo. This field is required.
repoKind :: SourceRepo -> RepoKind

-- | The type of the source repository system for this repo, eg
--   <a>Darcs</a> or <a>Git</a>. This field is required.
repoType :: SourceRepo -> Maybe RepoType

-- | The location of the repository. For most <a>RepoType</a>s this is a
--   URL. This field is required.
repoLocation :: SourceRepo -> Maybe String

-- | <a>CVS</a> can put multiple "modules" on one server and requires a
--   module name in addition to the location to identify a particular repo.
--   Logically this is part of the location but unfortunately has to be
--   specified separately. This field is required for the <a>CVS</a>
--   <a>RepoType</a> and should not be given otherwise.
repoModule :: SourceRepo -> Maybe String

-- | The name or identifier of the branch, if any. Many source control
--   systems have the notion of multiple branches in a repo that exist in
--   the same location. For example <a>Git</a> and <a>CVS</a> use this
--   while systems like <a>Darcs</a> use different locations for different
--   branches. This field is optional but should be used if necessary to
--   identify the sources, especially for the <a>RepoThis</a> repo kind.
repoBranch :: SourceRepo -> Maybe String

-- | The tag identify a particular state of the repository. This should be
--   given for the <a>RepoThis</a> repo kind and not for <a>RepoHead</a>
--   kind.
repoTag :: SourceRepo -> Maybe String

-- | Some repositories contain multiple projects in different
--   subdirectories This field specifies the subdirectory where this
--   packages sources can be found, eg the subdirectory containing the
--   <tt>.cabal</tt> file. It is interpreted relative to the root of the
--   repository. This field is optional. If not given the default is "." ie
--   no subdirectory.
repoSubdir :: SourceRepo -> Maybe FilePath

-- | What this repo info is for, what it represents.
data RepoKind

-- | The repository for the "head" or development version of the project.
--   This repo is where we should track the latest development activity or
--   the usual repo people should get to contribute patches.
RepoHead :: RepoKind

-- | The repository containing the sources for this exact package version
--   or release. For this kind of repo a tag should be given to give enough
--   information to re-create the exact sources.
RepoThis :: RepoKind
RepoKindUnknown :: String -> RepoKind

-- | An enumeration of common source control systems. The fields used in
--   the <a>SourceRepo</a> depend on the type of repo. The tools and
--   methods used to obtain and track the repo depend on the repo type.
data RepoType
Darcs :: RepoType
Git :: RepoType
SVN :: RepoType
CVS :: RepoType
Mercurial :: RepoType
GnuArch :: RepoType
Bazaar :: RepoType
Monotone :: RepoType
OtherRepoType :: String -> RepoType
knownRepoTypes :: [RepoType]
instance Show BuildType
instance Read BuildType
instance Eq BuildType
instance Show TestType
instance Read TestType
instance Eq TestType
instance Eq TestSuiteInterface
instance Read TestSuiteInterface
instance Show TestSuiteInterface
instance Show BenchmarkType
instance Read BenchmarkType
instance Eq BenchmarkType
instance Eq BenchmarkInterface
instance Read BenchmarkInterface
instance Show BenchmarkInterface
instance Show BuildInfo
instance Read BuildInfo
instance Eq BuildInfo
instance Show Benchmark
instance Read Benchmark
instance Eq Benchmark
instance Show TestSuite
instance Read TestSuite
instance Eq TestSuite
instance Show Executable
instance Read Executable
instance Eq Executable
instance Show Library
instance Eq Library
instance Read Library
instance Eq RepoKind
instance Ord RepoKind
instance Read RepoKind
instance Show RepoKind
instance Eq RepoType
instance Ord RepoType
instance Read RepoType
instance Show RepoType
instance Eq SourceRepo
instance Read SourceRepo
instance Show SourceRepo
instance Show PackageDescription
instance Read PackageDescription
instance Eq PackageDescription
instance Eq FlagName
instance Ord FlagName
instance Show FlagName
instance Read FlagName
instance Show Flag
instance Eq Flag
instance Eq ConfVar
instance Show ConfVar
instance Show c => Show (Condition c)
instance Eq c => Eq (Condition c)
instance (Show v, Show c, Show a) => Show (CondTree v c a)
instance (Eq v, Eq c, Eq a) => Eq (CondTree v c a)
instance Show GenericPackageDescription
instance Eq GenericPackageDescription
instance Package GenericPackageDescription
instance Text RepoType
instance Text RepoKind
instance Monoid BuildInfo
instance Text BenchmarkType
instance Monoid BenchmarkInterface
instance Monoid Benchmark
instance Text TestType
instance Monoid TestSuiteInterface
instance Monoid TestSuite
instance Monoid Executable
instance Monoid Library
instance Text BuildType
instance Package PackageDescription


-- | This is about the cabal configurations feature. It exports
--   <a>finalizePackageDescription</a> and <a>flattenPackageDescription</a>
--   which are functions for converting <a>GenericPackageDescription</a>s
--   down to <a>PackageDescription</a>s. It has code for working with the
--   tree of conditions and resolving or flattening conditions.
module Distribution.PackageDescription.Configuration

-- | Create a package description with all configurations resolved.
--   
--   This function takes a <a>GenericPackageDescription</a> and several
--   environment parameters and tries to generate <a>PackageDescription</a>
--   by finding a flag assignment that result in satisfiable dependencies.
--   
--   It takes as inputs a not necessarily complete specifications of flags
--   assignments, an optional package index as well as platform parameters.
--   If some flags are not assigned explicitly, this function will try to
--   pick an assignment that causes this function to succeed. The package
--   index is optional since on some platforms we cannot determine which
--   packages have been installed before. When no package index is
--   supplied, every dependency is assumed to be satisfiable, therefore all
--   not explicitly assigned flags will get their default values.
--   
--   This function will fail if it cannot find a flag assignment that leads
--   to satisfiable dependencies. (It will not try alternative assignments
--   for explicitly specified flags.) In case of failure it will return a
--   <i>minimum</i> number of dependencies that could not be satisfied. On
--   success, it will return the package description and the full flag
--   assignment chosen.
finalizePackageDescription :: FlagAssignment -> (Dependency -> Bool) -> Platform -> CompilerId -> [Dependency] -> GenericPackageDescription -> Either [Dependency] (PackageDescription, FlagAssignment)

-- | Flatten a generic package description by ignoring all conditions and
--   just join the field descriptors into on package description. Note,
--   however, that this may lead to inconsistent field values, since all
--   values are joined into one field, which may not be possible in the
--   original package description, due to the use of exclusive choices (if
--   ... else ...).
--   
--   TODO: One particularly tricky case is defaulting. In the original
--   package description, e.g., the source directory might either be the
--   default or a certain, explicitly set path. Since defaults are filled
--   in only after the package has been resolved and when no explicit value
--   has been set, the default path will be missing from the package
--   description returned by this function.
flattenPackageDescription :: GenericPackageDescription -> PackageDescription

-- | Parse a configuration condition from a string.
parseCondition :: ReadP r (Condition ConfVar)
freeVars :: CondTree ConfVar c a -> [FlagName]
mapCondTree :: (a -> b) -> (c -> d) -> (Condition v -> Condition w) -> CondTree v c a -> CondTree w d b
mapTreeData :: (a -> b) -> CondTree v c a -> CondTree v c b
mapTreeConds :: (Condition v -> Condition w) -> CondTree v c a -> CondTree w c a
mapTreeConstrs :: (c -> d) -> CondTree v c a -> CondTree v d a
instance Show DependencyMap
instance Read DependencyMap
instance Show PDTagged
instance Monoid PDTagged
instance Monoid DependencyMap
instance Monoid d => Monoid (DepTestRslt d)


-- | This defined parsers and partial pretty printers for the
--   <tt>.cabal</tt> format. Some of the complexity in this module is due
--   to the fact that we have to be backwards compatible with old
--   <tt>.cabal</tt> files, so there's code to translate into the newer
--   structure.
module Distribution.PackageDescription.Parse

-- | Parse the given package file.
readPackageDescription :: Verbosity -> FilePath -> IO GenericPackageDescription
writePackageDescription :: FilePath -> PackageDescription -> IO ()

-- | Parses the given file into a <a>GenericPackageDescription</a>.
--   
--   In Cabal 1.2 the syntax for package descriptions was changed to a
--   format with sections and possibly indented property descriptions.
parsePackageDescription :: String -> ParseResult GenericPackageDescription
showPackageDescription :: PackageDescription -> String
data ParseResult a
ParseFailed :: PError -> ParseResult a
ParseOk :: [PWarning] -> a -> ParseResult a

-- | Field descriptor. The parameter <tt>a</tt> parameterizes over where
--   the field's value is stored in.
data FieldDescr a
FieldDescr :: String -> (a -> Doc) -> (LineNo -> String -> a -> ParseResult a) -> FieldDescr a
fieldName :: FieldDescr a -> String
fieldGet :: FieldDescr a -> a -> Doc

-- | <tt>fieldSet n str x</tt> Parses the field value from the given input
--   string <tt>str</tt> and stores the result in <tt>x</tt> if the parse
--   was successful. Otherwise, reports an error on line number <tt>n</tt>.
fieldSet :: FieldDescr a -> LineNo -> String -> a -> ParseResult a
type LineNo = Int
readHookedBuildInfo :: Verbosity -> FilePath -> IO HookedBuildInfo
parseHookedBuildInfo :: String -> ParseResult HookedBuildInfo
writeHookedBuildInfo :: FilePath -> HookedBuildInfo -> IO ()
showHookedBuildInfo :: HookedBuildInfo -> String
pkgDescrFieldDescrs :: [FieldDescr PackageDescription]
libFieldDescrs :: [FieldDescr Library]
executableFieldDescrs :: [FieldDescr Executable]
binfoFieldDescrs :: [FieldDescr BuildInfo]
sourceRepoFieldDescrs :: [FieldDescr SourceRepo]
testSuiteFieldDescrs :: [FieldDescr TestSuiteStanza]
flagFieldDescrs :: [FieldDescr Flag]
instance Monad m => Monad (StT s m)


-- | Pretty printing for cabal files
module Distribution.PackageDescription.PrettyPrint

-- | Writes a .cabal file from a generic package description
writeGenericPackageDescription :: FilePath -> GenericPackageDescription -> IO ()

-- | Writes a generic package description to a string
showGenericPackageDescription :: GenericPackageDescription -> String


-- | This has code for checking for various problems in packages. There is
--   one set of checks that just looks at a <a>PackageDescription</a> in
--   isolation and another set of checks that also looks at files in the
--   package. Some of the checks are basic sanity checks, others are
--   portability standards that we'd like to encourage. There is a
--   <a>PackageCheck</a> type that distinguishes the different kinds of
--   check so we can see which ones are appropriate to report in different
--   situations. This code gets uses when configuring a package when we
--   consider only basic problems. The higher standard is uses when when
--   preparing a source tarball and by hackage when uploading new packages.
--   The reason for this is that we want to hold packages that are expected
--   to be distributed to a higher standard than packages that are only
--   ever expected to be used on the author's own environment.
module Distribution.PackageDescription.Check

-- | Results of some kind of failed package check.
--   
--   There are a range of severities, from merely dubious to totally
--   insane. All of them come with a human readable explanation. In future
--   we may augment them with more machine readable explanations, for
--   example to help an IDE suggest automatic corrections.
data PackageCheck

-- | This package description is no good. There's no way it's going to
--   build sensibly. This should give an error at configure time.
PackageBuildImpossible :: String -> PackageCheck
explanation :: PackageCheck -> String

-- | A problem that is likely to affect building the package, or an issue
--   that we'd like every package author to be aware of, even if the
--   package is never distributed.
PackageBuildWarning :: String -> PackageCheck
explanation :: PackageCheck -> String

-- | An issue that might not be a problem for the package author but might
--   be annoying or determental when the package is distributed to users.
--   We should encourage distributed packages to be free from these issues,
--   but occasionally there are justifiable reasons so we cannot ban them
--   entirely.
PackageDistSuspicious :: String -> PackageCheck
explanation :: PackageCheck -> String

-- | An issue that is ok in the author's environment but is almost certain
--   to be a portability problem for other environments. We can quite
--   legitimately refuse to publicly distribute packages with these
--   problems.
PackageDistInexcusable :: String -> PackageCheck
explanation :: PackageCheck -> String

-- | Check for common mistakes and problems in package descriptions.
--   
--   This is the standard collection of checks covering all apsects except
--   for checks that require looking at files within the package. For those
--   see <a>checkPackageFiles</a>.
--   
--   It requires the <a>GenericPackageDescription</a> and optionally a
--   particular configuration of that package. If you pass <a>Nothing</a>
--   then we just check a version of the generic description using
--   <a>flattenPackageDescription</a>.
checkPackage :: GenericPackageDescription -> Maybe PackageDescription -> [PackageCheck]
checkConfiguredPackage :: PackageDescription -> [PackageCheck]

-- | Sanity check things that requires IO. It looks at the files in the
--   package and expects to find the package unpacked in at the given
--   filepath.
checkPackageFiles :: PackageDescription -> FilePath -> IO [PackageCheck]

-- | Sanity check things that requires looking at files in the package.
--   This is a generalised version of <a>checkPackageFiles</a> that can
--   work in any monad for which you can provide
--   <a>CheckPackageContentOps</a> operations.
--   
--   The point of this extra generality is to allow doing checks in some
--   virtual file system, for example a tarball in memory.
checkPackageContent :: Monad m => CheckPackageContentOps m -> PackageDescription -> m [PackageCheck]

-- | A record of operations needed to check the contents of packages. Used
--   by <a>checkPackageContent</a>.
data CheckPackageContentOps m
CheckPackageContentOps :: (FilePath -> m Bool) -> (FilePath -> m Bool) -> CheckPackageContentOps m
doesFileExist :: CheckPackageContentOps m -> FilePath -> m Bool
doesDirectoryExist :: CheckPackageContentOps m -> FilePath -> m Bool

-- | Check the names of all files in a package for portability problems.
--   This should be done for example when creating or validating a package
--   tarball.
checkPackageFileNames :: [FilePath] -> [PackageCheck]
instance Show PackageCheck


-- | 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 <a>Read</a> and <a>Show</a> so it can be
--   saved along with the <tt>LocalBuildInfo</tt>. The only interesting bit
--   of info it contains is a mapping between language extensions and
--   compiler command line flags. This module also defines a
--   <a>PackageDB</a> 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.
module Distribution.Simple.Compiler
data Compiler
Compiler :: CompilerId -> [(Language, Flag)] -> [(Extension, Flag)] -> Compiler
compilerId :: Compiler -> CompilerId
compilerLanguages :: Compiler -> [(Language, Flag)]
compilerExtensions :: Compiler -> [(Extension, Flag)]
showCompilerId :: Compiler -> String
compilerFlavor :: Compiler -> CompilerFlavor
compilerVersion :: Compiler -> Version

-- | 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.
data PackageDB
GlobalPackageDB :: PackageDB
UserPackageDB :: PackageDB
SpecificPackageDB :: FilePath -> 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:
--   
--   <pre>
--   [GlobalPackageDB]
--   [GlobalPackageDB, UserPackageDB]
--   [GlobalPackageDB, SpecificPackageDB "package.conf.inplace"]
--   </pre>
--   
--   Note that the <a>GlobalPackageDB</a> 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.
type PackageDBStack = [PackageDB]

-- | Return the package that we should register into. This is the package
--   db at the top of the stack.
registrationPackageDB :: PackageDBStack -> PackageDB

-- | Some compilers support optimising. Some have different levels. For
--   compliers that do not the level is just capped to the level they do
--   support.
data OptimisationLevel
NoOptimisation :: OptimisationLevel
NormalOptimisation :: OptimisationLevel
MaximumOptimisation :: OptimisationLevel
flagToOptimisationLevel :: Maybe String -> OptimisationLevel
type Flag = String
languageToFlags :: Compiler -> Maybe Language -> [Flag]
unsupportedLanguages :: Compiler -> [Language] -> [Language]

-- | For the given compiler, return the flags for the supported extensions.
extensionsToFlags :: Compiler -> [Extension] -> [Flag]

-- | For the given compiler, return the extensions it does not support.
unsupportedExtensions :: Compiler -> [Extension] -> [Extension]
instance Eq PackageDB
instance Ord PackageDB
instance Show PackageDB
instance Read PackageDB
instance Eq OptimisationLevel
instance Show OptimisationLevel
instance Read OptimisationLevel
instance Enum OptimisationLevel
instance Bounded OptimisationLevel
instance Show Compiler
instance Read Compiler


-- | This module provides an library interface to the <tt>hc-pkg</tt>
--   program. Currently only GHC and LHC have hc-pkg programs.
module Distribution.Simple.Program.HcPkg

-- | Call <tt>hc-pkg</tt> to register a package.
--   
--   <pre>
--   hc-pkg register {filename | -} [--user | --global | --package-db]
--   </pre>
register :: Verbosity -> ConfiguredProgram -> PackageDBStack -> Either FilePath InstalledPackageInfo -> IO ()

-- | Call <tt>hc-pkg</tt> to re-register a package.
--   
--   <pre>
--   hc-pkg register {filename | -} [--user | --global | --package-db]
--   </pre>
reregister :: Verbosity -> ConfiguredProgram -> PackageDBStack -> Either FilePath InstalledPackageInfo -> IO ()

-- | Call <tt>hc-pkg</tt> to unregister a package
--   
--   <pre>
--   hc-pkg unregister [pkgid] [--user | --global | --package-db]
--   </pre>
unregister :: Verbosity -> ConfiguredProgram -> PackageDB -> PackageId -> IO ()

-- | Call <tt>hc-pkg</tt> to expose a package.
--   
--   <pre>
--   hc-pkg expose [pkgid] [--user | --global | --package-db]
--   </pre>
expose :: Verbosity -> ConfiguredProgram -> PackageDB -> PackageId -> IO ()

-- | Call <tt>hc-pkg</tt> to expose a package.
--   
--   <pre>
--   hc-pkg expose [pkgid] [--user | --global | --package-db]
--   </pre>
hide :: Verbosity -> ConfiguredProgram -> PackageDB -> PackageId -> IO ()

-- | Call <tt>hc-pkg</tt> to get all the installed packages.
dump :: Verbosity -> ConfiguredProgram -> PackageDB -> IO [InstalledPackageInfo]
registerInvocation :: ConfiguredProgram -> Verbosity -> PackageDBStack -> Either FilePath InstalledPackageInfo -> ProgramInvocation
reregisterInvocation :: ConfiguredProgram -> Verbosity -> PackageDBStack -> Either FilePath InstalledPackageInfo -> ProgramInvocation
unregisterInvocation :: ConfiguredProgram -> Verbosity -> PackageDB -> PackageId -> ProgramInvocation
exposeInvocation :: ConfiguredProgram -> Verbosity -> PackageDB -> PackageId -> ProgramInvocation
hideInvocation :: ConfiguredProgram -> Verbosity -> PackageDB -> PackageId -> ProgramInvocation
dumpInvocation :: ConfiguredProgram -> Verbosity -> PackageDB -> ProgramInvocation


-- | This manages everything to do with where files get installed (though
--   does not get involved with actually doing any installation). It
--   provides an <a>InstallDirs</a> type which is a set of directories for
--   where to install things. It also handles the fact that we use
--   templates in these install dirs. For example most install dirs are
--   relative to some <tt>$prefix</tt> and by changing the prefix all other
--   dirs still end up changed appropriately. So it provides a
--   <a>PathTemplate</a> type and functions for substituting for these
--   templates.
module Distribution.Simple.InstallDirs

-- | The directories where we will install files for packages.
--   
--   We have several different directories for different types of files
--   since many systems have conventions whereby different types of files
--   in a package are installed in different direcotries. This is
--   particularly the case on unix style systems.
data InstallDirs dir
InstallDirs :: dir -> dir -> dir -> dir -> dir -> dir -> dir -> dir -> dir -> dir -> dir -> dir -> dir -> dir -> InstallDirs dir
prefix :: InstallDirs dir -> dir
bindir :: InstallDirs dir -> dir
libdir :: InstallDirs dir -> dir
libsubdir :: InstallDirs dir -> dir
dynlibdir :: InstallDirs dir -> dir
libexecdir :: InstallDirs dir -> dir
progdir :: InstallDirs dir -> dir
includedir :: InstallDirs dir -> dir
datadir :: InstallDirs dir -> dir
datasubdir :: InstallDirs dir -> dir
docdir :: InstallDirs dir -> dir
mandir :: InstallDirs dir -> dir
htmldir :: InstallDirs dir -> dir
haddockdir :: InstallDirs dir -> dir

-- | The installation directories in terms of <a>PathTemplate</a>s that
--   contain variables.
--   
--   The defaults for most of the directories are relative to each other,
--   in particular they are all relative to a single prefix. This makes it
--   convenient for the user to override the default installation directory
--   by only having to specify --prefix=... rather than overriding each
--   individually. This is done by allowing $-style variables in the dirs.
--   These are expanded by textual substituion (see
--   <a>substPathTemplate</a>).
--   
--   A few of these installation directories are split into two components,
--   the dir and subdir. The full installation path is formed by combining
--   the two together with <tt>/</tt>. The reason for this is compatibility
--   with other unix build systems which also support <tt>--libdir</tt> and
--   <tt>--datadir</tt>. We would like users to be able to configure
--   <tt>--libdir=/usr/lib64</tt> for example but because by default we
--   want to support installing multiple versions of packages and building
--   the same package for multiple compilers we append the libsubdir to
--   get: <tt>/usr/lib64/$pkgid/$compiler</tt>.
--   
--   An additional complication is the need to support relocatable packages
--   on systems which support such things, like Windows.
type InstallDirTemplates = InstallDirs PathTemplate
defaultInstallDirs :: CompilerFlavor -> Bool -> Bool -> IO InstallDirTemplates
combineInstallDirs :: (a -> b -> c) -> InstallDirs a -> InstallDirs b -> InstallDirs c

-- | Convert from abstract install directories to actual absolute ones by
--   substituting for all the variables in the abstract paths, to get real
--   absolute path.
absoluteInstallDirs :: PackageIdentifier -> CompilerId -> CopyDest -> InstallDirs PathTemplate -> InstallDirs FilePath

-- | The location prefix for the <i>copy</i> command.
data CopyDest
NoCopyDest :: CopyDest
CopyTo :: FilePath -> CopyDest

-- | Check which of the paths are relative to the installation $prefix.
--   
--   If any of the paths are not relative, ie they are absolute paths, then
--   it prevents us from making a relocatable package (also known as a
--   "prefix independent" package).
prefixRelativeInstallDirs :: PackageIdentifier -> CompilerId -> InstallDirTemplates -> InstallDirs (Maybe FilePath)

-- | Substitute the install dir templates into each other.
--   
--   To prevent cyclic substitutions, only some variables are allowed in
--   particular dir templates. If out of scope vars are present, they are
--   not substituted for. Checking for any remaining unsubstituted vars can
--   be done as a subsequent operation.
--   
--   The reason it is done this way is so that in
--   <a>prefixRelativeInstallDirs</a> we can replace <a>prefix</a> with the
--   <a>PrefixVar</a> and get resulting <a>PathTemplate</a>s that still
--   have the <a>PrefixVar</a> in them. Doing this makes it each to check
--   which paths are relative to the $prefix.
substituteInstallDirTemplates :: PathTemplateEnv -> InstallDirTemplates -> InstallDirTemplates

-- | An abstract path, posibly containing variables that need to be
--   substituted for to get a real <a>FilePath</a>.
data PathTemplate
data PathTemplateVariable

-- | The <tt>$prefix</tt> path variable
PrefixVar :: PathTemplateVariable

-- | The <tt>$bindir</tt> path variable
BindirVar :: PathTemplateVariable

-- | The <tt>$libdir</tt> path variable
LibdirVar :: PathTemplateVariable

-- | The <tt>$libsubdir</tt> path variable
LibsubdirVar :: PathTemplateVariable

-- | The <tt>$datadir</tt> path variable
DatadirVar :: PathTemplateVariable

-- | The <tt>$datasubdir</tt> path variable
DatasubdirVar :: PathTemplateVariable

-- | The <tt>$docdir</tt> path variable
DocdirVar :: PathTemplateVariable

-- | The <tt>$htmldir</tt> path variable
HtmldirVar :: PathTemplateVariable

-- | The <tt>$pkg</tt> package name path variable
PkgNameVar :: PathTemplateVariable

-- | The <tt>$version</tt> package version path variable
PkgVerVar :: PathTemplateVariable

-- | The <tt>$pkgid</tt> package Id path variable, eg <tt>foo-1.0</tt>
PkgIdVar :: PathTemplateVariable

-- | The compiler name and version, eg <tt>ghc-6.6.1</tt>
CompilerVar :: PathTemplateVariable

-- | The operating system name, eg <tt>windows</tt> or <tt>linux</tt>
OSVar :: PathTemplateVariable

-- | The cpu architecture name, eg <tt>i386</tt> or <tt>x86_64</tt>
ArchVar :: PathTemplateVariable

-- | The executable name; used in shell wrappers
ExecutableNameVar :: PathTemplateVariable

-- | The name of the test suite being run
TestSuiteNameVar :: PathTemplateVariable

-- | The result of the test suite being run, eg <tt>pass</tt>,
--   <tt>fail</tt>, or <tt>error</tt>.
TestSuiteResultVar :: PathTemplateVariable

-- | The name of the benchmark being run
BenchmarkNameVar :: PathTemplateVariable
type PathTemplateEnv = [(PathTemplateVariable, PathTemplate)]

-- | Convert a <a>FilePath</a> to a <a>PathTemplate</a> including any
--   template vars.
toPathTemplate :: FilePath -> PathTemplate

-- | Convert back to a path, any remaining vars are included
fromPathTemplate :: PathTemplate -> FilePath
substPathTemplate :: PathTemplateEnv -> PathTemplate -> PathTemplate

-- | The initial environment has all the static stuff but no paths
initialPathTemplateEnv :: PackageIdentifier -> CompilerId -> PathTemplateEnv
platformTemplateEnv :: Platform -> PathTemplateEnv
compilerTemplateEnv :: CompilerId -> PathTemplateEnv
packageTemplateEnv :: PackageIdentifier -> PathTemplateEnv
installDirsTemplateEnv :: InstallDirs PathTemplate -> PathTemplateEnv
instance Read dir => Read (InstallDirs dir)
instance Show dir => Show (InstallDirs dir)
instance Eq CopyDest
instance Show CopyDest
instance Eq PathTemplateVariable
instance Eq PathComponent
instance Read PathTemplate
instance Show PathTemplate
instance Read PathComponent
instance Show PathComponent
instance Read PathTemplateVariable
instance Show PathTemplateVariable
instance Monoid dir => Monoid (InstallDirs dir)
instance Functor InstallDirs


-- | This is a big module, but not very complicated. The code is very
--   regular and repetitive. It defines the command line interface for all
--   the Cabal commands. For each command (like <tt>configure</tt>,
--   <tt>build</tt> etc) it defines a type that holds all the flags, the
--   default set of flags and a <a>CommandUI</a> that maps command line
--   flags to and from the corresponding flags type.
--   
--   All the flags types are instances of <a>Monoid</a>, see
--   <a>http://www.haskell.org/pipermail/cabal-devel/2007-December/001509.html</a>
--   for an explanation.
--   
--   The types defined here get used in the front end and especially in
--   <tt>cabal-install</tt> which has to do quite a bit of manipulating
--   sets of command line flags.
--   
--   This is actually relatively nice, it works quite well. The main change
--   it needs is to unify it with the code for managing sets of fields that
--   can be read and written from files. This would allow us to save
--   configure flags in config files.
module Distribution.Simple.Setup

-- | Flags that apply at the top level, not to any sub-command.
data GlobalFlags
GlobalFlags :: Flag Bool -> Flag Bool -> GlobalFlags
globalVersion :: GlobalFlags -> Flag Bool
globalNumericVersion :: GlobalFlags -> Flag Bool
emptyGlobalFlags :: GlobalFlags
defaultGlobalFlags :: GlobalFlags
globalCommand :: CommandUI GlobalFlags

-- | Flags to <tt>configure</tt> command
data ConfigFlags
ConfigFlags :: ProgramConfiguration -> [(String, FilePath)] -> [(String, [String])] -> Flag CompilerFlavor -> Flag FilePath -> Flag FilePath -> Flag Bool -> Flag Bool -> Flag Bool -> Flag Bool -> Flag Bool -> [String] -> Flag OptimisationLevel -> Flag PathTemplate -> Flag PathTemplate -> InstallDirs (Flag PathTemplate) -> Flag FilePath -> [FilePath] -> [FilePath] -> Flag FilePath -> Flag Verbosity -> Flag Bool -> [Maybe PackageDB] -> Flag Bool -> Flag Bool -> Flag Bool -> [Dependency] -> FlagAssignment -> Flag Bool -> Flag Bool -> Flag Bool -> ConfigFlags

-- | All programs that cabal may run
configPrograms :: ConfigFlags -> ProgramConfiguration

-- | user specifed programs paths
configProgramPaths :: ConfigFlags -> [(String, FilePath)]

-- | user specifed programs args
configProgramArgs :: ConfigFlags -> [(String, [String])]

-- | The "flavor" of the compiler, sugh as GHC or Hugs.
configHcFlavor :: ConfigFlags -> Flag CompilerFlavor

-- | given compiler location
configHcPath :: ConfigFlags -> Flag FilePath

-- | given hc-pkg location
configHcPkg :: ConfigFlags -> Flag FilePath

-- | Enable vanilla library
configVanillaLib :: ConfigFlags -> Flag Bool

-- | Enable profiling in the library
configProfLib :: ConfigFlags -> Flag Bool

-- | Build shared library
configSharedLib :: ConfigFlags -> Flag Bool

-- | Enable dynamic linking of the executables.
configDynExe :: ConfigFlags -> Flag Bool

-- | Enable profiling in the executables.
configProfExe :: ConfigFlags -> Flag Bool

-- | Extra arguments to <tt>configure</tt>
configConfigureArgs :: ConfigFlags -> [String]

-- | Enable optimization.
configOptimization :: ConfigFlags -> Flag OptimisationLevel

-- | Installed executable prefix.
configProgPrefix :: ConfigFlags -> Flag PathTemplate

-- | Installed executable suffix.
configProgSuffix :: ConfigFlags -> Flag PathTemplate

-- | Installation paths
configInstallDirs :: ConfigFlags -> InstallDirs (Flag PathTemplate)
configScratchDir :: ConfigFlags -> Flag FilePath

-- | path to search for extra libraries
configExtraLibDirs :: ConfigFlags -> [FilePath]

-- | path to search for header files
configExtraIncludeDirs :: ConfigFlags -> [FilePath]

-- | <a>dist</a> prefix
configDistPref :: ConfigFlags -> Flag FilePath

-- | verbosity level
configVerbosity :: ConfigFlags -> Flag Verbosity

-- | The --user/--global flag
configUserInstall :: ConfigFlags -> Flag Bool

-- | Which package DBs to use
configPackageDBs :: ConfigFlags -> [Maybe PackageDB]

-- | Enable compiling library for GHCi
configGHCiLib :: ConfigFlags -> Flag Bool

-- | Enable -split-objs with GHC
configSplitObjs :: ConfigFlags -> Flag Bool

-- | Enable executable stripping
configStripExes :: ConfigFlags -> Flag Bool

-- | Additional constraints for dependencies
configConstraints :: ConfigFlags -> [Dependency]
configConfigurationsFlags :: ConfigFlags -> FlagAssignment

-- | Enable test suite compilation
configTests :: ConfigFlags -> Flag Bool

-- | Enable benchmark compilation
configBenchmarks :: ConfigFlags -> Flag Bool

-- | Enable test suite program coverage
configLibCoverage :: ConfigFlags -> Flag Bool
emptyConfigFlags :: ConfigFlags
defaultConfigFlags :: ProgramConfiguration -> ConfigFlags
configureCommand :: ProgramConfiguration -> CommandUI ConfigFlags

-- | Flags to <tt>copy</tt>: (destdir, copy-prefix (backwards compat),
--   verbosity)
data CopyFlags
CopyFlags :: Flag CopyDest -> Flag FilePath -> Flag Verbosity -> CopyFlags
copyDest :: CopyFlags -> Flag CopyDest
copyDistPref :: CopyFlags -> Flag FilePath
copyVerbosity :: CopyFlags -> Flag Verbosity
emptyCopyFlags :: CopyFlags
defaultCopyFlags :: CopyFlags
copyCommand :: CommandUI CopyFlags

-- | Flags to <tt>install</tt>: (package db, verbosity)
data InstallFlags
InstallFlags :: Flag PackageDB -> Flag FilePath -> Flag Bool -> Flag Bool -> Flag Verbosity -> InstallFlags
installPackageDB :: InstallFlags -> Flag PackageDB
installDistPref :: InstallFlags -> Flag FilePath
installUseWrapper :: InstallFlags -> Flag Bool
installInPlace :: InstallFlags -> Flag Bool
installVerbosity :: InstallFlags -> Flag Verbosity
emptyInstallFlags :: InstallFlags
defaultInstallFlags :: InstallFlags
installCommand :: CommandUI InstallFlags
data HaddockFlags
HaddockFlags :: [(String, FilePath)] -> [(String, [String])] -> Flag Bool -> Flag Bool -> Flag String -> Flag Bool -> Flag Bool -> Flag FilePath -> Flag Bool -> Flag FilePath -> Flag PathTemplate -> Flag FilePath -> Flag Verbosity -> HaddockFlags
haddockProgramPaths :: HaddockFlags -> [(String, FilePath)]
haddockProgramArgs :: HaddockFlags -> [(String, [String])]
haddockHoogle :: HaddockFlags -> Flag Bool
haddockHtml :: HaddockFlags -> Flag Bool
haddockHtmlLocation :: HaddockFlags -> Flag String
haddockExecutables :: HaddockFlags -> Flag Bool
haddockInternal :: HaddockFlags -> Flag Bool
haddockCss :: HaddockFlags -> Flag FilePath
haddockHscolour :: HaddockFlags -> Flag Bool
haddockHscolourCss :: HaddockFlags -> Flag FilePath
haddockContents :: HaddockFlags -> Flag PathTemplate
haddockDistPref :: HaddockFlags -> Flag FilePath
haddockVerbosity :: HaddockFlags -> Flag Verbosity
emptyHaddockFlags :: HaddockFlags
defaultHaddockFlags :: HaddockFlags
haddockCommand :: CommandUI HaddockFlags
data HscolourFlags
HscolourFlags :: Flag FilePath -> Flag Bool -> Flag FilePath -> Flag Verbosity -> HscolourFlags
hscolourCSS :: HscolourFlags -> Flag FilePath
hscolourExecutables :: HscolourFlags -> Flag Bool
hscolourDistPref :: HscolourFlags -> Flag FilePath
hscolourVerbosity :: HscolourFlags -> Flag Verbosity
emptyHscolourFlags :: HscolourFlags
defaultHscolourFlags :: HscolourFlags
hscolourCommand :: CommandUI HscolourFlags
data BuildFlags
BuildFlags :: [(String, FilePath)] -> [(String, [String])] -> Flag FilePath -> Flag Verbosity -> BuildFlags
buildProgramPaths :: BuildFlags -> [(String, FilePath)]
buildProgramArgs :: BuildFlags -> [(String, [String])]
buildDistPref :: BuildFlags -> Flag FilePath
buildVerbosity :: BuildFlags -> Flag Verbosity
emptyBuildFlags :: BuildFlags
defaultBuildFlags :: BuildFlags
buildCommand :: ProgramConfiguration -> CommandUI BuildFlags

-- | <i>Deprecated: Use buildVerbosity instead </i>
buildVerbose :: BuildFlags -> Verbosity
data CleanFlags
CleanFlags :: Flag Bool -> Flag FilePath -> Flag Verbosity -> CleanFlags
cleanSaveConf :: CleanFlags -> Flag Bool
cleanDistPref :: CleanFlags -> Flag FilePath
cleanVerbosity :: CleanFlags -> Flag Verbosity
emptyCleanFlags :: CleanFlags
defaultCleanFlags :: CleanFlags
cleanCommand :: CommandUI CleanFlags

-- | Flags to <tt>register</tt> and <tt>unregister</tt>: (user package,
--   gen-script, in-place, verbosity)
data RegisterFlags
RegisterFlags :: Flag PackageDB -> Flag Bool -> Flag (Maybe FilePath) -> Flag Bool -> Flag FilePath -> Flag Verbosity -> RegisterFlags
regPackageDB :: RegisterFlags -> Flag PackageDB
regGenScript :: RegisterFlags -> Flag Bool
regGenPkgConf :: RegisterFlags -> Flag (Maybe FilePath)
regInPlace :: RegisterFlags -> Flag Bool
regDistPref :: RegisterFlags -> Flag FilePath
regVerbosity :: RegisterFlags -> Flag Verbosity
emptyRegisterFlags :: RegisterFlags
defaultRegisterFlags :: RegisterFlags
registerCommand :: CommandUI RegisterFlags
unregisterCommand :: CommandUI RegisterFlags

-- | Flags to <tt>sdist</tt>: (snapshot, verbosity)
data SDistFlags
SDistFlags :: Flag Bool -> Flag FilePath -> Flag FilePath -> Flag Verbosity -> SDistFlags
sDistSnapshot :: SDistFlags -> Flag Bool
sDistDirectory :: SDistFlags -> Flag FilePath
sDistDistPref :: SDistFlags -> Flag FilePath
sDistVerbosity :: SDistFlags -> Flag Verbosity
emptySDistFlags :: SDistFlags
defaultSDistFlags :: SDistFlags
sdistCommand :: CommandUI SDistFlags
data TestFlags
TestFlags :: Flag FilePath -> Flag Verbosity -> Flag PathTemplate -> Flag PathTemplate -> Flag TestShowDetails -> Flag Bool -> Flag [String] -> [PathTemplate] -> TestFlags
testDistPref :: TestFlags -> Flag FilePath
testVerbosity :: TestFlags -> Flag Verbosity
testHumanLog :: TestFlags -> Flag PathTemplate
testMachineLog :: TestFlags -> Flag PathTemplate
testShowDetails :: TestFlags -> Flag TestShowDetails
testKeepTix :: TestFlags -> Flag Bool
testList :: TestFlags -> Flag [String]
testOptions :: TestFlags -> [PathTemplate]
emptyTestFlags :: TestFlags
defaultTestFlags :: TestFlags
testCommand :: CommandUI TestFlags
data TestShowDetails
Never :: TestShowDetails
Failures :: TestShowDetails
Always :: TestShowDetails
data BenchmarkFlags
BenchmarkFlags :: Flag FilePath -> Flag Verbosity -> [PathTemplate] -> BenchmarkFlags
benchmarkDistPref :: BenchmarkFlags -> Flag FilePath
benchmarkVerbosity :: BenchmarkFlags -> Flag Verbosity
benchmarkOptions :: BenchmarkFlags -> [PathTemplate]
emptyBenchmarkFlags :: BenchmarkFlags
defaultBenchmarkFlags :: BenchmarkFlags
benchmarkCommand :: CommandUI BenchmarkFlags

-- | The location prefix for the <i>copy</i> command.
data CopyDest
NoCopyDest :: CopyDest
CopyTo :: FilePath -> CopyDest

-- | Arguments to pass to a <tt>configure</tt> script, e.g. generated by
--   <tt>autoconf</tt>.
configureArgs :: Bool -> ConfigFlags -> [String]
configureOptions :: ShowOrParseArgs -> [OptionField ConfigFlags]
configureCCompiler :: Verbosity -> ProgramConfiguration -> IO (FilePath, [String])
configureLinker :: Verbosity -> ProgramConfiguration -> IO (FilePath, [String])
installDirsOptions :: [OptionField (InstallDirs (Flag PathTemplate))]
defaultDistPref :: FilePath

-- | All flags are monoids, they come in two flavours:
--   
--   <ol>
--   <li>list flags eg</li>
--   </ol>
--   
--   <pre>
--   --ghc-option=foo --ghc-option=bar
--   </pre>
--   
--   gives us all the values [<a>foo</a>, <a>bar</a>]
--   
--   <ol>
--   <li>singular value flags, eg:</li>
--   </ol>
--   
--   <pre>
--   --enable-foo --disable-foo
--   </pre>
--   
--   gives us Just False So this Flag type is for the latter singular kind
--   of flag. Its monoid instance gives us the behaviour where it starts
--   out as <a>NoFlag</a> and later flags override earlier ones.
data Flag a
Flag :: a -> Flag a
NoFlag :: Flag a
toFlag :: a -> Flag a
fromFlag :: Flag a -> a
fromFlagOrDefault :: a -> Flag a -> a
flagToMaybe :: Flag a -> Maybe a
flagToList :: Flag a -> [a]
boolOpt :: SFlags -> SFlags -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
boolOpt' :: OptFlags -> OptFlags -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a
trueArg :: SFlags -> LFlags -> Description -> (b -> Flag Bool) -> (Flag Bool -> (b -> b)) -> OptDescr b
falseArg :: SFlags -> LFlags -> Description -> (b -> Flag Bool) -> (Flag Bool -> (b -> b)) -> OptDescr b
optionVerbosity :: (flags -> Flag Verbosity) -> (Flag Verbosity -> flags -> flags) -> OptionField flags
instance Show a => Show (Flag a)
instance Read a => Read (Flag a)
instance Eq a => Eq (Flag a)
instance Read ConfigFlags
instance Show ConfigFlags
instance Show CopyFlags
instance Show InstallFlags
instance Show SDistFlags
instance Show RegisterFlags
instance Show HscolourFlags
instance Show HaddockFlags
instance Show CleanFlags
instance Show BuildFlags
instance Eq TestShowDetails
instance Ord TestShowDetails
instance Enum TestShowDetails
instance Bounded TestShowDetails
instance Show TestShowDetails
instance Monoid BenchmarkFlags
instance Monoid TestFlags
instance Monoid TestShowDetails
instance Text TestShowDetails
instance Monoid BuildFlags
instance Monoid CleanFlags
instance Monoid HaddockFlags
instance Monoid HscolourFlags
instance Monoid RegisterFlags
instance Monoid SDistFlags
instance Monoid InstallFlags
instance Monoid CopyFlags
instance Monoid ConfigFlags
instance Monoid GlobalFlags
instance Enum a => Enum (Flag a)
instance Bounded a => Bounded (Flag a)
instance Monoid (Flag a)
instance Functor Flag


-- | This is an alternative build system that delegates everything to the
--   <tt>make</tt> program. All the commands just end up calling
--   <tt>make</tt> with appropriate arguments. The intention was to allow
--   preexisting packages that used makefiles to be wrapped into Cabal
--   packages. In practice essentially all such packages were converted
--   over to the "Simple" build system instead. Consequently this module is
--   not used much and it certainly only sees cursory maintenance and no
--   testing. Perhaps at some point we should stop pretending that it
--   works.
--   
--   Uses the parsed command-line from <a>Distribution.Simple.Setup</a> in
--   order to build Haskell tools using a backend build system based on
--   make. Obviously we assume that there is a configure script, and that
--   after the ConfigCmd has been run, there is a Makefile. Further
--   assumptions:
--   
--   <ul>
--   <li><i>ConfigCmd</i> We assume the configure script accepts
--   <tt>--with-hc</tt>, <tt>--with-hc-pkg</tt>, <tt>--prefix</tt>,
--   <tt>--bindir</tt>, <tt>--libdir</tt>, <tt>--libexecdir</tt>,
--   <tt>--datadir</tt>.</li>
--   <li><i>BuildCmd</i> We assume that the default Makefile target will
--   build everything.</li>
--   <li><i>InstallCmd</i> We assume there is an <tt>install</tt> target.
--   Note that we assume that this does *not* register the package!</li>
--   <li><i>CopyCmd</i> We assume there is a <tt>copy</tt> target, and a
--   variable <tt>$(destdir)</tt>. The <tt>copy</tt> target should probably
--   just invoke <tt>make install</tt> recursively (e.g. <tt>$(MAKE)
--   install prefix=$(destdir)/$(prefix) bindir=$(destdir)/$(bindir)</tt>.
--   The reason we can't invoke <tt>make install</tt> directly here is that
--   we don't know the value of <tt>$(prefix)</tt>.</li>
--   <li><i>SDistCmd</i> We assume there is a <tt>dist</tt> target.</li>
--   <li><i>RegisterCmd</i> We assume there is a <tt>register</tt> target
--   and a variable <tt>$(user)</tt>.</li>
--   <li><i>UnregisterCmd</i> We assume there is an <tt>unregister</tt>
--   target.</li>
--   <li><i>HaddockCmd</i> We assume there is a <tt>docs</tt> or
--   <tt>doc</tt> target.</li>
--   </ul>
module Distribution.Make

-- | This datatype indicates the license under which your package is
--   released. It is also wise to add your license to each source file
--   using the license-file field. The <a>AllRightsReserved</a> constructor
--   is not actually a license, but states that you are not giving anyone
--   else a license to use or distribute your work. The comments below are
--   general guidelines. Please read the licenses themselves and consult a
--   lawyer if you are unsure of your rights to release the software.
data License

-- | GNU Public License. Source code must accompany alterations.
GPL :: (Maybe Version) -> License

-- | Lesser GPL, Less restrictive than GPL, useful for libraries.
LGPL :: (Maybe Version) -> License

-- | 3-clause BSD license, newer, no advertising clause. Very free license.
BSD3 :: License

-- | 4-clause BSD license, older, with advertising clause. You almost
--   certainly want to use the BSD3 license instead.
BSD4 :: License

-- | The MIT license, similar to the BSD3. Very free license.
MIT :: License

-- | The Apache License. Version 2.0 is the current version, previous
--   versions are considered historical.
Apache :: (Maybe Version) -> License

-- | Holder makes no claim to ownership, least restrictive license.
PublicDomain :: License

-- | No rights are granted to others. Undistributable. Most restrictive.
AllRightsReserved :: License

-- | Some other license.
OtherLicense :: License

-- | Not a recognised license. Allows us to deal with future extensions
--   more gracefully.
UnknownLicense :: String -> License

-- | A <a>Version</a> represents the version of a software entity.
--   
--   An instance of <a>Eq</a> is provided, which implements exact equality
--   modulo reordering of the tags in the <a>versionTags</a> field.
--   
--   An instance of <a>Ord</a> is also provided, which gives lexicographic
--   ordering on the <a>versionBranch</a> fields (i.e. 2.1 &gt; 2.0, 1.2.3
--   &gt; 1.2.2, etc.). This is expected to be sufficient for many uses,
--   but note that you may need to use a more specific ordering for your
--   versioning scheme. For example, some versioning schemes may include
--   pre-releases which have tags <tt>"pre1"</tt>, <tt>"pre2"</tt>, and so
--   on, and these would need to be taken into account when determining
--   ordering. In some cases, date ordering may be more appropriate, so the
--   application would have to look for <tt>date</tt> tags in the
--   <a>versionTags</a> field and compare those. The bottom line is, don't
--   always assume that <a>compare</a> and other <a>Ord</a> operations are
--   the right thing for every <a>Version</a>.
--   
--   Similarly, concrete representations of versions may differ. One
--   possible concrete representation is provided (see <a>showVersion</a>
--   and <a>parseVersion</a>), but depending on the application a different
--   concrete representation may be more appropriate.
data Version :: *
Version :: [Int] -> [String] -> Version

-- | The numeric branch for this version. This reflects the fact that most
--   software versions are tree-structured; there is a main trunk which is
--   tagged with versions at various points (1,2,3...), and the first
--   branch off the trunk after version 3 is 3.1, the second branch off the
--   trunk after version 3 is 3.2, and so on. The tree can be branched
--   arbitrarily, just by adding more digits.
--   
--   We represent the branch as a list of <a>Int</a>, so version 3.2.1
--   becomes [3,2,1]. Lexicographic ordering (i.e. the default instance of
--   <a>Ord</a> for <tt>[Int]</tt>) gives the natural ordering of branches.
versionBranch :: Version -> [Int]

-- | A version can be tagged with an arbitrary list of strings. The
--   interpretation of the list of tags is entirely dependent on the entity
--   that this version applies to.
versionTags :: Version -> [String]
defaultMain :: IO ()
defaultMainArgs :: [String] -> IO ()

-- | <i>Deprecated: it ignores its PackageDescription arg </i>
defaultMainNoRead :: PackageDescription -> IO ()

module Distribution.Simple.Program.GHC

-- | A structured set of GHC options/flags
data GhcOptions
GhcOptions :: Flag GhcMode -> [String] -> [String] -> [FilePath] -> [ModuleName] -> Flag FilePath -> Flag Bool -> [FilePath] -> Flag PackageId -> PackageDBStack -> [(InstalledPackageId, PackageId)] -> Flag Bool -> Flag Bool -> [FilePath] -> [FilePath] -> [String] -> [String] -> Flag Bool -> [String] -> [String] -> [FilePath] -> [FilePath] -> [FilePath] -> Flag Language -> [Extension] -> [(Extension, String)] -> Flag GhcOptimisation -> Flag Bool -> Flag Bool -> [FilePath] -> Flag String -> Flag String -> Flag FilePath -> Flag FilePath -> Flag FilePath -> Flag Bool -> Flag Bool -> Flag Bool -> Flag String -> Flag Verbosity -> Flag Bool -> GhcOptions

-- | The major mode for the ghc invocation.
ghcOptMode :: GhcOptions -> Flag GhcMode

-- | Any extra options to pass directly to ghc. These go at the end and
--   hence override other stuff.
ghcOptExtra :: GhcOptions -> [String]

-- | Extra default flags to pass directly to ghc. These go at the beginning
--   and so can be overridden by other stuff.
ghcOptExtraDefault :: GhcOptions -> [String]

-- | The main input files; could be .hs, .hi, .c, .o, depending on mode.
ghcOptInputFiles :: GhcOptions -> [FilePath]

-- | The names of input Haskell modules, mainly for <tt>--make</tt> mode.
ghcOptInputModules :: GhcOptions -> [ModuleName]

-- | Location for output file; the <tt>ghc -o</tt> flag.
ghcOptOutputFile :: GhcOptions -> Flag FilePath

-- | Start with an empty search path for Haskell source files; the <tt>ghc
--   -i</tt> flag (<tt>-i</tt> on it's own with no path argument).
ghcOptSourcePathClear :: GhcOptions -> Flag Bool

-- | Search path for Haskell source files; the <tt>ghc -i</tt> flag.
ghcOptSourcePath :: GhcOptions -> [FilePath]

-- | The package name the modules will belong to; the <tt>ghc
--   -package-name</tt> flag
ghcOptPackageName :: GhcOptions -> Flag PackageId

-- | GHC package databases to use, the <tt>ghc -package-conf</tt> flag
ghcOptPackageDBs :: GhcOptions -> PackageDBStack

-- | The GHC packages to use. For compatability with old and new ghc, this
--   requires both the short and long form of the package id; the <tt>ghc
--   -package</tt> or <tt>ghc -package-id</tt> flags.
ghcOptPackages :: GhcOptions -> [(InstalledPackageId, PackageId)]

-- | Start with a clean package set; the <tt>ghc -hide-all-packages</tt>
--   flag
ghcOptHideAllPackages :: GhcOptions -> Flag Bool

-- | Don't automatically link in Haskell98 etc; the <tt>ghc
--   -no-auto-link-packages</tt> flag.
ghcOptNoAutoLinkPackages :: GhcOptions -> Flag Bool

-- | Names of libraries to link in; the <tt>ghc -l</tt> flag.
ghcOptLinkLibs :: GhcOptions -> [FilePath]

-- | Search path for libraries to link in; the <tt>ghc -L</tt> flag.
ghcOptLinkLibPath :: GhcOptions -> [FilePath]

-- | Options to pass through to the linker; the <tt>ghc -optl</tt> flag.
ghcOptLinkOptions :: GhcOptions -> [String]

-- | OSX only: frameworks to link in; the <tt>ghc -framework</tt> flag.
ghcOptLinkFrameworks :: GhcOptions -> [String]

-- | Don't do the link step, useful in make mode; the <tt>ghc -no-link</tt>
--   flag.
ghcOptNoLink :: GhcOptions -> Flag Bool

-- | Options to pass through to the C compiler; the <tt>ghc -optc</tt>
--   flag.
ghcOptCcOptions :: GhcOptions -> [String]

-- | Options to pass through to CPP; the <tt>ghc -optP</tt> flag.
ghcOptCppOptions :: GhcOptions -> [String]

-- | Search path for CPP includes like header files; the <tt>ghc -I</tt>
--   flag.
ghcOptCppIncludePath :: GhcOptions -> [FilePath]

-- | Extra header files to include at CPP stage; the <tt>ghc
--   -optP-include</tt> flag.
ghcOptCppIncludes :: GhcOptions -> [FilePath]

-- | Extra header files to include for old-style FFI; the <tt>ghc
--   -#include</tt> flag.
ghcOptFfiIncludes :: GhcOptions -> [FilePath]

-- | The base language; the <tt>ghc -XHaskell98</tt> or
--   <tt>-XHaskell2010</tt> flag.
ghcOptLanguage :: GhcOptions -> Flag Language

-- | The language extensions; the <tt>ghc -X</tt> flag.
ghcOptExtensions :: GhcOptions -> [Extension]

-- | A GHC version-dependent mapping of extensions to flags. This must be
--   set to be able to make use of the <a>ghcOptExtensions</a>.
ghcOptExtensionMap :: GhcOptions -> [(Extension, String)]

-- | What optimisation level to use; the <tt>ghc -O</tt> flag.
ghcOptOptimisation :: GhcOptions -> Flag GhcOptimisation

-- | Compile in profiling mode; the <tt>ghc -prof</tt> flag.
ghcOptProfilingMode :: GhcOptions -> Flag Bool

-- | Use the "split object files" feature; the <tt>ghc -split-objs</tt>
--   flag.
ghcOptSplitObjs :: GhcOptions -> Flag Bool

-- | Extra GHCi startup scripts; the <tt>-ghci-script</tt> flag
ghcOptGHCiScripts :: GhcOptions -> [FilePath]
ghcOptHiSuffix :: GhcOptions -> Flag String
ghcOptObjSuffix :: GhcOptions -> Flag String
ghcOptHiDir :: GhcOptions -> Flag FilePath
ghcOptObjDir :: GhcOptions -> Flag FilePath
ghcOptStubDir :: GhcOptions -> Flag FilePath
ghcOptDynamic :: GhcOptions -> Flag Bool
ghcOptShared :: GhcOptions -> Flag Bool
ghcOptFPic :: GhcOptions -> Flag Bool
ghcOptDylibName :: GhcOptions -> Flag String

-- | Get GHC to be quiet or verbose with what it's doing; the <tt>ghc
--   -v</tt> flag.
ghcOptVerbosity :: GhcOptions -> Flag Verbosity

-- | Let GHC know that it is Cabal that's calling it. Modifies some of the
--   GHC error messages.
ghcOptCabal :: GhcOptions -> Flag Bool
data GhcMode

-- | <pre>
--   ghc -c
--   </pre>
GhcModeCompile :: GhcMode

-- | <pre>
--   ghc
--   </pre>
GhcModeLink :: GhcMode

-- | <pre>
--   ghc --make
--   </pre>
GhcModeMake :: GhcMode

-- | <tt>ghci</tt> / <tt>ghc --interactive</tt>
GhcModeInteractive :: GhcMode

-- | <tt>ghc --abi-hash</tt> | GhcModeDepAnalysis -- ^ <tt>ghc -M</tt> |
--   GhcModeEvaluate -- ^ <tt>ghc -e</tt>
GhcModeAbiHash :: GhcMode
data GhcOptimisation

-- | <pre>
--   -O0
--   </pre>
GhcNoOptimisation :: GhcOptimisation

-- | <pre>
--   -O
--   </pre>
GhcNormalOptimisation :: GhcOptimisation

-- | <pre>
--   -O2
--   </pre>
GhcMaximumOptimisation :: GhcOptimisation

-- | e.g. <tt>-Odph</tt>
GhcSpecialOptimisation :: String -> GhcOptimisation
ghcInvocation :: ConfiguredProgram -> GhcOptions -> ProgramInvocation
renderGhcOptions :: Version -> GhcOptions -> [String]
runGHC :: Verbosity -> ConfiguredProgram -> GhcOptions -> IO ()
instance Show GhcMode
instance Eq GhcMode
instance Show GhcOptimisation
instance Eq GhcOptimisation
instance Show GhcOptions
instance Monoid GhcOptions


-- | Once a package has been configured we have resolved conditionals and
--   dependencies, configured the compiler and other needed external
--   programs. The <a>LocalBuildInfo</a> is used to hold all this
--   information. It holds the install dirs, the compiler, the exact
--   package dependencies, the configured programs, the package database to
--   use and a bunch of miscellaneous configure flags. It gets saved and
--   reloaded from a file (<tt>dist/setup-config</tt>). It gets passed in
--   to very many subsequent build actions.
module Distribution.Simple.LocalBuildInfo

-- | Data cached after configuration step. See also <a>ConfigFlags</a>.
data LocalBuildInfo
LocalBuildInfo :: ConfigFlags -> [String] -> InstallDirTemplates -> Compiler -> FilePath -> FilePath -> Maybe ComponentLocalBuildInfo -> [(String, ComponentLocalBuildInfo)] -> [ComponentName] -> [(String, ComponentLocalBuildInfo)] -> [(String, ComponentLocalBuildInfo)] -> PackageIndex -> Maybe FilePath -> PackageDescription -> ProgramConfiguration -> PackageDBStack -> Bool -> Bool -> Bool -> Bool -> Bool -> OptimisationLevel -> Bool -> Bool -> Bool -> PathTemplate -> PathTemplate -> LocalBuildInfo

-- | Options passed to the configuration step. Needed to re-run
--   configuration when .cabal is out of date
configFlags :: LocalBuildInfo -> ConfigFlags

-- | Extra args on the command line for the configuration step. Needed to
--   re-run configuration when .cabal is out of date
extraConfigArgs :: LocalBuildInfo -> [String]

-- | The installation directories for the various differnt kinds of files
--   TODO: inplaceDirTemplates :: InstallDirs FilePath
installDirTemplates :: LocalBuildInfo -> InstallDirTemplates

-- | The compiler we're building with
compiler :: LocalBuildInfo -> Compiler

-- | Where to build the package. TODO: eliminate hugs's scratchDir, use
--   builddir
buildDir :: LocalBuildInfo -> FilePath

-- | Where to put the result of the Hugs build.
scratchDir :: LocalBuildInfo -> FilePath
libraryConfig :: LocalBuildInfo -> Maybe ComponentLocalBuildInfo
executableConfigs :: LocalBuildInfo -> [(String, ComponentLocalBuildInfo)]

-- | All the components to build, ordered by topological sort over the
--   intrapackage dependency graph
compBuildOrder :: LocalBuildInfo -> [ComponentName]
testSuiteConfigs :: LocalBuildInfo -> [(String, ComponentLocalBuildInfo)]
benchmarkConfigs :: LocalBuildInfo -> [(String, ComponentLocalBuildInfo)]

-- | All the info about the installed packages that the current package
--   depends on (directly or indirectly).
installedPkgs :: LocalBuildInfo -> PackageIndex

-- | the filename containing the .cabal file, if available
pkgDescrFile :: LocalBuildInfo -> Maybe FilePath

-- | The resolved package description, that does not contain any
--   conditionals.
localPkgDescr :: LocalBuildInfo -> PackageDescription

-- | Location and args for all programs
withPrograms :: LocalBuildInfo -> ProgramConfiguration

-- | What package database to use, global/user
withPackageDB :: LocalBuildInfo -> PackageDBStack

-- | Whether to build normal libs.
withVanillaLib :: LocalBuildInfo -> Bool

-- | Whether to build profiling versions of libs.
withProfLib :: LocalBuildInfo -> Bool

-- | Whether to build shared versions of libs.
withSharedLib :: LocalBuildInfo -> Bool

-- | Whether to link executables dynamically
withDynExe :: LocalBuildInfo -> Bool

-- | Whether to build executables for profiling.
withProfExe :: LocalBuildInfo -> Bool

-- | Whether to build with optimization (if available).
withOptimization :: LocalBuildInfo -> OptimisationLevel

-- | Whether to build libs suitable for use with GHCi.
withGHCiLib :: LocalBuildInfo -> Bool

-- | Use -split-objs with GHC, if available
splitObjs :: LocalBuildInfo -> Bool

-- | Whether to strip executables during install
stripExes :: LocalBuildInfo -> Bool

-- | Prefix to be prepended to installed executables
progPrefix :: LocalBuildInfo -> PathTemplate

-- | Suffix to be appended to installed executables
progSuffix :: LocalBuildInfo -> PathTemplate

-- | External package dependencies for the package as a whole. This is the
--   union of the individual <a>componentPackageDeps</a>, less any internal
--   deps.
externalPackageDeps :: LocalBuildInfo -> [(InstalledPackageId, PackageId)]

-- | The installed package Id we use for local packages registered in the
--   local package db. This is what is used for intra-package deps between
--   components.
inplacePackageId :: PackageId -> InstalledPackageId
data Component
CLib :: Library -> Component
CExe :: Executable -> Component
CTest :: TestSuite -> Component
CBench :: Benchmark -> Component
foldComponent :: (Library -> a) -> (Executable -> a) -> (TestSuite -> a) -> (Benchmark -> a) -> Component -> a
componentBuildInfo :: Component -> BuildInfo

-- | Obtains all components (libs, exes, or test suites), transformed by
--   the given function. Useful for gathering dependencies with component
--   context.
allComponentsBy :: PackageDescription -> (Component -> a) -> [a]
data ComponentName
CLibName :: ComponentName
CExeName :: String -> ComponentName
CTestName :: String -> ComponentName
CBenchName :: String -> ComponentName
data ComponentLocalBuildInfo
ComponentLocalBuildInfo :: [(InstalledPackageId, PackageId)] -> ComponentLocalBuildInfo

-- | Resolved internal and external package dependencies for this
--   component. The <a>BuildInfo</a> specifies a set of build dependencies
--   that must be satisfied in terms of version ranges. This field fixes
--   those dependencies to the specific versions available on this machine
--   for this compiler.
componentPackageDeps :: ComponentLocalBuildInfo -> [(InstalledPackageId, PackageId)]

-- | Perform the action on each buildable <a>Library</a> or
--   <a>Executable</a> (Component) in the PackageDescription, subject to
--   the build order specified by the <a>compBuildOrder</a> field of the
--   given <a>LocalBuildInfo</a>
withComponentsLBI :: PackageDescription -> LocalBuildInfo -> (Component -> ComponentLocalBuildInfo -> IO ()) -> IO ()

-- | If the package description has a library section, call the given
--   function with the library build info as argument. Extended version of
--   <a>withLib</a> that also gives corresponding build info.
withLibLBI :: PackageDescription -> LocalBuildInfo -> (Library -> ComponentLocalBuildInfo -> IO ()) -> IO ()

-- | Perform the action on each buildable <a>Executable</a> in the package
--   description. Extended version of <a>withExe</a> that also gives
--   corresponding build info.
withExeLBI :: PackageDescription -> LocalBuildInfo -> (Executable -> ComponentLocalBuildInfo -> IO ()) -> IO ()
withTestLBI :: PackageDescription -> LocalBuildInfo -> (TestSuite -> ComponentLocalBuildInfo -> IO ()) -> IO ()

-- | See <a>absoluteInstallDirs</a>
absoluteInstallDirs :: PackageDescription -> LocalBuildInfo -> CopyDest -> InstallDirs FilePath

-- | See <a>prefixRelativeInstallDirs</a>
prefixRelativeInstallDirs :: PackageId -> LocalBuildInfo -> InstallDirs (Maybe FilePath)
substPathTemplate :: PackageId -> LocalBuildInfo -> PathTemplate -> FilePath
instance Show Component
instance Eq Component
instance Read Component
instance Show ComponentName
instance Eq ComponentName
instance Read ComponentName
instance Read ComponentLocalBuildInfo
instance Show ComponentLocalBuildInfo
instance Read LocalBuildInfo
instance Show LocalBuildInfo


-- | A bunch of dirs, paths and file names used for intermediate build
--   steps.
module Distribution.Simple.BuildPaths
defaultDistPref :: FilePath
srcPref :: FilePath -> FilePath
hscolourPref :: FilePath -> PackageDescription -> FilePath
haddockPref :: FilePath -> PackageDescription -> FilePath

-- | The directory in which we put auto-generated modules
autogenModulesDir :: LocalBuildInfo -> String

-- | The name of the auto-generated module associated with a package
autogenModuleName :: PackageDescription -> ModuleName
cppHeaderName :: String
haddockName :: PackageDescription -> FilePath
mkLibName :: PackageIdentifier -> String
mkProfLibName :: PackageIdentifier -> String
mkSharedLibName :: PackageIdentifier -> CompilerId -> String

-- | Extension for executable files (typically <tt>""</tt> on Unix and
--   <tt>"exe"</tt> on Windows or OS/2)
exeExtension :: String

-- | Extension for object files. For GHC and NHC the extension is
--   <tt>"o"</tt>. Hugs uses either <tt>"o"</tt> or <tt>"obj"</tt>
--   depending on the used C compiler.
objExtension :: String

-- | Extension for dynamically linked (or shared) libraries (typically
--   <tt>"so"</tt> on Unix and <tt>"dll"</tt> on Windows)
dllExtension :: String


-- | This module contains most of the JHC-specific code for configuring,
--   building and installing packages.
module Distribution.Simple.JHC
configure :: Verbosity -> Maybe FilePath -> Maybe FilePath -> ProgramConfiguration -> IO (Compiler, ProgramConfiguration)
getInstalledPackages :: Verbosity -> PackageDBStack -> ProgramConfiguration -> IO PackageIndex

-- | Building a package for JHC. Currently C source files are not
--   supported.
buildLib :: Verbosity -> PackageDescription -> LocalBuildInfo -> Library -> ComponentLocalBuildInfo -> IO ()

-- | Building an executable for JHC. Currently C source files are not
--   supported.
buildExe :: Verbosity -> PackageDescription -> LocalBuildInfo -> Executable -> ComponentLocalBuildInfo -> IO ()
installLib :: Verbosity -> FilePath -> FilePath -> PackageDescription -> Library -> IO ()
installExe :: Verbosity -> FilePath -> FilePath -> (FilePath, FilePath) -> PackageDescription -> Executable -> IO ()


-- | This module contains most of the NHC-specific code for configuring,
--   building and installing packages.
module Distribution.Simple.NHC
configure :: Verbosity -> Maybe FilePath -> Maybe FilePath -> ProgramConfiguration -> IO (Compiler, ProgramConfiguration)
getInstalledPackages :: Verbosity -> PackageDBStack -> ProgramConfiguration -> IO PackageIndex

-- | FIX: For now, the target must contain a main module. Not used ATM.
--   Re-add later.
buildLib :: Verbosity -> PackageDescription -> LocalBuildInfo -> Library -> ComponentLocalBuildInfo -> IO ()

-- | Building an executable for NHC.
buildExe :: Verbosity -> PackageDescription -> LocalBuildInfo -> Executable -> ComponentLocalBuildInfo -> IO ()

-- | Install for nhc98: .hi and .a files
installLib :: Verbosity -> FilePath -> FilePath -> PackageIdentifier -> Library -> IO ()

-- | Install executables for NHC.
installExe :: Verbosity -> FilePath -> FilePath -> (FilePath, FilePath) -> Executable -> IO ()


-- | This module contains most of the UHC-specific code for configuring,
--   building and installing packages.
--   
--   Thanks to the authors of the other implementation-specific files, in
--   particular to Isaac Jones, Duncan Coutts and Henning Thielemann, for
--   inspiration on how to design this module.
module Distribution.Simple.UHC
configure :: Verbosity -> Maybe FilePath -> Maybe FilePath -> ProgramConfiguration -> IO (Compiler, ProgramConfiguration)
getInstalledPackages :: Verbosity -> Compiler -> PackageDBStack -> ProgramConfiguration -> IO PackageIndex
buildLib :: Verbosity -> PackageDescription -> LocalBuildInfo -> Library -> ComponentLocalBuildInfo -> IO ()
buildExe :: Verbosity -> PackageDescription -> LocalBuildInfo -> Executable -> ComponentLocalBuildInfo -> IO ()
installLib :: Verbosity -> LocalBuildInfo -> FilePath -> FilePath -> FilePath -> PackageDescription -> Library -> IO ()
registerPackage :: Verbosity -> InstalledPackageInfo -> PackageDescription -> LocalBuildInfo -> Bool -> PackageDBStack -> IO ()


-- | Generate cabal_macros.h - CPP macros for package version testing
--   
--   When using CPP you get
--   
--   <pre>
--   VERSION_&lt;package&gt;
--   MIN_VERSION_&lt;package&gt;(A,B,C)
--   </pre>
--   
--   for each <i>package</i> in <tt>build-depends</tt>, which is true if
--   the version of <i>package</i> in use is <tt>&gt;= A.B.C</tt>, using
--   the normal ordering on version numbers.
module Distribution.Simple.Build.Macros
generate :: PackageDescription -> LocalBuildInfo -> String


-- | Generating the Paths_pkgname module.
--   
--   This is a module that Cabal generates for the benefit of packages. It
--   enables them to find their version number and find any installed data
--   files at runtime. This code should probably be split off into another
--   module.
module Distribution.Simple.Build.PathsModule
generate :: PackageDescription -> LocalBuildInfo -> String

-- | Generates the name of the environment variable controlling the path
--   component of interest.
pkgPathEnvVar :: PackageDescription -> String -> String


-- | This is a fairly large module. It contains most of the GHC-specific
--   code for configuring, building and installing packages. It also
--   exports a function for finding out what packages are already
--   installed. Configuring involves finding the <tt>ghc</tt> and
--   <tt>ghc-pkg</tt> programs, finding what language extensions this
--   version of ghc supports and returning a <a>Compiler</a> value.
--   
--   <a>getInstalledPackages</a> involves calling the <tt>ghc-pkg</tt>
--   program to find out what packages are installed.
--   
--   Building is somewhat complex as there is quite a bit of information to
--   take into account. We have to build libs and programs, possibly for
--   profiling and shared libs. We have to support building libraries that
--   will be usable by GHCi and also ghc's <tt>-split-objs</tt> feature. We
--   have to compile any C files using ghc. Linking, especially for
--   <tt>split-objs</tt> is remarkably complex, partly because there tend
--   to be 1,000's of <tt>.o</tt> files and this can often be more than we
--   can pass to the <tt>ld</tt> or <tt>ar</tt> programs in one go.
--   
--   Installing for libs and exes involves finding the right files and
--   copying them to the right places. One of the more tricky things about
--   this module is remembering the layout of files in the build directory
--   (which is not explicitly documented) and thus what search dirs are
--   used for various kinds of files.
module Distribution.Simple.GHC
configure :: Verbosity -> Maybe FilePath -> Maybe FilePath -> ProgramConfiguration -> IO (Compiler, ProgramConfiguration)
getInstalledPackages :: Verbosity -> PackageDBStack -> ProgramConfiguration -> IO PackageIndex

-- | Build a library with GHC.
buildLib :: Verbosity -> PackageDescription -> LocalBuildInfo -> Library -> ComponentLocalBuildInfo -> IO ()

-- | Build an executable with GHC.
buildExe :: Verbosity -> PackageDescription -> LocalBuildInfo -> Executable -> ComponentLocalBuildInfo -> IO ()

-- | Install for ghc, .hi, .a and, if --with-ghci given, .o
installLib :: Verbosity -> LocalBuildInfo -> FilePath -> FilePath -> FilePath -> PackageDescription -> Library -> IO ()

-- | Install executables for GHC.
installExe :: Verbosity -> LocalBuildInfo -> InstallDirs FilePath -> FilePath -> (FilePath, FilePath) -> PackageDescription -> Executable -> IO ()

-- | Extracts a String representing a hash of the ABI of a built library.
--   It can fail if the library has not yet been built.
libAbiHash :: Verbosity -> PackageDescription -> LocalBuildInfo -> Library -> ComponentLocalBuildInfo -> IO String
registerPackage :: Verbosity -> InstalledPackageInfo -> PackageDescription -> LocalBuildInfo -> Bool -> PackageDBStack -> IO ()
componentGhcOptions :: Verbosity -> LocalBuildInfo -> BuildInfo -> ComponentLocalBuildInfo -> FilePath -> GhcOptions
ghcLibDir :: Verbosity -> LocalBuildInfo -> IO FilePath

-- | <i>Deprecated: Use the GhcOptions record instead </i>
ghcVerbosityOptions :: Verbosity -> [String]

-- | <i>Deprecated: Use the GhcOptions record instead </i>
ghcPackageDbOptions :: PackageDBStack -> [String]


-- | This is a fairly large module. It contains most of the GHC-specific
--   code for configuring, building and installing packages. It also
--   exports a function for finding out what packages are already
--   installed. Configuring involves finding the <tt>ghc</tt> and
--   <tt>ghc-pkg</tt> programs, finding what language extensions this
--   version of ghc supports and returning a <a>Compiler</a> value.
--   
--   <a>getInstalledPackages</a> involves calling the <tt>ghc-pkg</tt>
--   program to find out what packages are installed.
--   
--   Building is somewhat complex as there is quite a bit of information to
--   take into account. We have to build libs and programs, possibly for
--   profiling and shared libs. We have to support building libraries that
--   will be usable by GHCi and also ghc's <tt>-split-objs</tt> feature. We
--   have to compile any C files using ghc. Linking, especially for
--   <tt>split-objs</tt> is remarkably complex, partly because there tend
--   to be 1,000's of <tt>.o</tt> files and this can often be more than we
--   can pass to the <tt>ld</tt> or <tt>ar</tt> programs in one go.
--   
--   Installing for libs and exes involves finding the right files and
--   copying them to the right places. One of the more tricky things about
--   this module is remembering the layout of files in the build directory
--   (which is not explicitly documented) and thus what search dirs are
--   used for various kinds of files.
module Distribution.Simple.LHC
configure :: Verbosity -> Maybe FilePath -> Maybe FilePath -> ProgramConfiguration -> IO (Compiler, ProgramConfiguration)
getInstalledPackages :: Verbosity -> PackageDBStack -> ProgramConfiguration -> IO PackageIndex

-- | Build a library with LHC.
buildLib :: Verbosity -> PackageDescription -> LocalBuildInfo -> Library -> ComponentLocalBuildInfo -> IO ()

-- | Build an executable with LHC.
buildExe :: Verbosity -> PackageDescription -> LocalBuildInfo -> Executable -> ComponentLocalBuildInfo -> IO ()

-- | Install for ghc, .hi, .a and, if --with-ghci given, .o
installLib :: Verbosity -> LocalBuildInfo -> FilePath -> FilePath -> FilePath -> PackageDescription -> Library -> IO ()

-- | Install executables for GHC.
installExe :: Verbosity -> LocalBuildInfo -> InstallDirs FilePath -> FilePath -> (FilePath, FilePath) -> PackageDescription -> Executable -> IO ()
registerPackage :: Verbosity -> InstalledPackageInfo -> PackageDescription -> LocalBuildInfo -> Bool -> PackageDBStack -> IO ()
ghcOptions :: LocalBuildInfo -> BuildInfo -> ComponentLocalBuildInfo -> FilePath -> [String]
ghcVerbosityOptions :: Verbosity -> [String]


-- | This module provides functions for locating various HPC-related paths
--   and a function for adding the necessary options to a
--   PackageDescription to build test suites with HPC enabled.
module Distribution.Simple.Hpc

-- | Conditionally enable Haskell Program Coverage by adding the necessary
--   GHC options to a PackageDescription.
--   
--   TODO: do this differently in the build stage by constructing local
--   build info, not by modifying the original PackageDescription.
enableCoverage :: Bool -> String -> PackageDescription -> PackageDescription
htmlDir :: FilePath -> FilePath -> FilePath
tixDir :: FilePath -> FilePath -> FilePath

-- | Path to the .tix file containing a test suite's sum statistics.
tixFilePath :: FilePath -> FilePath -> FilePath

-- | Generate the HTML markup for all of a package's test suites.
markupPackage :: Verbosity -> LocalBuildInfo -> FilePath -> String -> [TestSuite] -> IO ()

-- | Generate the HTML markup for a test suite.
markupTest :: Verbosity -> LocalBuildInfo -> FilePath -> String -> TestSuite -> IO ()


-- | This is the entry point into testing a built package. It performs the
--   "<tt>./setup test</tt>" action. It runs test suites designated in the
--   package description and reports on the results.
module Distribution.Simple.Test

-- | Perform the "<tt>./setup test</tt>" action.
test :: PackageDescription -> LocalBuildInfo -> TestFlags -> IO ()

-- | Main function for test stubs. Once, it was written directly into the
--   stub, but minimizing the amount of code actually in the stub maximizes
--   the number of detectable errors when Cabal is compiled.
stubMain :: IO [Test] -> IO ()

-- | Write the source file for a library <tt>TestSuite</tt> stub
--   executable.
writeSimpleTestStub :: TestSuite -> FilePath -> IO ()

-- | The filename of the source file for the stub executable associated
--   with a library <tt>TestSuite</tt>.
stubFilePath :: TestSuite -> FilePath

-- | The name of the stub executable associated with a library
--   <tt>TestSuite</tt>.
stubName :: TestSuite -> FilePath

-- | Logs all test results for a package, broken down first by test suite
--   and then by test case.
data PackageLog
PackageLog :: PackageId -> CompilerId -> Platform -> [TestSuiteLog] -> PackageLog
package :: PackageLog -> PackageId
compiler :: PackageLog -> CompilerId
platform :: PackageLog -> Platform
testSuites :: PackageLog -> [TestSuiteLog]

-- | Logs test suite results, itemized by test case.
data TestSuiteLog
TestSuiteLog :: String -> TestLogs -> FilePath -> TestSuiteLog
testSuiteName :: TestSuiteLog -> String
testLogs :: TestSuiteLog -> TestLogs
logFile :: TestSuiteLog -> FilePath
data TestLogs
TestLog :: String -> Options -> Result -> TestLogs
testName :: TestLogs -> String
testOptionsReturned :: TestLogs -> Options
testResult :: TestLogs -> Result
GroupLogs :: String -> [TestLogs] -> TestLogs

-- | From a <a>TestSuiteLog</a>, determine if the test suite passed.
suitePassed :: TestSuiteLog -> Bool

-- | From a <a>TestSuiteLog</a>, determine if the test suite failed.
suiteFailed :: TestSuiteLog -> Bool

-- | From a <a>TestSuiteLog</a>, determine if the test suite encountered
--   errors.
suiteError :: TestSuiteLog -> Bool
instance Read TestLogs
instance Show TestLogs
instance Eq TestLogs
instance Read TestSuiteLog
instance Show TestSuiteLog
instance Eq TestSuiteLog
instance Read PackageLog
instance Show PackageLog
instance Eq PackageLog


-- | This defines a <a>PreProcessor</a> abstraction which represents a
--   pre-processor that can transform one kind of file into another. There
--   is also a <a>PPSuffixHandler</a> which is a combination of a file
--   extension and a function for configuring a <a>PreProcessor</a>. It
--   defines a bunch of known built-in preprocessors like <tt>cpp</tt>,
--   <tt>cpphs</tt>, <tt>c2hs</tt>, <tt>hsc2hs</tt>, <tt>happy</tt>,
--   <tt>alex</tt> etc and lists them in <a>knownSuffixHandlers</a>. On top
--   of this it provides a function for actually preprocessing some sources
--   given a bunch of known suffix handlers. This module is not as good as
--   it could be, it could really do with a rewrite to address some of the
--   problems we have with pre-processors.
module Distribution.Simple.PreProcess

-- | Apply preprocessors to the sources from <a>hsSourceDirs</a> for a
--   given component (lib, exe, or test suite).
preprocessComponent :: PackageDescription -> Component -> LocalBuildInfo -> Bool -> Verbosity -> [PPSuffixHandler] -> IO ()

-- | Standard preprocessors: GreenCard, c2hs, hsc2hs, happy, alex and
--   cpphs.
knownSuffixHandlers :: [PPSuffixHandler]

-- | Convenience function; get the suffixes of these preprocessors.
ppSuffixes :: [PPSuffixHandler] -> [String]

-- | A preprocessor for turning non-Haskell files with the given extension
--   into plain Haskell source files.
type PPSuffixHandler = (String, BuildInfo -> LocalBuildInfo -> PreProcessor)

-- | The interface to a preprocessor, which may be implemented using an
--   external program, but need not be. The arguments are the name of the
--   input file, the name of the output file and a verbosity level. Here is
--   a simple example that merely prepends a comment to the given source
--   file:
--   
--   <pre>
--   ppTestHandler :: PreProcessor
--   ppTestHandler =
--     PreProcessor {
--       platformIndependent = True,
--       runPreProcessor = mkSimplePreProcessor $ \inFile outFile verbosity -&gt;
--         do info verbosity (inFile++" has been preprocessed to "++outFile)
--            stuff &lt;- readFile inFile
--            writeFile outFile ("-- preprocessed as a test\n\n" ++ stuff)
--            return ExitSuccess
--   </pre>
--   
--   We split the input and output file names into a base directory and the
--   rest of the file name. The input base dir is the path in the list of
--   search dirs that this file was found in. The output base dir is the
--   build dir where all the generated source files are put.
--   
--   The reason for splitting it up this way is that some pre-processors
--   don't simply generate one output .hs file from one input file but have
--   dependencies on other genereated files (notably c2hs, where building
--   one .hs file may require reading other .chi files, and then compiling
--   the .hs file may require reading a generated .h file). In these cases
--   the generated files need to embed relative path names to each other
--   (eg the generated .hs file mentions the .h file in the FFI imports).
--   This path must be relative to the base directory where the genereated
--   files are located, it cannot be relative to the top level of the build
--   tree because the compilers do not look for .h files relative to there,
--   ie we do not use "-I .", instead we use "-I dist/build" (or whatever
--   dist dir has been set by the user)
--   
--   Most pre-processors do not care of course, so mkSimplePreProcessor and
--   runSimplePreProcessor functions handle the simple case.
data PreProcessor
PreProcessor :: Bool -> ((FilePath, FilePath) -> (FilePath, FilePath) -> Verbosity -> IO ()) -> PreProcessor
platformIndependent :: PreProcessor -> Bool
runPreProcessor :: PreProcessor -> (FilePath, FilePath) -> (FilePath, FilePath) -> Verbosity -> IO ()
mkSimplePreProcessor :: (FilePath -> FilePath -> Verbosity -> IO ()) -> (FilePath, FilePath) -> (FilePath, FilePath) -> Verbosity -> IO ()
runSimplePreProcessor :: PreProcessor -> FilePath -> FilePath -> Verbosity -> IO ()
ppCpp :: BuildInfo -> LocalBuildInfo -> PreProcessor
ppCpp' :: [String] -> BuildInfo -> LocalBuildInfo -> PreProcessor
ppGreenCard :: BuildInfo -> LocalBuildInfo -> PreProcessor
ppC2hs :: BuildInfo -> LocalBuildInfo -> PreProcessor
ppHsc2hs :: BuildInfo -> LocalBuildInfo -> PreProcessor
ppHappy :: BuildInfo -> LocalBuildInfo -> PreProcessor
ppAlex :: BuildInfo -> LocalBuildInfo -> PreProcessor
ppUnlit :: PreProcessor


-- | This defines the API that <tt>Setup.hs</tt> scripts can use to
--   customise the way the build works. This module just defines the
--   <a>UserHooks</a> type. The predefined sets of hooks that implement the
--   <tt>Simple</tt>, <tt>Make</tt> and <tt>Configure</tt> build systems
--   are defined in <a>Distribution.Simple</a>. The <a>UserHooks</a> is a
--   big record of functions. There are 3 for each action, a pre, post and
--   the action itself. There are few other miscellaneous hooks, ones to
--   extend the set of programs and preprocessors and one to override the
--   function used to read the <tt>.cabal</tt> file.
--   
--   This hooks type is widely agreed to not be the right solution. Partly
--   this is because changes to it usually break custom <tt>Setup.hs</tt>
--   files and yet many internal code changes do require changes to the
--   hooks. For example we cannot pass any extra parameters to most of the
--   functions that implement the various phases because it would involve
--   changing the types of the corresponding hook. At some point it will
--   have to be replaced.
module Distribution.Simple.UserHooks

-- | Hooks allow authors to add specific functionality before and after a
--   command is run, and also to specify additional preprocessors.
--   
--   <ul>
--   <li>WARNING: The hooks interface is under rather constant flux as we
--   try to understand users needs. Setup files that depend on this
--   interface may break in future releases.</li>
--   </ul>
data UserHooks
UserHooks :: (Args -> Bool -> PackageDescription -> LocalBuildInfo -> IO ()) -> IO (Maybe GenericPackageDescription) -> [PPSuffixHandler] -> [Program] -> (Args -> ConfigFlags -> IO HookedBuildInfo) -> ((GenericPackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo) -> (Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ()) -> (Args -> BuildFlags -> IO HookedBuildInfo) -> (PackageDescription -> LocalBuildInfo -> UserHooks -> BuildFlags -> IO ()) -> (Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()) -> (Args -> CleanFlags -> IO HookedBuildInfo) -> (PackageDescription -> () -> UserHooks -> CleanFlags -> IO ()) -> (Args -> CleanFlags -> PackageDescription -> () -> IO ()) -> (Args -> CopyFlags -> IO HookedBuildInfo) -> (PackageDescription -> LocalBuildInfo -> UserHooks -> CopyFlags -> IO ()) -> (Args -> CopyFlags -> PackageDescription -> LocalBuildInfo -> IO ()) -> (Args -> InstallFlags -> IO HookedBuildInfo) -> (PackageDescription -> LocalBuildInfo -> UserHooks -> InstallFlags -> IO ()) -> (Args -> InstallFlags -> PackageDescription -> LocalBuildInfo -> IO ()) -> (Args -> SDistFlags -> IO HookedBuildInfo) -> (PackageDescription -> Maybe LocalBuildInfo -> UserHooks -> SDistFlags -> IO ()) -> (Args -> SDistFlags -> PackageDescription -> Maybe LocalBuildInfo -> IO ()) -> (Args -> RegisterFlags -> IO HookedBuildInfo) -> (PackageDescription -> LocalBuildInfo -> UserHooks -> RegisterFlags -> IO ()) -> (Args -> RegisterFlags -> PackageDescription -> LocalBuildInfo -> IO ()) -> (Args -> RegisterFlags -> IO HookedBuildInfo) -> (PackageDescription -> LocalBuildInfo -> UserHooks -> RegisterFlags -> IO ()) -> (Args -> RegisterFlags -> PackageDescription -> LocalBuildInfo -> IO ()) -> (Args -> HscolourFlags -> IO HookedBuildInfo) -> (PackageDescription -> LocalBuildInfo -> UserHooks -> HscolourFlags -> IO ()) -> (Args -> HscolourFlags -> PackageDescription -> LocalBuildInfo -> IO ()) -> (Args -> HaddockFlags -> IO HookedBuildInfo) -> (PackageDescription -> LocalBuildInfo -> UserHooks -> HaddockFlags -> IO ()) -> (Args -> HaddockFlags -> PackageDescription -> LocalBuildInfo -> IO ()) -> (Args -> TestFlags -> IO HookedBuildInfo) -> (PackageDescription -> LocalBuildInfo -> UserHooks -> TestFlags -> IO ()) -> (Args -> TestFlags -> PackageDescription -> LocalBuildInfo -> IO ()) -> (Args -> BenchmarkFlags -> IO HookedBuildInfo) -> (Args -> PackageDescription -> LocalBuildInfo -> UserHooks -> BenchmarkFlags -> IO ()) -> (Args -> BenchmarkFlags -> PackageDescription -> LocalBuildInfo -> IO ()) -> UserHooks

-- | Used for <tt>./setup test</tt>

-- | <i>Deprecated: Please use the new testing interface instead! </i>
runTests :: UserHooks -> Args -> Bool -> PackageDescription -> LocalBuildInfo -> IO ()

-- | Read the description file
readDesc :: UserHooks -> IO (Maybe GenericPackageDescription)

-- | Custom preprocessors in addition to and overriding
--   <tt>knownSuffixHandlers</tt>.
hookedPreProcessors :: UserHooks -> [PPSuffixHandler]

-- | These programs are detected at configure time. Arguments for them are
--   added to the configure command.
hookedPrograms :: UserHooks -> [Program]

-- | Hook to run before configure command
preConf :: UserHooks -> Args -> ConfigFlags -> IO HookedBuildInfo

-- | Over-ride this hook to get different behavior during configure.
confHook :: UserHooks -> (GenericPackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo

-- | Hook to run after configure command
postConf :: UserHooks -> Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ()

-- | Hook to run before build command. Second arg indicates verbosity
--   level.
preBuild :: UserHooks -> Args -> BuildFlags -> IO HookedBuildInfo

-- | Over-ride this hook to gbet different behavior during build.
buildHook :: UserHooks -> PackageDescription -> LocalBuildInfo -> UserHooks -> BuildFlags -> IO ()

-- | Hook to run after build command. Second arg indicates verbosity level.
postBuild :: UserHooks -> Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()

-- | Hook to run before clean command. Second arg indicates verbosity
--   level.
preClean :: UserHooks -> Args -> CleanFlags -> IO HookedBuildInfo

-- | Over-ride this hook to get different behavior during clean.
cleanHook :: UserHooks -> PackageDescription -> () -> UserHooks -> CleanFlags -> IO ()

-- | Hook to run after clean command. Second arg indicates verbosity level.
postClean :: UserHooks -> Args -> CleanFlags -> PackageDescription -> () -> IO ()

-- | Hook to run before copy command
preCopy :: UserHooks -> Args -> CopyFlags -> IO HookedBuildInfo

-- | Over-ride this hook to get different behavior during copy.
copyHook :: UserHooks -> PackageDescription -> LocalBuildInfo -> UserHooks -> CopyFlags -> IO ()

-- | Hook to run after copy command
postCopy :: UserHooks -> Args -> CopyFlags -> PackageDescription -> LocalBuildInfo -> IO ()

-- | Hook to run before install command
preInst :: UserHooks -> Args -> InstallFlags -> IO HookedBuildInfo

-- | Over-ride this hook to get different behavior during install.
instHook :: UserHooks -> PackageDescription -> LocalBuildInfo -> UserHooks -> InstallFlags -> IO ()

-- | Hook to run after install command. postInst should be run on the
--   target, not on the build machine.
postInst :: UserHooks -> Args -> InstallFlags -> PackageDescription -> LocalBuildInfo -> IO ()

-- | Hook to run before sdist command. Second arg indicates verbosity
--   level.
preSDist :: UserHooks -> Args -> SDistFlags -> IO HookedBuildInfo

-- | Over-ride this hook to get different behavior during sdist.
sDistHook :: UserHooks -> PackageDescription -> Maybe LocalBuildInfo -> UserHooks -> SDistFlags -> IO ()

-- | Hook to run after sdist command. Second arg indicates verbosity level.
postSDist :: UserHooks -> Args -> SDistFlags -> PackageDescription -> Maybe LocalBuildInfo -> IO ()

-- | Hook to run before register command
preReg :: UserHooks -> Args -> RegisterFlags -> IO HookedBuildInfo

-- | Over-ride this hook to get different behavior during registration.
regHook :: UserHooks -> PackageDescription -> LocalBuildInfo -> UserHooks -> RegisterFlags -> IO ()

-- | Hook to run after register command
postReg :: UserHooks -> Args -> RegisterFlags -> PackageDescription -> LocalBuildInfo -> IO ()

-- | Hook to run before unregister command
preUnreg :: UserHooks -> Args -> RegisterFlags -> IO HookedBuildInfo

-- | Over-ride this hook to get different behavior during registration.
unregHook :: UserHooks -> PackageDescription -> LocalBuildInfo -> UserHooks -> RegisterFlags -> IO ()

-- | Hook to run after unregister command
postUnreg :: UserHooks -> Args -> RegisterFlags -> PackageDescription -> LocalBuildInfo -> IO ()

-- | Hook to run before hscolour command. Second arg indicates verbosity
--   level.
preHscolour :: UserHooks -> Args -> HscolourFlags -> IO HookedBuildInfo

-- | Over-ride this hook to get different behavior during hscolour.
hscolourHook :: UserHooks -> PackageDescription -> LocalBuildInfo -> UserHooks -> HscolourFlags -> IO ()

-- | Hook to run after hscolour command. Second arg indicates verbosity
--   level.
postHscolour :: UserHooks -> Args -> HscolourFlags -> PackageDescription -> LocalBuildInfo -> IO ()

-- | Hook to run before haddock command. Second arg indicates verbosity
--   level.
preHaddock :: UserHooks -> Args -> HaddockFlags -> IO HookedBuildInfo

-- | Over-ride this hook to get different behavior during haddock.
haddockHook :: UserHooks -> PackageDescription -> LocalBuildInfo -> UserHooks -> HaddockFlags -> IO ()

-- | Hook to run after haddock command. Second arg indicates verbosity
--   level.
postHaddock :: UserHooks -> Args -> HaddockFlags -> PackageDescription -> LocalBuildInfo -> IO ()

-- | Hook to run before test command.
preTest :: UserHooks -> Args -> TestFlags -> IO HookedBuildInfo

-- | Over-ride this hook to get different behavior during test.
testHook :: UserHooks -> PackageDescription -> LocalBuildInfo -> UserHooks -> TestFlags -> IO ()

-- | Hook to run after test command.
postTest :: UserHooks -> Args -> TestFlags -> PackageDescription -> LocalBuildInfo -> IO ()

-- | Hook to run before bench command.
preBench :: UserHooks -> Args -> BenchmarkFlags -> IO HookedBuildInfo

-- | Over-ride this hook to get different behavior during bench.
benchHook :: UserHooks -> Args -> PackageDescription -> LocalBuildInfo -> UserHooks -> BenchmarkFlags -> IO ()

-- | Hook to run after bench command.
postBench :: UserHooks -> Args -> BenchmarkFlags -> PackageDescription -> LocalBuildInfo -> IO ()
type Args = [String]

-- | Empty <a>UserHooks</a> which do nothing.
emptyUserHooks :: UserHooks


-- | This is the entry point into running the benchmarks in a built
--   package. It performs the "<tt>./setup bench</tt>" action. It runs
--   benchmarks designated in the package description.
module Distribution.Simple.Bench

-- | Perform the "<tt>./setup bench</tt>" action.
bench :: Args -> PackageDescription -> LocalBuildInfo -> BenchmarkFlags -> IO ()


-- | This handles the <tt>sdist</tt> command. The module exports an
--   <a>sdist</a> action but also some of the phases that make it up so
--   that other tools can use just the bits they need. In particular the
--   preparation of the tree of files to go into the source tarball is
--   separated from actually building the source tarball.
--   
--   The <a>createArchive</a> action uses the external <tt>tar</tt> program
--   and assumes that it accepts the <tt>-z</tt> flag. Neither of these
--   assumptions are valid on Windows. The <a>sdist</a> action now also
--   does some distribution QA checks.
module Distribution.Simple.SrcDist

-- | Create a source distribution.
sdist :: PackageDescription -> Maybe LocalBuildInfo -> SDistFlags -> (FilePath -> FilePath) -> [PPSuffixHandler] -> IO ()
printPackageProblems :: Verbosity -> PackageDescription -> IO ()

-- | Prepare a directory tree of source files.
prepareTree :: Verbosity -> PackageDescription -> Maybe LocalBuildInfo -> FilePath -> FilePath -> [PPSuffixHandler] -> IO ()

-- | Create an archive from a tree of source files, and clean up the tree.
createArchive :: Verbosity -> PackageDescription -> Maybe LocalBuildInfo -> FilePath -> FilePath -> IO FilePath

-- | Prepare a directory tree of source files for a snapshot version. It is
--   expected that the appropriate snapshot version has already been set in
--   the package description, eg using <a>snapshotPackage</a> or
--   <a>snapshotVersion</a>.
prepareSnapshotTree :: Verbosity -> PackageDescription -> Maybe LocalBuildInfo -> FilePath -> FilePath -> [PPSuffixHandler] -> IO ()

-- | Modifies a <a>PackageDescription</a> by appending a snapshot number
--   corresponding to the given date.
snapshotPackage :: CalendarTime -> PackageDescription -> PackageDescription

-- | Modifies a <a>Version</a> by appending a snapshot number corresponding
--   to the given date.
snapshotVersion :: CalendarTime -> Version -> Version

-- | Given a date produce a corresponding integer representation. For
--   example given a date <tt>18<i>03</i>2008</tt> produce the number
--   <tt>20080318</tt>.
dateToSnapshotNumber :: CalendarTime -> Int


-- | This module contains most of the NHC-specific code for configuring,
--   building and installing packages.
module Distribution.Simple.Hugs
configure :: Verbosity -> Maybe FilePath -> Maybe FilePath -> ProgramConfiguration -> IO (Compiler, ProgramConfiguration)
getInstalledPackages :: Verbosity -> PackageDBStack -> ProgramConfiguration -> IO PackageIndex

-- | Building a package for Hugs.
buildLib :: Verbosity -> PackageDescription -> LocalBuildInfo -> Library -> ComponentLocalBuildInfo -> IO ()

-- | Building an executable for Hugs.
buildExe :: Verbosity -> PackageDescription -> LocalBuildInfo -> Executable -> ComponentLocalBuildInfo -> IO ()

-- | Install for Hugs. For install, copy-prefix = prefix, but for copy
--   they're different. The library goes in
--   &lt;copy-prefix&gt;/lib/hugs/packages/&lt;pkgname&gt; (i.e.
--   &lt;prefix&gt;/lib/hugs/packages/&lt;pkgname&gt; on the target
--   system). Each executable goes in
--   &lt;copy-prefix&gt;/lib/hugs/programs/&lt;exename&gt; (i.e.
--   &lt;prefix&gt;/lib/hugs/programs/&lt;exename&gt; on the target system)
--   with a script &lt;copy-prefix&gt;/bin/&lt;exename&gt; pointing at
--   &lt;prefix&gt;/lib/hugs/programs/&lt;exename&gt;.
install :: Verbosity -> LocalBuildInfo -> FilePath -> FilePath -> FilePath -> FilePath -> FilePath -> (FilePath, FilePath) -> PackageDescription -> IO ()
registerPackage :: Verbosity -> InstalledPackageInfo -> PackageDescription -> LocalBuildInfo -> Bool -> PackageDBStack -> IO ()


-- | This module deals with registering and unregistering packages. There
--   are a couple ways it can do this, one is to do it directly. Another is
--   to generate a script that can be run later to do it. The idea here
--   being that the user is shielded from the details of what command to
--   use for package registration for a particular compiler. In practice
--   this aspect was not especially popular so we also provide a way to
--   simply generate the package registration file which then must be
--   manually passed to <tt>ghc-pkg</tt>. It is possible to generate
--   registration information for where the package is to be installed, or
--   alternatively to register the package inplace in the build tree. The
--   latter is occasionally handy, and will become more important when we
--   try to build multi-package systems.
--   
--   This module does not delegate anything to the per-compiler modules but
--   just mixes it all in in this module, which is rather unsatisfactory.
--   The script generation and the unregister feature are not well used or
--   tested.
module Distribution.Simple.Register
register :: PackageDescription -> LocalBuildInfo -> RegisterFlags -> IO ()
unregister :: PackageDescription -> LocalBuildInfo -> RegisterFlags -> IO ()
registerPackage :: Verbosity -> InstalledPackageInfo -> PackageDescription -> LocalBuildInfo -> Bool -> PackageDBStack -> IO ()
generateRegistrationInfo :: Verbosity -> PackageDescription -> Library -> LocalBuildInfo -> ComponentLocalBuildInfo -> Bool -> FilePath -> IO InstalledPackageInfo

-- | Construct <a>InstalledPackageInfo</a> for a library that is inplace in
--   the build tree.
--   
--   This function knows about the layout of inplace packages.
inplaceInstalledPackageInfo :: FilePath -> FilePath -> PackageDescription -> Library -> LocalBuildInfo -> ComponentLocalBuildInfo -> InstalledPackageInfo

-- | Construct <a>InstalledPackageInfo</a> for the final install location
--   of a library package.
--   
--   This function knows about the layout of installed packages.
absoluteInstalledPackageInfo :: PackageDescription -> Library -> LocalBuildInfo -> ComponentLocalBuildInfo -> InstalledPackageInfo

-- | Construct <a>InstalledPackageInfo</a> for a library in a package,
--   given a set of installation directories.
generalInstalledPackageInfo :: ([FilePath] -> [FilePath]) -> PackageDescription -> Library -> ComponentLocalBuildInfo -> InstallDirs FilePath -> InstalledPackageInfo


-- | This deals with the <i>configure</i> phase. It provides the
--   <a>configure</a> action which is given the package description and
--   configure flags. It then tries to: configure the compiler; resolves
--   any conditionals in the package description; resolve the package
--   dependencies; check if all the extensions used by this package are
--   supported by the compiler; check that all the build tools are
--   available (including version checks if appropriate); checks for any
--   required <tt>pkg-config</tt> packages (updating the <a>BuildInfo</a>
--   with the results)
--   
--   Then based on all this it saves the info in the <a>LocalBuildInfo</a>
--   and writes it out to the <tt>dist/setup-config</tt> file. It also
--   displays various details to the user, the amount of information
--   displayed depending on the verbosity level.
module Distribution.Simple.Configure

-- | Perform the "<tt>./setup configure</tt>" action. Returns the
--   <tt>.setup-config</tt> file.
configure :: (GenericPackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo

-- | After running configure, output the <a>LocalBuildInfo</a> to the
--   <a>localBuildInfoFile</a>.
writePersistBuildConfig :: FilePath -> LocalBuildInfo -> IO ()

-- | Read the <a>localBuildInfoFile</a>. Error if it doesn't exist. Also
--   fail if the file containing LocalBuildInfo is older than the .cabal
--   file, indicating that a re-configure is required.
getPersistBuildConfig :: FilePath -> IO LocalBuildInfo

-- | Check that localBuildInfoFile is up-to-date with respect to the .cabal
--   file.
checkPersistBuildConfigOutdated :: FilePath -> FilePath -> IO Bool

-- | Try to read the <a>localBuildInfoFile</a>.
maybeGetPersistBuildConfig :: FilePath -> IO (Maybe LocalBuildInfo)

-- | <pre>
--   dist/setup-config
--   </pre>
localBuildInfoFile :: FilePath -> FilePath
getInstalledPackages :: Verbosity -> Compiler -> PackageDBStack -> ProgramConfiguration -> IO PackageIndex
configCompiler :: Maybe CompilerFlavor -> Maybe FilePath -> Maybe FilePath -> ProgramConfiguration -> Verbosity -> IO (Compiler, ProgramConfiguration)
configCompilerAux :: ConfigFlags -> IO (Compiler, ProgramConfiguration)

-- | Makes a <a>BuildInfo</a> from C compiler and linker flags.
--   
--   This can be used with the output from configuration programs like
--   pkg-config and similar package-specific programs like mysql-config,
--   freealut-config etc. For example:
--   
--   <pre>
--   ccflags &lt;- rawSystemProgramStdoutConf verbosity prog conf ["--cflags"]
--   ldflags &lt;- rawSystemProgramStdoutConf verbosity prog conf ["--libs"]
--   return (ccldOptionsBuildInfo (words ccflags) (words ldflags))
--   </pre>
ccLdOptionsBuildInfo :: [String] -> [String] -> BuildInfo
tryGetConfigStateFile :: Read a => FilePath -> IO (Either String a)
checkForeignDeps :: PackageDescription -> LocalBuildInfo -> Verbosity -> IO ()

-- | The user interface specifies the package dbs to use with a combination
--   of <tt>--global</tt>, <tt>--user</tt> and
--   <tt>--package-db=global|user|clear|$file</tt>. This function combines
--   the global/user flag and interprets the package-db flag into a single
--   package db stack.
interpretPackageDbFlags :: Bool -> [Maybe PackageDB] -> PackageDBStack


-- | This is the entry point into installing a built package. Performs the
--   "<tt>./setup install</tt>" and "<tt>./setup copy</tt>" actions. It
--   moves files into place based on the prefix argument. It does the
--   generic bits and then calls compiler-specific functions to do the
--   rest.
module Distribution.Simple.Install

-- | Perform the "<tt>./setup install</tt>" and "<tt>./setup copy</tt>"
--   actions. Move files into place based on the prefix argument. FIX: nhc
--   isn't implemented yet.
install :: PackageDescription -> LocalBuildInfo -> CopyFlags -> IO ()


-- | This is the entry point to actually building the modules in a package.
--   It doesn't actually do much itself, most of the work is delegated to
--   compiler-specific actions. It does do some non-compiler specific bits
--   like running pre-processors.
module Distribution.Simple.Build

-- | Build the libraries and executables in this package.
build :: PackageDescription -> LocalBuildInfo -> BuildFlags -> [PPSuffixHandler] -> IO ()
initialBuildSteps :: FilePath -> PackageDescription -> LocalBuildInfo -> Verbosity -> IO ()

-- | Generate and write out the Paths_<a>pkg</a>.hs and cabal_macros.h
--   files
writeAutogenFiles :: Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()


-- | This module deals with the <tt>haddock</tt> and <tt>hscolour</tt>
--   commands. Sadly this is a rather complicated module. It deals with two
--   versions of haddock (0.x and 2.x). It has to do pre-processing for
--   haddock 0.x which involves 'unlit'ing and using <tt>-DHADDOCK</tt> for
--   any source code that uses <tt>cpp</tt>. It uses information about
--   installed packages (from <tt>ghc-pkg</tt>) to find the locations of
--   documentation for dependent packages, so it can create links.
--   
--   The <tt>hscolour</tt> support allows generating html versions of the
--   original source, with coloured syntax highlighting.
module Distribution.Simple.Haddock
haddock :: PackageDescription -> LocalBuildInfo -> [PPSuffixHandler] -> HaddockFlags -> IO ()
hscolour :: PackageDescription -> LocalBuildInfo -> [PPSuffixHandler] -> HscolourFlags -> IO ()
instance Read Directory
instance Show Directory
instance Eq Directory
instance Ord Directory
instance Monoid Directory
instance Monoid HaddockArgs


-- | This is the command line front end to the Simple build system. When
--   given the parsed command-line args and package information, is able to
--   perform basic commands like configure, build, install, register, etc.
--   
--   This module exports the main functions that Setup.hs scripts use. It
--   re-exports the <a>UserHooks</a> type, the standard entry points like
--   <a>defaultMain</a> and <a>defaultMainWithHooks</a> and the predefined
--   sets of <a>UserHooks</a> that custom <tt>Setup.hs</tt> scripts can
--   extend to add their own behaviour.
--   
--   This module isn't called "Simple" because it's simple. Far from it.
--   It's called "Simple" because it does complicated things to simple
--   software.
--   
--   The original idea was that there could be different build systems that
--   all presented the same compatible command line interfaces. There is
--   still a <a>Distribution.Make</a> system but in practice no packages
--   use it.
module Distribution.Simple

-- | A simple implementation of <tt>main</tt> for a Cabal setup script. It
--   reads the package description file using IO, and performs the action
--   specified on the command line.
defaultMain :: IO ()

-- | Like <a>defaultMain</a>, but accepts the package description as input
--   rather than using IO to read it.
defaultMainNoRead :: GenericPackageDescription -> IO ()

-- | A version of <a>defaultMain</a> that is passed the command line
--   arguments, rather than getting them from the environment.
defaultMainArgs :: [String] -> IO ()

-- | Hooks allow authors to add specific functionality before and after a
--   command is run, and also to specify additional preprocessors.
--   
--   <ul>
--   <li>WARNING: The hooks interface is under rather constant flux as we
--   try to understand users needs. Setup files that depend on this
--   interface may break in future releases.</li>
--   </ul>
data UserHooks
UserHooks :: (Args -> Bool -> PackageDescription -> LocalBuildInfo -> IO ()) -> IO (Maybe GenericPackageDescription) -> [PPSuffixHandler] -> [Program] -> (Args -> ConfigFlags -> IO HookedBuildInfo) -> ((GenericPackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo) -> (Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ()) -> (Args -> BuildFlags -> IO HookedBuildInfo) -> (PackageDescription -> LocalBuildInfo -> UserHooks -> BuildFlags -> IO ()) -> (Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()) -> (Args -> CleanFlags -> IO HookedBuildInfo) -> (PackageDescription -> () -> UserHooks -> CleanFlags -> IO ()) -> (Args -> CleanFlags -> PackageDescription -> () -> IO ()) -> (Args -> CopyFlags -> IO HookedBuildInfo) -> (PackageDescription -> LocalBuildInfo -> UserHooks -> CopyFlags -> IO ()) -> (Args -> CopyFlags -> PackageDescription -> LocalBuildInfo -> IO ()) -> (Args -> InstallFlags -> IO HookedBuildInfo) -> (PackageDescription -> LocalBuildInfo -> UserHooks -> InstallFlags -> IO ()) -> (Args -> InstallFlags -> PackageDescription -> LocalBuildInfo -> IO ()) -> (Args -> SDistFlags -> IO HookedBuildInfo) -> (PackageDescription -> Maybe LocalBuildInfo -> UserHooks -> SDistFlags -> IO ()) -> (Args -> SDistFlags -> PackageDescription -> Maybe LocalBuildInfo -> IO ()) -> (Args -> RegisterFlags -> IO HookedBuildInfo) -> (PackageDescription -> LocalBuildInfo -> UserHooks -> RegisterFlags -> IO ()) -> (Args -> RegisterFlags -> PackageDescription -> LocalBuildInfo -> IO ()) -> (Args -> RegisterFlags -> IO HookedBuildInfo) -> (PackageDescription -> LocalBuildInfo -> UserHooks -> RegisterFlags -> IO ()) -> (Args -> RegisterFlags -> PackageDescription -> LocalBuildInfo -> IO ()) -> (Args -> HscolourFlags -> IO HookedBuildInfo) -> (PackageDescription -> LocalBuildInfo -> UserHooks -> HscolourFlags -> IO ()) -> (Args -> HscolourFlags -> PackageDescription -> LocalBuildInfo -> IO ()) -> (Args -> HaddockFlags -> IO HookedBuildInfo) -> (PackageDescription -> LocalBuildInfo -> UserHooks -> HaddockFlags -> IO ()) -> (Args -> HaddockFlags -> PackageDescription -> LocalBuildInfo -> IO ()) -> (Args -> TestFlags -> IO HookedBuildInfo) -> (PackageDescription -> LocalBuildInfo -> UserHooks -> TestFlags -> IO ()) -> (Args -> TestFlags -> PackageDescription -> LocalBuildInfo -> IO ()) -> (Args -> BenchmarkFlags -> IO HookedBuildInfo) -> (Args -> PackageDescription -> LocalBuildInfo -> UserHooks -> BenchmarkFlags -> IO ()) -> (Args -> BenchmarkFlags -> PackageDescription -> LocalBuildInfo -> IO ()) -> UserHooks

-- | Used for <tt>./setup test</tt>

-- | <i>Deprecated: Please use the new testing interface instead! </i>
runTests :: UserHooks -> Args -> Bool -> PackageDescription -> LocalBuildInfo -> IO ()

-- | Read the description file
readDesc :: UserHooks -> IO (Maybe GenericPackageDescription)

-- | Custom preprocessors in addition to and overriding
--   <tt>knownSuffixHandlers</tt>.
hookedPreProcessors :: UserHooks -> [PPSuffixHandler]

-- | These programs are detected at configure time. Arguments for them are
--   added to the configure command.
hookedPrograms :: UserHooks -> [Program]

-- | Hook to run before configure command
preConf :: UserHooks -> Args -> ConfigFlags -> IO HookedBuildInfo

-- | Over-ride this hook to get different behavior during configure.
confHook :: UserHooks -> (GenericPackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo

-- | Hook to run after configure command
postConf :: UserHooks -> Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ()

-- | Hook to run before build command. Second arg indicates verbosity
--   level.
preBuild :: UserHooks -> Args -> BuildFlags -> IO HookedBuildInfo

-- | Over-ride this hook to gbet different behavior during build.
buildHook :: UserHooks -> PackageDescription -> LocalBuildInfo -> UserHooks -> BuildFlags -> IO ()

-- | Hook to run after build command. Second arg indicates verbosity level.
postBuild :: UserHooks -> Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()

-- | Hook to run before clean command. Second arg indicates verbosity
--   level.
preClean :: UserHooks -> Args -> CleanFlags -> IO HookedBuildInfo

-- | Over-ride this hook to get different behavior during clean.
cleanHook :: UserHooks -> PackageDescription -> () -> UserHooks -> CleanFlags -> IO ()

-- | Hook to run after clean command. Second arg indicates verbosity level.
postClean :: UserHooks -> Args -> CleanFlags -> PackageDescription -> () -> IO ()

-- | Hook to run before copy command
preCopy :: UserHooks -> Args -> CopyFlags -> IO HookedBuildInfo

-- | Over-ride this hook to get different behavior during copy.
copyHook :: UserHooks -> PackageDescription -> LocalBuildInfo -> UserHooks -> CopyFlags -> IO ()

-- | Hook to run after copy command
postCopy :: UserHooks -> Args -> CopyFlags -> PackageDescription -> LocalBuildInfo -> IO ()

-- | Hook to run before install command
preInst :: UserHooks -> Args -> InstallFlags -> IO HookedBuildInfo

-- | Over-ride this hook to get different behavior during install.
instHook :: UserHooks -> PackageDescription -> LocalBuildInfo -> UserHooks -> InstallFlags -> IO ()

-- | Hook to run after install command. postInst should be run on the
--   target, not on the build machine.
postInst :: UserHooks -> Args -> InstallFlags -> PackageDescription -> LocalBuildInfo -> IO ()

-- | Hook to run before sdist command. Second arg indicates verbosity
--   level.
preSDist :: UserHooks -> Args -> SDistFlags -> IO HookedBuildInfo

-- | Over-ride this hook to get different behavior during sdist.
sDistHook :: UserHooks -> PackageDescription -> Maybe LocalBuildInfo -> UserHooks -> SDistFlags -> IO ()

-- | Hook to run after sdist command. Second arg indicates verbosity level.
postSDist :: UserHooks -> Args -> SDistFlags -> PackageDescription -> Maybe LocalBuildInfo -> IO ()

-- | Hook to run before register command
preReg :: UserHooks -> Args -> RegisterFlags -> IO HookedBuildInfo

-- | Over-ride this hook to get different behavior during registration.
regHook :: UserHooks -> PackageDescription -> LocalBuildInfo -> UserHooks -> RegisterFlags -> IO ()

-- | Hook to run after register command
postReg :: UserHooks -> Args -> RegisterFlags -> PackageDescription -> LocalBuildInfo -> IO ()

-- | Hook to run before unregister command
preUnreg :: UserHooks -> Args -> RegisterFlags -> IO HookedBuildInfo

-- | Over-ride this hook to get different behavior during registration.
unregHook :: UserHooks -> PackageDescription -> LocalBuildInfo -> UserHooks -> RegisterFlags -> IO ()

-- | Hook to run after unregister command
postUnreg :: UserHooks -> Args -> RegisterFlags -> PackageDescription -> LocalBuildInfo -> IO ()

-- | Hook to run before hscolour command. Second arg indicates verbosity
--   level.
preHscolour :: UserHooks -> Args -> HscolourFlags -> IO HookedBuildInfo

-- | Over-ride this hook to get different behavior during hscolour.
hscolourHook :: UserHooks -> PackageDescription -> LocalBuildInfo -> UserHooks -> HscolourFlags -> IO ()

-- | Hook to run after hscolour command. Second arg indicates verbosity
--   level.
postHscolour :: UserHooks -> Args -> HscolourFlags -> PackageDescription -> LocalBuildInfo -> IO ()

-- | Hook to run before haddock command. Second arg indicates verbosity
--   level.
preHaddock :: UserHooks -> Args -> HaddockFlags -> IO HookedBuildInfo

-- | Over-ride this hook to get different behavior during haddock.
haddockHook :: UserHooks -> PackageDescription -> LocalBuildInfo -> UserHooks -> HaddockFlags -> IO ()

-- | Hook to run after haddock command. Second arg indicates verbosity
--   level.
postHaddock :: UserHooks -> Args -> HaddockFlags -> PackageDescription -> LocalBuildInfo -> IO ()

-- | Hook to run before test command.
preTest :: UserHooks -> Args -> TestFlags -> IO HookedBuildInfo

-- | Over-ride this hook to get different behavior during test.
testHook :: UserHooks -> PackageDescription -> LocalBuildInfo -> UserHooks -> TestFlags -> IO ()

-- | Hook to run after test command.
postTest :: UserHooks -> Args -> TestFlags -> PackageDescription -> LocalBuildInfo -> IO ()

-- | Hook to run before bench command.
preBench :: UserHooks -> Args -> BenchmarkFlags -> IO HookedBuildInfo

-- | Over-ride this hook to get different behavior during bench.
benchHook :: UserHooks -> Args -> PackageDescription -> LocalBuildInfo -> UserHooks -> BenchmarkFlags -> IO ()

-- | Hook to run after bench command.
postBench :: UserHooks -> Args -> BenchmarkFlags -> PackageDescription -> LocalBuildInfo -> IO ()
type Args = [String]

-- | A customizable version of <a>defaultMain</a>.
defaultMainWithHooks :: UserHooks -> IO ()

-- | A customizable version of <a>defaultMain</a> that also takes the
--   command line arguments.
defaultMainWithHooksArgs :: UserHooks -> [String] -> IO ()

-- | Hooks that correspond to a plain instantiation of the "simple" build
--   system
simpleUserHooks :: UserHooks
autoconfUserHooks :: UserHooks

-- | Basic autoconf <a>UserHooks</a>:
--   
--   <ul>
--   <li><a>postConf</a> runs <tt>./configure</tt>, if present.</li>
--   <li>the pre-hooks <a>preBuild</a>, <a>preClean</a>, <a>preCopy</a>,
--   <a>preInst</a>, <a>preReg</a> and <a>preUnreg</a> read additional
--   build information from <i>package</i><tt>.buildinfo</tt>, if
--   present.</li>
--   </ul>
--   
--   Thus <tt>configure</tt> can use local system information to generate
--   <i>package</i><tt>.buildinfo</tt> and possibly other files.

-- | <i>Deprecated: Use simpleUserHooks or autoconfUserHooks, unless you
--   need Cabal-1.2 compatibility in which case you must stick with
--   defaultUserHooks </i>
defaultUserHooks :: UserHooks

-- | Empty <a>UserHooks</a> which do nothing.
emptyUserHooks :: UserHooks

-- | Optional auxiliary package information file
--   (<i>pkgname</i><tt>.buildinfo</tt>)
defaultHookedPackageDesc :: IO (Maybe FilePath)
