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

-- | The command-line interface for Cabal and Hackage.
--   
--   The solver component used in cabal-install command-line program
@package cabal-install-solver
@version 3.12.1.0

module Distribution.Client.Utils.Assertion

-- | Like assert, but only enabled with
--   -fdebug-expensive-assertions. This function can be used for expensive
--   assertions that should only be turned on during testing or debugging.
expensiveAssert :: Bool -> a -> a

-- | This module does two things:
--   
--   
--   
- Acts as a compatibility layer, like base-compat.
--   
- Provides commonly used imports.
--   
--   
--   This module is a superset of Distribution.Compat.Prelude (which
--   this module re-exports)
module Distribution.Solver.Compat.Prelude

-- | deepseq: fully evaluates the first argument, before returning
--   the second.
--   
--   The name deepseq is used to illustrate the relationship to
--   seq: where seq is shallow in the sense that it only
--   evaluates the top level of its argument, deepseq traverses the
--   entire data structure evaluating it completely.
--   
--   deepseq can be useful for forcing pending exceptions,
--   eradicating space leaks, or forcing lazy I/O to happen. It is also
--   useful in conjunction with parallel Strategies (see the
--   parallel package).
--   
--   There is no guarantee about the ordering of evaluation. The
--   implementation may evaluate the components of the structure in any
--   order or in parallel. To impose an actual order on evaluation, use
--   pseq from Control.Parallel in the parallel
--   package.
deepseq :: NFData a => a -> b -> b
infixr 0 `deepseq`

-- | Exceptions that occur in the IO monad. An
--   IOException records a more specific error type, a descriptive
--   string and maybe the handle that was used when the error was flagged.
data IOException

-- | Any type that you wish to throw or catch as an exception must be an
--   instance of the Exception class. The simplest case is a new
--   exception type directly below the root:
--   
--   
--   data MyException = ThisException | ThatException
--       deriving Show
--   
--   instance Exception MyException
--   
--   
--   The default method definitions in the Exception class do what
--   we need in this case. You can now throw and catch
--   ThisException and ThatException as exceptions:
--   
--   
--   *Main> throw ThisException `catch` \e -> putStrLn ("Caught " ++ show (e :: MyException))
--   Caught ThisException
--   
--   
--   In more complicated examples, you may wish to define a whole hierarchy
--   of exceptions:
--   
--   
--   ---------------------------------------------------------------------
--   -- Make the root exception type for all the exceptions in a compiler
--   
--   data SomeCompilerException = forall e . Exception e => SomeCompilerException e
--   
--   instance Show SomeCompilerException where
--       show (SomeCompilerException e) = show e
--   
--   instance Exception SomeCompilerException
--   
--   compilerExceptionToException :: Exception e => e -> SomeException
--   compilerExceptionToException = toException . SomeCompilerException
--   
--   compilerExceptionFromException :: Exception e => SomeException -> Maybe e
--   compilerExceptionFromException x = do
--       SomeCompilerException a <- fromException x
--       cast a
--   
--   ---------------------------------------------------------------------
--   -- Make a subhierarchy for exceptions in the frontend of the compiler
--   
--   data SomeFrontendException = forall e . Exception e => SomeFrontendException e
--   
--   instance Show SomeFrontendException where
--       show (SomeFrontendException e) = show e
--   
--   instance Exception SomeFrontendException where
--       toException = compilerExceptionToException
--       fromException = compilerExceptionFromException
--   
--   frontendExceptionToException :: Exception e => e -> SomeException
--   frontendExceptionToException = toException . SomeFrontendException
--   
--   frontendExceptionFromException :: Exception e => SomeException -> Maybe e
--   frontendExceptionFromException x = do
--       SomeFrontendException a <- fromException x
--       cast a
--   
--   ---------------------------------------------------------------------
--   -- Make an exception type for a particular frontend compiler exception
--   
--   data MismatchedParentheses = MismatchedParentheses
--       deriving Show
--   
--   instance Exception MismatchedParentheses where
--       toException   = frontendExceptionToException
--       fromException = frontendExceptionFromException
--   
--   
--   We can now catch a MismatchedParentheses exception as
--   MismatchedParentheses, SomeFrontendException or
--   SomeCompilerException, but not other types, e.g.
--   IOException:
--   
--   
--   *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: MismatchedParentheses))
--   Caught MismatchedParentheses
--   *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeFrontendException))
--   Caught MismatchedParentheses
--   *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeCompilerException))
--   Caught MismatchedParentheses
--   *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: IOException))
--   *** Exception: MismatchedParentheses
--   
class (Typeable e, Show e) => Exception e

-- | toException should produce a SomeException with no
--   attached ExceptionContext.
toException :: Exception e => e -> SomeException
fromException :: Exception e => SomeException -> Maybe e

-- | Render this exception value in a human-friendly manner.
--   
--   Default implementation: show.
displayException :: Exception e => e -> String
backtraceDesired :: Exception e => e -> Bool

-- | 
--   comparing p x y = compare (p x) (p y)
--   
--   
--   Useful combinator for use in conjunction with the xxxBy
--   family of functions from Data.List, for example:
--   
--   
--   ... sortBy (comparing fst) ...
--   
comparing :: Ord a => (b -> a) -> b -> b -> Ordering

-- | intercalate xs xss is equivalent to (concat
--   (intersperse xs xss)). It inserts the list xs in
--   between the lists in xss and concatenates the result.
--   
--   
Laziness
--   
--   intercalate has the following properties:
--   
--   
--   >>> take 5 (intercalate undefined ("Lorem" : undefined))
--   "Lorem"
--   
--   
--   
--   >>> take 6 (intercalate ", " ("Lorem" : undefined))
--   "Lorem*** Exception: Prelude.undefined
--   
--   
--   
Examples
--   
--   
--   >>> intercalate ", " ["Lorem", "ipsum", "dolor"]
--   "Lorem, ipsum, dolor"
--   
--   
--   
--   >>> intercalate [0, 1] [[2, 3], [4, 5, 6], []]
--   [2,3,0,1,4,5,6,0,1]
--   
--   
--   
--   >>> intercalate [1, 2, 3] [[], []]
--   [1,2,3]
--   
intercalate :: [a] -> [[a]] -> [a]

-- | The Foldable class represents data structures that can be reduced to a
--   summary value one element at a time. Strict left-associative folds are
--   a good fit for space-efficient reduction, while lazy right-associative
--   folds are a good fit for corecursive iteration, or for folds that
--   short-circuit after processing an initial subsequence of the
--   structure's elements.
--   
--   Instances can be derived automatically by enabling the
--   DeriveFoldable extension. For example, a derived instance for
--   a binary tree might be:
--   
--   
--   {-# LANGUAGE DeriveFoldable #-}
--   data Tree a = Empty
--               | Leaf a
--               | Node (Tree a) a (Tree a)
--       deriving Foldable
--   
--   
--   A more detailed description can be found in the Overview
--   section of Data.Foldable#overview.
--   
--   For the class laws see the Laws section of
--   Data.Foldable#laws.
class Foldable (t :: Type -> Type)

-- | Map each element of the structure into a monoid, and combine the
--   results with (<>). This fold is
--   right-associative and lazy in the accumulator. For strict
--   left-associative folds consider foldMap' instead.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> foldMap Sum [1, 3, 5]
--   Sum {getSum = 9}
--   
--   
--   
--   >>> foldMap Product [1, 3, 5]
--   Product {getProduct = 15}
--   
--   
--   
--   >>> foldMap (replicate 3) [1, 2, 3]
--   [1,1,1,2,2,2,3,3,3]
--   
--   
--   When a Monoid's (<>) is lazy in its second
--   argument, foldMap can return a result even from an unbounded
--   structure. For example, lazy accumulation enables
--   Data.ByteString.Builder to efficiently serialise large data
--   structures and produce the output incrementally:
--   
--   
--   >>> import qualified Data.ByteString.Lazy as L
--   
--   >>> import qualified Data.ByteString.Builder as B
--   
--   >>> let bld :: Int -> B.Builder; bld i = B.intDec i <> B.word8 0x20
--   
--   >>> let lbs = B.toLazyByteString $ foldMap bld [0..]
--   
--   >>> L.take 64 lbs
--   "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24"
--   
foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m

-- | Right-associative fold of a structure, lazy in the accumulator.
--   
--   In the case of lists, foldr, when applied to a binary operator,
--   a starting value (typically the right-identity of the operator), and a
--   list, reduces the list using the binary operator, from right to left:
--   
--   
--   foldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)
--   
--   
--   Note that since the head of the resulting expression is produced by an
--   application of the operator to the first element of the list, given an
--   operator lazy in its right argument, foldr can produce a
--   terminating expression from an unbounded list.
--   
--   For a general Foldable structure this should be semantically
--   identical to,
--   
--   
--   foldr f z = foldr f z . toList
--   
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> foldr (||) False [False, True, False]
--   True
--   
--   
--   
--   >>> foldr (||) False []
--   False
--   
--   
--   
--   >>> foldr (\c acc -> acc ++ [c]) "foo" ['a', 'b', 'c', 'd']
--   "foodcba"
--   
--   
--   
Infinite structures
--   
--   ⚠️ Applying foldr to infinite structures usually doesn't
--   terminate.
--   
--   It may still terminate under one of the following conditions:
--   
--   
--   
- the folding function is short-circuiting
--   
- the folding function is lazy on its second argument
--   
--   
--   
Short-circuiting
--   
--   (||) short-circuits on True values, so the
--   following terminates because there is a True value finitely far
--   from the left side:
--   
--   
--   >>> foldr (||) False (True : repeat False)
--   True
--   
--   
--   But the following doesn't terminate:
--   
--   
--   >>> foldr (||) False (repeat False ++ [True])
--   * Hangs forever *
--   
--   
--   
Laziness in the second argument
--   
--   Applying foldr to infinite structures terminates when the
--   operator is lazy in its second argument (the initial accumulator is
--   never used in this case, and so could be left undefined, but
--   [] is more clear):
--   
--   
--   >>> take 5 $ foldr (\i acc -> i : fmap (+3) acc) [] (repeat 1)
--   [1,4,7,10,13]
--   
foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b

-- | Left-associative fold of a structure, lazy in the accumulator. This is
--   rarely what you want, but can work well for structures with efficient
--   right-to-left sequencing and an operator that is lazy in its left
--   argument.
--   
--   In the case of lists, foldl, when applied to a binary operator,
--   a starting value (typically the left-identity of the operator), and a
--   list, reduces the list using the binary operator, from left to right:
--   
--   
--   foldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn
--   
--   
--   Note that to produce the outermost application of the operator the
--   entire input list must be traversed. Like all left-associative folds,
--   foldl will diverge if given an infinite list.
--   
--   If you want an efficient strict left-fold, you probably want to use
--   foldl' instead of foldl. The reason for this is that the
--   latter does not force the inner results (e.g. z `f` x1
--   in the above example) before applying them to the operator (e.g. to
--   (`f` x2)). This results in a thunk chain O(n) elements
--   long, which then must be evaluated from the outside-in.
--   
--   For a general Foldable structure this should be semantically
--   identical to:
--   
--   
--   foldl f z = foldl f z . toList
--   
--   
--   
Examples
--   
--   The first example is a strict fold, which in practice is best
--   performed with foldl'.
--   
--   
--   >>> foldl (+) 42 [1,2,3,4]
--   52
--   
--   
--   Though the result below is lazy, the input is reversed before
--   prepending it to the initial accumulator, so corecursion begins only
--   after traversing the entire input string.
--   
--   
--   >>> foldl (\acc c -> c : acc) "abcd" "efgh"
--   "hgfeabcd"
--   
--   
--   A left fold of a structure that is infinite on the right cannot
--   terminate, even when for any finite input the fold just returns the
--   initial accumulator:
--   
--   
--   >>> foldl (\a _ -> a) 0 $ repeat 1
--   * Hangs forever *
--   
--   
--   WARNING: When it comes to lists, you always want to use either
--   foldl' or foldr instead.
foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b

-- | Left-associative fold of a structure but with strict application of
--   the operator.
--   
--   This ensures that each step of the fold is forced to Weak Head Normal
--   Form before being applied, avoiding the collection of thunks that
--   would otherwise occur. This is often what you want to strictly reduce
--   a finite structure to a single strict result (e.g. sum).
--   
--   For a general Foldable structure this should be semantically
--   identical to,
--   
--   
--   foldl' f z = foldl' f z . toList
--   
foldl' :: Foldable t => (b -> a -> b) -> b -> t a -> b

-- | List of elements of a structure, from left to right. If the entire
--   list is intended to be reduced via a fold, just fold the structure
--   directly bypassing the list.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> toList Nothing
--   []
--   
--   
--   
--   >>> toList (Just 42)
--   [42]
--   
--   
--   
--   >>> toList (Left "foo")
--   []
--   
--   
--   
--   >>> toList (Node (Leaf 5) 17 (Node Empty 12 (Leaf 8)))
--   [5,17,12,8]
--   
--   
--   For lists, toList is the identity:
--   
--   
--   >>> toList [1, 2, 3]
--   [1,2,3]
--   
toList :: Foldable t => t a -> [a]

-- | Test whether the structure is empty. The default implementation is
--   Left-associative and lazy in both the initial element and the
--   accumulator. Thus optimised for structures where the first element can
--   be accessed in constant time. Structures where this is not the case
--   should have a non-default implementation.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> null []
--   True
--   
--   
--   
--   >>> null [1]
--   False
--   
--   
--   null is expected to terminate even for infinite structures. The
--   default implementation terminates provided the structure is bounded on
--   the left (there is a leftmost element).
--   
--   
--   >>> null [1..]
--   False
--   
null :: Foldable t => t a -> Bool

-- | Returns the size/length of a finite structure as an Int. The
--   default implementation just counts elements starting with the
--   leftmost. Instances for structures that can compute the element count
--   faster than via element-by-element counting, should provide a
--   specialised implementation.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> length []
--   0
--   
--   
--   
--   >>> length ['a', 'b', 'c']
--   3
--   
--   >>> length [1..]
--   * Hangs forever *
--   
length :: Foldable t => t a -> Int

-- | Does the element occur in the structure?
--   
--   Note: elem is often used in infix form.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> 3 `elem` []
--   False
--   
--   
--   
--   >>> 3 `elem` [1,2]
--   False
--   
--   
--   
--   >>> 3 `elem` [1,2,3,4,5]
--   True
--   
--   
--   For infinite structures, the default implementation of elem
--   terminates if the sought-after value exists at a finite distance from
--   the left side of the structure:
--   
--   
--   >>> 3 `elem` [1..]
--   True
--   
--   
--   
--   >>> 3 `elem` ([4..] ++ [3])
--   * Hangs forever *
--   
elem :: (Foldable t, Eq a) => a -> t a -> Bool

-- | The largest element of a non-empty structure.
--   
--   This function is non-total and will raise a runtime exception if the
--   structure happens to be empty. A structure that supports random access
--   and maintains its elements in order should provide a specialised
--   implementation to return the maximum in faster than linear time.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> maximum [1..10]
--   10
--   
--   
--   
--   >>> maximum []
--   *** Exception: Prelude.maximum: empty list
--   
--   
--   
--   >>> maximum Nothing
--   *** Exception: maximum: empty structure
--   
--   
--   WARNING: This function is partial for possibly-empty structures like
--   lists.
maximum :: (Foldable t, Ord a) => t a -> a

-- | The least element of a non-empty structure.
--   
--   This function is non-total and will raise a runtime exception if the
--   structure happens to be empty. A structure that supports random access
--   and maintains its elements in order should provide a specialised
--   implementation to return the minimum in faster than linear time.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> minimum [1..10]
--   1
--   
--   
--   
--   >>> minimum []
--   *** Exception: Prelude.minimum: empty list
--   
--   
--   
--   >>> minimum Nothing
--   *** Exception: minimum: empty structure
--   
--   
--   WARNING: This function is partial for possibly-empty structures like
--   lists.
minimum :: (Foldable t, Ord a) => t a -> a

-- | The sum function computes the sum of the numbers of a
--   structure.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> sum []
--   0
--   
--   
--   
--   >>> sum [42]
--   42
--   
--   
--   
--   >>> sum [1..10]
--   55
--   
--   
--   
--   >>> sum [4.1, 2.0, 1.7]
--   7.8
--   
--   
--   
--   >>> sum [1..]
--   * Hangs forever *
--   
sum :: (Foldable t, Num a) => t a -> a

-- | The product function computes the product of the numbers of a
--   structure.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> product []
--   1
--   
--   
--   
--   >>> product [42]
--   42
--   
--   
--   
--   >>> product [1..10]
--   3628800
--   
--   
--   
--   >>> product [4.1, 2.0, 1.7]
--   13.939999999999998
--   
--   
--   
--   >>> product [1..]
--   * Hangs forever *
--   
product :: (Foldable t, Num a) => t a -> a
infix 4 `elem`

-- | Extract everything except the last element of the stream.
init :: NonEmpty a -> [a]

-- | Catch ExitCode
catchExit :: IO a -> (ExitCode -> IO a) -> IO a

-- | Catch IOException.
catchIO :: IO a -> (IOException -> IO a) -> IO a

-- | Try IOException.
tryIO :: IO a -> IO (Either IOException a)

-- | New name for <>
(<<>>) :: Doc -> Doc -> Doc
foldl1 :: (a -> a -> a) -> NonEmpty a -> a
foldr1 :: (a -> a -> a) -> NonEmpty a -> a

-- | GHC.Generics-based rnf implementation
--   
--   This is needed in order to support deepseq < 1.4 which
--   didn't have a Generic-based default rnf implementation
--   yet.
--   
--   In order to define instances, use e.g.
--   
--   
--   instance NFData MyType where rnf = genericRnf
--   
--   
--   The implementation has been taken from deepseq-1.4.2's
--   default rnf implementation.
genericRnf :: (Generic a, GNFData (Rep a)) => a -> ()
trace :: String -> a -> a
traceM :: Applicative f => String -> f ()
traceShow :: Show a => a -> b -> b
traceShowId :: Show a => a -> a
traceShowM :: (Show a, Applicative f) => a -> f ()

-- | Generically generate a Semigroup (<>) operation
--   for any type implementing Generic. This operation will append
--   two values by point-wise appending their component fields. It is only
--   defined for product types.
--   
--   
--   gmappend a (gmappend b c) = gmappend (gmappend a b) c
--   
gmappend :: (Generic a, GSemigroup (Rep a)) => a -> a -> a

-- | Generically generate a Monoid mempty for any
--   product-like type implementing Generic.
--   
--   It is only defined for product types.
--   
--   
--   gmappend gmempty a = a = gmappend a gmempty
--   
gmempty :: (Generic a, GMonoid (Rep a)) => a

-- | Extract the first element of the stream.
head :: NonEmpty a -> a

-- | Extract the last element of the stream.
last :: NonEmpty a -> a

-- | nonEmpty efficiently turns a normal list into a NonEmpty
--   stream, producing Nothing if the input is empty.
nonEmpty :: [a] -> Maybe (NonEmpty a)

-- | Extract the possibly-empty tail of the stream.
tail :: NonEmpty a -> [a]

-- | a variant of deepseq that is useful in some circumstances:
--   
--   
--   force x = x `deepseq` x
--   
--   
--   force x fully evaluates x, and then returns it. Note
--   that force x only performs evaluation when the value of
--   force x itself is demanded, so essentially it turns shallow
--   evaluation into deep evaluation.
--   
--   force can be conveniently used in combination with
--   ViewPatterns:
--   
--   
--   {-# LANGUAGE BangPatterns, ViewPatterns #-}
--   import Control.DeepSeq
--   
--   someFun :: ComplexData -> SomeResult
--   someFun (force -> !arg) = {- 'arg' will be fully evaluated -}
--   
--   
--   Another useful application is to combine force with
--   evaluate in order to force deep evaluation relative to other
--   IO operations:
--   
--   
--   import Control.Exception (evaluate)
--   import Control.DeepSeq
--   
--   main = do
--     result <- evaluate $ force $ pureComputation
--     {- 'result' will be fully evaluated at this point -}
--     return ()
--   
--   
--   Finally, here's an exception safe variant of the readFile'
--   example:
--   
--   
--   readFile' :: FilePath -> IO String
--   readFile' fn = bracket (openFile fn ReadMode) hClose $ \h ->
--                          evaluate . force =<< hGetContents h
--   
force :: NFData a => a -> a

-- | ($) is the function application operator.
--   
--   Applying ($) to a function f and an argument
--   x gives the same result as applying f to x
--   directly. The definition is akin to this:
--   
--   
--   ($) :: (a -> b) -> a -> b
--   ($) f x = f x
--   
--   
--   This is id specialized from a -> a to
--   (a -> b) -> (a -> b) which by the associativity of
--   (->) is the same as (a -> b) -> a -> b.
--   
--   On the face of it, this may appear pointless! But it's actually one of
--   the most useful and important operators in Haskell.
--   
--   The order of operations is very different between ($) and
--   normal function application. Normal function application has
--   precedence 10 - higher than any operator - and associates to the left.
--   So these two definitions are equivalent:
--   
--   
--   expr = min 5 1 + 5
--   expr = ((min 5) 1) + 5
--   
--   
--   ($) has precedence 0 (the lowest) and associates to the
--   right, so these are equivalent:
--   
--   
--   expr = min 5 $ 1 + 5
--   expr = (min 5) (1 + 5)
--   
--   
--   
Examples
--   
--   A common use cases of ($) is to avoid parentheses in complex
--   expressions.
--   
--   For example, instead of using nested parentheses in the following
--   Haskell function:
--   
--   
--   -- | Sum numbers in a string: strSum "100  5 -7" == 98
--   strSum :: String -> Int
--   strSum s = sum (mapMaybe readMaybe (words s))
--   
--   
--   we can deploy the function application operator:
--   
--   
--   -- | Sum numbers in a string: strSum "100  5 -7" == 98
--   strSum :: String -> Int
--   strSum s = sum $ mapMaybe readMaybe $ words s
--   
--   
--   ($) is also used as a section (a partially applied operator),
--   in order to indicate that we wish to apply some yet-unspecified
--   function to a given value. For example, to apply the argument
--   5 to a list of functions:
--   
--   
--   applyFive :: [Int]
--   applyFive = map ($ 5) [(+1), (2^)]
--   >>> [6, 32]
--   
--   
--   
Technical Remark (Representation Polymorphism)
--   
--   ($) is fully representation-polymorphic. This allows it to
--   also be used with arguments of unlifted and even unboxed kinds, such
--   as unboxed integers:
--   
--   
--   fastMod :: Int -> Int -> Int
--   fastMod (I# x) (I# m) = I# $ remInt# x m
--   
($) :: (a -> b) -> a -> b
infixr 0 $

-- | Strict (call-by-value) application operator. It takes a function and
--   an argument, evaluates the argument to weak head normal form (WHNF),
--   then calls the function with that value.
($!) :: (a -> b) -> a -> b
infixr 0 $!

-- | (++) appends two lists, i.e.,
--   
--   
--   [x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn]
--   [x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]
--   
--   
--   If the first list is not finite, the result is the first list.
--   
--   
Performance considerations
--   
--   This function takes linear time in the number of elements of the
--   first list. Thus it is better to associate repeated
--   applications of (++) to the right (which is the default
--   behaviour): xs ++ (ys ++ zs) or simply xs ++ ys ++
--   zs, but not (xs ++ ys) ++ zs. For the same reason
--   concat = foldr (++) [] has
--   linear performance, while foldl (++) [] is
--   prone to quadratic slowdown
--   
--   
Examples
--   
--   
--   >>> [1, 2, 3] ++ [4, 5, 6]
--   [1,2,3,4,5,6]
--   
--   
--   
--   >>> [] ++ [1, 2, 3]
--   [1,2,3]
--   
--   
--   
--   >>> [3, 2, 1] ++ []
--   [3,2,1]
--   
(++) :: [a] -> [a] -> [a]
infixr 5 ++

-- | Right to left function composition.
--   
--   
--   (f . g) x = f (g x)
--   
--   
--   
--   f . id = f = id . f
--   
--   
--   
Examples
--   
--   
--   >>> map ((*2) . length) [[], [0, 1, 2], [0]]
--   [0,6,2]
--   
--   
--   
--   >>> foldr (.) id [(+1), (*3), (^3)] 2
--   25
--   
--   
--   
--   >>> let (...) = (.).(.) in ((*2)...(+)) 5 10
--   30
--   
(.) :: (b -> c) -> (a -> b) -> a -> c
infixr 9 .

-- | Same as >>=, but with the arguments interchanged.
--   
--   
--   as >>= f == f =<< as
--   
(=<<) :: Monad m => (a -> m b) -> m a -> m b
infixr 1 =<<

-- | Since Void values logically don't exist, this witnesses the
--   logical reasoning tool of "ex falso quodlibet".
--   
--   
--   >>> let x :: Either Void Int; x = Right 5
--   
--   >>> :{
--   case x of
--       Right r -> r
--       Left l  -> absurd l
--   :}
--   5
--   
absurd :: Void -> a

-- | In many situations, the liftM operations can be replaced by
--   uses of ap, which promotes function application.
--   
--   
--   return f `ap` x1 `ap` ... `ap` xn
--   
--   
--   is equivalent to
--   
--   
--   liftM<n> f x1 x2 ... xn
--   
--   
--   
Examples
--   
--   
--   >>> pure (\x y z -> x + y * z) `ap` Just 1 `ap` Just 5 `ap` Just 10
--   Just 51
--   
ap :: Monad m => m (a -> b) -> m a -> m b

-- | asTypeOf is a type-restricted version of const. It is
--   usually used as an infix operator, and its typing forces its first
--   argument (which is usually overloaded) to have the same type as the
--   second.
asTypeOf :: a -> a -> a

-- | const x y always evaluates to x, ignoring its second
--   argument.
--   
--   
--   const x = \_ -> x
--   
--   
--   This function might seem useless at first glance, but it can be very
--   useful in a higher order context.
--   
--   
Examples
--   
--   
--   >>> const 42 "hello"
--   42
--   
--   
--   
--   >>> map (const 42) [0..3]
--   [42,42,42,42]
--   
const :: a -> b -> a

-- | flip f takes its (first) two arguments in the reverse
--   order of f.
--   
--   
--   flip f x y = f y x
--   
--   
--   
--   flip . flip = id
--   
--   
--   
Examples
--   
--   
--   >>> flip (++) "hello" "world"
--   "worldhello"
--   
--   
--   
--   >>> let (.>) = flip (.) in (+1) .> show $ 5
--   "6"
--   
flip :: (a -> b -> c) -> b -> a -> c

-- | Identity function.
--   
--   
--   id x = x
--   
--   
--   This function might seem useless at first glance, but it can be very
--   useful in a higher order context.
--   
--   
Examples
--   
--   
--   >>> length $ filter id [True, True, False, True]
--   3
--   
--   
--   
--   >>> Just (Just 3) >>= id
--   Just 3
--   
--   
--   
--   >>> foldr id 0 [(^3), (*5), (+2)]
--   1000
--   
id :: a -> a

-- | The join function is the conventional monad join operator. It
--   is used to remove one level of monadic structure, projecting its bound
--   argument into the outer level.
--   
--   'join bss' can be understood as the do
--   expression
--   
--   
--   do bs <- bss
--      bs
--   
--   
--   
Examples
--   
--   
--   >>> join [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
--   [1,2,3,4,5,6,7,8,9]
--   
--   
--   
--   >>> join (Just (Just 3))
--   Just 3
--   
--   
--   A common use of join is to run an IO computation
--   returned from an STM transaction, since STM transactions
--   can't perform IO directly. Recall that
--   
--   
--   atomically :: STM a -> IO a
--   
--   
--   is used to run STM transactions atomically. So, by specializing
--   the types of atomically and join to
--   
--   
--   atomically :: STM (IO b) -> IO (IO b)
--   join       :: IO (IO b)  -> IO b
--   
--   
--   we can compose them as
--   
--   
--   join . atomically :: STM (IO b) -> IO b
--   
--   
--   to run an STM transaction and the IO action it returns.
join :: Monad m => m (m a) -> m a

-- | Promote a function to a monad. This is equivalent to fmap but
--   specialised to Monads.
liftM :: Monad m => (a1 -> r) -> m a1 -> m r

-- | Promote a function to a monad, scanning the monadic arguments from
--   left to right.
--   
--   
Examples
--   
--   
--   >>> liftM2 (+) [0,1] [0,2]
--   [0,2,1,3]
--   
--   
--   
--   >>> liftM2 (+) (Just 1) Nothing
--   Nothing
--   
--   
--   
--   >>> liftM2 (+) (+ 3) (* 2) 5
--   18
--   
liftM2 :: Monad m => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r

-- | <math>. map f xs is the list obtained by
--   applying f to each element of xs, i.e.,
--   
--   
--   map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn]
--   map f [x1, x2, ...] == [f x1, f x2, ...]
--   
--   
--   this means that map id == id
--   
--   
Examples
--   
--   
--   >>> map (+1) [1, 2, 3]
--   [2,3,4]
--   
--   
--   
--   >>> map id [1, 2, 3]
--   [1,2,3]
--   
--   
--   
--   >>> map (\n -> 3 * n + 1) [1, 2, 3]
--   [4,7,10]
--   
map :: (a -> b) -> [a] -> [b]

-- | The fromEnum method restricted to the type Char.
ord :: Char -> Int

-- | otherwise is defined as the value True. It helps to make
--   guards more readable. eg.
--   
--   
--   f x | x < 0     = ...
--       | otherwise = ...
--   
otherwise :: Bool

-- | until p f yields the result of applying f
--   until p holds.
until :: (a -> Bool) -> (a -> a) -> a -> a

-- | If Void is uninhabited then any Functor that holds only
--   values of type Void is holding no values. It is implemented in
--   terms of fmap absurd.
vacuous :: Functor f => f Void -> f a

-- | Conditional execution of Applicative expressions. For example,
--   
--   
Examples
--   
--   
--   when debug (putStrLn "Debugging")
--   
--   
--   will output the string Debugging if the Boolean value
--   debug is True, and otherwise do nothing.
--   
--   
--   >>> putStr "pi:" >> when False (print 3.14159)
--   pi:
--   
when :: Applicative f => Bool -> f () -> f ()

-- | The toEnum method restricted to the type Char.
chr :: Int -> Char

-- | This generalizes the list-based filter function.
--   
--   
--   runIdentity (filterM (Identity . p) xs) == filter p xs
--   
--   
--   
Examples
--   
--   
--   >>> filterM (\x -> do
--         putStrLn ("Keep: " ++ show x ++ "?")
--         answer <- getLine
--         pure (answer == "y"))
--       [1, 2, 3]
--   Keep: 1?
--   y
--   Keep: 2?
--   n
--   Keep: 3?
--   y
--   [1,3]
--   
--   
--   
--   >>> filterM (\x -> do
--         putStr (show x)
--         x' <- readLn
--         pure (x == x'))
--       [1, 2, 3]
--   12
--   22
--   33
--   [2,3]
--   
filterM :: Applicative m => (a -> m Bool) -> [a] -> m [a]

-- | The foldM function is analogous to foldl, except that
--   its result is encapsulated in a monad. Note that foldM works
--   from left-to-right over the list arguments. This could be an issue
--   where (>>) and the `folded function' are not
--   commutative.
--   
--   
--   foldM f a1 [x1, x2, ..., xm]
--   
--   ==
--   
--   do
--     a2 <- f a1 x1
--     a3 <- f a2 x2
--     ...
--     f am xm
--   
--   
--   If right-to-left evaluation is required, the input list should be
--   reversed.
--   
--   Note: foldM is the same as foldlM
foldM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b

-- | Conditional failure of Alternative computations. Defined by
--   
--   
--   guard True  = pure ()
--   guard False = empty
--   
--   
--   
Examples
--   
--   Common uses of guard include conditionally signalling an error
--   in an error monad and conditionally rejecting the current choice in an
--   Alternative-based parser.
--   
--   As an example of signalling an error in the error monad Maybe,
--   consider a safe division function safeDiv x y that returns
--   Nothing when the denominator y is zero and
--   Just (x `div` y) otherwise. For example:
--   
--   
--   >>> safeDiv 4 0
--   Nothing
--   
--   
--   
--   >>> safeDiv 4 2
--   Just 2
--   
--   
--   A definition of safeDiv using guards, but not guard:
--   
--   
--   safeDiv :: Int -> Int -> Maybe Int
--   safeDiv x y | y /= 0    = Just (x `div` y)
--               | otherwise = Nothing
--   
--   
--   A definition of safeDiv using guard and Monad
--   do-notation:
--   
--   
--   safeDiv :: Int -> Int -> Maybe Int
--   safeDiv x y = do
--     guard (y /= 0)
--     return (x `div` y)
--   
guard :: Alternative f => Bool -> f ()

-- | The reverse of when.
--   
--   
Examples
--   
--   
--   >>> do x <- getLine
--          unless (x == "hi") (putStrLn "hi!")
--   comingupwithexamplesisdifficult
--   hi!
--   
--   
--   
--   >>> unless (pi > exp 1) Nothing
--   Just ()
--   
unless :: Applicative f => Bool -> f () -> f ()

-- | Case analysis for the Either type. If the value is
--   Left a, apply the first function to a; if it
--   is Right b, apply the second function to b.
--   
--   
Examples
--   
--   We create two values of type Either String
--   Int, one using the Left constructor and another
--   using the Right constructor. Then we apply "either" the
--   length function (if we have a String) or the "times-two"
--   function (if we have an Int):
--   
--   
--   >>> let s = Left "foo" :: Either String Int
--   
--   >>> let n = Right 3 :: Either String Int
--   
--   >>> either length (*2) s
--   3
--   
--   >>> either length (*2) n
--   6
--   
either :: (a -> c) -> (b -> c) -> Either a b -> c

-- | Partitions a list of Either into two lists. All the Left
--   elements are extracted, in order, to the first component of the
--   output. Similarly the Right elements are extracted to the
--   second component of the output.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]
--   
--   >>> partitionEithers list
--   (["foo","bar","baz"],[3,7])
--   
--   
--   The pair returned by partitionEithers x should be the
--   same pair as (lefts x, rights x):
--   
--   
--   >>> let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]
--   
--   >>> partitionEithers list == (lefts list, rights list)
--   True
--   
partitionEithers :: [Either a b] -> ([a], [b])

-- | Determines whether all elements of the structure satisfy the
--   predicate.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> all (> 3) []
--   True
--   
--   
--   
--   >>> all (> 3) [1,2]
--   False
--   
--   
--   
--   >>> all (> 3) [1,2,3,4,5]
--   False
--   
--   
--   
--   >>> all (> 3) [1..]
--   False
--   
--   
--   
--   >>> all (> 3) [4..]
--   * Hangs forever *
--   
all :: Foldable t => (a -> Bool) -> t a -> Bool

-- | and returns the conjunction of a container of Bools. For the
--   result to be True, the container must be finite; False,
--   however, results from a False value finitely far from the left
--   end.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> and []
--   True
--   
--   
--   
--   >>> and [True]
--   True
--   
--   
--   
--   >>> and [False]
--   False
--   
--   
--   
--   >>> and [True, True, False]
--   False
--   
--   
--   
--   >>> and (False : repeat True) -- Infinite list [False,True,True,True,...
--   False
--   
--   
--   
--   >>> and (repeat True)
--   * Hangs forever *
--   
and :: Foldable t => t Bool -> Bool

-- | Determines whether any element of the structure satisfies the
--   predicate.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> any (> 3) []
--   False
--   
--   
--   
--   >>> any (> 3) [1,2]
--   False
--   
--   
--   
--   >>> any (> 3) [1,2,3,4,5]
--   True
--   
--   
--   
--   >>> any (> 3) [1..]
--   True
--   
--   
--   
--   >>> any (> 3) [0, -1..]
--   * Hangs forever *
--   
any :: Foldable t => (a -> Bool) -> t a -> Bool

-- | The concatenation of all the elements of a container of lists.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> concat (Just [1, 2, 3])
--   [1,2,3]
--   
--   
--   
--   >>> concat (Left 42)
--   []
--   
--   
--   
--   >>> concat [[1, 2, 3], [4, 5], [6], []]
--   [1,2,3,4,5,6]
--   
concat :: Foldable t => t [a] -> [a]

-- | Map a function over all the elements of a container and concatenate
--   the resulting lists.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> concatMap (take 3) [[1..], [10..], [100..], [1000..]]
--   [1,2,3,10,11,12,100,101,102,1000,1001,1002]
--   
--   
--   
--   >>> concatMap (take 3) (Just [1..])
--   [1,2,3]
--   
concatMap :: Foldable t => (a -> [b]) -> t a -> [b]

-- | The find function takes a predicate and a structure and returns
--   the leftmost element of the structure matching the predicate, or
--   Nothing if there is no such element.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> find (> 42) [0, 5..]
--   Just 45
--   
--   
--   
--   >>> find (> 12) [1..7]
--   Nothing
--   
find :: Foldable t => (a -> Bool) -> t a -> Maybe a

-- | for_ is traverse_ with its arguments flipped. For a
--   version that doesn't ignore the results see for. This is
--   forM_ generalised to Applicative actions.
--   
--   for_ is just like forM_, but generalised to
--   Applicative actions.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> for_ [1..4] print
--   1
--   2
--   3
--   4
--   
for_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f ()

-- | notElem is the negation of elem.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> 3 `notElem` []
--   True
--   
--   
--   
--   >>> 3 `notElem` [1,2]
--   True
--   
--   
--   
--   >>> 3 `notElem` [1,2,3,4,5]
--   False
--   
--   
--   For infinite structures, notElem terminates if the value exists
--   at a finite distance from the left side of the structure:
--   
--   
--   >>> 3 `notElem` [1..]
--   False
--   
--   
--   
--   >>> 3 `notElem` ([4..] ++ [3])
--   * Hangs forever *
--   
notElem :: (Foldable t, Eq a) => a -> t a -> Bool
infix 4 `notElem`

-- | or returns the disjunction of a container of Bools. For the
--   result to be False, the container must be finite; True,
--   however, results from a True value finitely far from the left
--   end.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> or []
--   False
--   
--   
--   
--   >>> or [True]
--   True
--   
--   
--   
--   >>> or [False]
--   False
--   
--   
--   
--   >>> or [True, True, False]
--   True
--   
--   
--   
--   >>> or (True : repeat False) -- Infinite list [True,False,False,False,...
--   True
--   
--   
--   
--   >>> or (repeat False)
--   * Hangs forever *
--   
or :: Foldable t => t Bool -> Bool

-- | Evaluate each monadic action in the structure from left to right, and
--   ignore the results. For a version that doesn't ignore the results see
--   sequence.
--   
--   sequence_ is just like sequenceA_, but specialised to
--   monadic actions.
sequence_ :: (Foldable t, Monad m) => t (m a) -> m ()

-- | Map each element of a structure to an Applicative action,
--   evaluate these actions from left to right, and ignore the results. For
--   a version that doesn't ignore the results see traverse.
--   
--   traverse_ is just like mapM_, but generalised to
--   Applicative actions.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> traverse_ print ["Hello", "world", "!"]
--   "Hello"
--   "world"
--   "!"
--   
traverse_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f ()

-- | on b u x y runs the binary function b
--   on the results of applying unary function u to two
--   arguments x and y. From the opposite perspective, it
--   transforms two inputs and combines the outputs.
--   
--   
--   (op `<a>on</a>` f) x y = f x `<tt>op</tt>` f y
--   
--   
--   
Examples
--   
--   
--   >>> sortBy (compare `on` length) [[0, 1, 2], [0, 1], [], [0]]
--   [[],[0],[0,1],[0,1,2]]
--   
--   
--   
--   >>> ((+) `on` length) [1, 2, 3] [-1]
--   4
--   
--   
--   
--   >>> ((,) `on` (*2)) 2 3
--   (4,6)
--   
--   
--   
Algebraic properties
--   
--   
--   
- 
(*) `on` id = (*) -- (if (*) ∉ {⊥, const
--   ⊥})

--   
--   
--   
--   
- 
((*) `on` f) `on` g = (*) `on` (f . g)

--   
- 
flip on f . flip on g = flip on (g .
--   f)

--   
on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
infixl 0 `on`

-- | An infix synonym for fmap.
--   
--   The name of this operator is an allusion to $. Note the
--   similarities between their types:
--   
--   
--    ($)  ::              (a -> b) ->   a ->   b
--   (<$>) :: Functor f => (a -> b) -> f a -> f b
--   
--   
--   Whereas $ is function application, <$> is function
--   application lifted over a Functor.
--   
--   
Examples
--   
--   Convert from a Maybe Int to a Maybe
--   String using show:
--   
--   
--   >>> show <$> Nothing
--   Nothing
--   
--   
--   
--   >>> show <$> Just 3
--   Just "3"
--   
--   
--   Convert from an Either Int Int to an
--   Either Int String using show:
--   
--   
--   >>> show <$> Left 17
--   Left 17
--   
--   
--   
--   >>> show <$> Right 17
--   Right "17"
--   
--   
--   Double each element of a list:
--   
--   
--   >>> (*2) <$> [1,2,3]
--   [2,4,6]
--   
--   
--   Apply even to the second element of a pair:
--   
--   
--   >>> even <$> (2,2)
--   (2,True)
--   
(<$>) :: Functor f => (a -> b) -> f a -> f b
infixl 4 <$>

-- | void value discards or ignores the result of
--   evaluation, such as the return value of an IO action.
--   
--   
Examples
--   
--   Replace the contents of a Maybe Int with unit:
--   
--   
--   >>> void Nothing
--   Nothing
--   
--   
--   
--   >>> void (Just 3)
--   Just ()
--   
--   
--   Replace the contents of an Either Int
--   Int with unit, resulting in an Either
--   Int ():
--   
--   
--   >>> void (Left 8675309)
--   Left 8675309
--   
--   
--   
--   >>> void (Right 8675309)
--   Right ()
--   
--   
--   Replace every element of a list with unit:
--   
--   
--   >>> void [1,2,3]
--   [(),(),()]
--   
--   
--   Replace the second element of a pair with unit:
--   
--   
--   >>> void (1,2)
--   (1,())
--   
--   
--   Discard the result of an IO action:
--   
--   
--   >>> mapM print [1,2]
--   1
--   2
--   [(),()]
--   
--   
--   
--   >>> void $ mapM print [1,2]
--   1
--   2
--   
void :: Functor f => f a -> f ()

-- | The catMaybes function takes a list of Maybes and
--   returns a list of all the Just values.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> catMaybes [Just 1, Nothing, Just 3]
--   [1,3]
--   
--   
--   When constructing a list of Maybe values, catMaybes can
--   be used to return all of the "success" results (if the list is the
--   result of a map, then mapMaybe would be more
--   appropriate):
--   
--   
--   >>> import GHC.Internal.Text.Read ( readMaybe )
--   
--   >>> [readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ]
--   [Just 1,Nothing,Just 3]
--   
--   >>> catMaybes $ [readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ]
--   [1,3]
--   
catMaybes :: [Maybe a] -> [a]

-- | The fromMaybe function takes a default value and a Maybe
--   value. If the Maybe is Nothing, it returns the default
--   value; otherwise, it returns the value contained in the Maybe.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> fromMaybe "" (Just "Hello, World!")
--   "Hello, World!"
--   
--   
--   
--   >>> fromMaybe "" Nothing
--   ""
--   
--   
--   Read an integer from a string using readMaybe. If we fail to
--   parse an integer, we want to return 0 by default:
--   
--   
--   >>> import GHC.Internal.Text.Read ( readMaybe )
--   
--   >>> fromMaybe 0 (readMaybe "5")
--   5
--   
--   >>> fromMaybe 0 (readMaybe "")
--   0
--   
fromMaybe :: a -> Maybe a -> a

-- | The isJust function returns True iff its argument is of
--   the form Just _.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> isJust (Just 3)
--   True
--   
--   
--   
--   >>> isJust (Just ())
--   True
--   
--   
--   
--   >>> isJust Nothing
--   False
--   
--   
--   Only the outer constructor is taken into consideration:
--   
--   
--   >>> isJust (Just Nothing)
--   True
--   
isJust :: Maybe a -> Bool

-- | The isNothing function returns True iff its argument is
--   Nothing.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> isNothing (Just 3)
--   False
--   
--   
--   
--   >>> isNothing (Just ())
--   False
--   
--   
--   
--   >>> isNothing Nothing
--   True
--   
--   
--   Only the outer constructor is taken into consideration:
--   
--   
--   >>> isNothing (Just Nothing)
--   False
--   
isNothing :: Maybe a -> Bool

-- | The listToMaybe function returns Nothing on an empty
--   list or Just a where a is the first element
--   of the list.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> listToMaybe []
--   Nothing
--   
--   
--   
--   >>> listToMaybe [9]
--   Just 9
--   
--   
--   
--   >>> listToMaybe [1,2,3]
--   Just 1
--   
--   
--   Composing maybeToList with listToMaybe should be the
--   identity on singleton/empty lists:
--   
--   
--   >>> maybeToList $ listToMaybe [5]
--   [5]
--   
--   >>> maybeToList $ listToMaybe []
--   []
--   
--   
--   But not on lists with more than one element:
--   
--   
--   >>> maybeToList $ listToMaybe [1,2,3]
--   [1]
--   
listToMaybe :: [a] -> Maybe a

-- | The mapMaybe function is a version of map which can
--   throw out elements. In particular, the functional argument returns
--   something of type Maybe b. If this is Nothing,
--   no element is added on to the result list. If it is Just
--   b, then b is included in the result list.
--   
--   
Examples
--   
--   Using mapMaybe f x is a shortcut for
--   catMaybes $ map f x in most cases:
--   
--   
--   >>> import GHC.Internal.Text.Read ( readMaybe )
--   
--   >>> let readMaybeInt = readMaybe :: String -> Maybe Int
--   
--   >>> mapMaybe readMaybeInt ["1", "Foo", "3"]
--   [1,3]
--   
--   >>> catMaybes $ map readMaybeInt ["1", "Foo", "3"]
--   [1,3]
--   
--   
--   If we map the Just constructor, the entire list should be
--   returned:
--   
--   
--   >>> mapMaybe Just [1,2,3]
--   [1,2,3]
--   
mapMaybe :: (a -> Maybe b) -> [a] -> [b]

-- | The maybe function takes a default value, a function, and a
--   Maybe value. If the Maybe value is Nothing, the
--   function returns the default value. Otherwise, it applies the function
--   to the value inside the Just and returns the result.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> maybe False odd (Just 3)
--   True
--   
--   
--   
--   >>> maybe False odd Nothing
--   False
--   
--   
--   Read an integer from a string using readMaybe. If we succeed,
--   return twice the integer; that is, apply (*2) to it. If
--   instead we fail to parse an integer, return 0 by default:
--   
--   
--   >>> import GHC.Internal.Text.Read ( readMaybe )
--   
--   >>> maybe 0 (*2) (readMaybe "5")
--   10
--   
--   >>> maybe 0 (*2) (readMaybe "")
--   0
--   
--   
--   Apply show to a Maybe Int. If we have Just n,
--   we want to show the underlying Int n. But if we have
--   Nothing, we return the empty string instead of (for example)
--   "Nothing":
--   
--   
--   >>> maybe "" show (Just 5)
--   "5"
--   
--   >>> maybe "" show Nothing
--   ""
--   
maybe :: b -> (a -> b) -> Maybe a -> b

-- | The maybeToList function returns an empty list when given
--   Nothing or a singleton list when given Just.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> maybeToList (Just 7)
--   [7]
--   
--   
--   
--   >>> maybeToList Nothing
--   []
--   
--   
--   One can use maybeToList to avoid pattern matching when combined
--   with a function that (safely) works on lists:
--   
--   
--   >>> import GHC.Internal.Text.Read ( readMaybe )
--   
--   >>> sum $ maybeToList (readMaybe "3")
--   3
--   
--   >>> sum $ maybeToList (readMaybe "")
--   0
--   
maybeToList :: Maybe a -> [a]

-- | The dropWhileEnd function drops the largest suffix of a list in
--   which the given predicate holds for all elements.
--   
--   
Laziness
--   
--   This function is lazy in spine, but strict in elements, which makes it
--   different from reverse . dropWhile p
--   . reverse, which is strict in spine, but lazy in
--   elements. For instance:
--   
--   
--   >>> take 1 (dropWhileEnd (< 0) (1 : undefined))
--   [1]
--   
--   
--   
--   >>> take 1 (reverse $ dropWhile (< 0) $ reverse (1 : undefined))
--   *** Exception: Prelude.undefined
--   
--   
--   but on the other hand
--   
--   
--   >>> last (dropWhileEnd (< 0) [undefined, 1])
--   *** Exception: Prelude.undefined
--   
--   
--   
--   >>> last (reverse $ dropWhile (< 0) $ reverse [undefined, 1])
--   1
--   
--   
--   
Examples
--   
--   
--   >>> dropWhileEnd isSpace "foo\n"
--   "foo"
--   
--   
--   
--   >>> dropWhileEnd isSpace "foo bar"
--   "foo bar"
--   
--   >>> dropWhileEnd (> 10) [1..20]
--   [1,2,3,4,5,6,7,8,9,10]
--   
dropWhileEnd :: (a -> Bool) -> [a] -> [a]

-- | <math>. The intersperse function takes an element and a
--   list and `intersperses' that element between the elements of the list.
--   
--   
Laziness
--   
--   intersperse has the following properties
--   
--   
--   >>> take 1 (intersperse undefined ('a' : undefined))
--   "a"
--   
--   
--   
--   >>> take 2 (intersperse ',' ('a' : undefined))
--   "a*** Exception: Prelude.undefined
--   
--   
--   
Examples
--   
--   
--   >>> intersperse ',' "abcde"
--   "a,b,c,d,e"
--   
--   
--   
--   >>> intersperse 1 [3, 4, 5]
--   [3,1,4,1,5]
--   
intersperse :: a -> [a] -> [a]

-- | <math>. The isPrefixOf function takes two lists and
--   returns True iff the first list is a prefix of the second.
--   
--   
Examples
--   
--   
--   >>> "Hello" `isPrefixOf` "Hello World!"
--   True
--   
--   
--   
--   >>> "Hello" `isPrefixOf` "Wello Horld!"
--   False
--   
--   
--   For the result to be True, the first list must be finite;
--   False, however, results from any mismatch:
--   
--   
--   >>> [0..] `isPrefixOf` [1..]
--   False
--   
--   
--   
--   >>> [0..] `isPrefixOf` [0..99]
--   False
--   
--   
--   
--   >>> [0..99] `isPrefixOf` [0..]
--   True
--   
--   
--   
--   >>> [0..] `isPrefixOf` [0..]
--   * Hangs forever *
--   
--   
--   isPrefixOf shortcuts when the first argument is empty:
--   
--   
--   >>> isPrefixOf [] undefined
--   True
--   
isPrefixOf :: Eq a => [a] -> [a] -> Bool

-- | The isSuffixOf function takes two lists and returns True
--   iff the first list is a suffix of the second.
--   
--   
Examples
--   
--   
--   >>> "ld!" `isSuffixOf` "Hello World!"
--   True
--   
--   
--   
--   >>> "World" `isSuffixOf` "Hello World!"
--   False
--   
--   
--   The second list must be finite; however the first list may be
--   infinite:
--   
--   
--   >>> [0..] `isSuffixOf` [0..99]
--   False
--   
--   
--   
--   >>> [0..99] `isSuffixOf` [0..]
--   * Hangs forever *
--   
isSuffixOf :: Eq a => [a] -> [a] -> Bool

-- | Splits the argument into a list of lines stripped of their
--   terminating \n characters. The \n terminator is
--   optional in a final non-empty line of the argument string.
--   
--   When the argument string is empty, or ends in a \n character,
--   it can be recovered by passing the result of lines to the
--   unlines function. Otherwise, unlines appends the missing
--   terminating \n. This makes unlines . lines
--   idempotent:
--   
--   
--   (unlines . lines) . (unlines . lines) = (unlines . lines)
--   
--   
--   
Examples
--   
--   
--   >>> lines ""           -- empty input contains no lines
--   []
--   
--   
--   
--   >>> lines "\n"         -- single empty line
--   [""]
--   
--   
--   
--   >>> lines "one"        -- single unterminated line
--   ["one"]
--   
--   
--   
--   >>> lines "one\n"      -- single non-empty line
--   ["one"]
--   
--   
--   
--   >>> lines "one\n\n"    -- second line is empty
--   ["one",""]
--   
--   
--   
--   >>> lines "one\ntwo"   -- second line is unterminated
--   ["one","two"]
--   
--   
--   
--   >>> lines "one\ntwo\n" -- two non-empty lines
--   ["one","two"]
--   
lines :: String -> [String]

-- | <math>. The nub function removes duplicate elements from
--   a list. In particular, it keeps only the first occurrence of each
--   element. (The name nub means `essence'.) It is a special case
--   of nubBy, which allows the programmer to supply their own
--   equality test.
--   
--   If there exists instance Ord a, it's faster to use
--   nubOrd from the containers package (link to the
--   latest online documentation), which takes only <math> time
--   where d is the number of distinct elements in the list.
--   
--   Another approach to speed up nub is to use map
--   Data.List.NonEmpty.head .
--   Data.List.NonEmpty.group . sort, which takes
--   <math> time, requires instance Ord a and doesn't
--   preserve the order.
--   
--   
Examples
--   
--   
--   >>> nub [1,2,3,4,3,2,1,2,4,3,5]
--   [1,2,3,4,5]
--   
--   
--   
--   >>> nub "hello, world!"
--   "helo, wrd!"
--   
nub :: Eq a => [a] -> [a]

-- | The nubBy function behaves just like nub, except it uses
--   a user-supplied equality predicate instead of the overloaded
--   (==) function.
--   
--   
Examples
--   
--   
--   >>> nubBy (\x y -> mod x 3 == mod y 3) [1,2,4,5,6]
--   [1,2,6]
--   
--   
--   
--   >>> nubBy (/=) [2, 7, 1, 8, 2, 8, 1, 8, 2, 8]
--   [2,2,2]
--   
--   
--   
--   >>> nubBy (>) [1, 2, 3, 2, 1, 5, 4, 5, 3, 2]
--   [1,2,3,5,5]
--   
nubBy :: (a -> a -> Bool) -> [a] -> [a]

-- | The partition function takes a predicate and a list, and
--   returns the pair of lists of elements which do and do not satisfy the
--   predicate, respectively; i.e.,
--   
--   
--   partition p xs == (filter p xs, filter (not . p) xs)
--   
--   
--   
Examples
--   
--   
--   >>> partition (`elem` "aeiou") "Hello World!"
--   ("eoo","Hll Wrld!")
--   
--   
--   
--   >>> partition even [1..10]
--   ([2,4,6,8,10],[1,3,5,7,9])
--   
--   
--   
--   >>> partition (< 5) [1..10]
--   ([1,2,3,4],[5,6,7,8,9,10])
--   
partition :: (a -> Bool) -> [a] -> ([a], [a])

-- | The sort function implements a stable sorting algorithm. It is
--   a special case of sortBy, which allows the programmer to supply
--   their own comparison function.
--   
--   Elements are arranged from lowest to highest, keeping duplicates in
--   the order they appeared in the input.
--   
--   The argument must be finite.
--   
--   
Examples
--   
--   
--   >>> sort [1,6,4,3,2,5]
--   [1,2,3,4,5,6]
--   
--   
--   
--   >>> sort "haskell"
--   "aehklls"
--   
--   
--   
--   >>> import Data.Semigroup(Arg(..))
--   
--   >>> sort [Arg ":)" 0, Arg ":D" 0, Arg ":)" 1, Arg ":3" 0, Arg ":D" 1]
--   [Arg ":)" 0,Arg ":)" 1,Arg ":3" 0,Arg ":D" 0,Arg ":D" 1]
--   
sort :: Ord a => [a] -> [a]

-- | The sortBy function is the non-overloaded version of
--   sort. The argument must be finite.
--   
--   The supplied comparison relation is supposed to be reflexive and
--   antisymmetric, otherwise, e. g., for _ _ -> GT, the
--   ordered list simply does not exist. The relation is also expected to
--   be transitive: if it is not then sortBy might fail to find an
--   ordered permutation, even if it exists.
--   
--   
Examples
--   
--   
--   >>> sortBy (\(a,_) (b,_) -> compare a b) [(2, "world"), (4, "!"), (1, "Hello")]
--   [(1,"Hello"),(2,"world"),(4,"!")]
--   
sortBy :: (a -> a -> Ordering) -> [a] -> [a]

-- | The unfoldr function is a `dual' to foldr: while
--   foldr reduces a list to a summary value, unfoldr builds
--   a list from a seed value. The function takes the element and returns
--   Nothing if it is done producing the list or returns Just
--   (a,b), in which case, a is a prepended to the list
--   and b is used as the next element in a recursive call. For
--   example,
--   
--   
--   iterate f == unfoldr (\x -> Just (x, f x))
--   
--   
--   In some cases, unfoldr can undo a foldr operation:
--   
--   
--   unfoldr f' (foldr f z xs) == xs
--   
--   
--   if the following holds:
--   
--   
--   f' (f x y) = Just (x,y)
--   f' z       = Nothing
--   
--   
--   
Laziness
--   
--   
--   >>> take 1 (unfoldr (\x -> Just (x, undefined)) 'a')
--   "a"
--   
--   
--   
Examples
--   
--   
--   >>> unfoldr (\b -> if b == 0 then Nothing else Just (b, b-1)) 10
--   [10,9,8,7,6,5,4,3,2,1]
--   
--   
--   
--   >>> take 10 $ unfoldr (\(x, y) -> Just (x, (y, x + y))) (0, 1)
--   [0,1,1,2,3,5,8,13,21,54]
--   
unfoldr :: (b -> Maybe (a, b)) -> b -> [a]

-- | Appends a \n character to each input string, then
--   concatenates the results. Equivalent to foldMap (s ->
--   s ++ "\n").
--   
--   
Examples
--   
--   
--   >>> unlines ["Hello", "World", "!"]
--   "Hello\nWorld\n!\n"
--   
--   
--   Note that unlines . lines /=
--   id when the input is not \n-terminated:
--   
--   
--   >>> unlines . lines $ "foo\nbar"
--   "foo\nbar\n"
--   
unlines :: [String] -> String

-- | unwords joins words with separating spaces (U+0020 SPACE).
--   
--   unwords is neither left nor right inverse of words:
--   
--   
--   >>> words (unwords [" "])
--   []
--   
--   >>> unwords (words "foo\nbar")
--   "foo bar"
--   
--   
--   
Examples
--   
--   
--   >>> unwords ["Lorem", "ipsum", "dolor"]
--   "Lorem ipsum dolor"
--   
--   
--   
--   >>> unwords ["foo", "bar", "", "baz"]
--   "foo bar  baz"
--   
unwords :: [String] -> String

-- | words breaks a string up into a list of words, which were
--   delimited by white space (as defined by isSpace). This function
--   trims any white spaces at the beginning and at the end.
--   
--   
Examples
--   
--   
--   >>> words "Lorem ipsum\ndolor"
--   ["Lorem","ipsum","dolor"]
--   
--   
--   
--   >>> words " foo bar "
--   ["foo","bar"]
--   
words :: String -> [String]

-- | for is traverse with its arguments flipped. For a
--   version that ignores the results see for_.
for :: (Traversable t, Applicative f) => t a -> (a -> f b) -> f (t b)

-- | Convert an uncurried function to a curried function.
--   
--   
Examples
--   
--   
--   >>> curry fst 1 2
--   1
--   
curry :: ((a, b) -> c) -> a -> b -> c

-- | Extract the first component of a pair.
fst :: (a, b) -> a

-- | Extract the second component of a pair.
snd :: (a, b) -> b

-- | uncurry converts a curried function to a function on pairs.
--   
--   
Examples
--   
--   
--   >>> uncurry (+) (1,2)
--   3
--   
--   
--   
--   >>> uncurry ($) (show, 1)
--   "1"
--   
--   
--   
--   >>> map (uncurry max) [(1,2), (3,4), (6,8)]
--   [2,4,8]
--   
uncurry :: (a -> b -> c) -> (a, b) -> c

-- | Takes a value of type a and returns a concrete representation
--   of that type.
typeRep :: forall {k} proxy (a :: k). Typeable a => proxy a -> TypeRep

-- | error stops execution and displays an error message.
error :: HasCallStack => [Char] -> a

-- | A variant of error that does not produce a stack trace.
errorWithoutStackTrace :: [Char] -> a

-- | A special case of error. It is expected that compilers will
--   recognize this and insert error messages which are more appropriate to
--   the context in which undefined appears.
undefined :: HasCallStack => a

-- | This is the simplest of the exception-catching functions. It takes a
--   single argument, runs it, and if an exception is raised the "handler"
--   is executed, with the value of the exception passed as an argument.
--   Otherwise, the result is returned as normal. For example:
--   
--   
--   catch (readFile f)
--         (\e -> do let err = show (e :: IOException)
--                   hPutStr stderr ("Warning: Couldn't open " ++ f ++ ": " ++ err)
--                   return "")
--   
--   
--   Note that we have to give a type signature to e, or the
--   program will not typecheck as the type is ambiguous. While it is
--   possible to catch exceptions of any type, see the section "Catching
--   all exceptions" (in Control.Exception) for an explanation of
--   the problems with doing so.
--   
--   For catching exceptions in pure (non-IO) expressions, see the
--   function evaluate.
--   
--   Note that due to Haskell's unspecified evaluation order, an expression
--   may throw one of several possible exceptions: consider the expression
--   (error "urk") + (1 `div` 0). Does the expression throw
--   ErrorCall "urk", or DivideByZero?
--   
--   The answer is "it might throw either"; the choice is
--   non-deterministic. If you are catching any type of exception then you
--   might catch either. If you are calling catch with type IO
--   Int -> (ArithException -> IO Int) -> IO Int then the
--   handler may get run with DivideByZero as an argument, or an
--   ErrorCall "urk" exception may be propagated further up. If
--   you call it again, you might get the opposite behaviour. This is ok,
--   because catch is an IO computation.
catch :: Exception e => IO a -> (e -> IO a) -> IO a

-- | Evaluate the argument to weak head normal form.
--   
--   evaluate is typically used to uncover any exceptions that a
--   lazy value may contain, and possibly handle them.
--   
--   evaluate only evaluates to weak head normal form. If
--   deeper evaluation is needed, the force function from
--   Control.DeepSeq may be handy:
--   
--   
--   evaluate $ force x
--   
--   
--   There is a subtle difference between evaluate x and
--   return $! x, analogous to the difference
--   between throwIO and throw. If the lazy value x
--   throws an exception, return $! x will fail to
--   return an IO action and will throw an exception instead.
--   evaluate x, on the other hand, always produces an
--   IO action; that action will throw an exception upon
--   execution iff x throws an exception upon
--   evaluation.
--   
--   The practical implication of this difference is that due to the
--   imprecise exceptions semantics,
--   
--   
--   (return $! error "foo") >> error "bar"
--   
--   
--   may throw either "foo" or "bar", depending on the
--   optimizations performed by the compiler. On the other hand,
--   
--   
--   evaluate (error "foo") >> error "bar"
--   
--   
--   is guaranteed to throw "foo".
--   
--   The rule of thumb is to use evaluate to force or handle
--   exceptions in lazy values. If, on the other hand, you are forcing a
--   lazy value for efficiency reasons only and do not care about
--   exceptions, you may use return $! x.
evaluate :: a -> IO a

-- | A variant of throw that can only be used within the IO
--   monad.
--   
--   Although throwIO has a type that is an instance of the type of
--   throw, the two functions are subtly different:
--   
--   
--   throw e   `seq` ()  ===> throw e
--   throwIO e `seq` ()  ===> ()
--   
--   
--   The first example will cause the exception e to be raised,
--   whereas the second one won't. In fact, throwIO will only cause
--   an exception to be raised when it is used within the IO monad.
--   
--   The throwIO variant should be used in preference to
--   throw to raise an exception within the IO monad because
--   it guarantees ordering with respect to other operations, whereas
--   throw does not. We say that throwIO throws *precise*
--   exceptions and throw, error, etc. all throw *imprecise*
--   exceptions. For example
--   
--   
--   throw e + error "boom" ===> error "boom"
--   throw e + error "boom" ===> throw e
--   
--   
--   are both valid reductions and the compiler may pick any (loop, even),
--   whereas
--   
--   
--   throwIO e >> error "boom" ===> throwIO e
--   
--   
--   will always throw e when executed.
--   
--   See also the GHC wiki page on precise exceptions for a more
--   technical introduction to how GHC optimises around precise vs.
--   imprecise exceptions.
throwIO :: (HasCallStack, Exception e) => e -> IO a

-- | Raise an IOError in the IO monad.
ioError :: IOError -> IO a

-- | Construct an IOError value with a string describing the error.
--   The fail method of the IO instance of the Monad
--   class raises a userError, thus:
--   
--   
--   instance Monad IO where
--     ...
--     fail s = ioError (userError s)
--   
userError :: String -> IOError

-- | List index (subscript) operator, starting from 0. It is an instance of
--   the more general genericIndex, which takes an index of any
--   integral type.
--   
--   WARNING: This function is partial, and should only be used if you are
--   sure that the indexing will not fail. Otherwise, use !?.
--   
--   WARNING: This function takes linear time in the index.
--   
--   
Examples
--   
--   
--   >>> ['a', 'b', 'c'] !! 0
--   'a'
--   
--   
--   
--   >>> ['a', 'b', 'c'] !! 2
--   'c'
--   
--   
--   
--   >>> ['a', 'b', 'c'] !! 3
--   *** Exception: Prelude.!!: index too large
--   
--   
--   
--   >>> ['a', 'b', 'c'] !! (-1)
--   *** Exception: Prelude.!!: negative index
--   
(!!) :: HasCallStack => [a] -> Int -> a
infixl 9 !!

-- | break, applied to a predicate p and a list
--   xs, returns a tuple where first element is longest prefix
--   (possibly empty) of xs of elements that do not satisfy
--   p and second element is the remainder of the list:
--   
--   break p is equivalent to span (not .
--   p) and consequently to (takeWhile (not . p) xs,
--   dropWhile (not . p) xs), even if p is
--   _|_.
--   
--   
Laziness
--   
--   
--   >>> break undefined []
--   ([],[])
--   
--   
--   
--   >>> fst (break (const True) undefined)
--   *** Exception: Prelude.undefined
--   
--   
--   
--   >>> fst (break (const True) (undefined : undefined))
--   []
--   
--   
--   
--   >>> take 1 (fst (break (const False) (1 : undefined)))
--   [1]
--   
--   
--   break produces the first component of the tuple lazily:
--   
--   
--   >>> take 10 (fst (break (const False) [1..]))
--   [1,2,3,4,5,6,7,8,9,10]
--   
--   
--   
Examples
--   
--   
--   >>> break (> 3) [1,2,3,4,1,2,3,4]
--   ([1,2,3],[4,1,2,3,4])
--   
--   
--   
--   >>> break (< 9) [1,2,3]
--   ([],[1,2,3])
--   
--   
--   
--   >>> break (> 9) [1,2,3]
--   ([1,2,3],[])
--   
break :: (a -> Bool) -> [a] -> ([a], [a])

-- | cycle ties a finite list into a circular one, or equivalently,
--   the infinite repetition of the original list. It is the identity on
--   infinite lists.
--   
--   
Examples
--   
--   
--   >>> cycle []
--   *** Exception: Prelude.cycle: empty list
--   
--   
--   
--   >>> take 10 (cycle [42])
--   [42,42,42,42,42,42,42,42,42,42]
--   
--   
--   
--   >>> take 10 (cycle [2, 5, 7])
--   [2,5,7,2,5,7,2,5,7,2]
--   
--   
--   
--   >>> take 1 (cycle (42 : undefined))
--   [42]
--   
cycle :: HasCallStack => [a] -> [a]

-- | drop n xs returns the suffix of xs after the
--   first n elements, or [] if n >= length
--   xs.
--   
--   It is an instance of the more general genericDrop, in which
--   n may be of any integral type.
--   
--   
Examples
--   
--   
--   >>> drop 6 "Hello World!"
--   "World!"
--   
--   
--   
--   >>> drop 3 [1,2,3,4,5]
--   [4,5]
--   
--   
--   
--   >>> drop 3 [1,2]
--   []
--   
--   
--   
--   >>> drop 3 []
--   []
--   
--   
--   
--   >>> drop (-1) [1,2]
--   [1,2]
--   
--   
--   
--   >>> drop 0 [1,2]
--   [1,2]
--   
drop :: Int -> [a] -> [a]

-- | dropWhile p xs returns the suffix remaining after
--   takeWhile p xs.
--   
--   
Examples
--   
--   
--   >>> dropWhile (< 3) [1,2,3,4,5,1,2,3]
--   [3,4,5,1,2,3]
--   
--   
--   
--   >>> dropWhile (< 9) [1,2,3]
--   []
--   
--   
--   
--   >>> dropWhile (< 0) [1,2,3]
--   [1,2,3]
--   
dropWhile :: (a -> Bool) -> [a] -> [a]

-- | <math>. filter, applied to a predicate and a list,
--   returns the list of those elements that satisfy the predicate; i.e.,
--   
--   
--   filter p xs = [ x | x <- xs, p x]
--   
--   
--   
Examples
--   
--   
--   >>> filter odd [1, 2, 3]
--   [1,3]
--   
--   
--   
--   >>> filter (\l -> length l > 3) ["Hello", ", ", "World", "!"]
--   ["Hello","World"]
--   
--   
--   
--   >>> filter (/= 3) [1, 2, 3, 4, 3, 2, 1]
--   [1,2,4,2,1]
--   
filter :: (a -> Bool) -> [a] -> [a]

-- | iterate f x returns an infinite list of repeated
--   applications of f to x:
--   
--   
--   iterate f x == [x, f x, f (f x), ...]
--   
--   
--   
Laziness
--   
--   Note that iterate is lazy, potentially leading to thunk
--   build-up if the consumer doesn't force each iterate. See
--   iterate' for a strict variant of this function.
--   
--   
--   >>> take 1 $ iterate undefined 42
--   [42]
--   
--   
--   
Examples
--   
--   
--   >>> take 10 $ iterate not True
--   [True,False,True,False,True,False,True,False,True,False]
--   
--   
--   
--   >>> take 10 $ iterate (+3) 42
--   [42,45,48,51,54,57,60,63,66,69]
--   
--   
--   iterate id == repeat:
--   
--   
--   >>> take 10 $ iterate id 1
--   [1,1,1,1,1,1,1,1,1,1]
--   
iterate :: (a -> a) -> a -> [a]

-- | <math>. lookup key assocs looks up a key in an
--   association list. For the result to be Nothing, the list must
--   be finite.
--   
--   
Examples
--   
--   
--   >>> lookup 2 []
--   Nothing
--   
--   
--   
--   >>> lookup 2 [(1, "first")]
--   Nothing
--   
--   
--   
--   >>> lookup 2 [(1, "first"), (2, "second"), (3, "third")]
--   Just "second"
--   
lookup :: Eq a => a -> [(a, b)] -> Maybe b

-- | repeat x is an infinite list, with x the
--   value of every element.
--   
--   
Examples
--   
--   
--   >>> take 10 $ repeat 17
--   [17,17,17,17,17,17,17,17,17, 17]
--   
--   
--   
--   >>> repeat undefined
--   [*** Exception: Prelude.undefined
--   
repeat :: a -> [a]

-- | replicate n x is a list of length n with
--   x the value of every element. It is an instance of the more
--   general genericReplicate, in which n may be of any
--   integral type.
--   
--   
Examples
--   
--   
--   >>> replicate 0 True
--   []
--   
--   
--   
--   >>> replicate (-1) True
--   []
--   
--   
--   
--   >>> replicate 4 True
--   [True,True,True,True]
--   
replicate :: Int -> a -> [a]

-- | <math>. reverse xs returns the elements of
--   xs in reverse order. xs must be finite.
--   
--   
Laziness
--   
--   reverse is lazy in its elements.
--   
--   
--   >>> head (reverse [undefined, 1])
--   1
--   
--   
--   
--   >>> reverse (1 : 2 : undefined)
--   *** Exception: Prelude.undefined
--   
--   
--   
Examples
--   
--   
--   >>> reverse []
--   []
--   
--   
--   
--   >>> reverse [42]
--   [42]
--   
--   
--   
--   >>> reverse [2,5,7]
--   [7,5,2]
--   
--   
--   
--   >>> reverse [1..]
--   * Hangs forever *
--   
reverse :: [a] -> [a]

-- | <math>. scanl is similar to foldl, but returns a
--   list of successive reduced values from the left:
--   
--   
--   scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
--   
--   
--   Note that
--   
--   
--   last (scanl f z xs) == foldl f z xs
--   
--   
--   
Examples
--   
--   
--   >>> scanl (+) 0 [1..4]
--   [0,1,3,6,10]
--   
--   
--   
--   >>> scanl (+) 42 []
--   [42]
--   
--   
--   
--   >>> scanl (-) 100 [1..4]
--   [100,99,97,94,90]
--   
--   
--   
--   >>> scanl (\reversedString nextChar -> nextChar : reversedString) "foo" ['a', 'b', 'c', 'd']
--   ["foo","afoo","bafoo","cbafoo","dcbafoo"]
--   
--   
--   
--   >>> take 10 (scanl (+) 0 [1..])
--   [0,1,3,6,10,15,21,28,36,45]
--   
--   
--   
--   >>> take 1 (scanl undefined 'a' undefined)
--   "a"
--   
scanl :: (b -> a -> b) -> b -> [a] -> [b]

-- | <math>. scanl1 is a variant of scanl that has no
--   starting value argument:
--   
--   
--   scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
--   
--   
--   
Examples
--   
--   
--   >>> scanl1 (+) [1..4]
--   [1,3,6,10]
--   
--   
--   
--   >>> scanl1 (+) []
--   []
--   
--   
--   
--   >>> scanl1 (-) [1..4]
--   [1,-1,-4,-8]
--   
--   
--   
--   >>> scanl1 (&&) [True, False, True, True]
--   [True,False,False,False]
--   
--   
--   
--   >>> scanl1 (||) [False, False, True, True]
--   [False,False,True,True]
--   
--   
--   
--   >>> take 10 (scanl1 (+) [1..])
--   [1,3,6,10,15,21,28,36,45,55]
--   
--   
--   
--   >>> take 1 (scanl1 undefined ('a' : undefined))
--   "a"
--   
scanl1 :: (a -> a -> a) -> [a] -> [a]

-- | <math>. scanr is the right-to-left dual of scanl.
--   Note that the order of parameters on the accumulating function are
--   reversed compared to scanl. Also note that
--   
--   
--   head (scanr f z xs) == foldr f z xs.
--   
--   
--   
Examples
--   
--   
--   >>> scanr (+) 0 [1..4]
--   [10,9,7,4,0]
--   
--   
--   
--   >>> scanr (+) 42 []
--   [42]
--   
--   
--   
--   >>> scanr (-) 100 [1..4]
--   [98,-97,99,-96,100]
--   
--   
--   
--   >>> scanr (\nextChar reversedString -> nextChar : reversedString) "foo" ['a', 'b', 'c', 'd']
--   ["abcdfoo","bcdfoo","cdfoo","dfoo","foo"]
--   
--   
--   
--   >>> force $ scanr (+) 0 [1..]
--   *** Exception: stack overflow
--   
scanr :: (a -> b -> b) -> b -> [a] -> [b]

-- | <math>. scanr1 is a variant of scanr that has no
--   starting value argument.
--   
--   
Examples
--   
--   
--   >>> scanr1 (+) [1..4]
--   [10,9,7,4]
--   
--   
--   
--   >>> scanr1 (+) []
--   []
--   
--   
--   
--   >>> scanr1 (-) [1..4]
--   [-2,3,-1,4]
--   
--   
--   
--   >>> scanr1 (&&) [True, False, True, True]
--   [False,False,True,True]
--   
--   
--   
--   >>> scanr1 (||) [True, True, False, False]
--   [True,True,False,False]
--   
--   
--   
--   >>> force $ scanr1 (+) [1..]
--   *** Exception: stack overflow
--   
scanr1 :: (a -> a -> a) -> [a] -> [a]

-- | span, applied to a predicate p and a list xs,
--   returns a tuple where first element is the longest prefix (possibly
--   empty) of xs of elements that satisfy p and second
--   element is the remainder of the list:
--   
--   span p xs is equivalent to (takeWhile p xs,
--   dropWhile p xs), even if p is _|_.
--   
--   
Laziness
--   
--   
--   >>> span undefined []
--   ([],[])
--   
--   >>> fst (span (const False) undefined)
--   *** Exception: Prelude.undefined
--   
--   >>> fst (span (const False) (undefined : undefined))
--   []
--   
--   >>> take 1 (fst (span (const True) (1 : undefined)))
--   [1]
--   
--   
--   span produces the first component of the tuple lazily:
--   
--   
--   >>> take 10 (fst (span (const True) [1..]))
--   [1,2,3,4,5,6,7,8,9,10]
--   
--   
--   
Examples
--   
--   
--   >>> span (< 3) [1,2,3,4,1,2,3,4]
--   ([1,2],[3,4,1,2,3,4])
--   
--   
--   
--   >>> span (< 9) [1,2,3]
--   ([1,2,3],[])
--   
--   
--   
--   >>> span (< 0) [1,2,3]
--   ([],[1,2,3])
--   
span :: (a -> Bool) -> [a] -> ([a], [a])

-- | splitAt n xs returns a tuple where first element is
--   xs prefix of length n and second element is the
--   remainder of the list:
--   
--   splitAt is an instance of the more general
--   genericSplitAt, in which n may be of any integral
--   type.
--   
--   
Laziness
--   
--   It is equivalent to (take n xs, drop n xs)
--   unless n is _|_: splitAt _|_ xs = _|_, not
--   (_|_, _|_)).
--   
--   The first component of the tuple is produced lazily:
--   
--   
--   >>> fst (splitAt 0 undefined)
--   []
--   
--   
--   
--   >>> take 1 (fst (splitAt 10 (1 : undefined)))
--   [1]
--   
--   
--   
Examples
--   
--   
--   >>> splitAt 6 "Hello World!"
--   ("Hello ","World!")
--   
--   
--   
--   >>> splitAt 3 [1,2,3,4,5]
--   ([1,2,3],[4,5])
--   
--   
--   
--   >>> splitAt 1 [1,2,3]
--   ([1],[2,3])
--   
--   
--   
--   >>> splitAt 3 [1,2,3]
--   ([1,2,3],[])
--   
--   
--   
--   >>> splitAt 4 [1,2,3]
--   ([1,2,3],[])
--   
--   
--   
--   >>> splitAt 0 [1,2,3]
--   ([],[1,2,3])
--   
--   
--   
--   >>> splitAt (-1) [1,2,3]
--   ([],[1,2,3])
--   
splitAt :: Int -> [a] -> ([a], [a])

-- | take n, applied to a list xs, returns the
--   prefix of xs of length n, or xs itself if
--   n >= length xs.
--   
--   It is an instance of the more general genericTake, in which
--   n may be of any integral type.
--   
--   
Laziness
--   
--   
--   >>> take 0 undefined
--   []
--   
--   >>> take 2 (1 : 2 : undefined)
--   [1,2]
--   
--   
--   
Examples
--   
--   
--   >>> take 5 "Hello World!"
--   "Hello"
--   
--   
--   
--   >>> take 3 [1,2,3,4,5]
--   [1,2,3]
--   
--   
--   
--   >>> take 3 [1,2]
--   [1,2]
--   
--   
--   
--   >>> take 3 []
--   []
--   
--   
--   
--   >>> take (-1) [1,2]
--   []
--   
--   
--   
--   >>> take 0 [1,2]
--   []
--   
take :: Int -> [a] -> [a]

-- | takeWhile, applied to a predicate p and a list
--   xs, returns the longest prefix (possibly empty) of
--   xs of elements that satisfy p.
--   
--   
Laziness
--   
--   
--   >>> takeWhile (const False) undefined
--   *** Exception: Prelude.undefined
--   
--   
--   
--   >>> takeWhile (const False) (undefined : undefined)
--   []
--   
--   
--   
--   >>> take 1 (takeWhile (const True) (1 : undefined))
--   [1]
--   
--   
--   
Examples
--   
--   
--   >>> takeWhile (< 3) [1,2,3,4,1,2,3,4]
--   [1,2]
--   
--   
--   
--   >>> takeWhile (< 9) [1,2,3]
--   [1,2,3]
--   
--   
--   
--   >>> takeWhile (< 0) [1,2,3]
--   []
--   
takeWhile :: (a -> Bool) -> [a] -> [a]

-- | unzip transforms a list of pairs into a list of first
--   components and a list of second components.
--   
--   
Examples
--   
--   
--   >>> unzip []
--   ([],[])
--   
--   
--   
--   >>> unzip [(1, 'a'), (2, 'b')]
--   ([1,2],"ab")
--   
unzip :: [(a, b)] -> ([a], [b])

-- | The unzip3 function takes a list of triples and returns three
--   lists of the respective components, analogous to unzip.
--   
--   
Examples
--   
--   
--   >>> unzip3 []
--   ([],[],[])
--   
--   
--   
--   >>> unzip3 [(1, 'a', True), (2, 'b', False)]
--   ([1,2],"ab",[True,False])
--   
unzip3 :: [(a, b, c)] -> ([a], [b], [c])

-- | <math>. zip takes two lists and returns a list of
--   corresponding pairs.
--   
--   zip is right-lazy:
--   
--   
--   >>> zip [] undefined
--   []
--   
--   >>> zip undefined []
--   *** Exception: Prelude.undefined
--   ...
--   
--   
--   zip is capable of list fusion, but it is restricted to its
--   first list argument and its resulting list.
--   
--   
Examples
--   
--   
--   >>> zip [1, 2, 3] ['a', 'b', 'c']
--   [(1,'a'),(2,'b'),(3,'c')]
--   
--   
--   If one input list is shorter than the other, excess elements of the
--   longer list are discarded, even if one of the lists is infinite:
--   
--   
--   >>> zip [1] ['a', 'b']
--   [(1,'a')]
--   
--   
--   
--   >>> zip [1, 2] ['a']
--   [(1,'a')]
--   
--   
--   
--   >>> zip [] [1..]
--   []
--   
--   
--   
--   >>> zip [1..] []
--   []
--   
zip :: [a] -> [b] -> [(a, b)]

-- | zip3 takes three lists and returns a list of triples, analogous
--   to zip. It is capable of list fusion, but it is restricted to
--   its first list argument and its resulting list.
zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]

-- | <math>. zipWith generalises zip by zipping with
--   the function given as the first argument, instead of a tupling
--   function.
--   
--   
--   zipWith (,) xs ys == zip xs ys
--   zipWith f [x1,x2,x3..] [y1,y2,y3..] == [f x1 y1, f x2 y2, f x3 y3..]
--   
--   
--   zipWith is right-lazy:
--   
--   
--   >>> let f = undefined
--   
--   >>> zipWith f [] undefined
--   []
--   
--   
--   zipWith is capable of list fusion, but it is restricted to its
--   first list argument and its resulting list.
--   
--   
Examples
--   
--   zipWith (+) can be applied to two lists to
--   produce the list of corresponding sums:
--   
--   
--   >>> zipWith (+) [1, 2, 3] [4, 5, 6]
--   [5,7,9]
--   
--   
--   
--   >>> zipWith (++) ["hello ", "foo"] ["world!", "bar"]
--   ["hello world!","foobar"]
--   
zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]

-- | <math>. The zipWith3 function takes a function which
--   combines three elements, as well as three lists and returns a list of
--   the function applied to corresponding elements, analogous to
--   zipWith. It is capable of list fusion, but it is restricted to
--   its first list argument and its resulting list.
--   
--   
--   zipWith3 (,,) xs ys zs == zip3 xs ys zs
--   zipWith3 f [x1,x2,x3..] [y1,y2,y3..] [z1,z2,z3..] == [f x1 y1 z1, f x2 y2 z2, f x3 y3 z3..]
--   
--   
--   
Examples
--   
--   
--   >>> zipWith3 (\x y z -> [x, y, z]) "123" "abc" "xyz"
--   ["1ax","2by","3cz"]
--   
--   
--   
--   >>> zipWith3 (\x y z -> (x * y) + z) [1, 2, 3] [4, 5, 6] [7, 8, 9]
--   [11,18,27]
--   
zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]

-- | the same as flip (-).
--   
--   Because - is treated specially in the Haskell grammar,
--   (- e) is not a section, but an application of
--   prefix negation. However, (subtract
--   exp) is equivalent to the disallowed section.
subtract :: Num a => a -> a -> a

-- | The lex function reads a single lexeme from the input,
--   discarding initial white space, and returning the characters that
--   constitute the lexeme. If the input string contains only white space,
--   lex returns a single successful `lexeme' consisting of the
--   empty string. (Thus lex "" = [("","")].) If there is
--   no legal lexeme at the beginning of the input string, lex fails
--   (i.e. returns []).
--   
--   This lexer is not completely faithful to the Haskell lexical syntax in
--   the following respects:
--   
--   
--   
- Qualified names are not handled properly
--   
- Octal and hexadecimal numerics are not recognized as a single
--   token
--   
- Comments are not treated properly
--   
lex :: ReadS String

-- | readParen True p parses what p parses,
--   but surrounded with parentheses.
--   
--   readParen False p parses what p
--   parses, but optionally surrounded with parentheses.
readParen :: Bool -> ReadS a -> ReadS a

-- | raise a number to a non-negative integral power
(^) :: (Num a, Integral b) => a -> b -> a
infixr 8 ^

-- | raise a number to an integral power
(^^) :: (Fractional a, Integral b) => a -> b -> a
infixr 8 ^^
even :: Integral a => a -> Bool

-- | General coercion from Integral types.
--   
--   WARNING: This function performs silent truncation if the result type
--   is not at least as big as the argument's type.
fromIntegral :: (Integral a, Num b) => a -> b

-- | gcd x y is the non-negative factor of both x
--   and y of which every common factor of x and
--   y is also a factor; for example gcd 4 2 = 2,
--   gcd (-4) 6 = 2, gcd 0 4 = 4.
--   gcd 0 0 = 0. (That is, the common divisor
--   that is "greatest" in the divisibility preordering.)
--   
--   Note: Since for signed fixed-width integer types, abs
--   minBound < 0, the result may be negative if one of the
--   arguments is minBound (and necessarily is if the other
--   is 0 or minBound) for such types.
gcd :: Integral a => a -> a -> a

-- | lcm x y is the smallest positive integer that both
--   x and y divide.
lcm :: Integral a => a -> a -> a
odd :: Integral a => a -> Bool

-- | General coercion to Fractional types.
--   
--   WARNING: This function goes through the Rational type, which
--   does not have values for NaN for example. This means it does
--   not round-trip.
--   
--   For Double it also behaves differently with or without -O0:
--   
--   
--   Prelude> realToFrac nan -- With -O0
--   -Infinity
--   Prelude> realToFrac nan
--   NaN
--   
realToFrac :: (Real a, Fractional b) => a -> b

-- | utility function converting a Char to a show function that
--   simply prepends the character unchanged.
showChar :: Char -> ShowS

-- | utility function that surrounds the inner show function with
--   parentheses when the Bool parameter is True.
showParen :: Bool -> ShowS -> ShowS

-- | utility function converting a String to a show function that
--   simply prepends the string unchanged.
showString :: String -> ShowS

-- | equivalent to showsPrec with a precedence of 0.
shows :: Show a => a -> ShowS

-- | The computation exitFailure is equivalent to exitWith
--   (ExitFailure exitfail), where
--   exitfail is implementation-dependent.
exitFailure :: IO a

-- | The computation exitSuccess is equivalent to exitWith
--   ExitSuccess, It terminates the program successfully.
exitSuccess :: IO a

-- | Computation exitWith code throws ExitCode
--   code. Normally this terminates the program, returning
--   code to the program's caller.
--   
--   On program termination, the standard Handles stdout and
--   stderr are flushed automatically; any other buffered
--   Handles need to be flushed manually, otherwise the buffered
--   data will be discarded.
--   
--   A program that fails in any other way is treated as if it had called
--   exitFailure. A program that terminates successfully without
--   calling exitWith explicitly is treated as if it had called
--   exitWith ExitSuccess.
--   
--   As an ExitCode is an Exception, it can be caught using
--   the functions of Control.Exception. This means that cleanup
--   computations added with bracket (from Control.Exception)
--   are also executed properly on exitWith.
--   
--   Note: in GHC, exitWith should be called from the main program
--   thread in order to exit the process. When called from another thread,
--   exitWith will throw an ExitCode as normal, but the
--   exception will not cause the process itself to exit.
exitWith :: ExitCode -> IO a

-- | The computation appendFile file str function appends
--   the string str, to the file file.
--   
--   Note that writeFile and appendFile write a literal
--   string to a file. To write a value of any printable type, as with
--   print, use the show function to convert the value to a
--   string first.
--   
--   
--   main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]])
--   
appendFile :: FilePath -> String -> IO ()

-- | Read a character from the standard input device (same as
--   hGetChar stdin).
getChar :: IO Char

-- | The getContents operation returns all user input as a single
--   string, which is read lazily as it is needed (same as
--   hGetContents stdin).
getContents :: IO String

-- | Read a line from the standard input device (same as hGetLine
--   stdin).
getLine :: IO String

-- | The interact function takes a function of type
--   String->String as its argument. The entire input from the
--   standard input device is passed to this function as its argument, and
--   the resulting string is output on the standard output device.
interact :: (String -> String) -> IO ()

-- | The print function outputs a value of any printable type to the
--   standard output device. Printable types are those that are instances
--   of class Show; print converts values to strings for
--   output using the show operation and adds a newline.
--   
--   For example, a program to print the first 20 integers and their powers
--   of 2 could be written as:
--   
--   
--   main = print ([(n, 2^n) | n <- [0..19]])
--   
print :: Show a => a -> IO ()

-- | Write a character to the standard output device (same as
--   hPutChar stdout).
putChar :: Char -> IO ()

-- | Write a string to the standard output device (same as hPutStr
--   stdout).
putStr :: String -> IO ()

-- | The same as putStr, but adds a newline character.
putStrLn :: String -> IO ()

-- | The readFile function reads a file and returns the contents of
--   the file as a string. The file is read lazily, on demand, as with
--   getContents.
readFile :: FilePath -> IO String

-- | The readIO function is similar to read except that it
--   signals parse failure to the IO monad instead of terminating
--   the program.
readIO :: Read a => String -> IO a

-- | The readLn function combines getLine and readIO.
readLn :: Read a => IO a

-- | The computation writeFile file str function writes the
--   string str, to the file file.
writeFile :: FilePath -> String -> IO ()

-- | Parse a string using the Read instance. Succeeds if there is
--   exactly one valid result.
--   
--   
--   >>> readMaybe "123" :: Maybe Int
--   Just 123
--   
--   
--   
--   >>> readMaybe "hello" :: Maybe Int
--   Nothing
--   
readMaybe :: Read a => String -> Maybe a

-- | equivalent to readsPrec with a precedence of 0.
reads :: Read a => ReadS a

-- | Selects alphabetic Unicode characters (lower-case, upper-case and
--   title-case letters, plus letters of caseless scripts and modifiers
--   letters). This function is equivalent to isLetter.
--   
--   This function returns True if its argument has one of the
--   following GeneralCategorys, or False otherwise:
--   
--   
--   
- UppercaseLetter
--   
- LowercaseLetter
--   
- TitlecaseLetter
--   
- ModifierLetter
--   
- OtherLetter
--   
--   
--   These classes are defined in the Unicode Character Database,
--   part of the Unicode standard. The same document defines what is and is
--   not a "Letter".
isAlpha :: Char -> Bool

-- | Selects alphabetic or numeric Unicode characters.
--   
--   Note that numeric digits outside the ASCII range, as well as numeric
--   characters which aren't digits, are selected by this function but not
--   by isDigit. Such characters may be part of identifiers but are
--   not used by the printer and reader to represent numbers, e.g., Roman
--   numerals like V, full-width digits like '１'
--   (aka '65297').
--   
--   This function returns True if its argument has one of the
--   following GeneralCategorys, or False otherwise:
--   
--   
--   
- UppercaseLetter
--   
- LowercaseLetter
--   
- TitlecaseLetter
--   
- ModifierLetter
--   
- OtherLetter
--   
- DecimalNumber
--   
- LetterNumber
--   
- OtherNumber
--   
isAlphaNum :: Char -> Bool

-- | Selects ASCII digits, i.e. '0'..'9'.
isDigit :: Char -> Bool

-- | Returns True for any Unicode space character, and the control
--   characters \t, \n, \r, \f,
--   \v.
isSpace :: Char -> Bool

-- | Selects upper-case or title-case alphabetic Unicode characters
--   (letters). Title case is used by a small number of letter ligatures
--   like the single-character form of Lj.
--   
--   Note: this predicate does not work for letter-like
--   characters such as: 'Ⓐ' (U+24B6 circled Latin
--   capital letter A) and 'Ⅳ' (U+2163 Roman numeral
--   four). This is due to selecting only characters with the
--   GeneralCategory UppercaseLetter or
--   TitlecaseLetter.
--   
--   See isUpperCase for a more intuitive predicate. Note that
--   unlike isUpperCase, isUpper does select
--   title-case characters such as 'ǅ' (U+01C5
--   Latin capital letter d with small letter z with caron) or 'ᾯ'
--   (U+1FAF Greek capital letter omega with dasia and perispomeni
--   and prosgegrammeni).
isUpper :: Char -> Bool

-- | Convert a letter to the corresponding lower-case letter, if any. Any
--   other character is returned unchanged.
toLower :: Char -> Char

-- | Convert a letter to the corresponding upper-case letter, if any. Any
--   other character is returned unchanged.
toUpper :: Char -> Char

-- | Boolean "and", lazy in the second argument
(&&) :: Bool -> Bool -> Bool
infixr 3 &&

-- | Boolean "not"
not :: Bool -> Bool

-- | Boolean "or", lazy in the second argument
(||) :: Bool -> Bool -> Bool
infixr 2 ||

-- | Beside, separated by space, unless one of the arguments is
--   empty. <+> is associative, with identity
--   empty.
(<+>) :: Doc -> Doc -> Doc
infixl 6 <+>

-- | The value of seq a b is bottom if a is
--   bottom, and otherwise equal to b. In other words, it
--   evaluates the first argument a to weak head normal form
--   (WHNF). seq is usually introduced to improve performance by
--   avoiding unneeded laziness.
--   
--   A note on evaluation order: the expression seq a b
--   does not guarantee that a will be evaluated before
--   b. The only guarantee given by seq is that the both
--   a and b will be evaluated before seq returns
--   a value. In particular, this means that b may be evaluated
--   before a. If you need to guarantee a specific order of
--   evaluation, you must use the function pseq from the
--   "parallel" package.
seq :: a -> b -> b
infixr 0 `seq`

data NonEmptySet a

-- | Class of types with a known Structure.
--   
--   For regular data types Structured can be derived generically.
--   
--   
--   data Record = Record { a :: Int, b :: Bool, c :: [Char] } deriving (Generic)
--   instance Structured Record
--   
class Typeable a => Structured a

-- | The Binary class provides put and get, methods to
--   encode and decode a Haskell value to a lazy ByteString. It
--   mirrors the Read and Show classes for textual
--   representation of Haskell types, and is suitable for serialising
--   Haskell values to disk, over the network.
--   
--   For decoding and generating simple external binary formats (e.g. C
--   structures), Binary may be used, but in general is not suitable for
--   complex protocols. Instead use the Put and Get
--   primitives directly.
--   
--   Instances of Binary should satisfy the following property:
--   
--   
--   decode . encode == id
--   
--   
--   That is, the get and put methods should be the inverse
--   of each other. A range of instances are provided for basic Haskell
--   types.
class Binary t

-- | Encode a value in the Put monad.
put :: Binary t => t -> Put
($dmput) :: (Binary t, Generic t, GBinaryPut (Rep t)) => t -> Put

-- | Decode a value in the Get monad
get :: Binary t => Get t
($dmget) :: (Binary t, Generic t, GBinaryGet (Rep t)) => Get t

-- | Encode a list of values in the Put monad. The default implementation
--   may be overridden to be more efficient but must still have the same
--   encoding format.
putList :: Binary t => [t] -> Put

-- | A Map from keys k to values a.
--   
--   The Semigroup operation for Map is union, which
--   prefers values from the left operand. If m1 maps a key
--   k to a value a1, and m2 maps the same key
--   to a different value a2, then their union m1 <>
--   m2 maps k to a1.
data Map k a

-- | A set of values a.
data Set a

-- | A class of types that can be fully evaluated.
class NFData a

-- | rnf should reduce its argument to normal form (that is, fully
--   evaluate all sub-components), and then return ().
--   
--   
Generic NFData deriving
--   
--   Starting with GHC 7.2, you can automatically derive instances for
--   types possessing a Generic instance.
--   
--   Note: Generic1 can be auto-derived starting with GHC 7.4
--   
--   
--   {-# LANGUAGE DeriveGeneric #-}
--   
--   import GHC.Generics (Generic, Generic1)
--   import Control.DeepSeq
--   
--   data Foo a = Foo a String
--                deriving (Eq, Generic, Generic1)
--   
--   instance NFData a => NFData (Foo a)
--   instance NFData1 Foo
--   
--   data Colour = Red | Green | Blue
--                 deriving Generic
--   
--   instance NFData Colour
--   
--   
--   Starting with GHC 7.10, the example above can be written more
--   concisely by enabling the new DeriveAnyClass extension:
--   
--   
--   {-# LANGUAGE DeriveGeneric, DeriveAnyClass #-}
--   
--   import GHC.Generics (Generic)
--   import Control.DeepSeq
--   
--   data Foo a = Foo a String
--                deriving (Eq, Generic, Generic1, NFData, NFData1)
--   
--   data Colour = Red | Green | Blue
--                 deriving (Generic, NFData)
--   
--   
--   
Compatibility with previous deepseq versions
--   
--   Prior to version 1.4.0.0, the default implementation of the rnf
--   method was defined as
--   
--   
--   rnf a = seq a ()
--   
--   
--   However, starting with deepseq-1.4.0.0, the default
--   implementation is based on DefaultSignatures allowing for
--   more accurate auto-derived NFData instances. If you need the
--   previously used exact default rnf method implementation
--   semantics, use
--   
--   
--   instance NFData Colour where rnf x = seq x ()
--   
--   
--   or alternatively
--   
--   
--   instance NFData Colour where rnf = rwhnf
--   
--   
--   or
--   
--   
--   {-# LANGUAGE BangPatterns #-}
--   instance NFData Colour where rnf !_ = ()
--   
rnf :: NFData a => a -> ()
($dmrnf) :: (NFData a, Generic a, GNFData Zero (Rep a)) => a -> ()

-- | A monoid on applicative functors.
--   
--   If defined, some and many should be the least solutions
--   of the equations:
--   
--   
--   
- 
some v = (:) <$> v <*>
--   many v

--   
- 
many v = some v <|> pure
--   []

--   
--   
--   
Examples
--   
--   
--   >>> Nothing <|> Just 42
--   Just 42
--   
--   
--   
--   >>> [1, 2] <|> [3, 4]
--   [1,2,3,4]
--   
--   
--   
--   >>> empty <|> print (2^15)
--   32768
--   
class Applicative f => Alternative (f :: Type -> Type)

-- | The identity of <|>
--   
--   
--   empty <|> a     == a
--   a     <|> empty == a
--   
empty :: Alternative f => f a

-- | An associative binary operation
(<|>) :: Alternative f => f a -> f a -> f a

-- | One or more.
--   
--   
Examples
--   
--   
--   >>> some (putStr "la")
--   lalalalalalalalala... * goes on forever *
--   
--   
--   
--   >>> some Nothing
--   nothing
--   
--   
--   
--   >>> take 5 <$> some (Just 1)
--   * hangs forever *
--   
--   
--   Note that this function can be used with Parsers based on
--   Applicatives. In that case some parser will attempt to parse
--   parser one or more times until it fails.
some :: Alternative f => f a -> f [a]

-- | Zero or more.
--   
--   
Examples
--   
--   
--   >>> many (putStr "la")
--   lalalalalalalalala... * goes on forever *
--   
--   
--   
--   >>> many Nothing
--   Just []
--   
--   
--   
--   >>> take 5 <$> many (Just 1)
--   * hangs forever *
--   
--   
--   Note that this function can be used with Parsers based on
--   Applicatives. In that case many parser will attempt to parse
--   parser zero or more times until it fails.
many :: Alternative f => f a -> f [a]
infixl 3 <|>

-- | A functor with application, providing operations to
--   
--   
--   
- embed pure expressions (pure), and
--   
- sequence computations and combine their results (<*>
--   and liftA2).
--   
--   
--   A minimal complete definition must include implementations of
--   pure and of either <*> or liftA2. If it
--   defines both, then they must behave the same as their default
--   definitions:
--   
--   
--   (<*>) = liftA2 id
--   
--   
--   
--   liftA2 f x y = f <$> x <*> y
--   
--   
--   Further, any definition must satisfy the following:
--   
--   
--   
- Identity 
pure id <*> v =
--   v

--   
- Composition 
pure (.) <*> u
--   <*> v <*> w = u <*> (v
--   <*> w)

--   
- Homomorphism 
pure f <*>
--   pure x = pure (f x)

--   
- Interchange 
u <*> pure y =
--   pure ($ y) <*> u

--   
--   
--   The other methods have the following default definitions, which may be
--   overridden with equivalent specialized implementations:
--   
--   
--   
- 
u *> v = (id <$ u)
--   <*> v

--   
- 
u <* v = liftA2 const u v

--   
--   
--   As a consequence of these laws, the Functor instance for
--   f will satisfy
--   
--   
--   
- 
fmap f x = pure f <*> x

--   
--   
--   It may be useful to note that supposing
--   
--   
--   forall x y. p (q x y) = f x . g y
--   
--   
--   it follows from the above that
--   
--   
--   liftA2 p (liftA2 q u v) = liftA2 f u . liftA2 g v
--   
--   
--   If f is also a Monad, it should satisfy
--   
--   
--   
- 
pure = return

--   
- 
m1 <*> m2 = m1 >>= (\x1 -> m2
--   >>= (\x2 -> return (x1 x2)))

--   
- 
(*>) = (>>)

--   
--   
--   (which implies that pure and <*> satisfy the
--   applicative functor laws).
class Functor f => Applicative (f :: Type -> Type)

-- | Lift a value into the Structure.
--   
--   
Examples
--   
--   
--   >>> pure 1 :: Maybe Int
--   Just 1
--   
--   
--   
--   >>> pure 'z' :: [Char]
--   "z"
--   
--   
--   
--   >>> pure (pure ":D") :: Maybe [String]
--   Just [":D"]
--   
pure :: Applicative f => a -> f a

-- | Sequential application.
--   
--   A few functors support an implementation of <*> that is
--   more efficient than the default one.
--   
--   
Example
--   
--   Used in combination with (<$>),
--   (<*>) can be used to build a record.
--   
--   
--   >>> data MyState = MyState {arg1 :: Foo, arg2 :: Bar, arg3 :: Baz}
--   
--   
--   
--   >>> produceFoo :: Applicative f => f Foo
--   
--   >>> produceBar :: Applicative f => f Bar
--   
--   >>> produceBaz :: Applicative f => f Baz
--   
--   
--   
--   >>> mkState :: Applicative f => f MyState
--   
--   >>> mkState = MyState <$> produceFoo <*> produceBar <*> produceBaz
--   
(<*>) :: Applicative f => f (a -> b) -> f a -> f b

-- | Lift a binary function to actions.
--   
--   Some functors support an implementation of liftA2 that is more
--   efficient than the default one. In particular, if fmap is an
--   expensive operation, it is likely better to use liftA2 than to
--   fmap over the structure and then use <*>.
--   
--   This became a typeclass method in 4.10.0.0. Prior to that, it was a
--   function defined in terms of <*> and fmap.
--   
--   
Example
--   
--   
--   >>> liftA2 (,) (Just 3) (Just 5)
--   Just (3,5)
--   
--   
--   
--   >>> liftA2 (+) [1, 2, 3] [4, 5, 6]
--   [5,6,7,6,7,8,7,8,9]
--   
liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c

-- | Sequence actions, discarding the value of the first argument.
--   
--   
Examples
--   
--   If used in conjunction with the Applicative instance for Maybe,
--   you can chain Maybe computations, with a possible "early return" in
--   case of Nothing.
--   
--   
--   >>> Just 2 *> Just 3
--   Just 3
--   
--   
--   
--   >>> Nothing *> Just 3
--   Nothing
--   
--   
--   Of course a more interesting use case would be to have effectful
--   computations instead of just returning pure values.
--   
--   
--   >>> import Data.Char
--   
--   >>> import GHC.Internal.Text.ParserCombinators.ReadP
--   
--   >>> let p = string "my name is " *> munch1 isAlpha <* eof
--   
--   >>> readP_to_S p "my name is Simon"
--   [("Simon","")]
--   
(*>) :: Applicative f => f a -> f b -> f b

-- | Sequence actions, discarding the value of the second argument.
(<*) :: Applicative f => f a -> f b -> f a
infixl 4 <*>
infixl 4 *>
infixl 4 <*

-- | A type f is a Functor if it provides a function fmap
--   which, given any types a and b lets you apply any
--   function from (a -> b) to turn an f a into an
--   f b, preserving the structure of f. Furthermore
--   f needs to adhere to the following:
--   
--   
--   
- Identity fmap id == id
--   
- Composition fmap (f . g) == fmap f .
--   fmap g
--   
--   
--   Note, that the second law follows from the free theorem of the type
--   fmap and the first law, so you need only check that the former
--   condition holds. See these articles by School of Haskell or
--   David Luposchainsky for an explanation.
class Functor (f :: Type -> Type)

-- | fmap is used to apply a function of type (a -> b)
--   to a value of type f a, where f is a functor, to produce a
--   value of type f b. Note that for any type constructor with
--   more than one parameter (e.g., Either), only the last type
--   parameter can be modified with fmap (e.g., b in
--   `Either a b`).
--   
--   Some type constructors with two parameters or more have a
--   Bifunctor instance that allows both the last and the
--   penultimate parameters to be mapped over.
--   
--   
Examples
--   
--   Convert from a Maybe Int to a Maybe String
--   using show:
--   
--   
--   >>> fmap show Nothing
--   Nothing
--   
--   >>> fmap show (Just 3)
--   Just "3"
--   
--   
--   Convert from an Either Int Int to an Either Int
--   String using show:
--   
--   
--   >>> fmap show (Left 17)
--   Left 17
--   
--   >>> fmap show (Right 17)
--   Right "17"
--   
--   
--   Double each element of a list:
--   
--   
--   >>> fmap (*2) [1,2,3]
--   [2,4,6]
--   
--   
--   Apply even to the second element of a pair:
--   
--   
--   >>> fmap even (2,2)
--   (2,True)
--   
--   
--   It may seem surprising that the function is only applied to the last
--   element of the tuple compared to the list example above which applies
--   it to every element in the list. To understand, remember that tuples
--   are type constructors with multiple type parameters: a tuple of 3
--   elements (a,b,c) can also be written (,,) a b c and
--   its Functor instance is defined for Functor ((,,) a
--   b) (i.e., only the third parameter is free to be mapped over with
--   fmap).
--   
--   It explains why fmap can be used with tuples containing
--   values of different types as in the following example:
--   
--   
--   >>> fmap even ("hello", 1.0, 4)
--   ("hello",1.0,True)
--   
fmap :: Functor f => (a -> b) -> f a -> f b

-- | Replace all locations in the input with the same value. The default
--   definition is fmap . const, but this may be
--   overridden with a more efficient version.
--   
--   
Examples
--   
--   Perform a computation with Maybe and replace the result with a
--   constant value if it is Just:
--   
--   
--   >>> 'a' <$ Just 2
--   Just 'a'
--   
--   >>> 'a' <$ Nothing
--   Nothing
--   
(<$) :: Functor f => a -> f b -> f a
infixl 4 <$

-- | The Monad class defines the basic operations over a
--   monad, a concept from a branch of mathematics known as
--   category theory. From the perspective of a Haskell programmer,
--   however, it is best to think of a monad as an abstract datatype
--   of actions. Haskell's do expressions provide a convenient
--   syntax for writing monadic expressions.
--   
--   Instances of Monad should satisfy the following:
--   
--   
--   
- Left identity return a >>= k = k
--   a
--   
- Right identity m >>= return =
--   m
--   
- Associativity m >>= (\x -> k x
--   >>= h) = (m >>= k) >>=
--   h
--   
--   
--   Furthermore, the Monad and Applicative operations should
--   relate as follows:
--   
--   
--   
- 
pure = return

--   
- 
m1 <*> m2 = m1 >>= (\x1 -> m2
--   >>= (\x2 -> return (x1 x2)))

--   
--   
--   The above laws imply:
--   
--   
--   
- 
fmap f xs = xs >>= return .
--   f

--   
- 
(>>) = (*>)

--   
--   
--   and that pure and (<*>) satisfy the applicative
--   functor laws.
--   
--   The instances of Monad for List, Maybe and
--   IO defined in the Prelude satisfy these laws.
class Applicative m => Monad (m :: Type -> Type)

-- | Sequentially compose two actions, passing any value produced by the
--   first as an argument to the second.
--   
--   'as >>= bs' can be understood as the do
--   expression
--   
--   
--   do a <- as
--      bs a
--   
--   
--   An alternative name for this function is 'bind', but some people may
--   refer to it as 'flatMap', which results from it being equivialent to
--   
--   
--   \x f -> join (fmap f x) :: Monad m => m a -> (a -> m b) -> m b
--   
--   
--   which can be seen as mapping a value with Monad m => m a ->
--   m (m b) and then 'flattening' m (m b) to m b
--   using join.
(>>=) :: Monad m => m a -> (a -> m b) -> m b

-- | Sequentially compose two actions, discarding any value produced by the
--   first, like sequencing operators (such as the semicolon) in imperative
--   languages.
--   
--   'as >> bs' can be understood as the do
--   expression
--   
--   
--   do as
--      bs
--   
--   
--   or in terms of (>>=) as
--   
--   
--   as >>= const bs
--   
(>>) :: Monad m => m a -> m b -> m b

-- | Inject a value into the monadic type. This function should not
--   be different from its default implementation as pure. The
--   justification for the existence of this function is merely historic.
return :: Monad m => a -> m a
infixl 1 >>=
infixl 1 >>

-- | Monads that also support choice and failure.
class (Alternative m, Monad m) => MonadPlus (m :: Type -> Type)

-- | The identity of mplus. It should also satisfy the equations
--   
--   
--   mzero >>= f  =  mzero
--   v >> mzero   =  mzero
--   
--   
--   The default definition is
--   
--   
--   mzero = empty
--   
mzero :: MonadPlus m => m a

-- | An associative operation. The default definition is
--   
--   
--   mplus = (<|>)
--   
mplus :: MonadPlus m => m a -> m a -> m a

-- | The class of monoids (types with an associative binary operation that
--   has an identity). Instances should satisfy the following:
--   
--   
--   
- Right identity x <> mempty =
--   x
--   
- Left identity mempty <> x =
--   x
--   
- Associativity x <> (y <> z) =
--   (x <> y) <> z (Semigroup
--   law)
--   
- Concatenation mconcat = foldr
--   (<>) mempty
--   
--   
--   You can alternatively define mconcat instead of mempty,
--   in which case the laws are:
--   
--   
--   
- Unit mconcat (pure x) = x
--   
- Multiplication mconcat (join xss) =
--   mconcat (fmap mconcat xss)
--   
- Subclass mconcat (toList xs) =
--   sconcat xs
--   
--   
--   The method names refer to the monoid of lists under concatenation, but
--   there are many other instances.
--   
--   Some types can be viewed as a monoid in more than one way, e.g. both
--   addition and multiplication on numbers. In such cases we often define
--   newtypes and make those instances of Monoid, e.g.
--   Sum and Product.
--   
--   NOTE: Semigroup is a superclass of Monoid since
--   base-4.11.0.0.
class Semigroup a => Monoid a

-- | Identity of mappend
--   
--   
Examples
--   
--   
--   >>> "Hello world" <> mempty
--   "Hello world"
--   
--   
--   
--   >>> mempty <> [1, 2, 3]
--   [1,2,3]
--   
mempty :: Monoid a => a

-- | An associative operation
--   
--   NOTE: This method is redundant and has the default
--   implementation mappend = (<>) since
--   base-4.11.0.0. Should it be implemented manually, since
--   mappend is a synonym for (<>), it is expected that
--   the two functions are defined the same way. In a future GHC release
--   mappend will be removed from Monoid.
mappend :: Monoid a => a -> a -> a

-- | Fold a list using the monoid.
--   
--   For most types, the default definition for mconcat will be
--   used, but the function is included in the class definition so that an
--   optimized version can be provided for specific types.
--   
--   
--   >>> mconcat ["Hello", " ", "Haskell", "!"]
--   "Hello Haskell!"
--   
mconcat :: Monoid a => [a] -> a

-- | Non-empty (and non-strict) list type.
data NonEmpty a
(:|) :: a -> [a] -> NonEmpty a
infixr 5 :|

-- | The class of semigroups (types with an associative binary operation).
--   
--   Instances should satisfy the following:
--   
--   
--   
- Associativity x <> (y <> z) =
--   (x <> y) <> z
--   
--   
--   You can alternatively define sconcat instead of
--   (<>), in which case the laws are:
--   
--   
--   
- Unit sconcat (pure x) = x
--   
- Multiplication sconcat (join xss) =
--   sconcat (fmap sconcat xss)
--   
class Semigroup a

-- | An associative operation.
--   
--   
Examples
--   
--   
--   >>> [1,2,3] <> [4,5,6]
--   [1,2,3,4,5,6]
--   
--   
--   
--   >>> Just [1, 2, 3] <> Just [4, 5, 6]
--   Just [1,2,3,4,5,6]
--   
--   
--   
--   >>> putStr "Hello, " <> putStrLn "World!"
--   Hello, World!
--   
(<>) :: Semigroup a => a -> a -> a
infixr 6 <>

-- | Uninhabited data type
data Void

-- | Send the first component of the input through the argument arrow, and
--   copy the rest unchanged to the output.
first :: Arrow a => a b c -> a (b, d) (c, d)

-- | When a value is bound in do-notation, the pattern on the left
--   hand side of <- might not match. In this case, this class
--   provides a function to recover.
--   
--   A Monad without a MonadFail instance may only be used in
--   conjunction with pattern that always match, such as newtypes, tuples,
--   data types with only a single data constructor, and irrefutable
--   patterns (~pat).
--   
--   Instances of MonadFail should satisfy the following law:
--   fail s should be a left zero for >>=,
--   
--   
--   fail s >>= f  =  fail s
--   
--   
--   If your Monad is also MonadPlus, a popular definition is
--   
--   
--   fail _ = mzero
--   
--   
--   fail s should be an action that runs in the monad itself, not
--   an exception (except in instances of MonadIO). In particular,
--   fail should not be implemented in terms of error.
class Monad m => MonadFail (m :: Type -> Type)
fail :: MonadFail m => String -> m a

-- | The Data class comprehends a fundamental primitive
--   gfoldl for folding over constructor applications, say terms.
--   This primitive can be instantiated in several ways to map over the
--   immediate subterms of a term; see the gmap combinators later
--   in this class. Indeed, a generic programmer does not necessarily need
--   to use the ingenious gfoldl primitive but rather the intuitive
--   gmap combinators. The gfoldl primitive is completed by
--   means to query top-level constructors, to turn constructor
--   representations into proper terms, and to list all possible datatype
--   constructors. This completion allows us to serve generic programming
--   scenarios like read, show, equality, term generation.
--   
--   The combinators gmapT, gmapQ, gmapM, etc are all
--   provided with default definitions in terms of gfoldl, leaving
--   open the opportunity to provide datatype-specific definitions. (The
--   inclusion of the gmap combinators as members of class
--   Data allows the programmer or the compiler to derive
--   specialised, and maybe more efficient code per datatype. Note:
--   gfoldl is more higher-order than the gmap combinators.
--   This is subject to ongoing benchmarking experiments. It might turn out
--   that the gmap combinators will be moved out of the class
--   Data.)
--   
--   Conceptually, the definition of the gmap combinators in terms
--   of the primitive gfoldl requires the identification of the
--   gfoldl function arguments. Technically, we also need to
--   identify the type constructor c for the construction of the
--   result type from the folded term type.
--   
--   In the definition of gmapQx combinators, we use
--   phantom type constructors for the c in the type of
--   gfoldl because the result type of a query does not involve the
--   (polymorphic) type of the term argument. In the definition of
--   gmapQl we simply use the plain constant type constructor
--   because gfoldl is left-associative anyway and so it is readily
--   suited to fold a left-associative binary operation over the immediate
--   subterms. In the definition of gmapQr, extra effort is needed. We use
--   a higher-order accumulation trick to mediate between left-associative
--   constructor application vs. right-associative binary operation (e.g.,
--   (:)). When the query is meant to compute a value of type
--   r, then the result type within generic folding is r ->
--   r. So the result of folding is a function to which we finally
--   pass the right unit.
--   
--   With the -XDeriveDataTypeable option, GHC can generate
--   instances of the Data class automatically. For example, given
--   the declaration
--   
--   
--   data T a b = C1 a b | C2 deriving (Typeable, Data)
--   
--   
--   GHC will generate an instance that is equivalent to
--   
--   
--   instance (Data a, Data b) => Data (T a b) where
--       gfoldl k z (C1 a b) = z C1 `k` a `k` b
--       gfoldl k z C2       = z C2
--   
--       gunfold k z c = case constrIndex c of
--                           1 -> k (k (z C1))
--                           2 -> z C2
--   
--       toConstr (C1 _ _) = con_C1
--       toConstr C2       = con_C2
--   
--       dataTypeOf _ = ty_T
--   
--   con_C1 = mkConstr ty_T "C1" [] Prefix
--   con_C2 = mkConstr ty_T "C2" [] Prefix
--   ty_T   = mkDataType "Module.T" [con_C1, con_C2]
--   
--   
--   This is suitable for datatypes that are exported transparently.
class Typeable a => Data a

-- | The Either type represents values with two possibilities: a
--   value of type Either a b is either Left
--   a or Right b.
--   
--   The Either type is sometimes used to represent a value which is
--   either correct or an error; by convention, the Left constructor
--   is used to hold an error value and the Right constructor is
--   used to hold a correct value (mnemonic: "right" also means "correct").
--   
--   
Examples
--   
--   The type Either String Int is the type
--   of values which can be either a String or an Int. The
--   Left constructor can be used only on Strings, and the
--   Right constructor can be used only on Ints:
--   
--   
--   >>> let s = Left "foo" :: Either String Int
--   
--   >>> s
--   Left "foo"
--   
--   >>> let n = Right 3 :: Either String Int
--   
--   >>> n
--   Right 3
--   
--   >>> :type s
--   s :: Either String Int
--   
--   >>> :type n
--   n :: Either String Int
--   
--   
--   The fmap from our Functor instance will ignore
--   Left values, but will apply the supplied function to values
--   contained in a Right:
--   
--   
--   >>> let s = Left "foo" :: Either String Int
--   
--   >>> let n = Right 3 :: Either String Int
--   
--   >>> fmap (*2) s
--   Left "foo"
--   
--   >>> fmap (*2) n
--   Right 6
--   
--   
--   The Monad instance for Either allows us to chain
--   together multiple actions which may fail, and fail overall if any of
--   the individual steps failed. First we'll write a function that can
--   either parse an Int from a Char, or fail.
--   
--   
--   >>> import Data.Char ( digitToInt, isDigit )
--   
--   >>> :{
--       let parseEither :: Char -> Either String Int
--           parseEither c
--             | isDigit c = Right (digitToInt c)
--             | otherwise = Left "parse error"
--   
--   >>> :}
--   
--   
--   The following should work, since both '1' and '2'
--   can be parsed as Ints.
--   
--   
--   >>> :{
--       let parseMultiple :: Either String Int
--           parseMultiple = do
--             x <- parseEither '1'
--             y <- parseEither '2'
--             return (x + y)
--   
--   >>> :}
--   
--   
--   
--   >>> parseMultiple
--   Right 3
--   
--   
--   But the following should fail overall, since the first operation where
--   we attempt to parse 'm' as an Int will fail:
--   
--   
--   >>> :{
--       let parseMultiple :: Either String Int
--           parseMultiple = do
--             x <- parseEither 'm'
--             y <- parseEither '2'
--             return (x + y)
--   
--   >>> :}
--   
--   
--   
--   >>> parseMultiple
--   Left "parse error"
--   
data Either a b
Left :: a -> Either a b
Right :: b -> Either a b

-- | The Const functor.
--   
--   
Examples
--   
--   
--   >>> fmap (++ "World") (Const "Hello")
--   Const "Hello"
--   
--   
--   Because we ignore the second type parameter to Const, the
--   Applicative instance, which has (<*>) :: Monoid m
--   => Const m (a -> b) -> Const m a -> Const m b
--   essentially turns into Monoid m => m -> m -> m,
--   which is (<>)
--   
--   
--   >>> Const [1, 2, 3] <*> Const [4, 5, 6]
--   Const [1,2,3,4,5,6]
--   
newtype Const a (b :: k)
Const :: a -> Const a (b :: k)
[getConst] :: Const a (b :: k) -> a

-- | Identity functor and monad. (a non-strict monad)
--   
--   
Examples
--   
--   
--   >>> fmap (+1) (Identity 0)
--   Identity 1
--   
--   
--   
--   >>> Identity [1, 2, 3] <> Identity [4, 5, 6]
--   Identity [1,2,3,4,5,6]
--   
--   
--   
--   >>> do
--         x <- Identity 10
--         y <- Identity (x + 5)
--         pure (x + y)
--   Identity 25
--   
newtype Identity a
Identity :: a -> Identity a
[runIdentity] :: Identity a -> a

-- | Proxy is a type that holds no data, but has a phantom parameter
--   of arbitrary type (or even kind). Its use is to provide type
--   information, even though there is no value available of that type (or
--   it may be too costly to create one).
--   
--   Historically, Proxy :: Proxy a is a safer
--   alternative to the undefined :: a idiom.
--   
--   
--   >>> Proxy :: Proxy (Void, Int -> Int)
--   Proxy
--   
--   
--   Proxy can even hold types of higher kinds,
--   
--   
--   >>> Proxy :: Proxy Either
--   Proxy
--   
--   
--   
--   >>> Proxy :: Proxy Functor
--   Proxy
--   
--   
--   
--   >>> Proxy :: Proxy complicatedStructure
--   Proxy
--   
data Proxy (t :: k)
Proxy :: Proxy (t :: k)

-- | IsString is used in combination with the
--   -XOverloadedStrings language extension to convert the
--   literals to different string types.
--   
--   For example, if you use the text package, you can say
--   
--   
--   {-# LANGUAGE OverloadedStrings  #-}
--   
--   myText = "hello world" :: Text
--   
--   
--   Internally, the extension will convert this to the equivalent of
--   
--   
--   myText = fromString @Text ("hello world" :: String)
--   
--   
--   Note: You can use fromString in normal code as well,
--   but the usual performance/memory efficiency problems with
--   String apply.
class IsString a
fromString :: IsString a => String -> a

-- | Functors representing data structures that can be transformed to
--   structures of the same shape by performing an
--   Applicative (or, therefore, Monad) action on each
--   element from left to right.
--   
--   A more detailed description of what same shape means, the
--   various methods, how traversals are constructed, and example advanced
--   use-cases can be found in the Overview section of
--   Data.Traversable#overview.
--   
--   For the class laws see the Laws section of
--   Data.Traversable#laws.
class (Functor t, Foldable t) => Traversable (t :: Type -> Type)

-- | Map each element of a structure to an action, evaluate these actions
--   from left to right, and collect the results. For a version that
--   ignores the results see traverse_.
--   
--   
Examples
--   
--   Basic usage:
--   
--   In the first two examples we show each evaluated action mapping to the
--   output structure.
--   
--   
--   >>> traverse Just [1,2,3,4]
--   Just [1,2,3,4]
--   
--   
--   
--   >>> traverse id [Right 1, Right 2, Right 3, Right 4]
--   Right [1,2,3,4]
--   
--   
--   In the next examples, we show that Nothing and Left
--   values short circuit the created structure.
--   
--   
--   >>> traverse (const Nothing) [1,2,3,4]
--   Nothing
--   
--   
--   
--   >>> traverse (\x -> if odd x then Just x else Nothing)  [1,2,3,4]
--   Nothing
--   
--   
--   
--   >>> traverse id [Right 1, Right 2, Right 3, Right 4, Left 0]
--   Left 0
--   
traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)

-- | Evaluate each action in the structure from left to right, and collect
--   the results. For a version that ignores the results see
--   sequenceA_.
--   
--   
Examples
--   
--   Basic usage:
--   
--   For the first two examples we show sequenceA fully evaluating a a
--   structure and collecting the results.
--   
--   
--   >>> sequenceA [Just 1, Just 2, Just 3]
--   Just [1,2,3]
--   
--   
--   
--   >>> sequenceA [Right 1, Right 2, Right 3]
--   Right [1,2,3]
--   
--   
--   The next two example show Nothing and Just will short
--   circuit the resulting structure if present in the input. For more
--   context, check the Traversable instances for Either and
--   Maybe.
--   
--   
--   >>> sequenceA [Just 1, Just 2, Just 3, Nothing]
--   Nothing
--   
--   
--   
--   >>> sequenceA [Right 1, Right 2, Right 3, Left 4]
--   Left 4
--   
sequenceA :: (Traversable t, Applicative f) => t (f a) -> f (t a)

-- | A quantified type representation.
type TypeRep = SomeTypeRep

-- | The class Typeable allows a concrete representation of a type
--   to be calculated.
class Typeable (a :: k)

-- | The Bounded class is used to name the upper and lower limits of
--   a type. Ord is not a superclass of Bounded since types
--   that are not totally ordered may also have upper and lower bounds.
--   
--   The Bounded class may be derived for any enumeration type;
--   minBound is the first constructor listed in the data
--   declaration and maxBound is the last. Bounded may also
--   be derived for single-constructor datatypes whose constituent types
--   are in Bounded.
class Bounded a
minBound :: Bounded a => a
maxBound :: Bounded a => a

-- | Class Enum defines operations on sequentially ordered types.
--   
--   The enumFrom... methods are used in Haskell's translation of
--   arithmetic sequences.
--   
--   Instances of Enum may be derived for any enumeration type
--   (types whose constructors have no fields). The nullary constructors
--   are assumed to be numbered left-to-right by fromEnum from
--   0 through n-1. See Chapter 10 of the Haskell
--   Report for more details.
--   
--   For any type that is an instance of class Bounded as well as
--   Enum, the following should hold:
--   
--   
--   
- The calls succ maxBound and pred
--   minBound should result in a runtime error.
--   
- fromEnum and toEnum should give a runtime error if
--   the result value is not representable in the result type. For example,
--   toEnum 7 :: Bool is an error.
--   
- enumFrom and enumFromThen should be defined with an
--   implicit bound, thus:
--   
--   
--   
--   enumFrom     x   = enumFromTo     x maxBound
--   enumFromThen x y = enumFromThenTo x y bound
--     where
--       bound | fromEnum y >= fromEnum x = maxBound
--             | otherwise                = minBound
--   
class Enum a

-- | Successor of a value. For numeric types, succ adds 1.
succ :: Enum a => a -> a

-- | Predecessor of a value. For numeric types, pred subtracts 1.
pred :: Enum a => a -> a

-- | Convert from an Int.
toEnum :: Enum a => Int -> a

-- | Convert to an Int. It is implementation-dependent what
--   fromEnum returns when applied to a value that is too large to
--   fit in an Int.
fromEnum :: Enum a => a -> Int

-- | Used in Haskell's translation of [n..] with [n..] =
--   enumFrom n, a possible implementation being enumFrom n = n :
--   enumFrom (succ n).
--   
--   
Examples
--   
--   
--   
- 
enumFrom 4 :: [Integer] = [4,5,6,7,...]

--   
- 
enumFrom 6 :: [Int] = [6,7,8,9,...,maxBound ::
--   Int]

--   
enumFrom :: Enum a => a -> [a]

-- | Used in Haskell's translation of [n,n'..] with [n,n'..] =
--   enumFromThen n n', a possible implementation being
--   enumFromThen n n' = n : n' : worker (f x) (f x n'),
--   worker s v = v : worker s (s v), x = fromEnum n' -
--   fromEnum n and
--   
--   
--   f n y
--     | n > 0 = f (n - 1) (succ y)
--     | n < 0 = f (n + 1) (pred y)
--     | otherwise = y
--   
--   
--   
--   
Examples
--   
--   
--   
- 
enumFromThen 4 6 :: [Integer] = [4,6,8,10...]

--   
- 
enumFromThen 6 2 :: [Int] = [6,2,-2,-6,...,minBound ::
--   Int]

--   
enumFromThen :: Enum a => a -> a -> [a]

-- | Used in Haskell's translation of [n..m] with [n..m] =
--   enumFromTo n m, a possible implementation being
--   
--   
--   enumFromTo n m
--      | n <= m = n : enumFromTo (succ n) m
--      | otherwise = []
--   
--   
--   
--   
Examples
--   
--   
--   
- 
enumFromTo 6 10 :: [Int] = [6,7,8,9,10]

--   
- 
enumFromTo 42 1 :: [Integer] = []

--   
enumFromTo :: Enum a => a -> a -> [a]

-- | Used in Haskell's translation of [n,n'..m] with [n,n'..m]
--   = enumFromThenTo n n' m, a possible implementation being
--   enumFromThenTo n n' m = worker (f x) (c x) n m, x =
--   fromEnum n' - fromEnum n, c x = bool (>=) ((x
--   0)
--   
--   
--   f n y
--      | n > 0 = f (n - 1) (succ y)
--      | n < 0 = f (n + 1) (pred y)
--      | otherwise = y
--   
--   
--   
--   and
--   
--   
--   worker s c v m
--      | c v m = v : worker s c (s v) m
--      | otherwise = []
--   
--   
--   
--   
Examples
--   
--   
--   
- 
enumFromThenTo 4 2 -6 :: [Integer] =
--   [4,2,0,-2,-4,-6]

--   
- 
enumFromThenTo 6 8 2 :: [Int] = []

--   
enumFromThenTo :: Enum a => a -> a -> a -> [a]

-- | The SomeException type is the root of the exception type
--   hierarchy. When an exception of type e is thrown, behind the
--   scenes it is encapsulated in a SomeException.
data SomeException
SomeException :: e -> SomeException

-- | Trigonometric and hyperbolic functions and related functions.
--   
--   The Haskell Report defines no laws for Floating. However,
--   (+), (*) and exp are
--   customarily expected to define an exponential field and have the
--   following properties:
--   
--   
--   
- exp (a + b) = exp a * exp b
--   
- exp (fromInteger 0) = fromInteger 1
--   
class Fractional a => Floating a
pi :: Floating a => a
exp :: Floating a => a -> a
log :: Floating a => a -> a
sqrt :: Floating a => a -> a
(**) :: Floating a => a -> a -> a
logBase :: Floating a => a -> a -> a
sin :: Floating a => a -> a
cos :: Floating a => a -> a
tan :: Floating a => a -> a
asin :: Floating a => a -> a
acos :: Floating a => a -> a
atan :: Floating a => a -> a
sinh :: Floating a => a -> a
cosh :: Floating a => a -> a
tanh :: Floating a => a -> a
asinh :: Floating a => a -> a
acosh :: Floating a => a -> a
atanh :: Floating a => a -> a
infixr 8 **

-- | Efficient, machine-independent access to the components of a
--   floating-point number.
class (RealFrac a, Floating a) => RealFloat a

-- | a constant function, returning the radix of the representation (often
--   2)
floatRadix :: RealFloat a => a -> Integer

-- | a constant function, returning the number of digits of
--   floatRadix in the significand
floatDigits :: RealFloat a => a -> Int

-- | a constant function, returning the lowest and highest values the
--   exponent may assume
floatRange :: RealFloat a => a -> (Int, Int)

-- | The function decodeFloat applied to a real floating-point
--   number returns the significand expressed as an Integer and an
--   appropriately scaled exponent (an Int). If
--   decodeFloat x yields (m,n), then x
--   is equal in value to m*b^^n, where b is the
--   floating-point radix, and furthermore, either m and
--   n are both zero or else b^(d-1) <= abs m <
--   b^d, where d is the value of floatDigits
--   x. In particular, decodeFloat 0 = (0,0). If the
--   type contains a negative zero, also decodeFloat (-0.0) =
--   (0,0). The result of decodeFloat x is
--   unspecified if either of isNaN x or
--   isInfinite x is True.
decodeFloat :: RealFloat a => a -> (Integer, Int)

-- | encodeFloat performs the inverse of decodeFloat in the
--   sense that for finite x with the exception of -0.0,
--   uncurry encodeFloat (decodeFloat x) = x.
--   encodeFloat m n is one of the two closest
--   representable floating-point numbers to m*b^^n (or
--   ±Infinity if overflow occurs); usually the closer, but if
--   m contains too many bits, the result may be rounded in the
--   wrong direction.
encodeFloat :: RealFloat a => Integer -> Int -> a

-- | exponent corresponds to the second component of
--   decodeFloat. exponent 0 = 0 and for finite
--   nonzero x, exponent x = snd (decodeFloat x)
--   + floatDigits x. If x is a finite floating-point
--   number, it is equal in value to significand x * b ^^
--   exponent x, where b is the floating-point radix.
--   The behaviour is unspecified on infinite or NaN values.
exponent :: RealFloat a => a -> Int

-- | The first component of decodeFloat, scaled to lie in the open
--   interval (-1,1), either 0.0 or of absolute
--   value >= 1/b, where b is the floating-point
--   radix. The behaviour is unspecified on infinite or NaN
--   values.
significand :: RealFloat a => a -> a

-- | multiplies a floating-point number by an integer power of the radix
scaleFloat :: RealFloat a => Int -> a -> a

-- | True if the argument is an IEEE "not-a-number" (NaN) value
isNaN :: RealFloat a => a -> Bool

-- | True if the argument is an IEEE infinity or negative infinity
isInfinite :: RealFloat a => a -> Bool

-- | True if the argument is too small to be represented in
--   normalized format
isDenormalized :: RealFloat a => a -> Bool

-- | True if the argument is an IEEE negative zero
isNegativeZero :: RealFloat a => a -> Bool

-- | True if the argument is an IEEE floating point number
isIEEE :: RealFloat a => a -> Bool

-- | a version of arctangent taking two real floating-point arguments. For
--   real floating x and y, atan2 y x
--   computes the angle (from the positive x-axis) of the vector from the
--   origin to the point (x,y). atan2 y x returns
--   a value in the range [-pi, pi]. It follows the
--   Common Lisp semantics for the origin when signed zeroes are supported.
--   atan2 y 1, with y in a type that is
--   RealFloat, should return the same value as atan
--   y. A default definition of atan2 is provided, but
--   implementors can provide a more accurate implementation.
atan2 :: RealFloat a => a -> a -> a

-- | Representable types of kind *. This class is derivable in GHC
--   with the DeriveGeneric flag on.
--   
--   A Generic instance must satisfy the following laws:
--   
--   
--   from . to ≡ id
--   to . from ≡ id
--   
class Generic a

-- | File and directory names are values of type String, whose
--   precise meaning is operating system dependent. Files can be opened,
--   yielding a handle which can then be used to operate on the contents of
--   that file.
type FilePath = String

-- | Defines the exit codes that a program can return.
data ExitCode

-- | indicates successful termination;
ExitSuccess :: ExitCode

-- | indicates program failure with an exit code. The exact interpretation
--   of the code is operating-system dependent. In particular, some values
--   may be prohibited (e.g. 0 on a POSIX-compliant system).
ExitFailure :: Int -> ExitCode

-- | The Haskell 2010 type for exceptions in the IO monad. Any I/O
--   operation may raise an IOError instead of returning a result.
--   For a more general type of exception, including also those that arise
--   in pure code, see Exception.
--   
--   In Haskell 2010, this is an opaque type.
type IOError = IOException

-- | 16-bit signed integer type
data Int16

-- | 32-bit signed integer type
data Int32

-- | 64-bit signed integer type
data Int64

-- | 8-bit signed integer type
data Int8

-- | Basic numeric class.
--   
--   The Haskell Report defines no laws for Num. However,
--   (+) and (*) are customarily expected
--   to define a ring and have the following properties:
--   
--   
--   
- Associativity of (+) (x + y) +
--   z = x + (y + z)
--   
- Commutativity of (+) x + y
--   = y + x
--   
- fromInteger 0 is the additive
--   identity x + fromInteger 0 = x
--   
- negate gives the additive inverse x +
--   negate x = fromInteger 0
--   
- Associativity of (*) (x * y) *
--   z = x * (y * z)
--   
- fromInteger 1 is the multiplicative
--   identity x * fromInteger 1 = x and
--   fromInteger 1 * x = x
--   
- Distributivity of (*) with respect to
--   (+) a * (b + c) = (a * b) + (a *
--   c) and (b + c) * a = (b * a) + (c * a)
--   
- Coherence with toInteger if the type also
--   implements Integral, then fromInteger is a left inverse
--   for toInteger, i.e. fromInteger (toInteger i) ==
--   i
--   
--   
--   Note that it isn't customarily expected that a type instance of
--   both Num and Ord implement an ordered ring. Indeed, in
--   base only Integer and Rational do.
class Num a
(+) :: Num a => a -> a -> a
(-) :: Num a => a -> a -> a
(*) :: Num a => a -> a -> a

-- | Unary negation.
negate :: Num a => a -> a

-- | Absolute value.
abs :: Num a => a -> a

-- | Sign of a number. The functions abs and signum should
--   satisfy the law:
--   
--   
--   abs x * signum x == x
--   
--   
--   For real numbers, the signum is either -1 (negative),
--   0 (zero) or 1 (positive).
signum :: Num a => a -> a

-- | Conversion from an Integer. An integer literal represents the
--   application of the function fromInteger to the appropriate
--   value of type Integer, so such literals have type
--   (Num a) => a.
fromInteger :: Num a => Integer -> a
infixl 6 -
infixl 7 *
infixl 6 +

-- | Parsing of Strings, producing values.
--   
--   Derived instances of Read make the following assumptions, which
--   derived instances of Show obey:
--   
--   
--   
- If the constructor is defined to be an infix operator, then the
--   derived Read instance will parse only infix applications of the
--   constructor (not the prefix form).
--   
- Associativity is not used to reduce the occurrence of parentheses,
--   although precedence may be.
--   
- If the constructor is defined using record syntax, the derived
--   Read will parse only the record-syntax form, and furthermore,
--   the fields must be given in the same order as the original
--   declaration.
--   
- The derived Read instance allows arbitrary Haskell
--   whitespace between tokens of the input string. Extra parentheses are
--   also allowed.
--   
--   
--   For example, given the declarations
--   
--   
--   infixr 5 :^:
--   data Tree a =  Leaf a  |  Tree a :^: Tree a
--   
--   
--   the derived instance of Read in Haskell 2010 is equivalent to
--   
--   
--   instance (Read a) => Read (Tree a) where
--   
--           readsPrec d r =  readParen (d > app_prec)
--                            (\r -> [(Leaf m,t) |
--                                    ("Leaf",s) <- lex r,
--                                    (m,t) <- readsPrec (app_prec+1) s]) r
--   
--                         ++ readParen (d > up_prec)
--                            (\r -> [(u:^:v,w) |
--                                    (u,s) <- readsPrec (up_prec+1) r,
--                                    (":^:",t) <- lex s,
--                                    (v,w) <- readsPrec (up_prec+1) t]) r
--   
--             where app_prec = 10
--                   up_prec = 5
--   
--   
--   Note that right-associativity of :^: is unused.
--   
--   The derived instance in GHC is equivalent to
--   
--   
--   instance (Read a) => Read (Tree a) where
--   
--           readPrec = parens $ (prec app_prec $ do
--                                    Ident "Leaf" <- lexP
--                                    m <- step readPrec
--                                    return (Leaf m))
--   
--                        +++ (prec up_prec $ do
--                                    u <- step readPrec
--                                    Symbol ":^:" <- lexP
--                                    v <- step readPrec
--                                    return (u :^: v))
--   
--             where app_prec = 10
--                   up_prec = 5
--   
--           readListPrec = readListPrecDefault
--   
--   
--   Why do both readsPrec and readPrec exist, and why does
--   GHC opt to implement readPrec in derived Read instances
--   instead of readsPrec? The reason is that readsPrec is
--   based on the ReadS type, and although ReadS is mentioned
--   in the Haskell 2010 Report, it is not a very efficient parser data
--   structure.
--   
--   readPrec, on the other hand, is based on a much more efficient
--   ReadPrec datatype (a.k.a "new-style parsers"), but its
--   definition relies on the use of the RankNTypes language
--   extension. Therefore, readPrec (and its cousin,
--   readListPrec) are marked as GHC-only. Nevertheless, it is
--   recommended to use readPrec instead of readsPrec
--   whenever possible for the efficiency improvements it brings.
--   
--   As mentioned above, derived Read instances in GHC will
--   implement readPrec instead of readsPrec. The default
--   implementations of readsPrec (and its cousin, readList)
--   will simply use readPrec under the hood. If you are writing a
--   Read instance by hand, it is recommended to write it like so:
--   
--   
--   instance Read T where
--     readPrec     = ...
--     readListPrec = readListPrecDefault
--   
class Read a

-- | attempts to parse a value from the front of the string, returning a
--   list of (parsed value, remaining string) pairs. If there is no
--   successful parse, the returned list is empty.
--   
--   Derived instances of Read and Show satisfy the
--   following:
--   
--   
--   
- (x,"") is an element of (readsPrec d
--   (showsPrec d x "")).
--   
--   
--   That is, readsPrec parses the string produced by
--   showsPrec, and delivers the value that showsPrec started
--   with.
readsPrec :: Read a => Int -> ReadS a

-- | The method readList is provided to allow the programmer to give
--   a specialised way of parsing lists of values. For example, this is
--   used by the predefined Read instance of the Char type,
--   where values of type String are expected to use double quotes,
--   rather than square brackets.
readList :: Read a => ReadS [a]

-- | Fractional numbers, supporting real division.
--   
--   The Haskell Report defines no laws for Fractional. However,
--   (+) and (*) are customarily expected
--   to define a division ring and have the following properties:
--   
--   
--   
- recip gives the multiplicative inverse x
--   * recip x = recip x * x = fromInteger 1
--   
- Totality of toRational toRational is
--   total
--   
- Coherence with toRational if the type also
--   implements Real, then fromRational is a left inverse for
--   toRational, i.e. fromRational (toRational i) = i
--   
--   
--   Note that it isn't customarily expected that a type instance of
--   Fractional implement a field. However, all instances in
--   base do.
class Num a => Fractional a

-- | Fractional division.
(/) :: Fractional a => a -> a -> a

-- | Reciprocal fraction.
recip :: Fractional a => a -> a

-- | Conversion from a Rational (that is Ratio
--   Integer). A floating literal stands for an application of
--   fromRational to a value of type Rational, so such
--   literals have type (Fractional a) => a.
fromRational :: Fractional a => Rational -> a
infixl 7 /

-- | Integral numbers, supporting integer division.
--   
--   The Haskell Report defines no laws for Integral. However,
--   Integral instances are customarily expected to define a
--   Euclidean domain and have the following properties for the
--   div/mod and quot/rem pairs, given suitable
--   Euclidean functions f and g:
--   
--   
--   
- x = y * quot x y + rem x y with rem x y
--   = fromInteger 0 or g (rem x y) < g
--   y
--   
- x = y * div x y + mod x y with mod x y
--   = fromInteger 0 or f (mod x y) < f
--   y
--   
--   
--   An example of a suitable Euclidean function, for Integer's
--   instance, is abs.
--   
--   In addition, toInteger should be total, and
--   fromInteger should be a left inverse for it, i.e.
--   fromInteger (toInteger i) = i.
class (Real a, Enum a) => Integral a

-- | Integer division truncated toward zero.
--   
--   WARNING: This function is partial (because it throws when 0 is passed
--   as the divisor) for all the integer types in base.
quot :: Integral a => a -> a -> a

-- | Integer remainder, satisfying
--   
--   
--   (x `quot` y)*y + (x `rem` y) == x
--   
--   
--   WARNING: This function is partial (because it throws when 0 is passed
--   as the divisor) for all the integer types in base.
rem :: Integral a => a -> a -> a

-- | Integer division truncated toward negative infinity.
--   
--   WARNING: This function is partial (because it throws when 0 is passed
--   as the divisor) for all the integer types in base.
div :: Integral a => a -> a -> a

-- | Integer modulus, satisfying
--   
--   
--   (x `div` y)*y + (x `mod` y) == x
--   
--   
--   WARNING: This function is partial (because it throws when 0 is passed
--   as the divisor) for all the integer types in base.
mod :: Integral a => a -> a -> a

-- | Simultaneous quot and rem.
--   
--   WARNING: This function is partial (because it throws when 0 is passed
--   as the divisor) for all the integer types in base.
quotRem :: Integral a => a -> a -> (a, a)

-- | simultaneous div and mod.
--   
--   WARNING: This function is partial (because it throws when 0 is passed
--   as the divisor) for all the integer types in base.
divMod :: Integral a => a -> a -> (a, a)

-- | Conversion to Integer.
toInteger :: Integral a => a -> Integer
infixl 7 `div`
infixl 7 `mod`
infixl 7 `quot`
infixl 7 `rem`

-- | Arbitrary-precision rational numbers, represented as a ratio of two
--   Integer values. A rational number may be constructed using the
--   % operator.
type Rational = Ratio Integer

-- | Real numbers.
--   
--   The Haskell report defines no laws for Real, however
--   Real instances are customarily expected to adhere to the
--   following law:
--   
--   
--   
- Coherence with fromRational if the type also
--   implements Fractional, then fromRational is a left
--   inverse for toRational, i.e. fromRational (toRational i) =
--   i
--   
--   
--   The law does not hold for Float, Double, CFloat,
--   CDouble, etc., because these types contain non-finite values,
--   which cannot be roundtripped through Rational.
class (Num a, Ord a) => Real a

-- | Rational equivalent of its real argument with full precision.
toRational :: Real a => a -> Rational

-- | Extracting components of fractions.
class (Real a, Fractional a) => RealFrac a

-- | The function properFraction takes a real fractional number
--   x and returns a pair (n,f) such that x =
--   n+f, and:
--   
--   
--   
- n is an integral number with the same sign as x;
--   and
--   
- f is a fraction with the same type and sign as
--   x, and with absolute value less than 1.
--   
--   
--   The default definitions of the ceiling, floor,
--   truncate and round functions are in terms of
--   properFraction.
properFraction :: (RealFrac a, Integral b) => a -> (b, a)

-- | truncate x returns the integer nearest x
--   between zero and x
truncate :: (RealFrac a, Integral b) => a -> b

-- | round x returns the nearest integer to x; the
--   even integer if x is equidistant between two integers
round :: (RealFrac a, Integral b) => a -> b

-- | ceiling x returns the least integer not less than
--   x
ceiling :: (RealFrac a, Integral b) => a -> b

-- | floor x returns the greatest integer not greater than
--   x
floor :: (RealFrac a, Integral b) => a -> b

-- | Conversion of values to readable Strings.
--   
--   Derived instances of Show have the following properties, which
--   are compatible with derived instances of Read:
--   
--   
--   
- The result of show is a syntactically correct Haskell
--   expression containing only constants, given the fixity declarations in
--   force at the point where the type is declared. It contains only the
--   constructor names defined in the data type, parentheses, and spaces.
--   When labelled constructor fields are used, braces, commas, field
--   names, and equal signs are also used.
--   
- If the constructor is defined to be an infix operator, then
--   showsPrec will produce infix applications of the
--   constructor.
--   
- the representation will be enclosed in parentheses if the
--   precedence of the top-level constructor in x is less than
--   d (associativity is ignored). Thus, if d is
--   0 then the result is never surrounded in parentheses; if
--   d is 11 it is always surrounded in parentheses,
--   unless it is an atomic expression.
--   
- If the constructor is defined using record syntax, then
--   show will produce the record-syntax form, with the fields given
--   in the same order as the original declaration.
--   
--   
--   For example, given the declarations
--   
--   
--   infixr 5 :^:
--   data Tree a =  Leaf a  |  Tree a :^: Tree a
--   
--   
--   the derived instance of Show is equivalent to
--   
--   
--   instance (Show a) => Show (Tree a) where
--   
--          showsPrec d (Leaf m) = showParen (d > app_prec) $
--               showString "Leaf " . showsPrec (app_prec+1) m
--            where app_prec = 10
--   
--          showsPrec d (u :^: v) = showParen (d > up_prec) $
--               showsPrec (up_prec+1) u .
--               showString " :^: "      .
--               showsPrec (up_prec+1) v
--            where up_prec = 5
--   
--   
--   Note that right-associativity of :^: is ignored. For example,
--   
--   
--   
- show (Leaf 1 :^: Leaf 2 :^: Leaf 3) produces the
--   string "Leaf 1 :^: (Leaf 2 :^: Leaf 3)".
--   
class Show a

-- | Convert a value to a readable String.
--   
--   showsPrec should satisfy the law
--   
--   
--   showsPrec d x r ++ s  ==  showsPrec d x (r ++ s)
--   
--   
--   Derived instances of Read and Show satisfy the
--   following:
--   
--   
--   
- (x,"") is an element of (readsPrec d
--   (showsPrec d x "")).
--   
--   
--   That is, readsPrec parses the string produced by
--   showsPrec, and delivers the value that showsPrec started
--   with.
showsPrec :: Show a => Int -> a -> ShowS

-- | A specialised variant of showsPrec, using precedence context
--   zero, and returning an ordinary String.
show :: Show a => a -> String

-- | The method showList is provided to allow the programmer to give
--   a specialised way of showing lists of values. For example, this is
--   used by the predefined Show instance of the Char type,
--   where values of type String should be shown in double quotes,
--   rather than between square brackets.
showList :: Show a => [a] -> ShowS

-- | The shows functions return a function that prepends the
--   output String to an existing String. This allows
--   constant-time concatenation of results using function composition.
type ShowS = String -> String

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

-- | 16-bit unsigned integer type
data Word16

-- | 32-bit unsigned integer type
data Word32

-- | 64-bit unsigned integer type
data Word64

-- | 8-bit unsigned integer type
data Word8

-- | The Eq class defines equality (==) and inequality
--   (/=). All the basic datatypes exported by the Prelude
--   are instances of Eq, and Eq may be derived for any
--   datatype whose constituents are also instances of Eq.
--   
--   The Haskell Report defines no laws for Eq. However, instances
--   are encouraged to follow these properties:
--   
--   
--   
- Reflexivity x == x = True
--   
- Symmetry x == y = y == x
--   
- Transitivity if x == y && y == z =
--   True, then x == z = True
--   
- Extensionality if x == y = True and
--   f is a function whose return type is an instance of
--   Eq, then f x == f y = True
--   
- Negation x /= y = not (x ==
--   y)
--   
class Eq a
(==) :: Eq a => a -> a -> Bool
(/=) :: Eq a => a -> a -> Bool
infix 4 ==
infix 4 /=

-- | The Ord class is used for totally ordered datatypes.
--   
--   Instances of Ord can be derived for any user-defined datatype
--   whose constituent types are in Ord. The declared order of the
--   constructors in the data declaration determines the ordering in
--   derived Ord instances. The Ordering datatype allows a
--   single comparison to determine the precise ordering of two objects.
--   
--   Ord, as defined by the Haskell report, implements a total order
--   and has the following properties:
--   
--   
--   
- Comparability x <= y || y <= x =
--   True
--   
- Transitivity if x <= y && y <=
--   z = True, then x <= z = True
--   
- Reflexivity x <= x = True
--   
- Antisymmetry if x <= y && y <=
--   x = True, then x == y = True
--   
--   
--   The following operator interactions are expected to hold:
--   
--   
--   
- x >= y = y <= x
--   
- x < y = x <= y && x /= y
--   
- x > y = y < x
--   
- x < y = compare x y == LT
--   
- x > y = compare x y == GT
--   
- x == y = compare x y == EQ
--   
- min x y == if x <= y then x else y = True
--   
- max x y == if x >= y then x else y = True
--   
--   
--   Note that (7.) and (8.) do not require min and
--   max to return either of their arguments. The result is merely
--   required to equal one of the arguments in terms of (==).
--   
--   Minimal complete definition: either compare or <=.
--   Using compare can be more efficient for complex types.
class Eq a => Ord a
compare :: Ord a => a -> a -> Ordering
(<) :: Ord a => a -> a -> Bool
(<=) :: Ord a => a -> a -> Bool
(>) :: Ord a => a -> a -> Bool
(>=) :: Ord a => a -> a -> Bool
max :: Ord a => a -> a -> a
min :: Ord a => a -> a -> a
infix 4 >=
infix 4 <
infix 4 <=
infix 4 >
data Ordering
LT :: Ordering
EQ :: Ordering
GT :: Ordering

-- | Arbitrary precision integers. In contrast with fixed-size integral
--   types such as Int, the Integer type represents the
--   entire infinite range of integers.
--   
--   Integers are stored in a kind of sign-magnitude form, hence do not
--   expect two's complement form when using bit operations.
--   
--   If the value is small (i.e., fits into an Int), the IS
--   constructor is used. Otherwise IP and IN constructors
--   are used to store a BigNat representing the positive or the
--   negative value magnitude, respectively.
--   
--   Invariant: IP and IN are used iff the value does not fit
--   in IS.
data Integer

-- | String is an alias for a list of characters.
--   
--   String constants in Haskell are values of type String. That
--   means if you write a string literal like "hello world", it
--   will have the type [Char], which is the same as
--   String.
--   
--   Note: You can ask the compiler to automatically infer different
--   types with the -XOverloadedStrings language extension, for
--   example "hello world" :: Text. See IsString for more
--   information.
--   
--   Because String is just a list of characters, you can use
--   normal list functions to do basic string manipulation. See
--   Data.List for operations on lists.
--   
--   
Performance considerations
--   
--   [Char] is a relatively memory-inefficient type. It is a
--   linked list of boxed word-size characters, internally it looks
--   something like:
--   
--   
--   ╭─────┬───┬──╮  ╭─────┬───┬──╮  ╭─────┬───┬──╮  ╭────╮
--   │ (:) │   │ ─┼─>│ (:) │   │ ─┼─>│ (:) │   │ ─┼─>│ [] │
--   ╰─────┴─┼─┴──╯  ╰─────┴─┼─┴──╯  ╰─────┴─┼─┴──╯  ╰────╯
--           v               v               v
--          'a'             'b'             'c'
--   
--   
--   The String "abc" will use 5*3+1 = 16 (in general
--   5n+1) words of space in memory.
--   
--   Furthermore, operations like (++) (string concatenation) are
--   O(n) (in the left argument).
--   
--   For historical reasons, the base library uses String
--   in a lot of places for the conceptual simplicity, but library code
--   dealing with user-data should use the text package for Unicode
--   text, or the the bytestring package for binary data.
type String = [Char]

-- | The Maybe type encapsulates an optional value. A value of type
--   Maybe a either contains a value of type a
--   (represented as Just a), or it is empty (represented
--   as Nothing). Using Maybe is a good way to deal with
--   errors or exceptional cases without resorting to drastic measures such
--   as error.
--   
--   The Maybe type is also a monad. It is a simple kind of error
--   monad, where all errors are represented by Nothing. A richer
--   error monad can be built using the Either type.
data Maybe a
Nothing :: Maybe a
Just :: a -> Maybe a
data Bool
False :: Bool
True :: Bool

-- | The character type Char represents Unicode codespace and its
--   elements are code points as in definitions D9 and D10 of the
--   Unicode Standard.
--   
--   Character literals in Haskell are single-quoted: 'Q',
--   'Я' or 'Ω'. To represent a single quote itself use
--   '\'', and to represent a backslash use '\\'. The
--   full grammar can be found in the section 2.6 of the Haskell 2010
--   Language Report.
--   
--   To specify a character by its code point one can use decimal,
--   hexadecimal or octal notation: '\65', '\x41' and
--   '\o101' are all alternative forms of 'A'. The
--   largest code point is '\x10ffff'.
--   
--   There is a special escape syntax for ASCII control characters:
--   
--   TODO: table
--   
--   Data.Char provides utilities to work with Char.
data Char

-- | Double-precision floating point numbers. It is desirable that this
--   type be at least equal in range and precision to the IEEE
--   double-precision type.
data Double

-- | Single-precision floating point numbers. It is desirable that this
--   type be at least equal in range and precision to the IEEE
--   single-precision type.
data Float

-- | A fixed-precision integer type with at least the range [-2^29 ..
--   2^29-1]. The exact range for a given implementation can be
--   determined by using minBound and maxBound from the
--   Bounded class.
data Int

-- | A Word is an unsigned integral type, with the same size as
--   Int.
data Word

-- | Lifted, homogeneous equality. By lifted, we mean that it can be bogus
--   (deferred type error). By homogeneous, the two types a and
--   b must have the same kinds.
class a ~# b => (a :: k) ~ (b :: k)
infix 4 ~

-- | A value of type IO a is a computation which, when
--   performed, does some I/O before returning a value of type a.
--   
--   There is really only one way to "perform" an I/O action: bind it to
--   Main.main in your program. When your program is run, the I/O
--   will be performed. It isn't possible to perform I/O from an arbitrary
--   function, unless that function is itself in the IO monad and
--   called at some point, directly or indirectly, from Main.main.
--   
--   IO is a monad, so IO actions can be combined using
--   either the do-notation or the >> and >>=
--   operations from the Monad class.
data IO a

-- | Wrapper around Data.Graph with support for edge labels
module Distribution.Solver.Modular.LabeledGraph
type Graph e = Array Vertex [(e, Vertex)]

-- | Abstract representation of vertices.
type Vertex = Int

-- | Construct an edge-labeled graph
--   
--   This is a simple adaptation of the definition in Data.Graph
graphFromEdges :: Ord key => [(node, key, [(edge, key)])] -> (Graph edge, Vertex -> (node, key, [(edge, key)]), key -> Maybe Vertex)
graphFromEdges' :: Ord key => [(node, key, [(edge, key)])] -> (Graph edge, Vertex -> (node, key, [(edge, key)]))
buildG :: Bounds -> [Edge e] -> Graph e
transposeG :: Graph e -> Graph e
vertices :: Graph e -> [Vertex]
edges :: Graph e -> [Edge e]
forgetLabels :: Graph e -> Graph
topSort :: Graph e -> [Vertex]

-- | Utility functions providing extra context to cabal error messages
module Distribution.Solver.Modular.MessageUtils
allKnownExtensions :: [String]
cutoffRange :: Int
mostSimilarElement :: String -> [String] -> String
showUnsupportedExtension :: Extension -> String
showUnsupportedLanguage :: Language -> String
withinRange :: Int -> String -> String -> Bool

module Distribution.Solver.Modular.PSQ
newtype PSQ k v
PSQ :: [(k, v)] -> PSQ k v
casePSQ :: PSQ k a -> r -> (k -> a -> PSQ k a -> r) -> r
cons :: k -> a -> PSQ k a -> PSQ k a
length :: PSQ k a -> Int
lookup :: Eq k => k -> PSQ k v -> Maybe v
filter :: (a -> Bool) -> PSQ k a -> PSQ k a

-- | Will partition the list according to the predicate. If there is any
--   element that satisfies the predicate, then only the elements
--   satisfying the predicate are returned. Otherwise, the rest is
--   returned.
filterIfAny :: (a -> Bool) -> PSQ k a -> PSQ k a

-- | Variant of filterIfAny that takes a predicate on the keys
--   rather than on the values.
filterIfAnyByKeys :: (k -> Bool) -> PSQ k a -> PSQ k a
filterKeys :: (k -> Bool) -> PSQ k a -> PSQ k a
firstOnly :: PSQ k a -> PSQ k a
fromList :: [(k, a)] -> PSQ k a
isZeroOrOne :: PSQ k a -> Bool
keys :: PSQ k v -> [k]
map :: (v1 -> v2) -> PSQ k v1 -> PSQ k v2
mapKeys :: (k1 -> k2) -> PSQ k1 v -> PSQ k2 v
mapWithKey :: (k -> a -> b) -> PSQ k a -> PSQ k b
maximumBy :: (k -> Int) -> PSQ k a -> (k, a)
minimumBy :: (a -> Int) -> PSQ k a -> PSQ k a
null :: PSQ k a -> Bool

-- | Sort the list so that values satisfying the predicate are first.
prefer :: (a -> Bool) -> PSQ k a -> PSQ k a

-- | Sort the list so that keys satisfying the predicate are first.
preferByKeys :: (k -> Bool) -> PSQ k a -> PSQ k a
snoc :: PSQ k a -> k -> a -> PSQ k a
sortBy :: (a -> a -> Ordering) -> PSQ k a -> PSQ k a
sortByKeys :: (k -> k -> Ordering) -> PSQ k a -> PSQ k a
toList :: PSQ k a -> [(k, a)]
union :: PSQ k a -> PSQ k a -> PSQ k a
instance (GHC.Classes.Eq k, GHC.Classes.Eq v) => GHC.Classes.Eq (Distribution.Solver.Modular.PSQ.PSQ k v)
instance GHC.Internal.Data.Foldable.Foldable (Distribution.Solver.Modular.PSQ.PSQ k)
instance GHC.Internal.Base.Functor (Distribution.Solver.Modular.PSQ.PSQ k)
instance (GHC.Internal.Show.Show k, GHC.Internal.Show.Show v) => GHC.Internal.Show.Show (Distribution.Solver.Modular.PSQ.PSQ k v)
instance GHC.Internal.Data.Traversable.Traversable (Distribution.Solver.Modular.PSQ.PSQ k)

module Distribution.Solver.Modular.Version

-- | Preliminary type for versions.
type Ver = Version

-- | Version range. Consists of a lower and upper bound.
type VR = VersionRange

-- | Unconstrained version range.
anyVR :: VR

-- | Checking a version against a version range.
checkVR :: VR -> Ver -> Bool

-- | Version range fixing a single version.
eqVR :: Ver -> VR

-- | String representation of a version.
showVer :: Ver -> String

-- | String representation of a version range.
showVR :: VR -> String

-- | Simplify a version range.
simplifyVR :: VR -> VR

-- | Intersect two version ranges.
(.&&.) :: VR -> VR -> VR

-- | Union of two version ranges.
(.||.) :: VR -> VR -> VR

module Distribution.Solver.Modular.WeightedPSQ

-- | An association list that is sorted by weight.
--   
--   Each element has a key (k), value (v), and weight
--   (w). All operations that add elements or modify weights
--   stably sort the elements by weight.
data WeightedPSQ w k v

-- | O(N log N).
fromList :: Ord w => [(w, k, v)] -> WeightedPSQ w k v

-- | O(1). Return the elements in order.
toList :: WeightedPSQ w k v -> [(w, k, v)]

-- | O(N). Return the keys in order.
keys :: WeightedPSQ w k v -> [k]

-- | O(N). Return the weights in order.
weights :: WeightedPSQ w k v -> [w]

-- | O(1). Return True if the WeightedPSQ contains
--   zero or one elements.
isZeroOrOne :: WeightedPSQ w k v -> Bool

-- | O(N).
filter :: (v -> Bool) -> WeightedPSQ k w v -> WeightedPSQ k w v

-- | O(N). Return the value associated with the first occurrence of
--   the give key, if it exists.
lookup :: Eq k => k -> WeightedPSQ w k v -> Maybe v

-- | O(N). Update the values.
mapWithKey :: (k -> v1 -> v2) -> WeightedPSQ w k v1 -> WeightedPSQ w k v2

-- | O(N log N). Update the weights.
mapWeightsWithKey :: Ord w2 => (k -> w1 -> w2) -> WeightedPSQ w1 k v -> WeightedPSQ w2 k v

-- | O(N). Traverse and update values in some applicative functor.
traverseWithKey :: Applicative f => (k -> v -> f v') -> WeightedPSQ w k v -> f (WeightedPSQ w k v')

-- | O((N + M) log (N + M)). Combine two WeightedPSQs,
--   preserving all elements. Elements from the first WeightedPSQ
--   come before elements in the second when they have the same weight.
union :: Ord w => WeightedPSQ w k v -> WeightedPSQ w k v -> WeightedPSQ w k v

-- | O(N). Return the prefix of values ending with the first element
--   that satisfies p, or all elements if none satisfy p.
takeUntil :: forall w k v. (v -> Bool) -> WeightedPSQ w k v -> WeightedPSQ w k v
instance (GHC.Classes.Eq w, GHC.Classes.Eq k, GHC.Classes.Eq v) => GHC.Classes.Eq (Distribution.Solver.Modular.WeightedPSQ.WeightedPSQ w k v)
instance GHC.Internal.Data.Foldable.Foldable (Distribution.Solver.Modular.WeightedPSQ.WeightedPSQ w k)
instance GHC.Internal.Base.Functor (Distribution.Solver.Modular.WeightedPSQ.WeightedPSQ w k)
instance (GHC.Internal.Show.Show w, GHC.Internal.Show.Show k, GHC.Internal.Show.Show v) => GHC.Internal.Show.Show (Distribution.Solver.Modular.WeightedPSQ.WeightedPSQ w k v)
instance GHC.Internal.Data.Traversable.Traversable (Distribution.Solver.Modular.WeightedPSQ.WeightedPSQ w k)

-- | Fine-grained package dependencies
--   
--   Like many others, this module is meant to be "double-imported":
--   
--   
--   import Distribution.Solver.Types.ComponentDeps (
--       Component
--     , ComponentDep
--     , ComponentDeps
--     )
--   import qualified Distribution.Solver.Types.ComponentDeps as CD
--   
module Distribution.Solver.Types.ComponentDeps

-- | Component of a package.
data Component
ComponentLib :: Component
ComponentSubLib :: UnqualComponentName -> Component
ComponentFLib :: UnqualComponentName -> Component
ComponentExe :: UnqualComponentName -> Component
ComponentTest :: UnqualComponentName -> Component
ComponentBench :: UnqualComponentName -> Component
ComponentSetup :: Component
componentNameToComponent :: ComponentName -> Component

-- | Dependency for a single component.
type ComponentDep a = (Component, a)

-- | Fine-grained dependencies for a package.
--   
--   Typically used as ComponentDeps [Dependency], to represent
--   the list of dependencies for each named component within a package.
data ComponentDeps a
empty :: ComponentDeps a
fromList :: Monoid a => [ComponentDep a] -> ComponentDeps a
singleton :: Component -> a -> ComponentDeps a
insert :: Monoid a => Component -> a -> ComponentDeps a -> ComponentDeps a

-- | Zip two ComponentDeps together by Component, using
--   mempty as the neutral element when a Component is
--   present only in one.
zip :: (Monoid a, Monoid b) => ComponentDeps a -> ComponentDeps b -> ComponentDeps (a, b)

-- | Keep only selected components (and their associated deps info).
filterDeps :: (Component -> a -> Bool) -> ComponentDeps a -> ComponentDeps a

-- | Keep only selected components (and their associated deps info).
mapDeps :: (Component -> a -> b) -> ComponentDeps a -> ComponentDeps b

-- | ComponentDeps containing library dependencies only
fromLibraryDeps :: a -> ComponentDeps a

-- | ComponentDeps containing setup dependencies only.
fromSetupDeps :: a -> ComponentDeps a

-- | ComponentDeps for installed packages.
--   
--   We assume that installed packages only record their library
--   dependencies.
fromInstalled :: a -> ComponentDeps a
toList :: ComponentDeps a -> [ComponentDep a]

-- | All dependencies of a package.
--   
--   This is just a synonym for fold, but perhaps a use of
--   flatDeps is more obvious than a use of fold, and
--   moreover this avoids introducing lots of #ifdefs for 7.10
--   just for the use of fold.
flatDeps :: Monoid a => ComponentDeps a -> a

-- | All dependencies except the setup dependencies.
--   
--   Prior to the introduction of setup dependencies in version 1.24 this
--   would have been _all_ dependencies.
nonSetupDeps :: Monoid a => ComponentDeps a -> a

-- | Library dependencies proper only. (Includes dependencies of internal
--   libraries.)
libraryDeps :: Monoid a => ComponentDeps a -> a

-- | Setup dependencies.
setupDeps :: Monoid a => ComponentDeps a -> a

-- | Select dependencies satisfying a given predicate.
select :: Monoid a => (Component -> Bool) -> ComponentDeps a -> a

-- | List components
components :: ComponentDeps a -> Set Component
instance Data.Binary.Class.Binary Distribution.Solver.Types.ComponentDeps.Component
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Distribution.Solver.Types.ComponentDeps.ComponentDeps a)
instance GHC.Classes.Eq Distribution.Solver.Types.ComponentDeps.Component
instance GHC.Classes.Eq a => GHC.Classes.Eq (Distribution.Solver.Types.ComponentDeps.ComponentDeps a)
instance GHC.Internal.Data.Foldable.Foldable Distribution.Solver.Types.ComponentDeps.ComponentDeps
instance GHC.Internal.Base.Functor Distribution.Solver.Types.ComponentDeps.ComponentDeps
instance GHC.Internal.Generics.Generic Distribution.Solver.Types.ComponentDeps.Component
instance GHC.Internal.Generics.Generic (Distribution.Solver.Types.ComponentDeps.ComponentDeps a)
instance GHC.Internal.Base.Semigroup a => GHC.Internal.Base.Monoid (Distribution.Solver.Types.ComponentDeps.ComponentDeps a)
instance GHC.Classes.Ord Distribution.Solver.Types.ComponentDeps.Component
instance GHC.Classes.Ord a => GHC.Classes.Ord (Distribution.Solver.Types.ComponentDeps.ComponentDeps a)
instance Distribution.Pretty.Pretty Distribution.Solver.Types.ComponentDeps.Component
instance GHC.Internal.Base.Semigroup a => GHC.Internal.Base.Semigroup (Distribution.Solver.Types.ComponentDeps.ComponentDeps a)
instance GHC.Internal.Show.Show Distribution.Solver.Types.ComponentDeps.Component
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Distribution.Solver.Types.ComponentDeps.ComponentDeps a)
instance Distribution.Utils.Structured.Structured Distribution.Solver.Types.ComponentDeps.Component
instance Distribution.Utils.Structured.Structured a => Distribution.Utils.Structured.Structured (Distribution.Solver.Types.ComponentDeps.ComponentDeps a)
instance GHC.Internal.Data.Traversable.Traversable Distribution.Solver.Types.ComponentDeps.ComponentDeps

module Distribution.Solver.Types.Flag
data FlagType
Manual :: FlagType
Automatic :: FlagType
instance GHC.Classes.Eq Distribution.Solver.Types.Flag.FlagType
instance GHC.Internal.Show.Show Distribution.Solver.Types.Flag.FlagType

module Distribution.Solver.Types.InstalledPreference

-- | Whether we prefer an installed version of a package or simply the
--   latest version.
data InstalledPreference
PreferInstalled :: InstalledPreference
PreferLatest :: InstalledPreference
PreferOldest :: InstalledPreference
instance GHC.Internal.Show.Show Distribution.Solver.Types.InstalledPreference.InstalledPreference

module Distribution.Solver.Types.OptionalStanza
data OptionalStanza
TestStanzas :: OptionalStanza
BenchStanzas :: OptionalStanza

-- | String representation of an OptionalStanza.
showStanza :: OptionalStanza -> String
showStanzas :: OptionalStanzaSet -> String

-- | Convert a list of OptionalStanza into the corresponding Cabal's
--   ComponentRequestedSpec which records what components are
--   enabled.
enableStanzas :: OptionalStanzaSet -> ComponentRequestedSpec
data OptionalStanzaSet
optStanzaSetFromList :: [OptionalStanza] -> OptionalStanzaSet
optStanzaSetToList :: OptionalStanzaSet -> [OptionalStanza]
optStanzaSetMember :: OptionalStanza -> OptionalStanzaSet -> Bool
optStanzaSetInsert :: OptionalStanza -> OptionalStanzaSet -> OptionalStanzaSet
optStanzaSetSingleton :: OptionalStanza -> OptionalStanzaSet
optStanzaSetIntersection :: OptionalStanzaSet -> OptionalStanzaSet -> OptionalStanzaSet
optStanzaSetNull :: OptionalStanzaSet -> Bool
optStanzaSetIsSubset :: OptionalStanzaSet -> OptionalStanzaSet -> Bool

-- | Note: this is total map.
data OptionalStanzaMap a
optStanzaTabulate :: (OptionalStanza -> a) -> OptionalStanzaMap a
optStanzaIndex :: OptionalStanzaMap a -> OptionalStanza -> a
optStanzaLookup :: OptionalStanza -> OptionalStanzaMap a -> a
optStanzaKeysFilteredByValue :: (a -> Bool) -> OptionalStanzaMap a -> OptionalStanzaSet
instance Data.Binary.Class.Binary Distribution.Solver.Types.OptionalStanza.OptionalStanza
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Distribution.Solver.Types.OptionalStanza.OptionalStanzaMap a)
instance Data.Binary.Class.Binary Distribution.Solver.Types.OptionalStanza.OptionalStanzaSet
instance GHC.Internal.Enum.Bounded Distribution.Solver.Types.OptionalStanza.OptionalStanza
instance GHC.Internal.Enum.Enum Distribution.Solver.Types.OptionalStanza.OptionalStanza
instance GHC.Classes.Eq Distribution.Solver.Types.OptionalStanza.OptionalStanza
instance GHC.Classes.Eq a => GHC.Classes.Eq (Distribution.Solver.Types.OptionalStanza.OptionalStanzaMap a)
instance GHC.Classes.Eq Distribution.Solver.Types.OptionalStanza.OptionalStanzaSet
instance GHC.Internal.Generics.Generic Distribution.Solver.Types.OptionalStanza.OptionalStanza
instance GHC.Internal.Generics.Generic (Distribution.Solver.Types.OptionalStanza.OptionalStanzaMap a)
instance GHC.Internal.Base.Monoid Distribution.Solver.Types.OptionalStanza.OptionalStanzaSet
instance GHC.Classes.Ord Distribution.Solver.Types.OptionalStanza.OptionalStanza
instance GHC.Classes.Ord a => GHC.Classes.Ord (Distribution.Solver.Types.OptionalStanza.OptionalStanzaMap a)
instance GHC.Classes.Ord Distribution.Solver.Types.OptionalStanza.OptionalStanzaSet
instance GHC.Internal.Base.Semigroup Distribution.Solver.Types.OptionalStanza.OptionalStanzaSet
instance GHC.Internal.Show.Show Distribution.Solver.Types.OptionalStanza.OptionalStanza
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Distribution.Solver.Types.OptionalStanza.OptionalStanzaMap a)
instance GHC.Internal.Show.Show Distribution.Solver.Types.OptionalStanza.OptionalStanzaSet
instance Distribution.Utils.Structured.Structured Distribution.Solver.Types.OptionalStanza.OptionalStanza
instance Distribution.Utils.Structured.Structured a => Distribution.Utils.Structured.Structured (Distribution.Solver.Types.OptionalStanza.OptionalStanzaMap a)
instance Distribution.Utils.Structured.Structured Distribution.Solver.Types.OptionalStanza.OptionalStanzaSet

module Distribution.Solver.Types.PackageFixedDeps

-- | 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 -> ComponentDeps [UnitId]
instance Distribution.Solver.Types.PackageFixedDeps.PackageFixedDeps Distribution.Types.InstalledPackageInfo.InstalledPackageInfo

-- | An index of packages.
module Distribution.Solver.Types.PackageIndex

-- | The collection of information about packages from one or more
--   PackageDBs.
--   
--   It can be searched efficiently by package name and version.
data PackageIndex pkg

-- | Build an index out of a bunch of packages.
--   
--   If there are duplicates, later ones mask earlier ones.
fromList :: Package pkg => [pkg] -> PackageIndex pkg

-- | Merge two indexes.
--   
--   Packages from the second mask packages of the same exact name
--   (case-sensitively) from the first.
merge :: Package pkg => PackageIndex pkg -> PackageIndex pkg -> PackageIndex pkg

-- | Override-merge of two indexes.
--   
--   Packages from the second mask packages of the same exact name
--   (case-sensitively) from the first.
override :: Package pkg => PackageIndex pkg -> PackageIndex pkg -> PackageIndex pkg

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

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

-- | Removes a single package from the index.
deletePackageId :: Package pkg => PackageIdentifier -> PackageIndex pkg -> PackageIndex pkg

-- | Removes all packages satisfying this dependency from the index.
deleteDependency :: Package pkg => PackageName -> VersionRange -> PackageIndex pkg -> PackageIndex pkg
elemByPackageId :: Package pkg => PackageIndex pkg -> PackageIdentifier -> Bool
elemByPackageName :: Package pkg => PackageIndex pkg -> PackageName -> Bool

-- | Does a case-sensitive search by package name.
lookupPackageName :: Package pkg => PackageIndex pkg -> PackageName -> [pkg]

-- | Does a lookup by package id (name & version).
--   
--   Since multiple package DBs mask each other case-sensitively by package
--   name, then we get back at most one package.
lookupPackageId :: Package pkg => PackageIndex pkg -> PackageIdentifier -> Maybe pkg

-- | Does a case-sensitive search by 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 :: Package pkg => PackageIndex pkg -> PackageName -> VersionRange -> [pkg]

-- | Does a case-insensitive search by package name.
--   
--   If there is only one package that compares case-insensitively to this
--   name then the search is unambiguous and we get back all versions of
--   that package. If several match case-insensitively but one matches
--   exactly then it is also unambiguous.
--   
--   If however several match case-insensitively 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 pkg -> String -> [(PackageName, [pkg])]
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 pkg -> String -> [(PackageName, [pkg])]
searchWithPredicate :: PackageIndex pkg -> (String -> Bool) -> [(PackageName, [pkg])]

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

-- | Get all the packages from the index.
--   
--   They are grouped by package name, case-sensitively.
allPackagesByName :: PackageIndex pkg -> [[pkg]]
instance Data.Binary.Class.Binary pkg => Data.Binary.Class.Binary (Distribution.Solver.Types.PackageIndex.PackageIndex pkg)
instance GHC.Classes.Eq pkg => GHC.Classes.Eq (Distribution.Solver.Types.PackageIndex.PackageIndex pkg)
instance GHC.Internal.Base.Functor Distribution.Solver.Types.PackageIndex.PackageIndex
instance GHC.Internal.Generics.Generic (Distribution.Solver.Types.PackageIndex.PackageIndex pkg)
instance Distribution.Package.Package pkg => GHC.Internal.Base.Monoid (Distribution.Solver.Types.PackageIndex.PackageIndex pkg)
instance GHC.Internal.Read.Read pkg => GHC.Internal.Read.Read (Distribution.Solver.Types.PackageIndex.PackageIndex pkg)
instance Distribution.Package.Package pkg => GHC.Internal.Base.Semigroup (Distribution.Solver.Types.PackageIndex.PackageIndex pkg)
instance GHC.Internal.Show.Show pkg => GHC.Internal.Show.Show (Distribution.Solver.Types.PackageIndex.PackageIndex pkg)

module Distribution.Solver.Types.PackagePath

-- | A package path consists of a namespace and a package path inside that
--   namespace.
data PackagePath
PackagePath :: Namespace -> Qualifier -> PackagePath

-- | Top-level namespace
--   
--   Package choices in different namespaces are considered completely
--   independent by the solver.
data Namespace

-- | The default namespace
DefaultNamespace :: Namespace

-- | A namespace for a specific build target
Independent :: PackageName -> Namespace

-- | Qualifier of a package within a namespace (see PackagePath)
data Qualifier

-- | Top-level dependency in this namespace
QualToplevel :: Qualifier

-- | Any dependency on base is considered independent
--   
--   This makes it possible to have base shims.
QualBase :: PackageName -> Qualifier

-- | Setup dependency
--   
--   By rights setup dependencies ought to be nestable; after all, the
--   setup dependencies of a package might themselves have setup
--   dependencies, which are independent from everything else. However,
--   this very quickly leads to infinite search trees in the solver.
--   Therefore we limit ourselves to a single qualifier (within a given
--   namespace).
QualSetup :: PackageName -> Qualifier

-- | If we depend on an executable from a package (via
--   build-tools), we should solve for the dependencies of that
--   package separately (since we're not going to actually try to link it.)
--   We qualify for EACH package separately; e.g., Exe pn1
--   pn2 qualifies the build-tools dependency on pn2
--   from package pn1. (If we tracked only pn1, that
--   would require a consistent dependency resolution for all of the
--   depended upon executables from a package; if we tracked only
--   pn2, that would require us to pick only one version of an
--   executable over the entire install plan.)
QualExe :: PackageName -> PackageName -> Qualifier

-- | Pretty-prints a qualifier. The result is either empty or ends in a
--   period, so it can be prepended onto a package name.
--   
--   NOTE: the base qualifier is for a dependency _on_ base; the qualifier
--   is there to make sure different dependencies on base are all
--   independent. So we want to print something like "A.base",
--   where the "A." part is the qualifier and "base" is
--   the actual dependency (which, for the Base qualifier, will
--   always be base).
dispQualifier :: Qualifier -> Doc

-- | A qualified entity. Pairs a package path with the entity.
data Qualified a
Q :: PackagePath -> a -> Qualified a

-- | Qualified package name.
type QPN = Qualified PackageName

-- | Pretty-prints a qualified package name.
dispQPN :: QPN -> Doc

-- | String representation of a qualified package name.
showQPN :: QPN -> String
instance GHC.Classes.Eq Distribution.Solver.Types.PackagePath.Namespace
instance GHC.Classes.Eq Distribution.Solver.Types.PackagePath.PackagePath
instance GHC.Classes.Eq a => GHC.Classes.Eq (Distribution.Solver.Types.PackagePath.Qualified a)
instance GHC.Classes.Eq Distribution.Solver.Types.PackagePath.Qualifier
instance GHC.Classes.Ord Distribution.Solver.Types.PackagePath.Namespace
instance GHC.Classes.Ord Distribution.Solver.Types.PackagePath.PackagePath
instance GHC.Classes.Ord a => GHC.Classes.Ord (Distribution.Solver.Types.PackagePath.Qualified a)
instance GHC.Classes.Ord Distribution.Solver.Types.PackagePath.Qualifier
instance GHC.Internal.Show.Show Distribution.Solver.Types.PackagePath.Namespace
instance GHC.Internal.Show.Show Distribution.Solver.Types.PackagePath.PackagePath
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Distribution.Solver.Types.PackagePath.Qualified a)
instance GHC.Internal.Show.Show Distribution.Solver.Types.PackagePath.Qualifier

-- | Per-package constraints. Package constraints must be respected by the
--   solver. Multiple constraints for each package can be given, though
--   obviously it is possible to construct conflicting constraints (eg
--   impossible version range or inconsistent flag assignment).
module Distribution.Solver.Types.PackageConstraint

-- | Determines to what packages and in what contexts a constraint applies.
data ConstraintScope

-- | A scope that applies when the given package is used as a build target.
--   In other words, the scope applies iff a goal has a top-level qualifier
--   and its namespace matches the given package name. A namespace is
--   considered to match a package name when it is either the default
--   namespace (for --no-independent-goals) or it is an independent
--   namespace with the given package name (for --independent-goals).
ScopeTarget :: PackageName -> ConstraintScope

-- | The package with the specified name and qualifier.
ScopeQualified :: Qualifier -> PackageName -> ConstraintScope

-- | The package with the specified name when it has a setup qualifier.
ScopeAnySetupQualifier :: PackageName -> ConstraintScope

-- | The package with the specified name regardless of qualifier.
ScopeAnyQualifier :: PackageName -> ConstraintScope

-- | Constructor for a common use case: the constraint applies to the
--   package with the specified name when that package is a top-level
--   dependency in the default namespace.
scopeToplevel :: PackageName -> ConstraintScope

-- | Returns the package name associated with a constraint scope.
scopeToPackageName :: ConstraintScope -> PackageName
constraintScopeMatches :: ConstraintScope -> QPN -> Bool

-- | A package property is a logical predicate on packages.
data PackageProperty
PackagePropertyVersion :: VersionRange -> PackageProperty
PackagePropertyInstalled :: PackageProperty
PackagePropertySource :: PackageProperty
PackagePropertyFlags :: FlagAssignment -> PackageProperty
PackagePropertyStanzas :: [OptionalStanza] -> PackageProperty

-- | Pretty-prints a package property.
dispPackageProperty :: PackageProperty -> Doc

-- | A package constraint consists of a scope plus a property that must
--   hold for all packages within that scope.
data PackageConstraint
PackageConstraint :: ConstraintScope -> PackageProperty -> PackageConstraint

-- | Pretty-prints a package constraint.
dispPackageConstraint :: PackageConstraint -> Doc

-- | Alternative textual representation of a package constraint for
--   debugging purposes (slightly more verbose than that produced by
--   dispPackageConstraint).
showPackageConstraint :: PackageConstraint -> String

-- | Lossily convert a PackageConstraint to a Dependency.
packageConstraintToDependency :: PackageConstraint -> Maybe PackageVersionConstraint
instance Data.Binary.Class.Binary Distribution.Solver.Types.PackageConstraint.PackageProperty
instance GHC.Classes.Eq Distribution.Solver.Types.PackageConstraint.ConstraintScope
instance GHC.Classes.Eq Distribution.Solver.Types.PackageConstraint.PackageConstraint
instance GHC.Classes.Eq Distribution.Solver.Types.PackageConstraint.PackageProperty
instance GHC.Internal.Generics.Generic Distribution.Solver.Types.PackageConstraint.PackageProperty
instance GHC.Internal.Show.Show Distribution.Solver.Types.PackageConstraint.ConstraintScope
instance GHC.Internal.Show.Show Distribution.Solver.Types.PackageConstraint.PackageConstraint
instance GHC.Internal.Show.Show Distribution.Solver.Types.PackageConstraint.PackageProperty
instance Distribution.Utils.Structured.Structured Distribution.Solver.Types.PackageConstraint.PackageProperty

module Distribution.Solver.Modular.Package

-- | Instance. A version number and a location.
data I
I :: Ver -> Loc -> I

-- | Location. Info about whether a package is installed or not, and where
--   exactly it is located. For installed packages, uniquely identifies the
--   package instance via its PId.
--   
--   TODO: More information is needed about the repo.
data Loc
Inst :: PId -> Loc
InRepo :: Loc

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

-- | 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

-- | A package name.
--   
--   Use mkPackageName and unPackageName to convert from/to a
--   String.
--   
--   This type is opaque since Cabal-2.0
data PackageName

-- | Construct a PackageName from a String
--   
--   mkPackageName is the inverse to unPackageName
--   
--   Note: No validations are performed to ensure that the resulting
--   PackageName is valid
mkPackageName :: String -> PackageName

-- | Convert PackageName to String
unPackageName :: PackageName -> String

-- | A pkg-config library name
--   
--   This is parsed as any valid argument to the pkg-config utility.
data PkgconfigName

-- | Construct a PkgconfigName from a String
--   
--   mkPkgconfigName is the inverse to unPkgconfigName
--   
--   Note: No validations are performed to ensure that the resulting
--   PkgconfigName is valid
mkPkgconfigName :: String -> PkgconfigName

-- | Convert PkgconfigName to String
unPkgconfigName :: PkgconfigName -> String

-- | Package instance. A package name and an instance.
data PI qpn
PI :: qpn -> I -> PI qpn

-- | A package name.
type PN = PackageName

-- | Qualified package version.
type QPV = Qualified PV
instI :: I -> Bool

-- | Qualify a target package with its own name so that its dependencies
--   are not required to be consistent with other targets.
makeIndependent :: PN -> QPN

-- | Is the package in the primary group of packages. This is used to
--   determine (1) if we should try to establish stanza preferences for
--   this goal, and (2) whether or not a user specified
--   --constraint should apply to this dependency (grep
--   primaryPP to see the use sites). In particular this does not
--   include packages pulled in as setup deps.
primaryPP :: PackagePath -> Bool

-- | Is the package a dependency of a setup script. This is used to
--   establish whether or not certain constraints should apply to this
--   dependency (grep setupPP to see the use sites).
setupPP :: PackagePath -> Bool

-- | String representation of an instance.
showI :: I -> String

-- | String representation of a package instance.
showPI :: PI QPN -> String

-- | Unpacking a package name.
unPN :: PN -> String
instance GHC.Classes.Eq Distribution.Solver.Modular.Package.I
instance GHC.Classes.Eq Distribution.Solver.Modular.Package.Loc
instance GHC.Classes.Eq qpn => GHC.Classes.Eq (Distribution.Solver.Modular.Package.PI qpn)
instance GHC.Internal.Base.Functor Distribution.Solver.Modular.Package.PI
instance GHC.Classes.Ord Distribution.Solver.Modular.Package.I
instance GHC.Classes.Ord Distribution.Solver.Modular.Package.Loc
instance GHC.Classes.Ord qpn => GHC.Classes.Ord (Distribution.Solver.Modular.Package.PI qpn)
instance GHC.Internal.Show.Show Distribution.Solver.Modular.Package.I
instance GHC.Internal.Show.Show Distribution.Solver.Modular.Package.Loc
instance GHC.Internal.Show.Show qpn => GHC.Internal.Show.Show (Distribution.Solver.Modular.Package.PI qpn)

module Distribution.Solver.Modular.Configured

-- | A configured package is a package instance together with a flag
--   assignment and complete dependencies.
data CP qpn
CP :: PI qpn -> FlagAssignment -> OptionalStanzaSet -> ComponentDeps [PI qpn] -> CP qpn

module Distribution.Solver.Modular.Flag

-- | Flag info. Default value, whether the flag is manual, and whether the
--   flag is weak. Manual flags can only be set explicitly. Weak flags are
--   typically deferred by the solver.
data FInfo
FInfo :: Bool -> FlagType -> WeakOrTrivial -> FInfo
[fdefault] :: FInfo -> Bool
[fmanual] :: FInfo -> FlagType
[fweak] :: FInfo -> WeakOrTrivial

-- | Flag identifier. Just a string.
type Flag = FlagName

-- | Flag defaults.
type FlagInfo = Map Flag FInfo

-- | Flag name. Consists of a package instance and the flag identifier
--   itself.
data FN qpn
FN :: qpn -> Flag -> FN qpn

-- | Qualified flag name.
type QFN = FN QPN

-- | Qualified stanza name.
type QSN = SN QPN

-- | Stanza identifier.
type Stanza = OptionalStanza

-- | Stanza name. Paired with a package name, much like a flag.
data SN qpn
SN :: qpn -> Stanza -> SN qpn

-- | A property of flag and stanza choices that determines whether the
--   choice should be deferred in the solving process.
--   
--   A choice is called weak if we do want to defer it. This is the case
--   for flags that should be implied by what's currently installed on the
--   system, as opposed to flags that are used to explicitly enable or
--   disable some functionality.
--   
--   A choice is called trivial if it clearly does not matter. The special
--   case of triviality we actually consider is if there are no new
--   dependencies introduced by the choice.
newtype WeakOrTrivial
WeakOrTrivial :: Bool -> WeakOrTrivial
[unWeakOrTrivial] :: WeakOrTrivial -> Bool

-- | Value shown for a flag in a solver log message. The message can refer
--   to only the true choice, only the false choice, or both choices.
data FlagValue
FlagTrue :: FlagValue
FlagFalse :: FlagValue
FlagBoth :: FlagValue
mkFlag :: String -> Flag
showQFN :: QFN -> String
showQFNBool :: QFN -> Bool -> String

-- | String representation of a flag-value pair.
showFlagValue :: FlagName -> FlagValue -> String
showQSN :: QSN -> String
showQSNBool :: QSN -> Bool -> String
showSBool :: Stanza -> Bool -> String
instance GHC.Classes.Eq Distribution.Solver.Modular.Flag.FInfo
instance GHC.Classes.Eq qpn => GHC.Classes.Eq (Distribution.Solver.Modular.Flag.FN qpn)
instance GHC.Classes.Eq Distribution.Solver.Modular.Flag.FlagValue
instance GHC.Classes.Eq qpn => GHC.Classes.Eq (Distribution.Solver.Modular.Flag.SN qpn)
instance GHC.Classes.Eq Distribution.Solver.Modular.Flag.WeakOrTrivial
instance GHC.Internal.Base.Functor Distribution.Solver.Modular.Flag.FN
instance GHC.Internal.Base.Functor Distribution.Solver.Modular.Flag.SN
instance GHC.Classes.Ord qpn => GHC.Classes.Ord (Distribution.Solver.Modular.Flag.FN qpn)
instance GHC.Classes.Ord qpn => GHC.Classes.Ord (Distribution.Solver.Modular.Flag.SN qpn)
instance GHC.Classes.Ord Distribution.Solver.Modular.Flag.WeakOrTrivial
instance GHC.Internal.Show.Show Distribution.Solver.Modular.Flag.FInfo
instance GHC.Internal.Show.Show qpn => GHC.Internal.Show.Show (Distribution.Solver.Modular.Flag.FN qpn)
instance GHC.Internal.Show.Show Distribution.Solver.Modular.Flag.FlagValue
instance GHC.Internal.Show.Show qpn => GHC.Internal.Show.Show (Distribution.Solver.Modular.Flag.SN qpn)
instance GHC.Internal.Show.Show Distribution.Solver.Modular.Flag.WeakOrTrivial

module Distribution.Solver.Modular.Var

-- | The type of variables that play a role in the solver. Note that the
--   tree currently does not use this type directly, and rather has
--   separate tree nodes for the different types of variables. This fits
--   better with the fact that in most cases, these have to be treated
--   differently.
data Var qpn
P :: qpn -> Var qpn
F :: FN qpn -> Var qpn
S :: SN qpn -> Var qpn
showVar :: Var QPN -> String

-- | Extract the package name from a Var
varPN :: Var qpn -> qpn
instance GHC.Classes.Eq qpn => GHC.Classes.Eq (Distribution.Solver.Modular.Var.Var qpn)
instance GHC.Internal.Base.Functor Distribution.Solver.Modular.Var.Var
instance GHC.Classes.Ord qpn => GHC.Classes.Ord (Distribution.Solver.Modular.Var.Var qpn)
instance GHC.Internal.Show.Show qpn => GHC.Internal.Show.Show (Distribution.Solver.Modular.Var.Var qpn)

-- | Conflict sets
--   
--   Intended for double import
--   
--   
--   import Distribution.Solver.Modular.ConflictSet (ConflictSet)
--   import qualified Distribution.Solver.Modular.ConflictSet as CS
--   
module Distribution.Solver.Modular.ConflictSet

-- | The set of variables involved in a solver conflict, each paired with
--   details about the conflict.
data ConflictSet

-- | More detailed information about how a conflict set variable caused a
--   conflict. This information can be used to determine whether a second
--   value for that variable would lead to the same conflict.
--   
--   TODO: Handle dependencies under flags or stanzas.
data Conflict

-- | The conflict set variable represents a package which depends on the
--   specified problematic package. For example, the conflict set entry '(P
--   x, GoalConflict y)' means that package x introduced package y, and y
--   led to a conflict.
GoalConflict :: QPN -> Conflict

-- | The conflict set variable represents a package with a constraint that
--   excluded the specified package and version. For example, the conflict
--   set entry '(P x, VersionConstraintConflict y (mkVersion [2, 0]))'
--   means that package x's constraint on y excluded y-2.0.
VersionConstraintConflict :: QPN -> Ver -> Conflict

-- | The conflict set variable represents a package that was excluded by a
--   constraint from the specified package. For example, the conflict set
--   entry '(P x, VersionConflict y (orLaterVersion (mkVersion [2, 0])))'
--   means that package y's constraint 'x >= 2.0' excluded some version
--   of x.
VersionConflict :: QPN -> OrderedVersionRange -> Conflict

-- | Any other conflict.
OtherConflict :: Conflict
type ConflictMap = Map Var QPN Int

-- | Version range with an Ord instance.
newtype OrderedVersionRange
OrderedVersionRange :: VR -> OrderedVersionRange
showConflictSet :: ConflictSet -> String
showCSSortedByFrequency :: ConflictMap -> ConflictSet -> String
showCSWithFrequency :: ConflictMap -> ConflictSet -> String
toSet :: ConflictSet -> Set (Var QPN)
toList :: ConflictSet -> [Var QPN]
union :: ConflictSet -> ConflictSet -> ConflictSet
unions :: [ConflictSet] -> ConflictSet
insert :: Var QPN -> ConflictSet -> ConflictSet
delete :: Var QPN -> ConflictSet -> ConflictSet
empty :: ConflictSet
singleton :: Var QPN -> ConflictSet
singletonWithConflict :: Var QPN -> Conflict -> ConflictSet
size :: ConflictSet -> Int
member :: Var QPN -> ConflictSet -> Bool
lookup :: Var QPN -> ConflictSet -> Maybe (Set Conflict)

-- | <math>. filter, applied to a predicate and a list,
--   returns the list of those elements that satisfy the predicate; i.e.,
--   
--   
--   filter p xs = [ x | x <- xs, p x]
--   
--   
--   
Examples
--   
--   
--   >>> filter odd [1, 2, 3]
--   [1,3]
--   
--   
--   
--   >>> filter (\l -> length l > 3) ["Hello", ", ", "World", "!"]
--   ["Hello","World"]
--   
--   
--   
--   >>> filter (/= 3) [1, 2, 3, 4, 3, 2, 1]
--   [1,2,4,2,1]
--   
filter :: (a -> Bool) -> [a] -> [a]
fromList :: [Var QPN] -> ConflictSet
instance GHC.Classes.Eq Distribution.Solver.Modular.ConflictSet.Conflict
instance GHC.Classes.Eq Distribution.Solver.Modular.ConflictSet.ConflictSet
instance GHC.Classes.Eq Distribution.Solver.Modular.ConflictSet.OrderedVersionRange
instance GHC.Classes.Ord Distribution.Solver.Modular.ConflictSet.Conflict
instance GHC.Classes.Ord Distribution.Solver.Modular.ConflictSet.OrderedVersionRange
instance GHC.Internal.Show.Show Distribution.Solver.Modular.ConflictSet.Conflict
instance GHC.Internal.Show.Show Distribution.Solver.Modular.ConflictSet.ConflictSet
instance GHC.Internal.Show.Show Distribution.Solver.Modular.ConflictSet.OrderedVersionRange

module Distribution.Solver.Modular.Dependency

-- | The type of variables that play a role in the solver. Note that the
--   tree currently does not use this type directly, and rather has
--   separate tree nodes for the different types of variables. This fits
--   better with the fact that in most cases, these have to be treated
--   differently.
data Var qpn
P :: qpn -> Var qpn
F :: FN qpn -> Var qpn
S :: SN qpn -> Var qpn
showVar :: Var QPN -> String

-- | Extract the package name from a Var
varPN :: Var qpn -> qpn

-- | The set of variables involved in a solver conflict, each paired with
--   details about the conflict.
data ConflictSet
type ConflictMap = Map Var QPN Int
showConflictSet :: ConflictSet -> String

-- | Constrained instance. It represents the allowed instances for a
--   package, which can be either a fixed instance or a version range.
data CI
Fixed :: I -> CI
Constrained :: VR -> CI

-- | Flagged dependencies
--   
--   FlaggedDeps is the modular solver's view of a packages
--   dependencies: rather than having the dependencies indexed by
--   component, each dependency defines what component it is in.
--   
--   Note that each dependency is associated with a Component. We must know
--   what component the dependencies belong to, or else we won't be able to
--   construct fine-grained reverse dependencies.
type FlaggedDeps qpn = [FlaggedDep qpn]

-- | Flagged dependencies can either be plain dependency constraints, or
--   flag-dependent dependency trees.
data FlaggedDep qpn

-- | Dependencies which are conditional on a flag choice.
Flagged :: FN qpn -> FInfo -> TrueFlaggedDeps qpn -> FalseFlaggedDeps qpn -> FlaggedDep qpn

-- | Dependencies which are conditional on whether or not a stanza (e.g., a
--   test suite or benchmark) is enabled.
Stanza :: SN qpn -> TrueFlaggedDeps qpn -> FlaggedDep qpn

-- | Dependencies which are always enabled, for the component
--   comp.
Simple :: LDep qpn -> Component -> FlaggedDep qpn

-- | A Dep labeled with the reason it was introduced.
--   
--   LDep intentionally has no Functor instance because the
--   type variable is used both to record the dependencies as well as who's
--   doing the depending; having a Functor instance makes bugs where
--   we don't distinguish these two far too likely. (By rights LDep
--   ought to have two type variables.)
data LDep qpn
LDep :: DependencyReason qpn -> Dep qpn -> LDep qpn

-- | A dependency (constraint) associates a package name with a constrained
--   instance. It can also represent other types of dependencies, such as
--   dependencies on language extensions.
data Dep qpn

-- | dependency on a package component
Dep :: PkgComponent qpn -> CI -> Dep qpn

-- | dependency on a language extension
Ext :: Extension -> Dep qpn

-- | dependency on a language version
Lang :: Language -> Dep qpn

-- | dependency on a pkg-config package
Pkg :: PkgconfigName -> PkgconfigVersionRange -> Dep qpn

-- | An exposed component within a package. This type is used to represent
--   build-depends and build-tool-depends dependencies.
data PkgComponent qpn
PkgComponent :: qpn -> ExposedComponent -> PkgComponent qpn

-- | A component that can be depended upon by another package, i.e., a
--   library or an executable.
data ExposedComponent
ExposedLib :: LibraryName -> ExposedComponent
ExposedExe :: UnqualComponentName -> ExposedComponent

-- | The reason that a dependency is active. It identifies the package and
--   any flag and stanza choices that introduced the dependency. It
--   contains everything needed for creating ConflictSets or describing
--   conflicts in solver log messages.
data DependencyReason qpn
DependencyReason :: qpn -> Map Flag FlagValue -> Set Stanza -> DependencyReason qpn

-- | Print the reason that a dependency was introduced.
showDependencyReason :: DependencyReason QPN -> String

-- | Conservatively flatten out flagged dependencies
--   
--   NOTE: We do not filter out duplicates.
flattenFlaggedDeps :: FlaggedDeps qpn -> [(LDep qpn, Component)]

-- | Options for goal qualification (used in qualifyDeps)
--   
--   See also defaultQualifyOptions
data QualifyOptions
QO :: Bool -> Bool -> QualifyOptions

-- | Do we have a version of base relying on another version of base?
[qoBaseShim] :: QualifyOptions -> Bool
[qoSetupIndependent] :: QualifyOptions -> Bool

-- | Apply built-in rules for package qualifiers
--   
--   Although the behaviour of qualifyDeps depends on the
--   QualifyOptions, it is important that these
--   QualifyOptions are _static_. Qualification does NOT depend on
--   flag assignment; in other words, it behaves the same no matter which
--   choices the solver makes (modulo the global QualifyOptions); we
--   rely on this in linkDeps (see comment there).
--   
--   NOTE: It's the _dependencies_ of a package that may or may not be
--   independent from the package itself. Package flag choices must of
--   course be consistent.
qualifyDeps :: QualifyOptions -> QPN -> FlaggedDeps PN -> FlaggedDeps QPN

-- | Remove qualifiers from set of dependencies
--   
--   This is used during link validation: when we link package Q.A
--   to Q'.A, then all dependencies Q.B need to be linked
--   to Q'.B. In order to compute what to link these dependencies
--   to, we need to requalify Q.B to become Q'.B; we do
--   this by first removing all qualifiers and then calling
--   qualifyDeps again.
unqualifyDeps :: FlaggedDeps QPN -> FlaggedDeps PN

-- | A map containing reverse dependencies between qualified package names.
type RevDepMap = Map QPN [(Component, QPN)]

-- | A goal is just a solver variable paired with a reason. The reason is
--   only used for tracing.
data Goal qpn
Goal :: Var qpn -> GoalReason qpn -> Goal qpn

-- | Reason why a goal is being added to a goal set.
data GoalReason qpn
UserGoal :: GoalReason qpn
DependencyGoal :: DependencyReason qpn -> GoalReason qpn
type QGoalReason = GoalReason QPN
goalToVar :: Goal a -> Var a

-- | Compute a singleton conflict set from a Var
varToConflictSet :: Var QPN -> ConflictSet

-- | Convert a GoalReason to a ConflictSet that can be used
--   when the goal leads to a conflict.
goalReasonToConflictSet :: GoalReason QPN -> ConflictSet

-- | Convert a GoalReason to a ConflictSet containing the
--   reason that the conflict occurred, namely the conflict set variables
--   caused a conflict by introducing the given package goal. See the
--   documentation for GoalConflict.
--   
--   This function currently only specifies the reason for the conflict in
--   the simple case where the GoalReason does not involve any flags
--   or stanzas. Otherwise, it falls back to calling
--   goalReasonToConflictSet.
goalReasonToConflictSetWithConflict :: QPN -> GoalReason QPN -> ConflictSet

-- | This function returns the solver variables responsible for the
--   dependency. It drops the values chosen for flag and stanza variables,
--   which are only needed for log messages.
dependencyReasonToConflictSet :: DependencyReason QPN -> ConflictSet

-- | Convert a DependencyReason to a ConflictSet specifying
--   that the conflict occurred because the conflict set variables
--   introduced a problematic version constraint. See the documentation for
--   VersionConstraintConflict.
--   
--   This function currently only specifies the reason for the conflict in
--   the simple case where the DependencyReason does not involve any
--   flags or stanzas. Otherwise, it falls back to calling
--   dependencyReasonToConflictSet.
dependencyReasonToConflictSetWithVersionConstraintConflict :: QPN -> Ver -> DependencyReason QPN -> ConflictSet

-- | Convert a DependencyReason to a ConflictSet specifying
--   that the conflict occurred because the conflict set variables
--   introduced a version of a package that was excluded by a version
--   constraint. See the documentation for VersionConflict.
--   
--   This function currently only specifies the reason for the conflict in
--   the simple case where the DependencyReason does not involve any
--   flags or stanzas. Otherwise, it falls back to calling
--   dependencyReasonToConflictSet.
dependencyReasonToConflictSetWithVersionConflict :: QPN -> OrderedVersionRange -> DependencyReason QPN -> ConflictSet
instance GHC.Classes.Eq Distribution.Solver.Modular.Dependency.CI
instance GHC.Classes.Eq qpn => GHC.Classes.Eq (Distribution.Solver.Modular.Dependency.DependencyReason qpn)
instance GHC.Classes.Eq Distribution.Solver.Modular.Dependency.ExposedComponent
instance GHC.Classes.Eq qpn => GHC.Classes.Eq (Distribution.Solver.Modular.Dependency.Goal qpn)
instance GHC.Classes.Eq qpn => GHC.Classes.Eq (Distribution.Solver.Modular.Dependency.GoalReason qpn)
instance GHC.Classes.Eq qpn => GHC.Classes.Eq (Distribution.Solver.Modular.Dependency.PkgComponent qpn)
instance GHC.Internal.Base.Functor Distribution.Solver.Modular.Dependency.Dep
instance GHC.Internal.Base.Functor Distribution.Solver.Modular.Dependency.DependencyReason
instance GHC.Internal.Base.Functor Distribution.Solver.Modular.Dependency.Goal
instance GHC.Internal.Base.Functor Distribution.Solver.Modular.Dependency.GoalReason
instance GHC.Internal.Base.Functor Distribution.Solver.Modular.Dependency.PkgComponent
instance GHC.Classes.Ord Distribution.Solver.Modular.Dependency.ExposedComponent
instance GHC.Classes.Ord qpn => GHC.Classes.Ord (Distribution.Solver.Modular.Dependency.PkgComponent qpn)
instance GHC.Internal.Show.Show Distribution.Solver.Modular.Dependency.CI
instance GHC.Internal.Show.Show qpn => GHC.Internal.Show.Show (Distribution.Solver.Modular.Dependency.DependencyReason qpn)
instance GHC.Internal.Show.Show Distribution.Solver.Modular.Dependency.ExposedComponent
instance GHC.Internal.Show.Show qpn => GHC.Internal.Show.Show (Distribution.Solver.Modular.Dependency.Goal qpn)
instance GHC.Internal.Show.Show qpn => GHC.Internal.Show.Show (Distribution.Solver.Modular.Dependency.GoalReason qpn)
instance GHC.Internal.Show.Show qpn => GHC.Internal.Show.Show (Distribution.Solver.Modular.Dependency.PkgComponent qpn)
instance GHC.Internal.Show.Show Distribution.Solver.Modular.Dependency.QualifyOptions

module Distribution.Solver.Modular.Assignment

-- | A (partial) assignment of variables.
data Assignment
A :: PAssignment -> FAssignment -> SAssignment -> Assignment

-- | A (partial) package assignment. Qualified package names are associated
--   with instances.
type PAssignment = Map QPN I
type FAssignment = Map QFN Bool
type SAssignment = Map QSN Bool

-- | Delivers an ordered list of fully configured packages.
--   
--   TODO: This function is (sort of) ok. However, there's an open bug
--   w.r.t. unqualification. There might be several different instances of
--   one package version chosen by the solver, which will lead to clashes.
toCPs :: Assignment -> RevDepMap -> [CP QPN]
instance GHC.Classes.Eq Distribution.Solver.Modular.Assignment.Assignment
instance GHC.Internal.Show.Show Distribution.Solver.Modular.Assignment.Assignment

module Distribution.Solver.Types.PackagePreferences

-- | Per-package preferences on the version. It is a soft constraint that
--   the DependencyResolver should try to respect where possible.
--   It consists of an InstalledPreference which says if we prefer
--   versions of packages that are already installed. It also has (possibly
--   multiple) PackageVersionPreferences which are suggested
--   constraints on the version number. The resolver should try to use
--   package versions that satisfy the maximum number of the suggested
--   version constraints.
--   
--   It is not specified if preferences on some packages are more important
--   than others.
data PackagePreferences
PackagePreferences :: [VersionRange] -> InstalledPreference -> [OptionalStanza] -> PackagePreferences

-- | Read the list of packages available to pkg-config.
module Distribution.Solver.Types.PkgConfigDb

-- | The list of packages installed in the system visible to
--   pkg-config. This is an opaque datatype, to be constructed
--   with readPkgConfigDb and queried with
--   pkgConfigPkgPresent.
data PkgConfigDb

-- | If an entry is Nothing, this means that the package seems to be
--   present, but we don't know the exact version (because parsing of the
--   version number failed).
PkgConfigDb :: Map PkgconfigName (Maybe PkgconfigVersion) -> PkgConfigDb

-- | For when we could not run pkg-config successfully.
NoPkgConfigDb :: PkgConfigDb

-- | Query pkg-config for the list of installed packages, together with
--   their versions. Return a PkgConfigDb encapsulating this
--   information.
readPkgConfigDb :: Verbosity -> ProgramDb -> IO PkgConfigDb

-- | Create a PkgConfigDb from a list of (packageName,
--   version) pairs.
pkgConfigDbFromList :: [(String, String)] -> PkgConfigDb

-- | Check whether a given package range is satisfiable in the given
--   pkg-config database.
pkgConfigPkgIsPresent :: PkgConfigDb -> PkgconfigName -> PkgconfigVersionRange -> Bool

-- | Query the version of a package in the pkg-config database.
--   Nothing indicates the package is not in the database, while
--   Just Nothing indicates that the package is in the database,
--   but its version is not known.
pkgConfigDbPkgVersion :: PkgConfigDb -> PkgconfigName -> Maybe (Maybe PkgconfigVersion)

-- | Query pkg-config for the locations of pkg-config's package files. Use
--   this to monitor for changes in the pkg-config DB.
getPkgConfigDbDirs :: Verbosity -> ProgramDb -> IO [FilePath]
instance Data.Binary.Class.Binary Distribution.Solver.Types.PkgConfigDb.PkgConfigDb
instance GHC.Internal.Generics.Generic Distribution.Solver.Types.PkgConfigDb.PkgConfigDb
instance GHC.Internal.Show.Show Distribution.Solver.Types.PkgConfigDb.PkgConfigDb
instance Distribution.Utils.Structured.Structured Distribution.Solver.Types.PkgConfigDb.PkgConfigDb

module Distribution.Solver.Types.Progress

-- | A type to represent the unfolding of an expensive long running
--   calculation that may fail. We may get intermediate steps before the
--   final result which may be used to indicate progress and/or logging
--   messages.
data Progress step fail done
Step :: step -> Progress step fail done -> Progress step fail done
Fail :: fail -> Progress step fail done
Done :: done -> Progress step fail done

-- | Consume a Progress calculation. Much like foldr for
--   lists but with two base cases, one for a final result and one for
--   failure.
--   
--   Eg to convert into a simple Either result use:
--   
--   
--   foldProgress (flip const) Left Right
--   
foldProgress :: (step -> a -> a) -> (fail -> a) -> (done -> a) -> Progress step fail done -> a
instance GHC.Internal.Base.Monoid fail => GHC.Internal.Base.Alternative (Distribution.Solver.Types.Progress.Progress step fail)
instance GHC.Internal.Base.Applicative (Distribution.Solver.Types.Progress.Progress step fail)
instance GHC.Internal.Base.Functor (Distribution.Solver.Types.Progress.Progress step fail)
instance GHC.Internal.Base.Monad (Distribution.Solver.Types.Progress.Progress step fail)

module Distribution.Solver.Types.ProjectConfigPath

-- | Path to a configuration file, either a singleton project root, or a
--   longer list representing a path to an import. The path is a non-empty
--   list that we build up by prepending relative imports with
--   consProjectConfigPath.
--   
--   An import can be a URI, such as a stackage cabal.config, but we
--   do not support URIs in the middle of the path, URIs that import other
--   URIs, or URIs that import local files.
--   
--   List elements are relative to each other but once canonicalized,
--   elements are relative to the directory of the project root.
newtype ProjectConfigPath
ProjectConfigPath :: NonEmpty FilePath -> ProjectConfigPath

-- | The root of the path, the project itself.
projectConfigPathRoot :: ProjectConfigPath -> FilePath

-- | Used by some tests as a dummy "unused" project root.
nullProjectConfigPath :: ProjectConfigPath

-- | Prepends the path of the importee to the importer path.
consProjectConfigPath :: FilePath -> ProjectConfigPath -> ProjectConfigPath

-- | Renders the path like this;  D.config imported by: C.config
--   imported by: B.config imported by: A.project  >>> render
--   . docProjectConfigPath $ ProjectConfigPath $ "D.config" :|
--   ["C.config", "B.config", "A.project"] "D.confign imported by:
--   C.confign imported by: B.confign imported by: A.project"
docProjectConfigPath :: ProjectConfigPath -> Doc

-- | Renders the paths as a list without showing which path imports
--   another, like this;  - cabal.project -
--   project-cabal/constraints.config - project-cabal/ghc-latest.config -
--   project-cabal/ghc-options.config - project-cabal/pkgs.config -
--   project-cabalpkgsbenchmarks.config -
--   project-cabalpkgsbuildinfo.config -
--   project-cabalpkgscabal.config -
--   project-cabalpkgsinstall.config -
--   project-cabalpkgsintegration-tests.config -
--   project-cabalpkgstests.config 
--   
--   
--   >>> :{
--     do
--       let ps =
--                [ ProjectConfigPath ("cabal.project" :| [])
--                , ProjectConfigPath ("project-cabal/constraints.config" :| ["cabal.project"])
--                , ProjectConfigPath ("project-cabal/ghc-latest.config" :| ["cabal.project"])
--                , ProjectConfigPath ("project-cabal/ghc-options.config" :| ["cabal.project"])
--                , ProjectConfigPath ("project-cabal/pkgs.config" :| ["cabal.project"])
--                , ProjectConfigPath ("project-cabal/pkgs/benchmarks.config" :| ["project-cabal/pkgs.config","cabal.project"])
--                , ProjectConfigPath ("project-cabal/pkgs/buildinfo.config" :| ["project-cabal/pkgs.config","cabal.project"])
--                , ProjectConfigPath ("project-cabal/pkgs/cabal.config" :| ["project-cabal/pkgs.config","cabal.project"])
--                , ProjectConfigPath ("project-cabal/pkgs/install.config" :| ["project-cabal/pkgs.config","cabal.project"])
--                , ProjectConfigPath ("project-cabal/pkgs/integration-tests.config" :| ["project-cabal/pkgs.config","cabal.project"])
--                , ProjectConfigPath ("project-cabal/pkgs/tests.config" :| ["project-cabal/pkgs.config","cabal.project"])
--                ]
--       return . render $ docProjectConfigPaths ps
--   :}
--   "- cabal.project\n- project-cabal/constraints.config\n- project-cabal/ghc-latest.config\n- project-cabal/ghc-options.config\n- project-cabal/pkgs.config\n- project-cabal/pkgs/benchmarks.config\n- project-cabal/pkgs/buildinfo.config\n- project-cabal/pkgs/cabal.config\n- project-cabal/pkgs/install.config\n- project-cabal/pkgs/integration-tests.config\n- project-cabal/pkgs/tests.config"
--   
docProjectConfigPaths :: [ProjectConfigPath] -> Doc

-- | A message for a cyclical import, assuming the head of the path is the
--   duplicate.
cyclicalImportMsg :: ProjectConfigPath -> Doc
docProjectConfigPathFailReason :: VR -> ProjectConfigPath -> Doc

-- | Check if the path has duplicates. A cycle of imports is not allowed.
--   This check should only be done after the path has been canonicalized
--   with canonicalizeConfigPath. This is because the import path
--   may contain paths that are the same in relation to their importers but
--   different in relation to the project root directory.
isCyclicConfigPath :: ProjectConfigPath -> Bool

-- | Normalizes and canonicalizes a path removing . and '..'
--   indirections. Makes the path relative to the given directory
--   (typically the project root) instead of relative to the file it was
--   imported from.
--   
--   It converts paths like this:  └─ hops-0.project └─
--   hops/hops-1.config └─ ../hops-2.config └─ hops/hops-3.config └─
--   ../hops-4.config └─ hops/hops-5.config └─ ../hops-6.config └─
--   hops/hops-7.config └─ ../hops-8.config └─ hops/hops-9.config 
--   
--   Into paths like this:  └─ hops-0.project └─ hops/hops-1.config └─
--   hops-2.config └─ hops/hops-3.config └─ hops-4.config └─
--   hops/hops-5.config └─ hops-6.config └─ hops/hops-7.config └─
--   hops-8.config └─ hops/hops-9.config 
--   
--   That way we have hops-8.config instead of
--   .hops..hops..hops..hops../hops-8.config.
--   
--   Let's see how canonicalizePath works that is used in the
--   implementation then we'll see how canonicalizeConfigPath
--   works.
--   
--   
--   >>> let d = testDir
--   
--   >>> makeRelative d <$> canonicalizePath (d </> "hops/../hops/../hops/../hops/../hops-8.config")
--   "hops-8.config"
--   
--   
--   
--   >>> let d = testDir
--   
--   >>> p <- canonicalizeConfigPath d (ProjectConfigPath $ (d </> "hops/../hops/../hops/../hops/../hops-8.config") :| [])
--   
--   >>> render $ docProjectConfigPath p
--   "hops-8.config"
--   
--   
--   
--   >>> :{
--     do
--       let expected = unlines
--             [ "hops/hops-9.config"
--             , "  imported by: hops-8.config"
--             , "  imported by: hops/hops-7.config"
--             , "  imported by: hops-6.config"
--             , "  imported by: hops/hops-5.config"
--             , "  imported by: hops-4.config"
--             , "  imported by: hops/hops-3.config"
--             , "  imported by: hops-2.config"
--             , "  imported by: hops/hops-1.config"
--             , "  imported by: hops-0.project"
--             ]
--       let d = testDir
--       let configPath = ProjectConfigPath ("hops/hops-9.config" :|
--             [ "../hops-8.config"
--             , "hops/hops-7.config"
--             , "../hops-6.config"
--             , "hops/hops-5.config"
--             , "../hops-4.config"
--             , "hops/hops-3.config"
--             , "../hops-2.config"
--             , "hops/hops-1.config"
--             , d </> "hops-0.project"])
--       p <- canonicalizeConfigPath d configPath
--       return $ expected == render (docProjectConfigPath p) ++ "\n"
--   :}
--   True
--   
canonicalizeConfigPath :: FilePath -> ProjectConfigPath -> IO ProjectConfigPath
instance Data.Binary.Class.Binary Distribution.Solver.Types.ProjectConfigPath.ProjectConfigPath
instance GHC.Classes.Eq Distribution.Solver.Types.ProjectConfigPath.ProjectConfigPath
instance GHC.Internal.Generics.Generic Distribution.Solver.Types.ProjectConfigPath.ProjectConfigPath
instance GHC.Classes.Ord Distribution.Solver.Types.ProjectConfigPath.ProjectConfigPath
instance GHC.Internal.Show.Show Distribution.Solver.Types.ProjectConfigPath.ProjectConfigPath
instance Distribution.Utils.Structured.Structured Distribution.Solver.Types.ProjectConfigPath.ProjectConfigPath

module Distribution.Solver.Types.ConstraintSource

-- | Source of a PackageConstraint.
data ConstraintSource

-- | Main config file, which is ~.cabalconfig by default.
ConstraintSourceMainConfig :: FilePath -> ConstraintSource

-- | Local cabal.project file
ConstraintSourceProjectConfig :: ProjectConfigPath -> ConstraintSource

-- | User config file, which is ./cabal.config by default.
ConstraintSourceUserConfig :: FilePath -> ConstraintSource

-- | Flag specified on the command line.
ConstraintSourceCommandlineFlag :: ConstraintSource

-- | Target specified by the user, e.g., cabal install
--   package-0.1.0.0 implies package==0.1.0.0.
ConstraintSourceUserTarget :: ConstraintSource

-- | Internal requirement to use installed versions of packages like
--   ghc-prim.
ConstraintSourceNonReinstallablePackage :: ConstraintSource

-- | Internal constraint used by cabal freeze.
ConstraintSourceFreeze :: ConstraintSource

-- | Constraint specified by a config file, a command line flag, or a user
--   target, when a more specific source is not known.
ConstraintSourceConfigFlagOrTarget :: ConstraintSource

-- | Constraint introduced by --enable-multi-repl, which requires features
--   from Cabal >= 3.11
ConstraintSourceMultiRepl :: ConstraintSource

-- | The source of the constraint is not specified.
ConstraintSourceUnknown :: ConstraintSource

-- | An internal constraint due to compatibility issues with the Setup.hs
--   command line interface requires a minimum lower bound on Cabal
ConstraintSetupCabalMinVersion :: ConstraintSource

-- | An internal constraint due to compatibility issues with the Setup.hs
--   command line interface requires a maximum upper bound on Cabal
ConstraintSetupCabalMaxVersion :: ConstraintSource

-- | Description of a ConstraintSource.
showConstraintSource :: ConstraintSource -> String
instance Data.Binary.Class.Binary Distribution.Solver.Types.ConstraintSource.ConstraintSource
instance GHC.Classes.Eq Distribution.Solver.Types.ConstraintSource.ConstraintSource
instance GHC.Internal.Generics.Generic Distribution.Solver.Types.ConstraintSource.ConstraintSource
instance GHC.Internal.Show.Show Distribution.Solver.Types.ConstraintSource.ConstraintSource
instance Distribution.Utils.Structured.Structured Distribution.Solver.Types.ConstraintSource.ConstraintSource

module Distribution.Solver.Types.LabeledPackageConstraint

-- | PackageConstraint labeled with its source.
data LabeledPackageConstraint
LabeledPackageConstraint :: PackageConstraint -> ConstraintSource -> LabeledPackageConstraint
unlabelPackageConstraint :: LabeledPackageConstraint -> PackageConstraint

module Distribution.Solver.Modular.Tree

-- | A package option is a package instance with an optional linking
--   annotation
--   
--   The modular solver has a number of package goals to solve for, and can
--   only pick a single package version for a single goal. In order to
--   allow to install multiple versions of the same package as part of a
--   single solution the solver uses qualified goals. For example,
--   0.P and 1.P might both be qualified goals for
--   P, allowing to pick a difference version of package
--   P for 0.P and 1.P.
--   
--   Linking is an essential part of this story. In addition to picking a
--   specific version for 1.P, the solver can also decide to link
--   1.P to 0.P (or vice versa). It means that
--   1.P and 0.P really must be the very same package
--   (and hence must have the same build time configuration, and their
--   dependencies must also be the exact same).
--   
--   See http://www.well-typed.com/blog/2015/03/qualified-goals/ for
--   details.
data POption
POption :: I -> Maybe PackagePath -> POption

-- | Type of the search tree. Inlining the choice nodes for now. Weights on
--   package, flag, and stanza choices control the traversal order.
--   
--   The tree can hold additional data on Done nodes (type
--   d) and choice nodes (type c). For example, during
--   the final traversal, choice nodes contain the variables that
--   introduced the choices, and Done nodes contain the assignments
--   for all variables.
--   
--   TODO: The weight type should be changed from [Double] to Double to
--   avoid giving too much weight to preferences that are applied later.
data Tree d c

-- | Choose a version for a package (or choose to link)
PChoice :: QPN -> RevDepMap -> c -> WeightedPSQ [Weight] POption (Tree d c) -> Tree d c

-- | Choose a value for a flag
--   
--   The Bool is the default value.
FChoice :: QFN -> RevDepMap -> c -> WeakOrTrivial -> FlagType -> Bool -> WeightedPSQ [Weight] Bool (Tree d c) -> Tree d c

-- | Choose whether or not to enable a stanza
SChoice :: QSN -> RevDepMap -> c -> WeakOrTrivial -> WeightedPSQ [Weight] Bool (Tree d c) -> Tree d c

-- | Choose which choice to make next
--   
--   Invariants:
--   
--   
--   
- PSQ should never be empty
--   
- For each choice we additionally record the QGoalReason why
--   we are introducing that goal into tree. Note that most of the time we
--   are working with Tree QGoalReason; in that case, we must have
--   the invariant that the QGoalReason cached in the
--   PChoice, FChoice or SChoice directly below a
--   GoalChoice node must equal the reason recorded on that
--   GoalChoice node.
--   
GoalChoice :: RevDepMap -> PSQ (Goal QPN) (Tree d c) -> Tree d c

-- | We're done -- we found a solution!
Done :: RevDepMap -> d -> Tree d c

-- | We failed to find a solution in this path through the tree
Fail :: ConflictSet -> FailReason -> Tree d c

-- | Functor for the tree type. a is the type of nodes' children.
--   d and c have the same meaning as in Tree.
data TreeF d c a
PChoiceF :: QPN -> RevDepMap -> c -> WeightedPSQ [Weight] POption a -> TreeF d c a
FChoiceF :: QFN -> RevDepMap -> c -> WeakOrTrivial -> FlagType -> Bool -> WeightedPSQ [Weight] Bool a -> TreeF d c a
SChoiceF :: QSN -> RevDepMap -> c -> WeakOrTrivial -> WeightedPSQ [Weight] Bool a -> TreeF d c a
GoalChoiceF :: RevDepMap -> PSQ (Goal QPN) a -> TreeF d c a
DoneF :: RevDepMap -> d -> TreeF d c a
FailF :: ConflictSet -> FailReason -> TreeF d c a
type Weight = Double
data FailReason
UnsupportedExtension :: Extension -> FailReason
UnsupportedLanguage :: Language -> FailReason
MissingPkgconfigPackage :: PkgconfigName -> PkgconfigVersionRange -> FailReason
NewPackageDoesNotMatchExistingConstraint :: ConflictingDep -> FailReason
ConflictingConstraints :: ConflictingDep -> ConflictingDep -> FailReason
NewPackageIsMissingRequiredComponent :: ExposedComponent -> DependencyReason QPN -> FailReason
NewPackageHasPrivateRequiredComponent :: ExposedComponent -> DependencyReason QPN -> FailReason
NewPackageHasUnbuildableRequiredComponent :: ExposedComponent -> DependencyReason QPN -> FailReason
PackageRequiresMissingComponent :: QPN -> ExposedComponent -> FailReason
PackageRequiresPrivateComponent :: QPN -> ExposedComponent -> FailReason
PackageRequiresUnbuildableComponent :: QPN -> ExposedComponent -> FailReason
CannotReinstall :: FailReason
NotExplicit :: FailReason
Shadowed :: FailReason
Broken :: UnitId -> FailReason
UnknownPackage :: FailReason
GlobalConstraintVersion :: VR -> ConstraintSource -> FailReason
GlobalConstraintInstalled :: ConstraintSource -> FailReason
GlobalConstraintSource :: ConstraintSource -> FailReason
GlobalConstraintFlag :: ConstraintSource -> FailReason
ManualFlag :: FailReason
MalformedFlagChoice :: QFN -> FailReason
MalformedStanzaChoice :: QSN -> FailReason
EmptyGoalChoice :: FailReason
Backjump :: FailReason
MultipleInstances :: FailReason
DependenciesNotLinked :: String -> FailReason
CyclicDependencies :: FailReason
UnsupportedSpecVer :: Ver -> FailReason

-- | Information about a dependency involved in a conflict, for error
--   messages.
data ConflictingDep
ConflictingDep :: DependencyReason QPN -> PkgComponent QPN -> CI -> ConflictingDep

-- | Anamorphism on trees.
ana :: (a -> TreeF d c a) -> a -> Tree d c

-- | Catamorphism on trees.
cata :: (TreeF d c a -> a) -> Tree d c -> a
inn :: TreeF d c (Tree d c) -> Tree d c
innM :: Monad m => TreeF d c (m (Tree d c)) -> m (Tree d c)

-- | Paramorphism on trees.
para :: (TreeF d c (a, Tree d c) -> a) -> Tree d c -> a
trav :: TreeTrav d c a -> Tree d c -> Tree d a

-- | Approximates the number of active choices that are available in a
--   node. Note that we count goal choices as having one choice, always.
zeroOrOneChoices :: Tree d c -> Bool

-- | Determines whether a tree is active, i.e., isn't a failure node.
active :: Tree d c -> Bool
type TreeTrav d c a = TreeF d c Tree d a -> TreeF d a Tree d a
type EndoTreeTrav d c = TreeTrav d c c
instance GHC.Classes.Eq Distribution.Solver.Modular.Tree.ConflictingDep
instance GHC.Classes.Eq Distribution.Solver.Modular.Tree.FailReason
instance GHC.Classes.Eq Distribution.Solver.Modular.Tree.POption
instance GHC.Internal.Data.Foldable.Foldable (Distribution.Solver.Modular.Tree.TreeF d c)
instance GHC.Internal.Base.Functor (Distribution.Solver.Modular.Tree.TreeF d c)
instance GHC.Internal.Show.Show Distribution.Solver.Modular.Tree.ConflictingDep
instance GHC.Internal.Show.Show Distribution.Solver.Modular.Tree.FailReason
instance GHC.Internal.Show.Show Distribution.Solver.Modular.Tree.POption
instance GHC.Internal.Data.Traversable.Traversable (Distribution.Solver.Modular.Tree.TreeF d c)

module Distribution.Solver.Modular.Index

-- | An index contains information about package instances. This is a
--   nested dictionary. Package names are mapped to instances, which in
--   turn is mapped to info.
type Index = Map PN Map I PInfo

-- | Info associated with a package instance. Currently, dependencies,
--   component names, flags and failure reasons. The component map records
--   whether any components are unbuildable in the current environment
--   (compiler, os, arch, and global flag constraints). Packages that have
--   a failure reason recorded for them are disabled globally, for reasons
--   external to the solver. We currently use this for shadowing which
--   essentially is a GHC limitation, and for installed packages that are
--   broken.
data PInfo
PInfo :: FlaggedDeps PN -> Map ExposedComponent ComponentInfo -> FlagInfo -> Maybe FailReason -> PInfo

-- | Info associated with each library and executable in a package
--   instance.
data ComponentInfo
ComponentInfo :: IsVisible -> IsBuildable -> ComponentInfo
[compIsVisible] :: ComponentInfo -> IsVisible
[compIsBuildable] :: ComponentInfo -> IsBuildable

-- | Whether a component is visible in the current environment.
newtype IsVisible
IsVisible :: Bool -> IsVisible

-- | Whether a component is made unbuildable by a "buildable: False" field.
newtype IsBuildable
IsBuildable :: Bool -> IsBuildable
defaultQualifyOptions :: Index -> QualifyOptions
mkIndex :: [(PN, I, PInfo)] -> Index
instance GHC.Classes.Eq Distribution.Solver.Modular.Index.IsBuildable
instance GHC.Classes.Eq Distribution.Solver.Modular.Index.IsVisible
instance GHC.Internal.Show.Show Distribution.Solver.Modular.Index.ComponentInfo
instance GHC.Internal.Show.Show Distribution.Solver.Modular.Index.IsBuildable
instance GHC.Internal.Show.Show Distribution.Solver.Modular.Index.IsVisible

module Distribution.Solver.Modular.Validate

-- | Interface.
validateTree :: CompilerInfo -> Index -> PkgConfigDb -> Tree d c -> Tree d c
instance GHC.Internal.Base.Applicative Distribution.Solver.Modular.Validate.Validate
instance GHC.Internal.Base.Functor Distribution.Solver.Modular.Validate.Validate
instance Control.Monad.Reader.Class.MonadReader Distribution.Solver.Modular.Validate.ValidateState Distribution.Solver.Modular.Validate.Validate
instance GHC.Internal.Base.Monad Distribution.Solver.Modular.Validate.Validate

module Distribution.Solver.Modular.Linking

-- | Validate linked packages
--   
--   Verify that linked packages have
--   
--   
--   
- Linked dependencies,
--   
- Equal flag assignments
--   
- Equal stanza assignments
--   
validateLinking :: Index -> Tree d c -> Tree d c
instance GHC.Internal.Base.Applicative Distribution.Solver.Modular.Linking.UpdateState
instance GHC.Classes.Eq Distribution.Solver.Modular.Linking.LinkGroup
instance GHC.Internal.Base.Functor Distribution.Solver.Modular.Linking.UpdateState
instance Control.Monad.State.Class.MonadState Distribution.Solver.Modular.Linking.ValidateState Distribution.Solver.Modular.Linking.UpdateState
instance GHC.Internal.Base.Monad Distribution.Solver.Modular.Linking.UpdateState
instance GHC.Internal.Show.Show Distribution.Solver.Modular.Linking.LinkGroup

module Distribution.Solver.Modular.Cycles

-- | Find and reject any nodes with cyclic dependencies
detectCyclesPhase :: Tree d c -> Tree d c
instance Distribution.Compat.Graph.IsNode Distribution.Solver.Modular.Cycles.RevDepMapNode

module Distribution.Solver.Modular.Message
data Message

-- | increase indentation level
Enter :: Message

-- | decrease indentation level
Leave :: Message
TryP :: QPN -> POption -> Message
TryF :: QFN -> Bool -> Message
TryS :: QSN -> Bool -> Message
Next :: Goal QPN -> Message
Skip :: Set Conflict -> Message
Success :: Message
Failure :: ConflictSet -> FailReason -> Message

-- | Transforms the structured message type to actual messages (strings).
--   
--   The log contains level numbers, which are useful for any trace that
--   involves backtracking, because only the level numbers will allow to
--   keep track of backjumps.
showMessages :: Progress Message a b -> Progress String a b

module Distribution.Solver.Modular.RetryLog

-- | Progress as a difference list that allows efficient appends at
--   failures.
data RetryLog step fail done

-- | O(1). Convert a RetryLog to a Progress.
toProgress :: RetryLog step fail done -> Progress step fail done

-- | O(N). Convert a Progress to a RetryLog.
fromProgress :: Progress step fail done -> RetryLog step fail done

-- | O(1). Apply a function to the failure value in a log.
mapFailure :: (fail1 -> fail2) -> RetryLog step fail1 done -> RetryLog step fail2 done

-- | O(1). If the first log leads to failure, continue with the
--   second.
retry :: RetryLog step fail1 done -> (fail1 -> RetryLog step fail2 done) -> RetryLog step fail2 done

-- | O(1). Create a log with one message before a failure.
failWith :: step -> fail -> RetryLog step fail done

-- | O(1). Create a log with one message before a success.
succeedWith :: step -> done -> RetryLog step fail done

-- | O(1). Prepend a message to a log.
continueWith :: step -> RetryLog step fail done -> RetryLog step fail done

-- | O(1). Prepend the given message and Enter to the log,
--   and insert Leave before the failure if the log fails.
tryWith :: Message -> RetryLog Message fail done -> RetryLog Message fail done

module Distribution.Solver.Modular.Log

-- | Postprocesses a log file. This function discards all log messages and
--   avoids calling showMessages if the log isn't needed (specified
--   by keepLog), for efficiency.
displayLogMessages :: Bool -> RetryLog Message SolverFailure a -> RetryLog String SolverFailure a

-- | Information about a dependency solver failure.
data SolverFailure
ExhaustiveSearch :: ConflictSet -> ConflictMap -> SolverFailure
BackjumpLimitReached :: SolverFailure

module Distribution.Solver.Types.Settings
newtype ReorderGoals
ReorderGoals :: Bool -> ReorderGoals
newtype IndependentGoals
IndependentGoals :: Bool -> IndependentGoals
newtype PreferOldest
PreferOldest :: Bool -> PreferOldest
newtype MinimizeConflictSet
MinimizeConflictSet :: Bool -> MinimizeConflictSet
newtype AvoidReinstalls
AvoidReinstalls :: Bool -> AvoidReinstalls
newtype ShadowPkgs
ShadowPkgs :: Bool -> ShadowPkgs
newtype StrongFlags
StrongFlags :: Bool -> StrongFlags
newtype AllowBootLibInstalls
AllowBootLibInstalls :: Bool -> AllowBootLibInstalls

-- | Should we consider all packages we know about, or only those that have
--   constraints explicitly placed on them or which are goals?
data OnlyConstrained
OnlyConstrainedNone :: OnlyConstrained
OnlyConstrainedAll :: OnlyConstrained
newtype EnableBackjumping
EnableBackjumping :: Bool -> EnableBackjumping
newtype CountConflicts
CountConflicts :: Bool -> CountConflicts
newtype FineGrainedConflicts
FineGrainedConflicts :: Bool -> FineGrainedConflicts
newtype SolveExecutables
SolveExecutables :: Bool -> SolveExecutables
instance Data.Binary.Class.Binary Distribution.Solver.Types.Settings.AllowBootLibInstalls
instance Data.Binary.Class.Binary Distribution.Solver.Types.Settings.AvoidReinstalls
instance Data.Binary.Class.Binary Distribution.Solver.Types.Settings.CountConflicts
instance Data.Binary.Class.Binary Distribution.Solver.Types.Settings.FineGrainedConflicts
instance Data.Binary.Class.Binary Distribution.Solver.Types.Settings.IndependentGoals
instance Data.Binary.Class.Binary Distribution.Solver.Types.Settings.MinimizeConflictSet
instance Data.Binary.Class.Binary Distribution.Solver.Types.Settings.OnlyConstrained
instance Data.Binary.Class.Binary Distribution.Solver.Types.Settings.PreferOldest
instance Data.Binary.Class.Binary Distribution.Solver.Types.Settings.ReorderGoals
instance Data.Binary.Class.Binary Distribution.Solver.Types.Settings.ShadowPkgs
instance Data.Binary.Class.Binary Distribution.Solver.Types.Settings.SolveExecutables
instance Data.Binary.Class.Binary Distribution.Solver.Types.Settings.StrongFlags
instance Distribution.Simple.Flag.BooleanFlag Distribution.Solver.Types.Settings.AllowBootLibInstalls
instance Distribution.Simple.Flag.BooleanFlag Distribution.Solver.Types.Settings.AvoidReinstalls
instance Distribution.Simple.Flag.BooleanFlag Distribution.Solver.Types.Settings.CountConflicts
instance Distribution.Simple.Flag.BooleanFlag Distribution.Solver.Types.Settings.EnableBackjumping
instance Distribution.Simple.Flag.BooleanFlag Distribution.Solver.Types.Settings.FineGrainedConflicts
instance Distribution.Simple.Flag.BooleanFlag Distribution.Solver.Types.Settings.IndependentGoals
instance Distribution.Simple.Flag.BooleanFlag Distribution.Solver.Types.Settings.MinimizeConflictSet
instance Distribution.Simple.Flag.BooleanFlag Distribution.Solver.Types.Settings.PreferOldest
instance Distribution.Simple.Flag.BooleanFlag Distribution.Solver.Types.Settings.ReorderGoals
instance Distribution.Simple.Flag.BooleanFlag Distribution.Solver.Types.Settings.ShadowPkgs
instance Distribution.Simple.Flag.BooleanFlag Distribution.Solver.Types.Settings.SolveExecutables
instance Distribution.Simple.Flag.BooleanFlag Distribution.Solver.Types.Settings.StrongFlags
instance GHC.Classes.Eq Distribution.Solver.Types.Settings.AllowBootLibInstalls
instance GHC.Classes.Eq Distribution.Solver.Types.Settings.AvoidReinstalls
instance GHC.Classes.Eq Distribution.Solver.Types.Settings.CountConflicts
instance GHC.Classes.Eq Distribution.Solver.Types.Settings.EnableBackjumping
instance GHC.Classes.Eq Distribution.Solver.Types.Settings.FineGrainedConflicts
instance GHC.Classes.Eq Distribution.Solver.Types.Settings.IndependentGoals
instance GHC.Classes.Eq Distribution.Solver.Types.Settings.MinimizeConflictSet
instance GHC.Classes.Eq Distribution.Solver.Types.Settings.OnlyConstrained
instance GHC.Classes.Eq Distribution.Solver.Types.Settings.PreferOldest
instance GHC.Classes.Eq Distribution.Solver.Types.Settings.ReorderGoals
instance GHC.Classes.Eq Distribution.Solver.Types.Settings.ShadowPkgs
instance GHC.Classes.Eq Distribution.Solver.Types.Settings.SolveExecutables
instance GHC.Classes.Eq Distribution.Solver.Types.Settings.StrongFlags
instance GHC.Internal.Generics.Generic Distribution.Solver.Types.Settings.AllowBootLibInstalls
instance GHC.Internal.Generics.Generic Distribution.Solver.Types.Settings.AvoidReinstalls
instance GHC.Internal.Generics.Generic Distribution.Solver.Types.Settings.CountConflicts
instance GHC.Internal.Generics.Generic Distribution.Solver.Types.Settings.EnableBackjumping
instance GHC.Internal.Generics.Generic Distribution.Solver.Types.Settings.FineGrainedConflicts
instance GHC.Internal.Generics.Generic Distribution.Solver.Types.Settings.IndependentGoals
instance GHC.Internal.Generics.Generic Distribution.Solver.Types.Settings.MinimizeConflictSet
instance GHC.Internal.Generics.Generic Distribution.Solver.Types.Settings.OnlyConstrained
instance GHC.Internal.Generics.Generic Distribution.Solver.Types.Settings.PreferOldest
instance GHC.Internal.Generics.Generic Distribution.Solver.Types.Settings.ReorderGoals
instance GHC.Internal.Generics.Generic Distribution.Solver.Types.Settings.ShadowPkgs
instance GHC.Internal.Generics.Generic Distribution.Solver.Types.Settings.SolveExecutables
instance GHC.Internal.Generics.Generic Distribution.Solver.Types.Settings.StrongFlags
instance Distribution.Parsec.Parsec Distribution.Solver.Types.Settings.OnlyConstrained
instance Distribution.Pretty.Pretty Distribution.Solver.Types.Settings.OnlyConstrained
instance GHC.Internal.Show.Show Distribution.Solver.Types.Settings.AllowBootLibInstalls
instance GHC.Internal.Show.Show Distribution.Solver.Types.Settings.AvoidReinstalls
instance GHC.Internal.Show.Show Distribution.Solver.Types.Settings.CountConflicts
instance GHC.Internal.Show.Show Distribution.Solver.Types.Settings.EnableBackjumping
instance GHC.Internal.Show.Show Distribution.Solver.Types.Settings.FineGrainedConflicts
instance GHC.Internal.Show.Show Distribution.Solver.Types.Settings.IndependentGoals
instance GHC.Internal.Show.Show Distribution.Solver.Types.Settings.MinimizeConflictSet
instance GHC.Internal.Show.Show Distribution.Solver.Types.Settings.OnlyConstrained
instance GHC.Internal.Show.Show Distribution.Solver.Types.Settings.PreferOldest
instance GHC.Internal.Show.Show Distribution.Solver.Types.Settings.ReorderGoals
instance GHC.Internal.Show.Show Distribution.Solver.Types.Settings.ShadowPkgs
instance GHC.Internal.Show.Show Distribution.Solver.Types.Settings.SolveExecutables
instance GHC.Internal.Show.Show Distribution.Solver.Types.Settings.StrongFlags
instance Distribution.Utils.Structured.Structured Distribution.Solver.Types.Settings.AllowBootLibInstalls
instance Distribution.Utils.Structured.Structured Distribution.Solver.Types.Settings.AvoidReinstalls
instance Distribution.Utils.Structured.Structured Distribution.Solver.Types.Settings.CountConflicts
instance Distribution.Utils.Structured.Structured Distribution.Solver.Types.Settings.FineGrainedConflicts
instance Distribution.Utils.Structured.Structured Distribution.Solver.Types.Settings.IndependentGoals
instance Distribution.Utils.Structured.Structured Distribution.Solver.Types.Settings.MinimizeConflictSet
instance Distribution.Utils.Structured.Structured Distribution.Solver.Types.Settings.OnlyConstrained
instance Distribution.Utils.Structured.Structured Distribution.Solver.Types.Settings.PreferOldest
instance Distribution.Utils.Structured.Structured Distribution.Solver.Types.Settings.ReorderGoals
instance Distribution.Utils.Structured.Structured Distribution.Solver.Types.Settings.ShadowPkgs
instance Distribution.Utils.Structured.Structured Distribution.Solver.Types.Settings.SolveExecutables
instance Distribution.Utils.Structured.Structured Distribution.Solver.Types.Settings.StrongFlags

module Distribution.Solver.Modular.Explore

-- | Interface.
--   
--   Takes as an argument a limit on allowed backjumps. If the limit is
--   Nothing, then infinitely many backjumps are allowed. If the
--   limit is 'Just 0', backtracking is completely disabled.
backjumpAndExplore :: Maybe Int -> EnableBackjumping -> FineGrainedConflicts -> CountConflicts -> Index -> Tree d QGoalReason -> RetryLog Message SolverFailure (Assignment, RevDepMap)

module Distribution.Solver.Modular.Builder

-- | Interface to the tree builder. Just takes an index and a list of
--   package names, and computes the initial state and then the tree from
--   there.
buildTree :: Index -> IndependentGoals -> [PN] -> Tree () QGoalReason

-- | Pairs each element of a list with the list resulting from removal of
--   that element from the original list.
splits :: [a] -> [(a, [a])]

module Distribution.Solver.Types.SolverId

-- | The solver can produce references to existing packages or packages we
--   plan to install. Unlike ConfiguredId we don't yet know the
--   UnitId for planned packages, because it's not the solver's job
--   to compute them.
data SolverId
PreExistingId :: PackageId -> UnitId -> SolverId
[solverSrcId] :: SolverId -> PackageId
[solverInstId] :: SolverId -> UnitId
PlannedId :: PackageId -> SolverId
[solverSrcId] :: SolverId -> PackageId
instance Data.Binary.Class.Binary Distribution.Solver.Types.SolverId.SolverId
instance GHC.Classes.Eq Distribution.Solver.Types.SolverId.SolverId
instance GHC.Internal.Generics.Generic Distribution.Solver.Types.SolverId.SolverId
instance GHC.Classes.Ord Distribution.Solver.Types.SolverId.SolverId
instance Distribution.Package.Package Distribution.Solver.Types.SolverId.SolverId
instance GHC.Internal.Show.Show Distribution.Solver.Types.SolverId.SolverId
instance Distribution.Utils.Structured.Structured Distribution.Solver.Types.SolverId.SolverId

module Distribution.Solver.Types.InstSolverPackage

-- | An InstSolverPackage is a pre-existing installed package
--   specified by the dependency solver.
data InstSolverPackage
InstSolverPackage :: InstalledPackageInfo -> ComponentDeps [SolverId] -> ComponentDeps [SolverId] -> InstSolverPackage
[instSolverPkgIPI] :: InstSolverPackage -> InstalledPackageInfo
[instSolverPkgLibDeps] :: InstSolverPackage -> ComponentDeps [SolverId]
[instSolverPkgExeDeps] :: InstSolverPackage -> ComponentDeps [SolverId]
instance Data.Binary.Class.Binary Distribution.Solver.Types.InstSolverPackage.InstSolverPackage
instance GHC.Classes.Eq Distribution.Solver.Types.InstSolverPackage.InstSolverPackage
instance GHC.Internal.Generics.Generic Distribution.Solver.Types.InstSolverPackage.InstSolverPackage
instance Distribution.Package.HasMungedPackageId Distribution.Solver.Types.InstSolverPackage.InstSolverPackage
instance Distribution.Package.HasUnitId Distribution.Solver.Types.InstSolverPackage.InstSolverPackage
instance Distribution.Package.Package Distribution.Solver.Types.InstSolverPackage.InstSolverPackage
instance GHC.Internal.Show.Show Distribution.Solver.Types.InstSolverPackage.InstSolverPackage
instance Distribution.Utils.Structured.Structured Distribution.Solver.Types.InstSolverPackage.InstSolverPackage

module Distribution.Solver.Types.SourcePackage

-- | We sometimes need to override the .cabal file in the tarball with the
--   newer one from the package index.
type PackageDescriptionOverride = Maybe ByteString

-- | A package description along with the location of the package sources.
data SourcePackage loc
SourcePackage :: PackageId -> GenericPackageDescription -> loc -> PackageDescriptionOverride -> SourcePackage loc
[srcpkgPackageId] :: SourcePackage loc -> PackageId

-- | Note, this field is lazy, e.g. when reading in hackage index we parse
--   only what we need, not whole index.
[srcpkgDescription] :: SourcePackage loc -> GenericPackageDescription
[srcpkgSource] :: SourcePackage loc -> loc
[srcpkgDescrOverride] :: SourcePackage loc -> PackageDescriptionOverride
instance Data.Binary.Class.Binary loc => Data.Binary.Class.Binary (Distribution.Solver.Types.SourcePackage.SourcePackage loc)
instance GHC.Classes.Eq loc => GHC.Classes.Eq (Distribution.Solver.Types.SourcePackage.SourcePackage loc)
instance GHC.Internal.Generics.Generic (Distribution.Solver.Types.SourcePackage.SourcePackage loc)
instance Distribution.Package.Package (Distribution.Solver.Types.SourcePackage.SourcePackage a)
instance GHC.Internal.Show.Show loc => GHC.Internal.Show.Show (Distribution.Solver.Types.SourcePackage.SourcePackage loc)
instance Distribution.Utils.Structured.Structured loc => Distribution.Utils.Structured.Structured (Distribution.Solver.Types.SourcePackage.SourcePackage loc)

module Distribution.Solver.Types.SolverPackage

-- | A SolverPackage is a package specified by the dependency
--   solver. It will get elaborated into a ConfiguredPackage or
--   even an ElaboratedConfiguredPackage.
--   
--   NB: SolverPackages are essentially always with
--   UnresolvedPkgLoc, but for symmetry we have the parameter.
--   (Maybe it can be removed.)
data SolverPackage loc
SolverPackage :: SourcePackage loc -> FlagAssignment -> OptionalStanzaSet -> ComponentDeps [SolverId] -> ComponentDeps [SolverId] -> SolverPackage loc
[solverPkgSource] :: SolverPackage loc -> SourcePackage loc
[solverPkgFlags] :: SolverPackage loc -> FlagAssignment
[solverPkgStanzas] :: SolverPackage loc -> OptionalStanzaSet
[solverPkgLibDeps] :: SolverPackage loc -> ComponentDeps [SolverId]
[solverPkgExeDeps] :: SolverPackage loc -> ComponentDeps [SolverId]
instance Data.Binary.Class.Binary loc => Data.Binary.Class.Binary (Distribution.Solver.Types.SolverPackage.SolverPackage loc)
instance GHC.Classes.Eq loc => GHC.Classes.Eq (Distribution.Solver.Types.SolverPackage.SolverPackage loc)
instance GHC.Internal.Generics.Generic (Distribution.Solver.Types.SolverPackage.SolverPackage loc)
instance Distribution.Package.Package (Distribution.Solver.Types.SolverPackage.SolverPackage loc)
instance GHC.Internal.Show.Show loc => GHC.Internal.Show.Show (Distribution.Solver.Types.SolverPackage.SolverPackage loc)
instance Distribution.Utils.Structured.Structured loc => Distribution.Utils.Structured.Structured (Distribution.Solver.Types.SolverPackage.SolverPackage loc)

module Distribution.Solver.Types.ResolverPackage

-- | The dependency resolver picks either pre-existing installed packages
--   or it picks source packages along with package configuration.
--   
--   This is like the PlanPackage but with fewer cases.
data ResolverPackage loc
PreExisting :: InstSolverPackage -> ResolverPackage loc
Configured :: SolverPackage loc -> ResolverPackage loc
resolverPackageLibDeps :: ResolverPackage loc -> ComponentDeps [SolverId]
resolverPackageExeDeps :: ResolverPackage loc -> ComponentDeps [SolverId]
instance Data.Binary.Class.Binary loc => Data.Binary.Class.Binary (Distribution.Solver.Types.ResolverPackage.ResolverPackage loc)
instance GHC.Classes.Eq loc => GHC.Classes.Eq (Distribution.Solver.Types.ResolverPackage.ResolverPackage loc)
instance GHC.Internal.Generics.Generic (Distribution.Solver.Types.ResolverPackage.ResolverPackage loc)
instance Distribution.Compat.Graph.IsNode (Distribution.Solver.Types.ResolverPackage.ResolverPackage loc)
instance Distribution.Package.Package (Distribution.Solver.Types.ResolverPackage.ResolverPackage loc)
instance GHC.Internal.Show.Show loc => GHC.Internal.Show.Show (Distribution.Solver.Types.ResolverPackage.ResolverPackage loc)
instance Distribution.Utils.Structured.Structured loc => Distribution.Utils.Structured.Structured (Distribution.Solver.Types.ResolverPackage.ResolverPackage loc)

module Distribution.Solver.Types.DependencyResolver

-- | A dependency resolver is a function that works out an installation
--   plan given the set of installed and available packages and a set of
--   deps to solve for.
--   
--   The reason for this interface is because there are dozens of
--   approaches to solving the package dependency problem and we want to
--   make it easy to swap in alternatives.
type DependencyResolver loc = Platform -> CompilerInfo -> InstalledPackageIndex -> PackageIndex SourcePackage loc -> PkgConfigDb -> PackageName -> PackagePreferences -> [LabeledPackageConstraint] -> Set PackageName -> Progress String String [ResolverPackage loc]

module Distribution.Solver.Modular.IndexConversion

-- | Convert both the installed package index and the source package index
--   into one uniform solver index.
--   
--   We use allPackagesBySourcePackageId for the installed package
--   index because that returns us several instances of the same package
--   and version in order of preference. This allows us in principle to
--   "shadow" packages if there are several installed packages of the same
--   version. There are currently some shortcomings in both GHC and Cabal
--   in resolving these situations. However, the right thing to do is to
--   fix the problem there, so for now, shadowing is only activated if
--   explicitly requested.
convPIs :: OS -> Arch -> CompilerInfo -> Map PN [LabeledPackageConstraint] -> ShadowPkgs -> StrongFlags -> SolveExecutables -> InstalledPackageIndex -> PackageIndex (SourcePackage loc) -> Index
instance GHC.Classes.Eq qpn => GHC.Classes.Eq (Distribution.Solver.Modular.IndexConversion.SimpleFlaggedDepKey qpn)
instance GHC.Classes.Ord qpn => GHC.Classes.Ord (Distribution.Solver.Modular.IndexConversion.SimpleFlaggedDepKey qpn)

module Distribution.Solver.Modular.ConfiguredConversion

-- | Converts from the solver specific result CP QPN into a
--   ResolverPackage, which can then be converted into the install
--   plan.
convCP :: InstalledPackageIndex -> PackageIndex (SourcePackage loc) -> CP QPN -> ResolverPackage loc

module Distribution.Solver.Types.Variable

-- | Variables used by the dependency solver. This type is similar to the
--   internal Var type.
data Variable qpn
PackageVar :: qpn -> Variable qpn
FlagVar :: qpn -> FlagName -> Variable qpn
StanzaVar :: qpn -> OptionalStanza -> Variable qpn
instance GHC.Classes.Eq qpn => GHC.Classes.Eq (Distribution.Solver.Types.Variable.Variable qpn)
instance GHC.Internal.Show.Show qpn => GHC.Internal.Show.Show (Distribution.Solver.Types.Variable.Variable qpn)

-- | Reordering or pruning the tree in order to prefer or make certain
--   choices.
module Distribution.Solver.Modular.Preference

-- | Avoid reinstalls.
--   
--   This is a tricky strategy. If a package version is installed already
--   and the same version is available from a repo, the repo version will
--   never be chosen. This would result in a reinstall (either
--   destructively, or potentially, shadowing). The old instance won't be
--   visible or even present anymore, but other packages might have
--   depended on it.
--   
--   TODO: It would be better to actually check the reverse dependencies of
--   installed packages. If they're not depended on, then reinstalling
--   should be fine. Even if they are, perhaps this should just result in
--   trying to reinstall those other packages as well. However, doing this
--   all neatly in one pass would require to change the builder, or at
--   least to change the goal set after building.
avoidReinstalls :: (PN -> Bool) -> EndoTreeTrav d c

-- | Deal with setup and build-tool-depends dependencies after regular
--   dependencies, so we will link setup/exe dependencies against package
--   dependencies when possible
deferSetupExeChoices :: EndoTreeTrav d c

-- | Transformation that tries to avoid making weak flag choices early.
--   Weak flags are trivial flags (not influencing dependencies) or such
--   flags that are explicitly declared to be weak in the index.
deferWeakFlagChoices :: EndoTreeTrav d c

-- | Transformation that tries to enforce the rule that manual flags can
--   only be set by the user.
--   
--   If there are no constraints on a manual flag, this function prunes all
--   but the default value. If there are constraints, then the flag is
--   allowed to have the values specified by the constraints. Note that the
--   type used for flag values doesn't need to be Bool.
--   
--   This function makes an exception for the case where there are multiple
--   goals for a single package (with different qualifiers), and flag
--   constraints for manual flag x only apply to some of those goals. In
--   that case, we allow the unconstrained goals to use the default value
--   for x OR any of the values in the constraints on x (even though the
--   constraints don't apply), in order to allow the unconstrained goals to
--   be linked to the constrained goals. See
--   https://github.com/haskell/cabal/issues/4299. Removing the
--   single instance restriction (SIR) would also fix #4299, so we may want
--   to remove this exception and only let the user toggle manual flags if
--   we remove the SIR.
--   
--   This function does not enforce any of the constraints, since that is
--   done by enforcePackageConstraints.
enforceManualFlags :: Map PN [LabeledPackageConstraint] -> EndoTreeTrav d c

-- | Traversal that tries to establish various kinds of user constraints.
--   Works by selectively disabling choices that have been ruled out by
--   global user constraints.
enforcePackageConstraints :: Map PN [LabeledPackageConstraint] -> EndoTreeTrav d c

-- | Enforce ghc's single instance restriction
--   
--   From the solver's perspective, this means that for any package
--   instance (that is, package name + package version) there can be at
--   most one qualified goal resolving to that instance (there may be other
--   goals _linking_ to that instance however).
enforceSingleInstanceRestriction :: Tree d c -> Tree d c

-- | Always choose the first goal in the list next, abandoning all other
--   choices.
--   
--   This is unnecessary for the default search strategy, because it
--   descends only into the first goal choice anyway, but may still make
--   sense to just reduce the tree size a bit.
firstGoal :: EndoTreeTrav d c

-- | Transformation that tries to make a decision on base as early as
--   possible by pruning all other goals when base is available. In nearly
--   all cases, there's a single choice for the base package. Also, fixing
--   base early should lead to better error messages.
preferBaseGoalChoice :: EndoTreeTrav d c

-- | Prefer to link packages whenever possible.
preferLinked :: EndoTreeTrav d c
preferPackagePreferences :: (PN -> PackagePreferences) -> EndoTreeTrav d c

-- | Transformation that prefers goals with lower branching degrees.
--   
--   When a goal choice node has at least one goal with zero or one
--   children, this function prunes all other goals. This transformation
--   can help the solver find a solution in fewer steps by allowing it to
--   backtrack sooner when it is exploring a subtree with no solutions.
--   However, each step is more expensive.
preferReallyEasyGoalChoices :: EndoTreeTrav d c

-- | Require all packages to be mentioned in a constraint or as a goal.
onlyConstrained :: (PN -> Bool) -> EndoTreeTrav d QGoalReason

-- | Sort all goals using the provided function.
sortGoals :: (Variable QPN -> Variable QPN -> Ordering) -> EndoTreeTrav d c

-- | Reduce the branching degree of the search tree by removing all choices
--   after the first successful choice at each level. The returned tree is
--   the minimal subtree containing the path to the first backjump.
pruneAfterFirstSuccess :: EndoTreeTrav d c

module Distribution.Solver.Modular.Solver

-- | Various options for the modular solver.
data SolverConfig
SolverConfig :: ReorderGoals -> CountConflicts -> FineGrainedConflicts -> MinimizeConflictSet -> IndependentGoals -> AvoidReinstalls -> ShadowPkgs -> StrongFlags -> OnlyConstrained -> Maybe Int -> EnableBackjumping -> SolveExecutables -> Maybe (Variable QPN -> Variable QPN -> Ordering) -> Verbosity -> PruneAfterFirstSuccess -> SolverConfig
[reorderGoals] :: SolverConfig -> ReorderGoals
[countConflicts] :: SolverConfig -> CountConflicts
[fineGrainedConflicts] :: SolverConfig -> FineGrainedConflicts
[minimizeConflictSet] :: SolverConfig -> MinimizeConflictSet
[independentGoals] :: SolverConfig -> IndependentGoals
[avoidReinstalls] :: SolverConfig -> AvoidReinstalls
[shadowPkgs] :: SolverConfig -> ShadowPkgs
[strongFlags] :: SolverConfig -> StrongFlags
[onlyConstrained] :: SolverConfig -> OnlyConstrained
[maxBackjumps] :: SolverConfig -> Maybe Int
[enableBackjumping] :: SolverConfig -> EnableBackjumping
[solveExecutables] :: SolverConfig -> SolveExecutables
[goalOrder] :: SolverConfig -> Maybe (Variable QPN -> Variable QPN -> Ordering)
[solverVerbosity] :: SolverConfig -> Verbosity
[pruneAfterFirstSuccess] :: SolverConfig -> PruneAfterFirstSuccess

-- | Run all solver phases.
--   
--   In principle, we have a valid tree after validationPhase,
--   which means that every Done node should correspond to valid
--   solution.
--   
--   There is one exception, though, and that is cycle detection, which has
--   been added relatively recently. Cycles are only removed directly
--   before exploration.
solve :: SolverConfig -> CompilerInfo -> Index -> PkgConfigDb -> (PN -> PackagePreferences) -> Map PN [LabeledPackageConstraint] -> Set PN -> RetryLog Message SolverFailure (Assignment, RevDepMap)

-- | Whether to remove all choices after the first successful choice at
--   each level in the search tree.
newtype PruneAfterFirstSuccess
PruneAfterFirstSuccess :: Bool -> PruneAfterFirstSuccess

module Distribution.Solver.Modular

-- | Ties the two worlds together: classic cabal-install vs. the modular
--   solver. Performs the necessary translations before and after.
modularResolver :: SolverConfig -> DependencyResolver loc

-- | Various options for the modular solver.
data SolverConfig
SolverConfig :: ReorderGoals -> CountConflicts -> FineGrainedConflicts -> MinimizeConflictSet -> IndependentGoals -> AvoidReinstalls -> ShadowPkgs -> StrongFlags -> OnlyConstrained -> Maybe Int -> EnableBackjumping -> SolveExecutables -> Maybe (Variable QPN -> Variable QPN -> Ordering) -> Verbosity -> PruneAfterFirstSuccess -> SolverConfig
[reorderGoals] :: SolverConfig -> ReorderGoals
[countConflicts] :: SolverConfig -> CountConflicts
[fineGrainedConflicts] :: SolverConfig -> FineGrainedConflicts
[minimizeConflictSet] :: SolverConfig -> MinimizeConflictSet
[independentGoals] :: SolverConfig -> IndependentGoals
[avoidReinstalls] :: SolverConfig -> AvoidReinstalls
[shadowPkgs] :: SolverConfig -> ShadowPkgs
[strongFlags] :: SolverConfig -> StrongFlags
[onlyConstrained] :: SolverConfig -> OnlyConstrained
[maxBackjumps] :: SolverConfig -> Maybe Int
[enableBackjumping] :: SolverConfig -> EnableBackjumping
[solveExecutables] :: SolverConfig -> SolveExecutables
[goalOrder] :: SolverConfig -> Maybe (Variable QPN -> Variable QPN -> Ordering)
[solverVerbosity] :: SolverConfig -> Verbosity
[pruneAfterFirstSuccess] :: SolverConfig -> PruneAfterFirstSuccess

-- | Whether to remove all choices after the first successful choice at
--   each level in the search tree.
newtype PruneAfterFirstSuccess
PruneAfterFirstSuccess :: Bool -> PruneAfterFirstSuccess
