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

-- | A game engine library for tactical squad ASCII roguelike dungeon crawlers
--   
--   LambdaHack is a Haskell game engine library for ASCII roguelike games
--   of arbitrary theme, size and complexity, with optional tactical squad
--   combat. It's packaged together with a sample dungeon crawler in a
--   quirky fantasy setting. The sample game can be tried out in the
--   browser at http://lambdahack.github.io.
--   
--   Please see the changelog file for recent improvements and the issue
--   tracker for short-term plans. Long term goals include multiplayer
--   tactical squad combat, in-game content creation, auto-balancing and
--   persistent content modification based on player behaviour.
--   Contributions are welcome.
--   
--   Other games known to use the LambdaHack library:
--   
--   
--   
- Allure of the Stars, a near-future Sci-Fi game,
--   http://hackage.haskell.org/package/Allure
--   
--   
--   Note: All modules in this library are kept visible, to let games
--   override and reuse them. OTOH, to reflect that some modules are
--   implementation details relative to others, the source code adheres to
--   the following convention. If a module has the same name as a
--   directory, the module is the exclusive interface to the directory. No
--   references to the modules in the directory are allowed except from the
--   interface module. This policy is only binding when developing the
--   library --- library users are free to access any modules, since the
--   library authors are in no position to guess their particular needs.
--   
--   This is a workaround .cabal file, flattened to eliminate internal
--   libraries until generating haddocks for them is fixed. The original
--   .cabal file is in .cabal.bkp file.
@package LambdaHack
@version 0.11.0.1

-- | Custom Prelude, compatible across many GHC versions.
module Game.LambdaHack.Core.Prelude

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

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

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

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

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

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

-- | 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 `quot`
infixl 7 `rem`
infixl 7 `div`
infixl 7 `mod`

-- | 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]
data Bool
False :: Bool
True :: Bool

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

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

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

-- | A Word is an unsigned integral type, with the same size as
--   Int.
data Word
data Ordering
LT :: Ordering
EQ :: Ordering
GT :: Ordering

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

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

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

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

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

-- | ($) 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 $

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

-- | (++) 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 ++

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

-- | A variant of foldr that has no base case, and thus may only be
--   applied to non-empty structures.
--   
--   This function is non-total and will raise a runtime exception if the
--   structure happens to be empty.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> foldr1 (+) [1..4]
--   10
--   
--   
--   
--   >>> foldr1 (+) []
--   Exception: Prelude.foldr1: empty list
--   
--   
--   
--   >>> foldr1 (+) Nothing
--   *** Exception: foldr1: empty structure
--   
--   
--   
--   >>> foldr1 (-) [1..4]
--   -2
--   
--   
--   
--   >>> foldr1 (&&) [True, False, True, True]
--   False
--   
--   
--   
--   >>> foldr1 (||) [False, False, True, True]
--   True
--   
--   
--   
--   >>> foldr1 (+) [1..]
--   * Hangs forever *
--   
foldr1 :: Foldable t => (a -> a -> a) -> t a -> a

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

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

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

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

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

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

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

-- | error stops execution and displays an error message.
error :: HasCallStack => [Char] -> 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)

-- | Map each element of a structure to a monadic action, evaluate these
--   actions from left to right, and collect the results. For a version
--   that ignores the results see mapM_.
--   
--   
Examples
--   
--   mapM is literally a traverse with a type signature
--   restricted to Monad. Its implementation may be more efficient
--   due to additional power of Monad.
mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b)

-- | Evaluate each monadic action in the structure from left to right, and
--   collect the results. For a version that ignores the results see
--   sequence_.
--   
--   
Examples
--   
--   Basic usage:
--   
--   The first two examples are instances where the input and and output of
--   sequence are isomorphic.
--   
--   
--   >>> sequence $ Right [1,2,3,4]
--   [Right 1,Right 2,Right 3,Right 4]
--   
--   
--   
--   >>> sequence $ [Right 1,Right 2,Right 3,Right 4]
--   Right [1,2,3,4]
--   
--   
--   The following examples demonstrate short circuit behavior for
--   sequence.
--   
--   
--   >>> sequence $ Left [1,2,3,4]
--   Left [1,2,3,4]
--   
--   
--   
--   >>> sequence $ [Left 0, Right 1,Right 2,Right 3,Right 4]
--   Left 0
--   
sequence :: (Traversable t, Monad m) => t (m a) -> m (t 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]

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

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

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

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

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

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

-- | 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 6 +
infixl 7 *

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

-- | <math>. Extract the first element of a list, which must be
--   non-empty.
--   
--   To disable the warning about partiality put {-# OPTIONS_GHC
--   -Wno-x-partial -Wno-unrecognised-warning-flags #-} at the top of
--   the file. To disable it throughout a package put the same options into
--   ghc-options section of Cabal file. To disable it in GHCi put
--   :set -Wno-x-partial -Wno-unrecognised-warning-flags into
--   ~/.ghci config file. See also the migration guide.
--   
--   
Examples
--   
--   
--   >>> head [1, 2, 3]
--   1
--   
--   
--   
--   >>> head [1..]
--   1
--   
--   
--   
--   >>> head []
--   *** Exception: Prelude.head: empty list
--   
head :: HasCallStack => [a] -> a

-- | <math>. Extract the elements after the head of a list, which
--   must be non-empty.
--   
--   To disable the warning about partiality put {-# OPTIONS_GHC
--   -Wno-x-partial -Wno-unrecognised-warning-flags #-} at the top of
--   the file. To disable it throughout a package put the same options into
--   ghc-options section of Cabal file. To disable it in GHCi put
--   :set -Wno-x-partial -Wno-unrecognised-warning-flags into
--   ~/.ghci config file. See also the migration guide.
--   
--   
Examples
--   
--   
--   >>> tail [1, 2, 3]
--   [2,3]
--   
--   
--   
--   >>> tail [1]
--   []
--   
--   
--   
--   >>> tail []
--   *** Exception: Prelude.tail: empty list
--   
tail :: HasCallStack => [a] -> [a]

-- | <math>. Extract the last element of a list, which must be finite
--   and non-empty.
--   
--   WARNING: This function is partial. Consider using unsnoc
--   instead.
--   
--   
Examples
--   
--   
--   >>> last [1, 2, 3]
--   3
--   
--   
--   
--   >>> last [1..]
--   * Hangs forever *
--   
--   
--   
--   >>> last []
--   *** Exception: Prelude.last: empty list
--   
last :: HasCallStack => [a] -> a

-- | <math>. Return all the elements of a list except the last one.
--   The list must be non-empty.
--   
--   WARNING: This function is partial. Consider using unsnoc
--   instead.
--   
--   
Examples
--   
--   
--   >>> init [1, 2, 3]
--   [1,2]
--   
--   
--   
--   >>> init [1]
--   []
--   
--   
--   
--   >>> init []
--   *** Exception: Prelude.init: empty list
--   
init :: HasCallStack => [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]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

-- | The read function reads input from a string, which must be
--   completely consumed by the input process. read fails with an
--   error if the parse is unsuccessful, and it is therefore
--   discouraged from being used in real applications. Use readMaybe
--   or readEither for safe alternatives.
--   
--   
--   >>> read "123" :: Int
--   123
--   
--   
--   
--   >>> read "hello" :: Int
--   *** Exception: Prelude.read: no parse
--   
read :: Read a => String -> a

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

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

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

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

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

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

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

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

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

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

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

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

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

-- | 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 computation writeFile file str function writes the
--   string str, to the file file.
writeFile :: FilePath -> String -> IO ()

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

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

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

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

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

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

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

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

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

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

-- | Evaluate each monadic action in the structure from left to right, and
--   collect the results. For a version that ignores the results see
--   sequence_.
--   
--   
Examples
--   
--   Basic usage:
--   
--   The first two examples are instances where the input and and output of
--   sequence are isomorphic.
--   
--   
--   >>> sequence $ Right [1,2,3,4]
--   [Right 1,Right 2,Right 3,Right 4]
--   
--   
--   
--   >>> sequence $ [Right 1,Right 2,Right 3,Right 4]
--   Right [1,2,3,4]
--   
--   
--   The following examples demonstrate short circuit behavior for
--   sequence.
--   
--   
--   >>> sequence $ Left [1,2,3,4]
--   Left [1,2,3,4]
--   
--   
--   
--   >>> sequence $ [Left 0, Right 1,Right 2,Right 3,Right 4]
--   Left 0
--   
sequence :: (Traversable t, Monad m) => t (m a) -> m (t a)

-- | Map each element of a structure to a monadic action, evaluate these
--   actions from left to right, and collect the results. For a version
--   that ignores the results see mapM_.
--   
--   
Examples
--   
--   mapM is literally a traverse with a type signature
--   restricted to Monad. Its implementation may be more efficient
--   due to additional power of Monad.
mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b)

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

-- | Promote a function to a monad, scanning the monadic arguments from
--   left to right (cf. liftM2).
liftM3 :: Monad m => (a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r

-- | Promote a function to a monad, scanning the monadic arguments from
--   left to right (cf. liftM2).
liftM4 :: Monad m => (a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r

-- | Promote a function to a monad, scanning the monadic arguments from
--   left to right (cf. liftM2).
liftM5 :: Monad m => (a1 -> a2 -> a3 -> a4 -> a5 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m a5 -> m r

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

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

-- | The sum of a collection of actions using (<|>),
--   generalizing concat.
--   
--   msum is just like asum, but specialised to
--   MonadPlus.
--   
--   
Examples
--   
--   Basic usage, using the MonadPlus instance for Maybe:
--   
--   
--   >>> msum [Just "Hello", Nothing, Just "World"]
--   Just "Hello"
--   
msum :: (Foldable t, MonadPlus m) => t (m a) -> m a

-- | forM is mapM with its arguments flipped. For a version
--   that ignores the results see forM_.
forM :: (Traversable t, Monad m) => t a -> (a -> m b) -> m (t b)

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

-- | Left-to-right composition of Kleisli arrows.
--   
--   '(bs >=> cs) a' can be understood as the
--   do expression
--   
--   
--   do b <- bs a
--      cs b
--   
--   
--   or in terms of (>>=) as
--   
--   
--   bs a >>= cs
--   
(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
infixr 1 >=>

-- | Right-to-left composition of Kleisli arrows.
--   (>=>), with the arguments flipped.
--   
--   Note how this operator resembles function composition
--   (.):
--   
--   
--   (.)   ::            (b ->   c) -> (a ->   b) -> a ->   c
--   (<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
--   
(<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
infixr 1 <=<

-- | Repeat an action indefinitely.
--   
--   
Examples
--   
--   A common use of forever is to process input from network
--   sockets, Handles, and channels (e.g. MVar and
--   Chan).
--   
--   For example, here is how we might implement an echo server,
--   using forever both to listen for client connections on a
--   network socket and to echo client input on client connection handles:
--   
--   
--   echoServer :: Socket -> IO ()
--   echoServer socket = forever $ do
--     client <- accept socket
--     forkFinally (echo client) (\_ -> hClose client)
--     where
--       echo :: Handle -> IO ()
--       echo client = forever $
--         hGetLine client >>= hPutStrLn client
--   
--   
--   Note that "forever" isn't necessarily non-terminating. If the action
--   is in a MonadPlus and short-circuits after some number
--   of iterations. then forever actually returns
--   mzero, effectively short-circuiting its caller.
forever :: Applicative f => f a -> f b

-- | The mapAndUnzipM function maps its first argument over a list,
--   returning the result as a pair of lists. This function is mainly used
--   with complicated data structures or a state monad.
mapAndUnzipM :: Applicative m => (a -> m (b, c)) -> [a] -> m ([b], [c])

-- | The zipWithM function generalizes zipWith to arbitrary
--   applicative functors.
zipWithM :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m [c]

-- | zipWithM_ is the extension of zipWithM which ignores the
--   final result.
zipWithM_ :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m ()

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

-- | Like foldM, but discards the result.
foldM_ :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m ()

-- | replicateM n act performs the action act
--   n times, and then returns the list of results.
--   
--   
--   replicateM n (pure x) == replicate n x
--   
--   
--   
Examples
--   
--   
--   >>> replicateM 3 getLine
--   hi
--   heya
--   hiya
--   ["hi","heya","hiya"]
--   
--   
--   
--   >>> import Control.Monad.State
--   
--   >>> runState (replicateM 3 $ state $ \s -> (s, s + 1)) 1
--   ([1,2,3],4)
--   
replicateM :: Applicative m => Int -> m a -> m [a]

-- | Like replicateM, but discards the result.
--   
--   
Examples
--   
--   
--   >>> replicateM_ 3 (putStr "a")
--   aaa
--   
replicateM_ :: Applicative m => Int -> m a -> m ()

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

-- | Strict version of <$>.
(<$!>) :: Monad m => (a -> b) -> m a -> m b
infixl 4 <$!>

-- | Direct MonadPlus equivalent of filter.
--   
--   
Examples
--   
--   The filter function is just mfilter specialized to the
--   list monad:
--   
--   
--   filter = ( mfilter :: (a -> Bool) -> [a] -> [a] )
--   
--   
--   An example using mfilter with the Maybe monad:
--   
--   
--   >>> mfilter odd (Just 1)
--   Just 1
--   
--   >>> mfilter odd (Just 2)
--   Nothing
--   
mfilter :: MonadPlus m => (a -> Bool) -> m a -> m 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]

-- | <math>. delete x removes the first occurrence of
--   x from its list argument.
--   
--   It is a special case of deleteBy, which allows the programmer
--   to supply their own equality test.
--   
--   
Examples
--   
--   
--   >>> delete 'a' "banana"
--   "bnana"
--   
--   
--   
--   >>> delete "not" ["haskell", "is", "not", "awesome"]
--   ["haskell","is","awesome"]
--   
delete :: Eq a => a -> [a] -> [a]

-- | The builtin linked list type.
--   
--   In Haskell, lists are one of the most important data types as they are
--   often used analogous to loops in imperative programming languages.
--   These lists are singly linked, which makes them unsuited for
--   operations that require <math> access. Instead, they are
--   intended to be traversed.
--   
--   You can use List a or [a] in type signatures:
--   
--   
--   length :: [a] -> Int
--   
--   
--   or
--   
--   
--   length :: List a -> Int
--   
--   
--   They are fully equivalent, and List a will be normalised to
--   [a].
--   
--   
Usage
--   
--   Lists are constructed recursively using the right-associative
--   constructor operator (or cons) (:) :: a -> [a] ->
--   [a], which prepends an element to a list, and the empty list
--   [].
--   
--   
--   (1 : 2 : 3 : []) == (1 : (2 : (3 : []))) == [1, 2, 3]
--   
--   
--   Lists can also be constructed using list literals of the form
--   [x_1, x_2, ..., x_n] which are syntactic sugar and, unless
--   -XOverloadedLists is enabled, are translated into uses of
--   (:) and []
--   
--   String literals, like "I 💜 hs", are translated into
--   Lists of characters, ['I', ' ', '💜', ' ', 'h', 's'].
--   
--   
Implementation
--   
--   Internally and in memory, all the above are represented like this,
--   with arrows being pointers to locations in memory.
--   
--   
--   ╭───┬───┬──╮   ╭───┬───┬──╮   ╭───┬───┬──╮   ╭────╮
--   │(:)│   │ ─┼──>│(:)│   │ ─┼──>│(:)│   │ ─┼──>│ [] │
--   ╰───┴─┼─┴──╯   ╰───┴─┼─┴──╯   ╰───┴─┼─┴──╯   ╰────╯
--         v              v              v
--         1              2              3
--   
--   
--   
Examples
--   
--   
--   >>> ['H', 'a', 's', 'k', 'e', 'l', 'l']
--   "Haskell"
--   
--   
--   
--   >>> 1 : [4, 1, 5, 9]
--   [1,4,1,5,9]
--   
--   
--   
--   >>> [] : [] : []
--   [[],[]]
--   
data [] a

-- | (++) 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-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 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

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

-- | A variant of foldr that has no base case, and thus may only be
--   applied to non-empty structures.
--   
--   This function is non-total and will raise a runtime exception if the
--   structure happens to be empty.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> foldr1 (+) [1..4]
--   10
--   
--   
--   
--   >>> foldr1 (+) []
--   Exception: Prelude.foldr1: empty list
--   
--   
--   
--   >>> foldr1 (+) Nothing
--   *** Exception: foldr1: empty structure
--   
--   
--   
--   >>> foldr1 (-) [1..4]
--   -2
--   
--   
--   
--   >>> foldr1 (&&) [True, False, True, True]
--   False
--   
--   
--   
--   >>> foldr1 (||) [False, False, True, True]
--   True
--   
--   
--   
--   >>> foldr1 (+) [1..]
--   * Hangs forever *
--   
foldr1 :: Foldable t => (a -> a -> a) -> t a -> a

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

-- | 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
infix 4 `elem`

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

-- | List index (subscript) operator, starting from 0. Returns
--   Nothing if the index is out of bounds
--   
--   This is the total variant of the partial !! operator.
--   
--   WARNING: This function takes linear time in the index.
--   
--   
Examples
--   
--   
--   >>> ['a', 'b', 'c'] !? 0
--   Just 'a'
--   
--   
--   
--   >>> ['a', 'b', 'c'] !? 2
--   Just 'c'
--   
--   
--   
--   >>> ['a', 'b', 'c'] !? 3
--   Nothing
--   
--   
--   
--   >>> ['a', 'b', 'c'] !? (-1)
--   Nothing
--   
(!?) :: [a] -> Int -> Maybe a
infixl 9 !?

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

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

-- | Sort a list by comparing the results of a key function applied to each
--   element. sortOn f is equivalent to sortBy
--   (comparing f), but has the performance advantage of only
--   evaluating f once for each element in the input list. This is
--   called the decorate-sort-undecorate paradigm, or Schwartzian
--   transform.
--   
--   Elements are arranged from lowest to highest, keeping duplicates in
--   the order they appeared in the input.
--   
--   The argument must be finite.
--   
--   
Examples
--   
--   
--   >>> sortOn fst [(2, "world"), (4, "!"), (1, "Hello")]
--   [(1,"Hello"),(2,"world"),(4,"!")]
--   
--   
--   
--   >>> sortOn length ["jim", "creed", "pam", "michael", "dwight", "kevin"]
--   ["jim","pam","creed","kevin","dwight","michael"]
--   
--   
--   
Performance notes
--   
--   This function minimises the projections performed, by materialising
--   the projections in an intermediate list.
--   
--   For trivial projections, you should prefer using sortBy with
--   comparing, for example:
--   
--   
--   >>> sortBy (comparing fst) [(3, 1), (2, 2), (1, 3)]
--   [(1,3),(2,2),(3,1)]
--   
--   
--   Or, for the exact same API as sortOn, you can use `sortBy .
--   comparing`:
--   
--   
--   >>> (sortBy . comparing) fst [(3, 1), (2, 2), (1, 3)]
--   [(1,3),(2,2),(3,1)]
--   
sortOn :: Ord b => (a -> b) -> [a] -> [a]

-- | The transpose function transposes the rows and columns of its
--   argument.
--   
--   
Laziness
--   
--   transpose is lazy in its elements
--   
--   
--   >>> take 1 (transpose ['a' : undefined, 'b' : undefined])
--   ["ab"]
--   
--   
--   
Examples
--   
--   
--   >>> transpose [[1,2,3],[4,5,6]]
--   [[1,4],[2,5],[3,6]]
--   
--   
--   If some of the rows are shorter than the following rows, their
--   elements are skipped:
--   
--   
--   >>> transpose [[10,11],[20],[],[30,31,32]]
--   [[10,20,30],[11,31],[32]]
--   
--   
--   For this reason the outer list must be finite; otherwise
--   transpose hangs:
--   
--   
--   >>> transpose (repeat [])
--   * Hangs forever *
--   
transpose :: [[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]

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

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

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

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

-- | <math>. Extract the first element of a list, which must be
--   non-empty.
--   
--   To disable the warning about partiality put {-# OPTIONS_GHC
--   -Wno-x-partial -Wno-unrecognised-warning-flags #-} at the top of
--   the file. To disable it throughout a package put the same options into
--   ghc-options section of Cabal file. To disable it in GHCi put
--   :set -Wno-x-partial -Wno-unrecognised-warning-flags into
--   ~/.ghci config file. See also the migration guide.
--   
--   
Examples
--   
--   
--   >>> head [1, 2, 3]
--   1
--   
--   
--   
--   >>> head [1..]
--   1
--   
--   
--   
--   >>> head []
--   *** Exception: Prelude.head: empty list
--   
head :: HasCallStack => [a] -> a

-- | <math>. Decompose a list into its head and tail.
--   
--   
--   
- If the list is empty, returns Nothing.
--   
- If the list is non-empty, returns Just (x, xs),
--   where x is the head of the list and xs its
--   tail.
--   
--   
--   
Examples
--   
--   
--   >>> uncons []
--   Nothing
--   
--   
--   
--   >>> uncons [1]
--   Just (1,[])
--   
--   
--   
--   >>> uncons [1, 2, 3]
--   Just (1,[2,3])
--   
uncons :: [a] -> Maybe (a, [a])

-- | <math>. Decompose a list into init and last.
--   
--   
--   
- If the list is empty, returns Nothing.
--   
- If the list is non-empty, returns Just (xs, x),
--   where xs is the initial part of the list and
--   x is its last element.
--   
--   
--   unsnoc is dual to uncons: for a finite list xs
--   
--   
--   unsnoc xs = (\(hd, tl) -> (reverse tl, hd)) <$> uncons (reverse xs)
--   
--   
--   
Examples
--   
--   
--   >>> unsnoc []
--   Nothing
--   
--   
--   
--   >>> unsnoc [1]
--   Just ([],1)
--   
--   
--   
--   >>> unsnoc [1, 2, 3]
--   Just ([1,2],3)
--   
--   
--   
Laziness
--   
--   
--   >>> fst <$> unsnoc [undefined]
--   Just []
--   
--   
--   
--   >>> head . fst <$> unsnoc (1 : undefined)
--   Just *** Exception: Prelude.undefined
--   
--   
--   
--   >>> head . fst <$> unsnoc (1 : 2 : undefined)
--   Just 1
--   
unsnoc :: [a] -> Maybe ([a], a)

-- | <math>. Extract the elements after the head of a list, which
--   must be non-empty.
--   
--   To disable the warning about partiality put {-# OPTIONS_GHC
--   -Wno-x-partial -Wno-unrecognised-warning-flags #-} at the top of
--   the file. To disable it throughout a package put the same options into
--   ghc-options section of Cabal file. To disable it in GHCi put
--   :set -Wno-x-partial -Wno-unrecognised-warning-flags into
--   ~/.ghci config file. See also the migration guide.
--   
--   
Examples
--   
--   
--   >>> tail [1, 2, 3]
--   [2,3]
--   
--   
--   
--   >>> tail [1]
--   []
--   
--   
--   
--   >>> tail []
--   *** Exception: Prelude.tail: empty list
--   
tail :: HasCallStack => [a] -> [a]

-- | <math>. Extract the last element of a list, which must be finite
--   and non-empty.
--   
--   WARNING: This function is partial. Consider using unsnoc
--   instead.
--   
--   
Examples
--   
--   
--   >>> last [1, 2, 3]
--   3
--   
--   
--   
--   >>> last [1..]
--   * Hangs forever *
--   
--   
--   
--   >>> last []
--   *** Exception: Prelude.last: empty list
--   
last :: HasCallStack => [a] -> a

-- | <math>. Return all the elements of a list except the last one.
--   The list must be non-empty.
--   
--   WARNING: This function is partial. Consider using unsnoc
--   instead.
--   
--   
Examples
--   
--   
--   >>> init [1, 2, 3]
--   [1,2]
--   
--   
--   
--   >>> init [1]
--   []
--   
--   
--   
--   >>> init []
--   *** Exception: Prelude.init: empty list
--   
init :: HasCallStack => [a] -> [a]

-- | A strict version of foldl1.
foldl1' :: HasCallStack => (a -> a -> a) -> [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>. A strict version of scanl.
scanl' :: (b -> a -> b) -> b -> [a] -> [b]

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

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

-- | iterate' is the strict version of iterate.
--   
--   It forces the result of each application of the function to weak head
--   normal form (WHNF) before proceeding.
--   
--   
--   >>> take 1 $ iterate' undefined 42
--   *** Exception: Prelude.undefined
--   
iterate' :: (a -> a) -> a -> [a]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

-- | The largest element of a non-empty structure with respect to the given
--   comparison function.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> maximumBy (compare `on` length) ["Hello", "World", "!", "Longest", "bar"]
--   "Longest"
--   
--   
--   WARNING: This function is partial for possibly-empty structures like
--   lists.
maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a

-- | The least element of a non-empty structure with respect to the given
--   comparison function.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> minimumBy (compare `on` length) ["Hello", "World", "!", "Longest", "bar"]
--   "!"
--   
--   
--   WARNING: This function is partial for possibly-empty structures like
--   lists.
minimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a

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

-- | 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 stripPrefix function drops the given prefix
--   from a list. It returns Nothing if the list did not start with
--   the prefix given, or Just the list after the prefix, if it
--   does.
--   
--   
Examples
--   
--   
--   >>> stripPrefix "foo" "foobar"
--   Just "bar"
--   
--   
--   
--   >>> stripPrefix "foo" "foo"
--   Just ""
--   
--   
--   
--   >>> stripPrefix "foo" "barfoo"
--   Nothing
--   
--   
--   
--   >>> stripPrefix "foo" "barfoobaz"
--   Nothing
--   
stripPrefix :: Eq a => [a] -> [a] -> Maybe [a]

-- | The elemIndex function returns the index of the first element
--   in the given list which is equal (by ==) to the query element,
--   or Nothing if there is no such element. For the result to be
--   Nothing, the list must be finite.
--   
--   
Examples
--   
--   
--   >>> elemIndex 4 [0..]
--   Just 4
--   
--   
--   
--   >>> elemIndex 'o' "haskell"
--   Nothing
--   
--   
--   
--   >>> elemIndex 0 [1..]
--   * hangs forever *
--   
elemIndex :: Eq a => a -> [a] -> Maybe Int

-- | The elemIndices function extends elemIndex, by returning
--   the indices of all elements equal to the query element, in ascending
--   order.
--   
--   
Examples
--   
--   
--   >>> elemIndices 'o' "Hello World"
--   [4,7]
--   
--   
--   
--   >>> elemIndices 1 [1, 2, 3, 1, 2, 3]
--   [0,3]
--   
elemIndices :: Eq a => a -> [a] -> [Int]

-- | The findIndex function takes a predicate and a list and returns
--   the index of the first element in the list satisfying the predicate,
--   or Nothing if there is no such element. For the result to be
--   Nothing, the list must be finite.
--   
--   
Examples
--   
--   
--   >>> findIndex isSpace "Hello World!"
--   Just 5
--   
--   
--   
--   >>> findIndex odd [0, 2, 4, 6]
--   Nothing
--   
--   
--   
--   >>> findIndex even [1..]
--   Just 1
--   
--   
--   
--   >>> findIndex odd [0, 2 ..]
--   * hangs forever *
--   
findIndex :: (a -> Bool) -> [a] -> Maybe Int

-- | The findIndices function extends findIndex, by returning
--   the indices of all elements satisfying the predicate, in ascending
--   order.
--   
--   
Examples
--   
--   
--   >>> findIndices (`elem` "aeiou") "Hello World!"
--   [1,4,7]
--   
--   
--   
--   >>> findIndices (\l -> length l > 3) ["a", "bcde", "fgh", "ijklmnop"]
--   [1,3]
--   
findIndices :: (a -> Bool) -> [a] -> [Int]

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

-- | The isInfixOf function takes two lists and returns True
--   iff the first list is contained, wholly and intact, anywhere within
--   the second.
--   
--   
Examples
--   
--   
--   >>> isInfixOf "Haskell" "I really like Haskell."
--   True
--   
--   
--   
--   >>> isInfixOf "Ial" "I really like Haskell."
--   False
--   
--   
--   For the result to be True, the first list must be finite; for
--   the result to be False, the second list must be finite:
--   
--   
--   >>> [20..50] `isInfixOf` [0..]
--   True
--   
--   
--   
--   >>> [0..] `isInfixOf` [20..50]
--   False
--   
--   
--   
--   >>> [0..] `isInfixOf` [0..]
--   * Hangs forever *
--   
isInfixOf :: Eq a => [a] -> [a] -> Bool

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

-- | <math>. The deleteBy function behaves like delete,
--   but takes a user-supplied equality predicate.
--   
--   
Examples
--   
--   
--   >>> deleteBy (<=) 4 [1..10]
--   [1,2,3,5,6,7,8,9,10]
--   
--   
--   
--   >>> deleteBy (/=) 5 [5, 5, 4, 3, 5, 2]
--   [5,5,3,5,2]
--   
deleteBy :: (a -> a -> Bool) -> a -> [a] -> [a]

-- | The \\ function is list difference (non-associative). In the
--   result of xs \\ ys, the first occurrence of
--   each element of ys in turn (if any) has been removed from
--   xs. Thus (xs ++ ys) \\ xs == ys.
--   
--   It is a special case of deleteFirstsBy, which allows the
--   programmer to supply their own equality test.
--   
--   
Examples
--   
--   
--   >>> "Hello World!" \\ "ell W"
--   "Hoorld!"
--   
--   
--   The second list must be finite, but the first may be infinite.
--   
--   
--   >>> take 5 ([0..] \\ [2..4])
--   [0,1,5,6,7]
--   
--   
--   
--   >>> take 5 ([0..] \\ [2..])
--   * Hangs forever *
--   
(\\) :: Eq a => [a] -> [a] -> [a]
infix 5 \\

-- | The union function returns the list union of the two lists. It
--   is a special case of unionBy, which allows the programmer to
--   supply their own equality test.
--   
--   
Examples
--   
--   
--   >>> "dog" `union` "cow"
--   "dogcw"
--   
--   
--   If equal elements are present in both lists, an element from the first
--   list will be used. If the second list contains equal elements, only
--   the first one will be retained:
--   
--   
--   >>> import Data.Semigroup(Arg(..))
--   
--   >>> union [Arg () "dog"] [Arg () "cow"]
--   [Arg () "dog"]
--   
--   >>> union [] [Arg () "dog", Arg () "cow"]
--   [Arg () "dog"]
--   
--   
--   However if the first list contains duplicates, so will the result:
--   
--   
--   >>> "coot" `union` "duck"
--   "cootduk"
--   
--   >>> "duck" `union` "coot"
--   "duckot"
--   
--   
--   union is productive even if both arguments are infinite.
--   
--   
--   >>> [0, 2 ..] `union` [1, 3 ..]
--   [0,2,4,6,8,10,12..
--   
union :: Eq a => [a] -> [a] -> [a]

-- | The unionBy function is the non-overloaded version of
--   union. Both arguments may be infinite.
--   
--   
Examples
--   
--   
--   >>> unionBy (>) [3, 4, 5] [1, 2, 3, 4, 5, 6]
--   [3,4,5,4,5,6]
--   
--   
--   
--   >>> import Data.Semigroup (Arg(..))
--   
--   >>> unionBy (/=) [Arg () "Saul"] [Arg () "Kim"]
--   [Arg () "Saul", Arg () "Kim"]
--   
unionBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]

-- | The intersect function takes the list intersection of two
--   lists. It is a special case of intersectBy, which allows the
--   programmer to supply their own equality test.
--   
--   
Examples
--   
--   
--   >>> [1,2,3,4] `intersect` [2,4,6,8]
--   [2,4]
--   
--   
--   If equal elements are present in both lists, an element from the first
--   list will be used, and all duplicates from the second list quashed:
--   
--   
--   >>> import Data.Semigroup
--   
--   >>> intersect [Arg () "dog"] [Arg () "cow", Arg () "cat"]
--   [Arg () "dog"]
--   
--   
--   However if the first list contains duplicates, so will the result.
--   
--   
--   >>> "coot" `intersect` "heron"
--   "oo"
--   
--   >>> "heron" `intersect` "coot"
--   "o"
--   
--   
--   If the second list is infinite, intersect either hangs or
--   returns its first argument in full. Otherwise if the first list is
--   infinite, intersect might be productive:
--   
--   
--   >>> intersect [100..] [0..]
--   [100,101,102,103...
--   
--   >>> intersect [0] [1..]
--   * Hangs forever *
--   
--   >>> intersect [1..] [0]
--   * Hangs forever *
--   
--   >>> intersect (cycle [1..3]) [2]
--   [2,2,2,2...
--   
intersect :: Eq a => [a] -> [a] -> [a]

-- | The intersectBy function is the non-overloaded version of
--   intersect. It is productive for infinite arguments only if the
--   first one is a subset of the second.
intersectBy :: (a -> a -> Bool) -> [a] -> [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]

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

-- | <math>. The insert function takes an element and a list
--   and inserts the element into the list at the first position where it
--   is less than or equal to the next element. In particular, if the list
--   is sorted before the call, the result will also be sorted. It is a
--   special case of insertBy, which allows the programmer to supply
--   their own comparison function.
--   
--   
Examples
--   
--   
--   >>> insert (-1) [1, 2, 3]
--   [-1,1,2,3]
--   
--   
--   
--   >>> insert 'd' "abcefg"
--   "abcdefg"
--   
--   
--   
--   >>> insert 4 [1, 2, 3, 5, 6, 7]
--   [1,2,3,4,5,6,7]
--   
insert :: Ord a => a -> [a] -> [a]

-- | <math>. The non-overloaded version of insert.
--   
--   
Examples
--   
--   
--   >>> insertBy (\x y -> compare (length x) (length y)) [1, 2] [[1], [1, 2, 3], [1, 2, 3, 4]]
--   [[1],[1,2],[1,2,3],[1,2,3,4]]
--   
insertBy :: (a -> a -> Ordering) -> a -> [a] -> [a]

-- | <math>. The genericLength function is an overloaded
--   version of length. In particular, instead of returning an
--   Int, it returns any type which is an instance of Num. It
--   is, however, less efficient than length.
--   
--   
Examples
--   
--   
--   >>> genericLength [1, 2, 3] :: Int
--   3
--   
--   >>> genericLength [1, 2, 3] :: Float
--   3.0
--   
--   
--   Users should take care to pick a return type that is wide enough to
--   contain the full length of the list. If the width is insufficient, the
--   overflow behaviour will depend on the (+) implementation in
--   the selected Num instance. The following example overflows
--   because the actual list length of 200 lies outside of the
--   Int8 range of -128..127.
--   
--   
--   >>> genericLength [1..200] :: Int8
--   -56
--   
genericLength :: Num i => [a] -> i

-- | The genericTake function is an overloaded version of
--   take, which accepts any Integral value as the number of
--   elements to take.
genericTake :: Integral i => i -> [a] -> [a]

-- | The genericDrop function is an overloaded version of
--   drop, which accepts any Integral value as the number of
--   elements to drop.
genericDrop :: Integral i => i -> [a] -> [a]

-- | The genericSplitAt function is an overloaded version of
--   splitAt, which accepts any Integral value as the
--   position at which to split.
genericSplitAt :: Integral i => i -> [a] -> ([a], [a])

-- | The genericIndex function is an overloaded version of
--   !!, which accepts any Integral value as the index.
genericIndex :: Integral i => [a] -> i -> a

-- | The genericReplicate function is an overloaded version of
--   replicate, which accepts any Integral value as the
--   number of repetitions to make.
genericReplicate :: Integral i => i -> a -> [a]

-- | The zip4 function takes four lists and returns a list of
--   quadruples, analogous to zip. It is capable of list fusion, but
--   it is restricted to its first list argument and its resulting list.
zip4 :: [a] -> [b] -> [c] -> [d] -> [(a, b, c, d)]

-- | The zip5 function takes five lists and returns a list of
--   five-tuples, analogous to zip. It is capable of list fusion,
--   but it is restricted to its first list argument and its resulting
--   list.
zip5 :: [a] -> [b] -> [c] -> [d] -> [e] -> [(a, b, c, d, e)]

-- | The zip6 function takes six lists and returns a list of
--   six-tuples, analogous to zip. It is capable of list fusion, but
--   it is restricted to its first list argument and its resulting list.
zip6 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [(a, b, c, d, e, f)]

-- | The zip7 function takes seven lists and returns a list of
--   seven-tuples, analogous to zip. It is capable of list fusion,
--   but it is restricted to its first list argument and its resulting
--   list.
zip7 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [(a, b, c, d, e, f, g)]

-- | The zipWith4 function takes a function which combines four
--   elements, as well as four lists and returns a list of their point-wise
--   combination, analogous to zipWith. It is capable of list
--   fusion, but it is restricted to its first list argument and its
--   resulting list.
zipWith4 :: (a -> b -> c -> d -> e) -> [a] -> [b] -> [c] -> [d] -> [e]

-- | The zipWith5 function takes a function which combines five
--   elements, as well as five lists and returns a list of their point-wise
--   combination, analogous to zipWith. It is capable of list
--   fusion, but it is restricted to its first list argument and its
--   resulting list.
zipWith5 :: (a -> b -> c -> d -> e -> f) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f]

-- | The zipWith6 function takes a function which combines six
--   elements, as well as six lists and returns a list of their point-wise
--   combination, analogous to zipWith. It is capable of list
--   fusion, but it is restricted to its first list argument and its
--   resulting list.
zipWith6 :: (a -> b -> c -> d -> e -> f -> g) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g]

-- | The zipWith7 function takes a function which combines seven
--   elements, as well as seven lists and returns a list of their
--   point-wise combination, analogous to zipWith. It is capable of
--   list fusion, but it is restricted to its first list argument and its
--   resulting list.
zipWith7 :: (a -> b -> c -> d -> e -> f -> g -> h) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [h]

-- | The unzip4 function takes a list of quadruples and returns four
--   lists, analogous to unzip.
unzip4 :: [(a, b, c, d)] -> ([a], [b], [c], [d])

-- | The unzip5 function takes a list of five-tuples and returns
--   five lists, analogous to unzip.
unzip5 :: [(a, b, c, d, e)] -> ([a], [b], [c], [d], [e])

-- | The unzip6 function takes a list of six-tuples and returns six
--   lists, analogous to unzip.
unzip6 :: [(a, b, c, d, e, f)] -> ([a], [b], [c], [d], [e], [f])

-- | The unzip7 function takes a list of seven-tuples and returns
--   seven lists, analogous to unzip.
unzip7 :: [(a, b, c, d, e, f, g)] -> ([a], [b], [c], [d], [e], [f], [g])

-- | The deleteFirstsBy function takes a predicate and two lists and
--   returns the first list with the first occurrence of each element of
--   the second list removed. This is the non-overloaded version of
--   (\\).
--   
--   
--   (\\) == deleteFirstsBy (==)
--   
--   
--   The second list must be finite, but the first may be infinite.
--   
--   
Examples
--   
--   
--   >>> deleteFirstsBy (>) [1..10] [3, 4, 5]
--   [4,5,6,7,8,9,10]
--   
--   
--   
--   >>> deleteFirstsBy (/=) [1..10] [1, 3, 5]
--   [4,5,6,7,8,9,10]
--   
deleteFirstsBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]

-- | The group function takes a list and returns a list of lists
--   such that the concatenation of the result is equal to the argument.
--   Moreover, each sublist in the result is non-empty, all elements are
--   equal to the first one, and consecutive equal elements of the input
--   end up in the same element of the output list.
--   
--   group is a special case of groupBy, which allows the
--   programmer to supply their own equality test.
--   
--   It's often preferable to use Data.List.NonEmpty.group,
--   which provides type-level guarantees of non-emptiness of inner lists.
--   A common idiom to squash repeating elements map head
--   . group is better served by map
--   Data.List.NonEmpty.head .
--   Data.List.NonEmpty.group because it avoids partial
--   functions.
--   
--   
Examples
--   
--   
--   >>> group "Mississippi"
--   ["M","i","ss","i","ss","i","pp","i"]
--   
--   
--   
--   >>> group [1, 1, 1, 2, 2, 3, 4, 5, 5]
--   [[1,1,1],[2,2],[3],[4],[5,5]]
--   
group :: Eq a => [a] -> [[a]]

-- | The groupBy function is the non-overloaded version of
--   group.
--   
--   When a supplied relation is not transitive, it is important to
--   remember that equality is checked against the first element in the
--   group, not against the nearest neighbour:
--   
--   
--   >>> groupBy (\a b -> b - a < 5) [0..19]
--   [[0,1,2,3,4],[5,6,7,8,9],[10,11,12,13,14],[15,16,17,18,19]]
--   
--   
--   It's often preferable to use
--   Data.List.NonEmpty.groupBy, which provides type-level
--   guarantees of non-emptiness of inner lists.
--   
--   
Examples
--   
--   
--   >>> groupBy (/=) [1, 1, 1, 2, 3, 1, 4, 4, 5]
--   [[1],[1],[1,2,3],[1,4,4,5]]
--   
--   
--   
--   >>> groupBy (>) [1, 3, 5, 1, 4, 2, 6, 5, 4]
--   [[1],[3],[5,1,4,2],[6,5,4]]
--   
--   
--   
--   >>> groupBy (const not) [True, False, True, False, False, False, True]
--   [[True,False],[True,False,False,False],[True]]
--   
groupBy :: (a -> a -> Bool) -> [a] -> [[a]]

-- | The inits function returns all initial segments of the
--   argument, shortest first.
--   
--   inits is semantically equivalent to map
--   reverse . scanl (flip (:)) [], but under the
--   hood uses a queue to amortize costs of reverse.
--   
--   
Laziness
--   
--   Note that inits has the following strictness property:
--   inits (xs ++ _|_) = inits xs ++ _|_
--   
--   In particular, inits _|_ = [] : _|_
--   
--   
Examples
--   
--   
--   >>> inits "abc"
--   ["","a","ab","abc"]
--   
--   
--   
--   >>> inits []
--   [[]]
--   
--   
--   inits is productive on infinite lists:
--   
--   
--   >>> take 5 $ inits [1..]
--   [[],[1],[1,2],[1,2,3],[1,2,3,4]]
--   
inits :: [a] -> [[a]]

-- | <math>. The tails function returns all final segments of
--   the argument, longest first.
--   
--   
Laziness
--   
--   Note that tails has the following strictness property:
--   tails _|_ = _|_ : _|_
--   
--   
--   >>> tails undefined
--   [*** Exception: Prelude.undefined
--   
--   
--   
--   >>> drop 1 (tails [undefined, 1, 2])
--   [[1, 2], [2], []]
--   
--   
--   
Examples
--   
--   
--   >>> tails "abc"
--   ["abc","bc","c",""]
--   
--   
--   
--   >>> tails [1, 2, 3]
--   [[1,2,3],[2,3],[3],[]]
--   
--   
--   
--   >>> tails []
--   [[]]
--   
tails :: [a] -> [[a]]

-- | The subsequences function returns the list of all subsequences
--   of the argument.
--   
--   
Laziness
--   
--   subsequences does not look ahead unless it must:
--   
--   
--   >>> take 1 (subsequences undefined)
--   [[]]
--   
--   >>> take 2 (subsequences ('a' : undefined))
--   ["","a"]
--   
--   
--   
Examples
--   
--   
--   >>> subsequences "abc"
--   ["","a","b","ab","c","ac","bc","abc"]
--   
--   
--   This function is productive on infinite inputs:
--   
--   
--   >>> take 8 $ subsequences ['a'..]
--   ["","a","b","ab","c","ac","bc","abc"]
--   
subsequences :: [a] -> [[a]]

-- | The permutations function returns the list of all permutations
--   of the argument.
--   
--   Note that the order of permutations is not lexicographic. It satisfies
--   the following property:
--   
--   
--   map (take n) (take (product [1..n]) (permutations ([1..n] ++ undefined))) == permutations [1..n]
--   
--   
--   
Laziness
--   
--   The permutations function is maximally lazy: for each
--   n, the value of permutations xs starts with
--   those permutations that permute take n xs and keep
--   drop n xs.
--   
--   
Examples
--   
--   
--   >>> permutations "abc"
--   ["abc","bac","cba","bca","cab","acb"]
--   
--   
--   
--   >>> permutations [1, 2]
--   [[1,2],[2,1]]
--   
--   
--   
--   >>> permutations []
--   [[]]
--   
--   
--   This function is productive on infinite inputs:
--   
--   
--   >>> take 6 $ map (take 3) $ permutations ['a'..]
--   ["abc","bac","cba","bca","cab","acb"]
--   
permutations :: [a] -> [[a]]

-- | Construct a list from a single element.
--   
--   
Examples
--   
--   
--   >>> singleton True
--   [True]
--   
--   
--   
--   >>> singleton [1, 2, 3]
--   [[1,2,3]]
--   
--   
--   
--   >>> singleton 'c'
--   "c"
--   
singleton :: a -> [a]

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

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

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

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

-- | The mapAccumL function behaves like a combination of
--   fmap and foldl; it applies a function to each element of
--   a structure, passing an accumulating parameter from left to right, and
--   returning a final value of this accumulator together with the new
--   structure.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> mapAccumL (\a b -> (a + b, a)) 0 [1..10]
--   (55,[0,1,3,6,10,15,21,28,36,45])
--   
--   
--   
--   >>> mapAccumL (\a b -> (a <> show b, a)) "0" [1..5]
--   ("012345",["0","01","012","0123","01234"])
--   
mapAccumL :: Traversable t => (s -> a -> (s, b)) -> s -> t a -> (s, t b)

-- | The mapAccumR function behaves like a combination of
--   fmap and foldr; it applies a function to each element of
--   a structure, passing an accumulating parameter from right to left, and
--   returning a final value of this accumulator together with the new
--   structure.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> mapAccumR (\a b -> (a + b, a)) 0 [1..10]
--   (55,[54,52,49,45,40,34,27,19,10,0])
--   
--   
--   
--   >>> mapAccumR (\a b -> (a <> show b, a)) "0" [1..5]
--   ("054321",["05432","0543","054","05","0"])
--   
mapAccumR :: Traversable t => (s -> a -> (s, b)) -> s -> t a -> (s, t b)

-- | The isSubsequenceOf function takes two lists and returns
--   True if all the elements of the first list occur, in order, in
--   the second. The elements do not have to occur consecutively.
--   
--   isSubsequenceOf x y is equivalent to x
--   `<a>elem</a>` (subsequences y).
--   
--   Note: isSubsequenceOf is often used in infix form.
--   
--   
Examples
--   
--   
--   >>> "GHC" `isSubsequenceOf` "The Glorious Haskell Compiler"
--   True
--   
--   
--   
--   >>> ['a','d'..'z'] `isSubsequenceOf` ['a'..'z']
--   True
--   
--   
--   
--   >>> [1..10] `isSubsequenceOf` [10,9..0]
--   False
--   
--   
--   For the result to be True, the first list must be finite; for
--   the result to be False, the second list must be finite:
--   
--   
--   >>> [0,2..10] `isSubsequenceOf` [0..]
--   True
--   
--   
--   
--   >>> [0..] `isSubsequenceOf` [0,2..10]
--   False
--   
--   
--   
--   >>> [0,2..] `isSubsequenceOf` [0..]
--   * Hangs forever*
--   
isSubsequenceOf :: Eq a => [a] -> [a] -> Bool

-- | The inits1 function returns all non-empty initial segments of
--   the argument, shortest first.
--   
--   
Laziness
--   
--   Note that inits1 has the following strictness property:
--   inits1 (xs ++ _|_) = inits1 xs ++ _|_
--   
--   In particular, inits1 _|_ = _|_
--   
--   
Examples
--   
--   
--   >>> inits1 "abc"
--   ['a' :| "",'a' :| "b",'a' :| "bc"]
--   
--   
--   
--   >>> inits1 []
--   []
--   
--   
--   inits1 is productive on infinite lists:
--   
--   
--   >>> take 3 $ inits1 [1..]
--   [1 :| [],1 :| [2],1 :| [2,3]]
--   
inits1 :: [a] -> [NonEmpty a]

-- | <math>. The tails1 function returns all non-empty final
--   segments of the argument, longest first.
--   
--   
Laziness
--   
--   Note that tails1 has the following strictness property:
--   tails1 _|_ = _|_
--   
--   
--   >>> tails1 undefined
--   *** Exception: Prelude.undefined
--   
--   
--   
--   >>> drop 1 (tails1 [undefined, 1, 2])
--   [1 :| [2],2 :| []]
--   
--   
--   
Examples
--   
--   
--   >>> tails1 "abc"
--   ['a' :| "bc",'b' :| "c",'c' :| ""]
--   
--   
--   
--   >>> tails1 [1, 2, 3]
--   [1 :| [2,3],2 :| [3],3 :| []]
--   
--   
--   
--   >>> tails1 []
--   []
--   
tails1 :: [a] -> [NonEmpty a]

-- | Use compareLength xs n as a safer and faster
--   alternative to compare (length xs) n.
--   Similarly, it's better to write compareLength xs 10 == LT
--   instead of length xs < 10.
--   
--   While length would force and traverse the entire spine of
--   xs (which could even diverge if xs is infinite),
--   compareLength traverses at most n elements to
--   determine its result.
--   
--   
--   >>> compareLength [] 0
--   EQ
--   
--   >>> compareLength [] 1
--   LT
--   
--   >>> compareLength ['a'] 1
--   EQ
--   
--   >>> compareLength ['a', 'b'] 1
--   GT
--   
--   >>> compareLength [0..] 100
--   GT
--   
--   >>> compareLength undefined (-1)
--   GT
--   
--   >>> compareLength ('a' : undefined) 0
--   GT
--   
compareLength :: [a] -> Int -> Ordering

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

-- | If the first argument evaluates to True, then the result is the
--   second argument. Otherwise an AssertionFailed exception is
--   raised, containing a String with the source file and line
--   number of the call to assert.
--   
--   Assertions can normally be turned on or off with a compiler flag (for
--   GHC, assertions are normally on unless optimisation is turned on with
--   -O or the -fignore-asserts option is given). When
--   assertions are turned off, the first argument to assert is
--   ignored, and the second argument is returned as the result.
assert :: Bool -> a -> a

-- | If the condition fails, display the value blamed for the failure. Used
--   as in
--   
--   
--   assert (age < 120 `blame` age) $ savings / (120 - age)
--   
blame :: Show v => Bool -> v -> Bool
infix 1 `blame`

-- | A helper function for error. To be used as in
--   
--   
--   case xs of
--     0 : _ -> error $ "insignificant zero" `showFailure` xs
--   
--   
--   Fixing the first argument to String instead of anything
--   Showable prevents warnings about defaulting, even when
--   OverloadedStrings extension is enabled.
showFailure :: Show v => String -> v -> String
infix 2 `showFailure`

-- | Syntactic sugar for the pair operation, to be used for blame as
--   in
--   
--   
--   assert (age < 120 `blame` "age too high" `swith` age) $ savings / (120 - age)
--   
--   
--   Fixing the first component of the pair to String prevents
--   warnings about defaulting, even when OverloadedStrings
--   extension is enabled.
swith :: String -> v -> (String, v)
infix 2 `swith`

-- | Like all, but if the predicate fails, blame all the list
--   elements and especially those for which it fails. To be used as in
--   
--   
--   assert (allB (<= height) [yf, y1, y2])
--   
allB :: Show v => (v -> Bool) -> [v] -> Bool

-- | A space efficient, packed, unboxed Unicode text type.
data Text
(<+>) :: Text -> Text -> Text

-- | Show and pack the result.
tshow :: Show a => a -> Text

-- | Integer division, rounding up.
divUp :: Integral a => a -> a -> a
infixl 7 `divUp`
sum :: Num a => [a] -> a
(<$$>) :: (Functor f, Functor g) => (a -> b) -> f (g a) -> f (g b)
infixl 4 <$$>
partitionM :: Applicative m => (a -> m Bool) -> [a] -> m ([a], [a])

-- | A version specialized to lists to avoid errors such as taking length
--   of Maybe [a] instead of [a]. Such errors are hard to
--   detect, because the type of elements of the list is not constrained.
length :: [a] -> Int

-- | A version specialized to lists to avoid errors such as taking null of
--   Maybe [a] instead of [a]. Such errors are hard to
--   detect, because the type of elements of the list is not constrained.
null :: [a] -> 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

-- | This is the same as from except that the type variables are in
--   the opposite order.
--   
--   
--   -- Avoid this:
--   from x :: t
--   
--   -- Prefer this:
--   into @t x
--   
into :: forall target source. From source target => source -> target

-- | Re-exported fromIntegral, but please give it explicit type to
--   make it obvious if wrapping, etc., may occur. Use
--   toIntegralCrash instead, if possible, because it fails instead
--   of wrapping, etc. In general, it may wrap or otherwise lose
--   information.
fromIntegralWrap :: (Integral a, Num b) => a -> b

-- | Re-exported toIntegralSized, but please give it explicit type
--   to make it obvious if wrapping, etc., may occur and to trigger
--   optimization. In general, it may crash.
toIntegralCrash :: (Integral a, Integral b, Bits a, Bits b) => a -> b
intToDouble :: Int -> Double
int64ToDouble :: Int64 -> Double

-- | This has a more specific type (unit result) than normally, to catch
--   errors.
mapM_ :: (Foldable t, Monad m) => (a -> m ()) -> t a -> m ()

-- | This has a more specific type (unit result) than normally, to catch
--   errors.
forM_ :: (Foldable t, Monad m) => t a -> (a -> m ()) -> m ()
vectorUnboxedUnsafeIndex :: Unbox a => Vector a -> Int -> a
unsafeShiftL :: Bits a => a -> Int -> a
unsafeShiftR :: Bits a => a -> Int -> a

-- | Split the input between the two argument arrows and combine their
--   output. Note that this is in general not a functor.
--   
--   The default definition may be overridden with a more efficient version
--   if desired.
(***) :: Arrow a => a b c -> a b' c' -> a (b, b') (c, c')
infixr 3 ***

-- | Fanout: send the input to both argument arrows and combine their
--   output.
--   
--   The default definition may be overridden with a more efficient version
--   if desired.
(&&&) :: Arrow a => a b c -> a b c' -> a b (c, c')
infixr 3 &&&

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

-- | A mirror image of first.
--   
--   The default definition may be overridden with a more efficient version
--   if desired.
second :: Arrow a => a b c -> a (d, b) (d, c)
instance GHC.Internal.Enum.Enum k => Data.Key.Adjustable (Data.EnumMap.Base.EnumMap k)
instance (GHC.Internal.Enum.Enum k, Data.Binary.Class.Binary k, Data.Binary.Class.Binary e) => Data.Binary.Class.Binary (Data.EnumMap.Base.EnumMap k e)
instance (GHC.Internal.Enum.Enum k, Data.Binary.Class.Binary k) => Data.Binary.Class.Binary (Data.EnumSet.EnumSet k)
instance (Data.Hashable.Class.Hashable k, GHC.Classes.Eq k, Data.Binary.Class.Binary k, Data.Binary.Class.Binary v) => Data.Binary.Class.Binary (Data.HashMap.Internal.HashMap k v)
instance Data.Binary.Class.Binary Data.Time.Clock.Internal.NominalDiffTime.NominalDiffTime
instance GHC.Internal.Enum.Enum k => Data.Key.FoldableWithKey (Data.EnumMap.Base.EnumMap k)
instance (GHC.Internal.Enum.Enum k, Data.Hashable.Class.Hashable k, Data.Hashable.Class.Hashable e) => Data.Hashable.Class.Hashable (Data.EnumMap.Base.EnumMap k e)
instance (GHC.Internal.Enum.Enum k, Data.Hashable.Class.Hashable k) => Data.Hashable.Class.Hashable (Data.EnumSet.EnumSet k)
instance GHC.Internal.Enum.Enum k => Data.Key.Indexable (Data.EnumMap.Base.EnumMap k)
instance GHC.Internal.Enum.Enum k => Data.Key.Keyed (Data.EnumMap.Base.EnumMap k)
instance GHC.Internal.Enum.Enum k => Data.Key.Lookup (Data.EnumMap.Base.EnumMap k)
instance Control.DeepSeq.NFData NLP.Miniutter.English.Part
instance Control.DeepSeq.NFData NLP.Miniutter.English.Person
instance Control.DeepSeq.NFData NLP.Miniutter.English.Polarity
instance GHC.Internal.Enum.Enum k => Data.Key.TraversableWithKey (Data.EnumMap.Base.EnumMap k)
instance Data.Key.Zip (Data.EnumMap.Base.EnumMap k)
instance GHC.Internal.Enum.Enum k => Data.Key.ZipWithKey (Data.EnumMap.Base.EnumMap k)

-- | A list of entities with relative frequencies of appearance.
module Game.LambdaHack.Core.Frequency

-- | The frequency distribution type. Not normalized (operations may or may
--   not group the same elements and sum their frequencies). However,
--   elements with less than zero frequency are removed upon construction.
--   
--   The Eq instance compares raw representations, not relative,
--   normalized frequencies, so operations don't need to preserve the
--   expected equalities.
data Frequency a

-- | Uniform discrete frequency distribution.
uniformFreq :: Text -> [a] -> Frequency a

-- | Takes a name and a list of frequencies and items into the frequency
--   distribution.
toFreq :: Text -> [(Int, a)] -> Frequency a
maxBoundInt32 :: Int

-- | Scale frequency distribution, multiplying it by a positive integer
--   constant.
scaleFreq :: Show a => Int -> Frequency a -> Frequency a

-- | Test if the frequency distribution is empty.
nullFreq :: Frequency a -> Bool

-- | give acces to raw frequency values
runFrequency :: Frequency a -> [(Int, a)]

-- | short description for debug, etc.
nameFrequency :: Frequency a -> Text
instance GHC.Internal.Base.Alternative Game.LambdaHack.Core.Frequency.Frequency
instance GHC.Internal.Base.Applicative Game.LambdaHack.Core.Frequency.Frequency
instance GHC.Classes.Eq a => GHC.Classes.Eq (Game.LambdaHack.Core.Frequency.Frequency a)
instance GHC.Internal.Data.Foldable.Foldable Game.LambdaHack.Core.Frequency.Frequency
instance GHC.Internal.Base.Functor Game.LambdaHack.Core.Frequency.Frequency
instance GHC.Internal.Generics.Generic (Game.LambdaHack.Core.Frequency.Frequency a)
instance GHC.Internal.Base.Monad Game.LambdaHack.Core.Frequency.Frequency
instance GHC.Internal.Base.MonadPlus Game.LambdaHack.Core.Frequency.Frequency
instance GHC.Classes.Ord a => GHC.Classes.Ord (Game.LambdaHack.Core.Frequency.Frequency a)
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Game.LambdaHack.Core.Frequency.Frequency a)
instance GHC.Internal.Data.Traversable.Traversable Game.LambdaHack.Core.Frequency.Frequency

-- | Representation of dice scaled with current level depth.
module Game.LambdaHack.Core.Dice

-- | Multiple dice rolls, some scaled with current level depth, in which
--   case the sum of all rolls is scaled in proportion to current depth
--   divided by maximal dungeon depth.
--   
--   The simple dice should have positive number of rolls and number of
--   sides.
--   
--   The Num instance doesn't have abs nor
--   signum defined, because the functions for computing infimum,
--   supremum and mean dice results would be too costly.
data Dice

-- | Absolute depth in the dungeon. When used for the maximum depth of the
--   whole dungeon, this can be different than dungeon size, e.g., when the
--   dungeon is branched, and it can even be different than the length of
--   the longest branch, if levels at some depths are missing.
newtype AbsDepth
AbsDepth :: Int -> AbsDepth

-- | Cast dice scaled with current level depth. When scaling, we round up,
--   so that the value of 1 dL 1 is 1 even at the
--   lowest level, but so is the value of 1 dL depth.
--   
--   The implementation calls RNG as many times as there are dice rolls,
--   which is costly, so content should prefer to cast fewer dice and then
--   multiply them by a constant. If rounded results are not desired (often
--   they are, to limit the number of distinct item varieties in
--   inventory), another dice may be added to the result.
--   
--   A different possible implementation, with dice represented as
--   Frequency, makes only one RNG call per dice, but due to lists
--   lengths proportional to the maximal value of the dice, it's is
--   intractable for 1000d1000 and problematic already for 100d100.
castDice :: Monad m => ((Int, Int) -> m Int) -> AbsDepth -> AbsDepth -> Dice -> m Int

-- | A die, rolled the given number of times. E.g., 1 d 2
--   rolls 2-sided die one time.
d :: Int -> Int -> Dice

-- | A die rolled the given number of times, with the result scaled with
--   dungeon level depth.
dL :: Int -> Int -> Dice

-- | A die, starting from zero, ending at one less than second argument,
--   rolled the given number of times. E.g., 1 z 1 always
--   rolls zero.
z :: Int -> Int -> Dice

-- | A die, starting from zero, ending at one less than second argument,
--   rolled the given number of times, with the result scaled with dungeon
--   level depth.
zL :: Int -> Int -> Dice
intToDice :: Int -> Dice
minDice :: Dice -> Dice -> Dice
maxDice :: Dice -> Dice -> Dice

-- | Minimal and maximal possible value of the dice.
--   
--   divUp in the implementation corresponds to ceiling,
--   applied to results of meanDice elsewhere in the code, and
--   prevents treating 1d1-power effects (on shallow levels) as null
--   effects.
infsupDice :: Dice -> (Int, Int)

-- | Maximal value of dice. The scaled part taken assuming median level.
supDice :: Dice -> Int

-- | Minimal value of dice. The scaled part taken assuming median level.
infDice :: Dice -> Int

-- | Mean value of dice. The scaled part taken assuming median level, but
--   not taking into account rounding up, and so too low, especially for
--   dice small compared to depth. To fix this, depth would need to be
--   taken as argument.
meanDice :: Dice -> Double
reduceDice :: Dice -> Maybe Int

-- | Dice for rolling a pair of integer parameters pertaining to,
--   respectively, the X and Y cartesian 2D coordinates.
data DiceXY
DiceXY :: Dice -> Dice -> DiceXY

-- | Maximal value of DiceXY.
supDiceXY :: DiceXY -> (Int, Int)

-- | Minimal value of DiceXY.
infDiceXY :: DiceXY -> (Int, Int)
instance Data.Binary.Class.Binary Game.LambdaHack.Core.Dice.AbsDepth
instance GHC.Classes.Eq Game.LambdaHack.Core.Dice.AbsDepth
instance GHC.Classes.Eq Game.LambdaHack.Core.Dice.Dice
instance GHC.Internal.Num.Num Game.LambdaHack.Core.Dice.Dice
instance GHC.Classes.Ord Game.LambdaHack.Core.Dice.AbsDepth
instance GHC.Internal.Show.Show Game.LambdaHack.Core.Dice.AbsDepth
instance GHC.Internal.Show.Show Game.LambdaHack.Core.Dice.Dice
instance GHC.Internal.Show.Show Game.LambdaHack.Core.Dice.DiceXY

-- | Keeping track of forked threads.
module Game.LambdaHack.Common.Thread
forkChild :: MVar [Async ()] -> IO () -> IO ()
waitForChildren :: MVar [Async ()] -> IO ()

-- | Ring buffers.
module Game.LambdaHack.Common.RingBuffer

-- | Ring buffers of a size determined at initialization.
data RingBuffer a
empty :: Int -> a -> RingBuffer a
cons :: a -> RingBuffer a -> RingBuffer a
toList :: RingBuffer a -> [a]
length :: RingBuffer a -> Int
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Game.LambdaHack.Common.RingBuffer.RingBuffer a)
instance GHC.Internal.Generics.Generic (Game.LambdaHack.Common.RingBuffer.RingBuffer a)
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Game.LambdaHack.Common.RingBuffer.RingBuffer a)

-- | Hacks that haven't found their home yet.
module Game.LambdaHack.Common.Misc
data FontDefinition

-- | filename, size, hinting mode
FontProportional :: Text -> Int -> HintingMode -> FontDefinition
FontMonospace :: Text -> Int -> HintingMode -> FontDefinition

-- | extra cell extension
FontMapScalable :: Text -> Int -> HintingMode -> Int -> FontDefinition

-- | size ignored for bitmap fonts and no hinting
FontMapBitmap :: Text -> Int -> FontDefinition
data HintingMode

-- | current libfreetype6 default, thin, large letter spacing
HintingHeavy :: HintingMode

-- | mimics OTF, blurry, thick, tight tracking, accurate shape
HintingLight :: HintingMode
data FontSet
FontSet :: Text -> Text -> Text -> Text -> Text -> FontSet
[fontMapScalable] :: FontSet -> Text
[fontMapBitmap] :: FontSet -> Text
[fontPropRegular] :: FontSet -> Text
[fontPropBold] :: FontSet -> Text
[fontMono] :: FontSet -> Text

-- | Re-exported English phrase creation functions, applied to our custom
--   irregular word sets.
makePhrase :: [Part] -> Text

-- | Re-exported English phrase creation functions, applied to our custom
--   irregular word sets.
makeSentence :: [Part] -> Text

-- | Apply the WWandW constructor, first representing repetitions
--   as CardinalWs. The parts are not sorted, only grouped, to
--   keep the order. The internal structure of speech parts is compared,
--   not their string rendering, so some coincidental clashes are avoided
--   (and code is simpler).
squashedWWandW :: [Part] -> (Part, Person)

-- | Personal data directory for the game. Depends on the OS and the game,
--   e.g., for LambdaHack under Linux it's ~/.LambdaHack/.
appDataDir :: IO FilePath

-- | Multiplies by a million.
xM :: Int -> Int64

-- | Multiplies by a million, double precision.
xD :: Double -> Double
minusM :: Int64
minusM1 :: Int64
minusM2 :: Int64
oneM :: Int64
tenthM :: Int64
show64With2 :: Int64 -> Text
workaroundOnMainThreadMVar :: MVar (IO ())
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Misc.FontDefinition
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Misc.FontSet
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Misc.HintingMode
instance GHC.Classes.Eq Game.LambdaHack.Common.Misc.FontDefinition
instance GHC.Classes.Eq Game.LambdaHack.Common.Misc.FontSet
instance GHC.Classes.Eq Game.LambdaHack.Common.Misc.HintingMode
instance GHC.Internal.Generics.Generic Game.LambdaHack.Common.Misc.FontDefinition
instance GHC.Internal.Generics.Generic Game.LambdaHack.Common.Misc.FontSet
instance GHC.Internal.Generics.Generic Game.LambdaHack.Common.Misc.HintingMode
instance Control.DeepSeq.NFData Game.LambdaHack.Common.Misc.FontDefinition
instance Control.DeepSeq.NFData Game.LambdaHack.Common.Misc.FontSet
instance Control.DeepSeq.NFData Game.LambdaHack.Common.Misc.HintingMode
instance GHC.Internal.Read.Read Game.LambdaHack.Common.Misc.FontDefinition
instance GHC.Internal.Read.Read Game.LambdaHack.Common.Misc.FontSet
instance GHC.Internal.Read.Read Game.LambdaHack.Common.Misc.HintingMode
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Misc.FontDefinition
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Misc.FontSet
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Misc.HintingMode

-- | Game time and speed.
module Game.LambdaHack.Common.Time

-- | Game time in ticks. The time dimension. One tick is 1 microsecond (one
--   millionth of a second), one turn is 0.5 s.
data Time
timeTicks :: Time -> Int64

-- | Start of the game time, or zero lenght time interval.
timeZero :: Time

-- | An infinitesimal time period.
timeEpsilon :: Time

-- | At least once per clip all moves are resolved and a frame or a frame
--   delay is generated. Currently one clip is 0.05 s, but it may change,
--   and the code should not depend on this fixed value.
timeClip :: Time

-- | One turn is 0.5 s. The code may depend on that. Actors at normal speed
--   (2 m/s) take one turn to move one tile (1 m by 1 m).
timeTurn :: Time

-- | This many ticks fits in a single second.
timeSecond :: Time

-- | This many clips fit in one turn. Determines the resolution of actor
--   move sampling and display updates.
clipsInTurn :: Int

-- | Absolute time addition, e.g., for summing the total game session time
--   from the times of individual games.
absoluteTimeAdd :: Time -> Time -> Time
absoluteTimeSubtract :: Time -> Time -> Time

-- | Absolute time negation. To be used for reversing time flow, e.g., for
--   comparing absolute times in the reverse order.
absoluteTimeNegate :: Time -> Time

-- | How many time intervals of the latter kind fits in an interval of the
--   former kind.
timeFit :: Time -> Time -> Int

-- | How many time intervals of the latter kind cover an interval of the
--   former kind (rounded up).
timeFitUp :: Time -> Time -> Int
timeRecent5 :: Time -> Time -> Bool

-- | One-dimentional vectors. Introduced to tell apart the 2 uses of Time:
--   as an absolute game time and as an increment.
newtype Delta a
Delta :: a -> Delta a

-- | Shifting an absolute time by a time vector.
timeShift :: Time -> Delta Time -> Time

-- | Time time vector between the second and the first absolute times. The
--   arguments are in the same order as in the underlying scalar
--   subtraction.
timeDeltaToFrom :: Time -> Time -> Delta Time

-- | Addition of time deltas.
timeDeltaAdd :: Delta Time -> Delta Time -> Delta Time

-- | Subtraction of time deltas. The arguments are in the same order as in
--   the underlying scalar subtraction.
timeDeltaSubtract :: Delta Time -> Delta Time -> Delta Time

-- | Reverse a time vector.
timeDeltaReverse :: Delta Time -> Delta Time

-- | Scale the time vector by an Int scalar value.
timeDeltaScale :: Delta Time -> Int -> Delta Time

-- | Take the given percent of the time vector.
timeDeltaPercent :: Delta Time -> Int -> Delta Time

-- | Divide a time vector.
timeDeltaDiv :: Delta Time -> Int -> Delta Time

-- | Represent the main 10 thresholds of a time range by digits, given the
--   total length of the time range.
timeDeltaToDigit :: Delta Time -> Delta Time -> Char
timeDeltaInSecondsText :: Delta Time -> Text

-- | Speed in meters per 1 million seconds (m/Ms). Actors at normal speed
--   (2 m/s) take one time turn (0.5 s) to make one step (move one tile,
--   which is 1 m by 1 m).
data Speed

-- | Constructor for content definitions.
toSpeed :: Int -> Speed

-- | Readable representation of speed in the format used in content
--   definitions.
fromSpeed :: Speed -> Int
minSpeed :: Int

-- | Pretty-print speed given in the format used in content definitions.
displaySpeed :: Int -> String

-- | Fast walk speed (2 m/s) that suffices to move one tile in one turn.
speedWalk :: Speed

-- | Limp speed (1 m/s) that suffices to move one tile in two turns. This
--   is the minimal speed for projectiles to fly just one space and drop.
speedLimp :: Speed

-- | Sword thrust speed (10 m/s). Base weapon damages, both melee and
--   ranged, are given assuming this speed and ranged damage is modified
--   accordingly when projectile speeds differ. Differences in melee weapon
--   swing speeds are captured in damage bonuses instead, since many other
--   factors influence total damage.
--   
--   Billiard ball is 25 ms, sword swing at the tip is 35 ms,
--   medieval bow is 70 ms, AK47 is 700 ms.
speedThrust :: Speed

-- | Modify damage when projectiles is at a non-standard speed. Energy and
--   so damage is proportional to the square of speed, hence the formula.
modifyDamageBySpeed :: Int64 -> Speed -> Int64

-- | Scale speed by a scalar value.
speedScale :: Rational -> Speed -> Speed

-- | Speed addition.
speedAdd :: Speed -> Speed -> Speed

-- | The number of time ticks it takes to walk 1 meter at the given speed.
ticksPerMeter :: Speed -> Delta Time

-- | Calculate projectile speed from item weight in grams and velocity
--   percent modifier. See
--   https://github.com/LambdaHack/LambdaHack/wiki/Item-statistics.
speedFromWeight :: Int -> Int -> Speed

-- | Calculate maximum range taking into account the linger percentage.
rangeFromSpeedAndLinger :: Speed -> Int -> Int

-- | The smallest unit of time. Should not be exported and used elsewhere,
--   because the proportion of turn to tick is an implementation detail.
--   The significance of this detail is only that it determines resolution
--   of the time dimension.
_timeTick :: Time

-- | This many turns fit in a single second.
turnsInSecond :: Int64

-- | Number of seconds in a mega-second.
sInMs :: Int64

-- | The minimal speed is half a meter (half a step across a tile) per
--   second (two standard turns, which the time span during which
--   projectile moves, unless it has modified linger value). This is four
--   times slower than standard human movement speed.
--   
--   It needen't be lower, because rangeFromSpeed gives 0 steps
--   with such speed, so the actor's trajectory is empty, so it drops down
--   at once. Twice that speed already moves a normal projectile one step
--   before it stops. It shouldn't be lower or a slow actor would incur
--   such a time debt for performing a single action that he'd be paralyzed
--   for many turns, e.g., leaving his dead body on the screen for very
--   long.
minimalSpeed :: Int64

-- | Calculate maximum range in meters of a projectile from its speed. See
--   https://github.com/LambdaHack/LambdaHack/wiki/Item-statistics.
--   With this formula, each projectile flies for at most 1 second, that is
--   2 standard turns, and then drops to the ground.
rangeFromSpeed :: Speed -> Int
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Game.LambdaHack.Common.Time.Delta a)
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Time.Speed
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Time.Time
instance GHC.Classes.Eq a => GHC.Classes.Eq (Game.LambdaHack.Common.Time.Delta a)
instance GHC.Classes.Eq Game.LambdaHack.Common.Time.Speed
instance GHC.Classes.Eq Game.LambdaHack.Common.Time.Time
instance GHC.Internal.Base.Functor Game.LambdaHack.Common.Time.Delta
instance GHC.Classes.Ord a => GHC.Classes.Ord (Game.LambdaHack.Common.Time.Delta a)
instance GHC.Classes.Ord Game.LambdaHack.Common.Time.Speed
instance GHC.Classes.Ord Game.LambdaHack.Common.Time.Time
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Game.LambdaHack.Common.Time.Delta a)
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Time.Speed
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Time.Time

-- | Saving/loading to files, with serialization and compression.
module Game.LambdaHack.Common.File

-- | Serialize, compress and save data with an EOF marker. The OK
--   is used as an EOF marker to ensure any apparent problems with
--   corrupted files are reported to the user ASAP.
encodeEOF :: Binary b => FilePath -> Version -> b -> IO ()

-- | Read, decompress and deserialize data with an EOF marker. The
--   OK EOF marker ensures any easily detectable file corruption
--   is discovered and reported before any value is decoded from the second
--   component and before the file handle is closed. OTOH, binary encoding
--   corruption is not discovered until a version check elswere ensures
--   that binary formats are compatible.
strictDecodeEOF :: Binary b => FilePath -> IO (Version, b)

-- | Try to create a directory, if it doesn't exist. We catch exceptions in
--   case many clients try to do the same thing at the same time.
tryCreateDir :: FilePath -> IO ()

-- | The operation doesFileExist returns True if the argument
--   file exists and is not a directory, and False otherwise.
doesFileExist :: FilePath -> IO Bool

-- | Try to write a file, given content, if the file not already there. We
--   catch exceptions in case many clients and/or the server try to do the
--   same thing at the same time. Using IO to avoid UTF conflicts
--   with OS or filesystem.
tryWriteFile :: FilePath -> Text -> 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

-- | renameFile old new changes the name of an existing
--   file system object from old to new. If the new
--   object already exists, it is replaced by the old object.
--   Neither path may refer to an existing directory.
--   
--   A conformant implementation need not support renaming files in all
--   situations (e.g. renaming across different physical devices), but the
--   constraints must be documented. On Windows, this does not support
--   renaming across different physical devices; if you are looking to do
--   so, consider using copyFileWithMetadata and removeFile.
--   
--   On Windows, this calls MoveFileEx with
--   MOVEFILE_REPLACE_EXISTING set, which is not guaranteed to be
--   atomic (https://github.com/haskell/directory/issues/109).
--   
--   On other platforms, this operation is atomic.
--   
--   The operation may fail with:
--   
--   
--   
- HardwareFault A physical I/O error has occurred.
--   [EIO]
--   
- InvalidArgument Either operand is not a valid file name.
--   [ENAMETOOLONG, ELOOP]
--   
- isDoesNotExistError The original file does not exist, or
--   there is no path to the target. [ENOENT, ENOTDIR]
--   
- isPermissionError The process has insufficient privileges
--   to perform the operation. [EROFS, EACCES, EPERM]
--   
- isFullError Insufficient resources are available to perform
--   the operation. [EDQUOT, ENOSPC, ENOMEM, EMLINK]
--   
- UnsatisfiedConstraints Implementation-dependent
--   constraints are not satisfied. [EBUSY]
--   
- UnsupportedOperation The implementation does not support
--   renaming in this situation. [EXDEV]
--   
- InappropriateType Either path refers to an existing
--   directory. [ENOTDIR, EISDIR, EINVAL, EEXIST, ENOTEMPTY]
--   
renameFile :: FilePath -> FilePath -> IO ()

-- | Options that affect the behaviour of the client.
module Game.LambdaHack.Common.ClientOptions

-- | Kinds of fullscreen or windowed mode. See
--   https://hackage.haskell.org/package/sdl2-2.5.3.0/docs/SDL-Video.html#t:WindowMode.
data FullscreenMode

-- | a normal window instead of fullscreen
NotFullscreen :: FullscreenMode

-- | fake fullscreen; window the size of the desktop; this is the preferred
--   one, if it works
BigBorderlessWindow :: FullscreenMode

-- | real fullscreen with a video mode change
ModeChange :: FullscreenMode

-- | Options that affect the behaviour of the client (but not game rules).
data ClientOptions
ClientOptions :: Maybe Text -> Maybe Double -> [(Text, FontDefinition)] -> [(Text, FontSet)] -> Maybe FullscreenMode -> Maybe Int -> Maybe Double -> Bool -> Maybe Bool -> Bool -> Bool -> Bool -> Maybe String -> String -> Bool -> Bool -> Bool -> Bool -> Bool -> Maybe Int -> Maybe Int -> Bool -> Bool -> Bool -> Bool -> ClientOptions

-- | Font set chosen by the player for the whole UI.
[schosenFontset] :: ClientOptions -> Maybe Text

-- | The scale applied to all fonts, resizing the whole UI.
[sallFontsScale] :: ClientOptions -> Maybe Double

-- | Available fonts as defined in config file.
[sfonts] :: ClientOptions -> [(Text, FontDefinition)]

-- | Available font sets as defined in config file.
[sfontsets] :: ClientOptions -> [(Text, FontSet)]

-- | Whether to start in fullscreen mode and in which one.
[sfullscreenMode] :: ClientOptions -> Maybe FullscreenMode

-- | How much to log (e.g., from SDL). 1 is all, 5 is errors, the default.
[slogPriority] :: ClientOptions -> Maybe Int

-- | Maximal frames per second. This is better low and fixed, to avoid
--   jerkiness and delays that tell the player there are many intelligent
--   enemies on the level. That's better than scaling AI sofistication down
--   based on the FPS setting and machine speed.
[smaxFps] :: ClientOptions -> Maybe Double

-- | Never auto-answer all prompts, even if under AI control.
[sdisableAutoYes] :: ClientOptions -> Bool

-- | Don't show any animations.
[snoAnim] :: ClientOptions -> Maybe Bool

-- | Start a new game, overwriting the save file.
[snewGameCli] :: ClientOptions -> Bool

-- | Don't create directories and files and show time stats.
[sbenchmark] :: ClientOptions -> Bool

-- | Display messages in realistic was under AI control (e.g., for
--   benchmarking).
[sbenchMessages] :: ClientOptions -> Bool
[stitle] :: ClientOptions -> Maybe String

-- | Prefix of the save game file name.
[ssavePrefixCli] :: ClientOptions -> String

-- | Whether to use the ANSI frontend.
[sfrontendANSI] :: ClientOptions -> Bool

-- | Whether to use the stdout/stdin frontend.
[sfrontendTeletype] :: ClientOptions -> Bool

-- | Whether to use null (no input/output) frontend.
[sfrontendNull] :: ClientOptions -> Bool

-- | Whether to use lazy (output not even calculated) frontend.
[sfrontendLazy] :: ClientOptions -> Bool

-- | Show clients' internal debug messages.
[sdbgMsgCli] :: ClientOptions -> Bool
[sstopAfterSeconds] :: ClientOptions -> Maybe Int
[sstopAfterFrames] :: ClientOptions -> Maybe Int
[sprintEachScreen] :: ClientOptions -> Bool
[sexposePlaces] :: ClientOptions -> Bool
[sexposeItems] :: ClientOptions -> Bool
[sexposeActors] :: ClientOptions -> Bool

-- | Default value of client options.
defClientOptions :: ClientOptions
instance Data.Binary.Class.Binary Game.LambdaHack.Common.ClientOptions.ClientOptions
instance Data.Binary.Class.Binary Game.LambdaHack.Common.ClientOptions.FullscreenMode
instance GHC.Classes.Eq Game.LambdaHack.Common.ClientOptions.ClientOptions
instance GHC.Classes.Eq Game.LambdaHack.Common.ClientOptions.FullscreenMode
instance GHC.Internal.Generics.Generic Game.LambdaHack.Common.ClientOptions.ClientOptions
instance GHC.Internal.Generics.Generic Game.LambdaHack.Common.ClientOptions.FullscreenMode
instance Control.DeepSeq.NFData Game.LambdaHack.Common.ClientOptions.FullscreenMode
instance GHC.Internal.Read.Read Game.LambdaHack.Common.ClientOptions.FullscreenMode
instance GHC.Internal.Show.Show Game.LambdaHack.Common.ClientOptions.ClientOptions
instance GHC.Internal.Show.Show Game.LambdaHack.Common.ClientOptions.FullscreenMode

module Game.LambdaHack.Client.UI.TutorialHints
data TutorialHints
DamageOfDifferentKind :: TutorialHints
NewFloorNewOpportunity :: TutorialHints
CannotHarmYouInMelee :: TutorialHints
CaughtProjectile :: TutorialHints
HitsWithNoDirectDamage :: TutorialHints
TemporaryConditions :: TutorialHints
WokenUpActors :: TutorialHints
AvoidWalkingEnemies :: TutorialHints
AlotOfDamageFromOneSource :: TutorialHints
TerrainNotFullyKnown :: TutorialHints
OutOfSightEvents :: TutorialHints
HearingRadius :: TutorialHints
SwitchTeammate :: TutorialHints
MeleeEnemies :: TutorialHints
UseTerrainEffect :: TutorialHints
SwitchPointmanAndAvoidMeleeAlone :: TutorialHints
SwitchPointmanAndSoftenFoes :: TutorialHints

-- | Generate the standard textual representation for the tutorial hints.
renderTutorialHints :: TutorialHints -> Text

-- | AI strategies to direct actors not controlled directly by human
--   players. No operation in this module involves the State type
--   or any of our client/server monads types.
module Game.LambdaHack.Client.AI.Strategy

-- | A strategy is a choice of (non-empty) frequency tables of possible
--   actions.
--   
--   Currently, the way we use it, the list could have at most one element
--   (we filter out void frequencies early and only ever access the first).
--   except for the argument of mapStrategyM, which may even be
--   process to the end of the list, if no earlier strategies can be
--   transformed into non-null ones.
data Strategy a
nullStrategy :: Strategy a -> Bool

-- | Strategy where only the actions from the given single frequency table
--   can be picked.
liftFrequency :: Frequency a -> Strategy a

-- | Strategy with the actions from both argument strategies, with original
--   frequencies.
(.|) :: Strategy a -> Strategy a -> Strategy a
infixr 2 .|

-- | Strategy with no actions at all.
reject :: Strategy a

-- | Conditionally accepted strategy.
(.=>) :: Bool -> Strategy a -> Strategy a
infix 3 .=>

-- | Strategy with all actions not satisfying the predicate removed. The
--   remaining actions keep their original relative frequency values.
only :: (a -> Bool) -> Strategy a -> Strategy a

-- | When better choices are towards the start of the list, this is the
--   best frequency of the strategy.
bestVariant :: Strategy a -> Frequency a

-- | Like return, but pick a name of the single frequency.
returN :: Text -> a -> Strategy a
mapStrategyM :: Monad m => (a -> m (Maybe b)) -> Strategy a -> m (Strategy b)
instance GHC.Internal.Base.Alternative Game.LambdaHack.Client.AI.Strategy.Strategy
instance GHC.Internal.Base.Applicative Game.LambdaHack.Client.AI.Strategy.Strategy
instance GHC.Internal.Data.Foldable.Foldable Game.LambdaHack.Client.AI.Strategy.Strategy
instance GHC.Internal.Base.Functor Game.LambdaHack.Client.AI.Strategy.Strategy
instance GHC.Internal.Base.MonadPlus Game.LambdaHack.Client.AI.Strategy.Strategy
instance GHC.Internal.Base.Monad Game.LambdaHack.Client.AI.Strategy.Strategy
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Game.LambdaHack.Client.AI.Strategy.Strategy a)
instance GHC.Internal.Data.Traversable.Traversable Game.LambdaHack.Client.AI.Strategy.Strategy

-- | Representation of probabilities and random computations.
module Game.LambdaHack.Core.Random

-- | The monad of computations with random generator state.
type Rnd a = State SMGen a

-- | Get a random object within a (inclusive) range with a uniform
--   distribution.
randomR :: Integral a => (a, a) -> Rnd a

-- | Generate random Integral in [0, x] range.
randomR0 :: Integral a => a -> Rnd a

-- | Generate a random integral value in [0, x] range, where
--   x is within Int32.
--   
--   The limitation to Int32 values is needed to keep it working
--   on signed types. In package random, a much more complex
--   scheme is used to keep it working for arbitrary fixed number of bits.
nextRandom :: Integral a => a -> SMGen -> (a, SMGen)

-- | Get a random Word32 using full range.
randomWord32 :: Rnd Word32

-- | Get any element of a list with equal probability.
oneOf :: [a] -> Rnd a

-- | Generates a random permutation. Naive, but good enough for small
--   inputs.
shuffle :: Eq a => [a] -> Rnd [a]

-- | Code that means the information (e.g., flavour or hidden kind index)
--   should be regenerated, because it could not be transferred from
--   previous playthrough (it's random in each playthrough or there was no
--   previous playthrough).
invalidInformationCode :: Word16

-- | Generates a random permutation, except for the existing mapping.
shuffleExcept :: Vector Word16 -> Int -> [Word16] -> Rnd [Word16]

-- | Gen an element according to a frequency distribution.
frequency :: Show a => Frequency a -> Rnd a

-- | Fractional chance.
type Chance = Rational

-- | Give True, with probability determined by the fraction.
chance :: Chance -> Rnd Bool

-- | Cast dice scaled with current level depth.
castDice :: AbsDepth -> AbsDepth -> Dice -> Rnd Int

-- | Cast dice scaled with current level depth and return True if
--   the results is greater than 50.
oddsDice :: AbsDepth -> AbsDepth -> Dice -> Rnd Bool

-- | Cast dice, scaled with current level depth, for coordinates.
castDiceXY :: AbsDepth -> AbsDepth -> DiceXY -> Rnd (Int, Int)
foldrM :: Foldable t => (a -> b -> Rnd b) -> b -> t a -> Rnd b
foldlM' :: Foldable t => (b -> a -> Rnd b) -> b -> t a -> Rnd b

-- | Randomly choose an item according to the distribution.
rollFreq :: Show a => Frequency a -> SMGen -> (a, SMGen)

-- | Abilities of items, actors and factions.
module Game.LambdaHack.Definition.Ability

-- | Actor and faction skills. They are a subset of actor aspects. See
--   skillDesc for documentation.
data Skill
SkMove :: Skill
SkMelee :: Skill
SkDisplace :: Skill
SkAlter :: Skill
SkWait :: Skill
SkMoveItem :: Skill
SkProject :: Skill
SkApply :: Skill
SkSwimming :: Skill
SkFlying :: Skill
SkHurtMelee :: Skill
SkArmorMelee :: Skill
SkArmorRanged :: Skill
SkMaxHP :: Skill
SkMaxCalm :: Skill
SkSpeed :: Skill

-- | FOV radius, where 1 means a single tile FOV area
SkSight :: Skill
SkSmell :: Skill
SkShine :: Skill
SkNocto :: Skill
SkHearing :: Skill
SkAggression :: Skill
SkOdor :: Skill

-- | intended to reflect how many items granting complete invulnerability
--   are among organs and equipment; this is not strength of deflection nor
--   duration, etc.
SkDeflectRanged :: Skill

-- | see above
SkDeflectMelee :: Skill

-- | Strength of particular skills. This is cumulative from actor organs
--   and equipment and so pertain to an actor as well as to items.
--   
--   This representation is sparse, so better than a record when there are
--   more item kinds (with few skills) than actors (with many skills),
--   especially if the number of skills grows as the engine is developed.
--   It's also easier to code and maintain.
--   
--   The tree is by construction sparse, so the derived equality is
--   semantical.
data Skills

-- | Item flag aspects.
data Flag

-- | as a projectile, break at target tile, even if no hit; also, at each
--   periodic activation a copy is destroyed and all other copies require
--   full cooldown (timeout)
Fragile :: Flag

-- | drop at target tile, even if no hit
Lobable :: Flag

-- | don't break even when hitting or applying
Durable :: Flag

-- | AI and UI flag: consider equipping (may or may not have
--   EqpSlot, e.g., if the benefit is periodic)
Equipable :: Flag

-- | AI and UI flag: the item is not meant to harm
Benign :: Flag

-- | AI and UI flag: don't risk identifying by use; also, can't throw or
--   apply if not calm enough; also may be used for UI flavour or AI hints
Precious :: Flag

-- | the item is an explosion blast particle
Blast :: Flag

-- | item is a condition (buff or de-buff) of an actor and is displayed as
--   such, not activated at death; this differs from belonging to the
--   CONDITION group, which doesn't guarantee any behaviour or
--   display, but governs removal by items that drop CONDITION
Condition :: Flag

-- | at most one copy can ever be generated
Unique :: Flag

-- | once identified, the item is known until savefile deleted
MetaGame :: Flag

-- | override: the effects on this item are considered minor and so
--   possibly not causing identification on use, and so this item will
--   identify on pick-up
MinorEffects :: Flag

-- | override: don't show question marks by weapons in HUD even when
--   unidentified item with this flag equipped
MinorAspects :: Flag

-- | meleeing with the item is permitted and so the item activates when
--   meleed with
Meleeable :: Flag

-- | at most one of any copies without cooldown (timeout) activates each
--   turn; the cooldown required after activation is specified in
--   Timeout (or is zero); the initial cooldown can also be
--   specified as TimerDice in CreateItem effect;
--   uniquely, this activation never destroys a copy, unless item is
--   fragile; all this happens only for items in equipment or organs;
--   kinetic damage is not applied
Periodic :: Flag

-- | activates when non-projectile actor with this item as equipment or
--   organ is under ranged attack; kinetic damage is not applied
UnderRanged :: Flag

-- | activates when non-projectile actor with this item as equipment or
--   organ is under melee attack; kinetic damage is not applied
UnderMelee :: Flag

-- | These flags correspond to the last cases of Flag and
--   addtionally to all the universal circumstances of item activation,
--   under which every item activates (even if vacuusly).
data ActivationFlag
ActivationMeleeable :: ActivationFlag
ActivationPeriodic :: ActivationFlag
ActivationUnderRanged :: ActivationFlag
ActivationUnderMelee :: ActivationFlag

-- | From here on, all items affected regardless of their Flag
--   content.
ActivationProjectile :: ActivationFlag
ActivationTrigger :: ActivationFlag
ActivationOnSmash :: ActivationFlag
ActivationOnCombine :: ActivationFlag
ActivationEmbed :: ActivationFlag
ActivationConsume :: ActivationFlag
newtype Flags
Flags :: EnumSet Flag -> Flags
[flags] :: Flags -> EnumSet Flag

-- | Doctrine of non-leader actors. Apart of determining AI operation, each
--   doctrine implies a skill modifier, that is added to the non-leader
--   skills defined in fskillsOther field of FactionKind.
data Doctrine

-- | if enemy nearby, attack, if no items, etc., explore unknown
TExplore :: Doctrine

-- | always follow leader's target or his position if no target
TFollow :: Doctrine

-- | follow but don't do any item management nor use
TFollowNoItems :: Doctrine

-- | only melee and do ranged combat
TMeleeAndRanged :: Doctrine

-- | only melee (or wait)
TMeleeAdjacent :: Doctrine

-- | always only wait, even if enemy in melee range
TBlock :: Doctrine

-- | if enemy nearby, attack, if no items, etc., roam randomly
TRoam :: Doctrine

-- | find an open and uncrowded area, patrol it according to sight radius
--   and fallback temporarily to TRoam when enemy is seen by the
--   faction and is within the actor's sight radius
TPatrol :: Doctrine

-- | AI and UI hints about the role of the item.
data EqpSlot
EqpSlotMove :: EqpSlot
EqpSlotMelee :: EqpSlot
EqpSlotDisplace :: EqpSlot
EqpSlotAlter :: EqpSlot
EqpSlotWait :: EqpSlot
EqpSlotMoveItem :: EqpSlot
EqpSlotProject :: EqpSlot
EqpSlotApply :: EqpSlot
EqpSlotSwimming :: EqpSlot
EqpSlotFlying :: EqpSlot
EqpSlotHurtMelee :: EqpSlot
EqpSlotArmorMelee :: EqpSlot
EqpSlotArmorRanged :: EqpSlot
EqpSlotMaxHP :: EqpSlot
EqpSlotSpeed :: EqpSlot
EqpSlotSight :: EqpSlot
EqpSlotShine :: EqpSlot
EqpSlotMiscBonus :: EqpSlot
EqpSlotWeaponFast :: EqpSlot
EqpSlotWeaponBig :: EqpSlot
getSk :: Skill -> Skills -> Int
addSk :: Skill -> Int -> Skills -> Skills
checkFl :: Flag -> Flags -> Bool
skillsToList :: Skills -> [(Skill, Int)]
zeroSkills :: Skills
addSkills :: Skills -> Skills -> Skills
sumScaledSkills :: [(Skills, Int)] -> Skills
nameDoctrine :: Doctrine -> Text
describeDoctrine :: Doctrine -> Text
doctrineSkills :: Doctrine -> Skills
blockOnly :: Skills
meleeAdjacent :: Skills
meleeAndRanged :: Skills
ignoreItems :: Skills
scaleSkills :: (Skills, Int) -> Skills
instance Data.Binary.Class.Binary Game.LambdaHack.Definition.Ability.Doctrine
instance Data.Binary.Class.Binary Game.LambdaHack.Definition.Ability.EqpSlot
instance Data.Binary.Class.Binary Game.LambdaHack.Definition.Ability.Flag
instance Data.Binary.Class.Binary Game.LambdaHack.Definition.Ability.Flags
instance Data.Binary.Class.Binary Game.LambdaHack.Definition.Ability.Skill
instance Data.Binary.Class.Binary Game.LambdaHack.Definition.Ability.Skills
instance GHC.Internal.Enum.Bounded Game.LambdaHack.Definition.Ability.Doctrine
instance GHC.Internal.Enum.Bounded Game.LambdaHack.Definition.Ability.EqpSlot
instance GHC.Internal.Enum.Bounded Game.LambdaHack.Definition.Ability.Flag
instance GHC.Internal.Enum.Bounded Game.LambdaHack.Definition.Ability.Skill
instance GHC.Internal.Enum.Enum Game.LambdaHack.Definition.Ability.Doctrine
instance GHC.Internal.Enum.Enum Game.LambdaHack.Definition.Ability.EqpSlot
instance GHC.Internal.Enum.Enum Game.LambdaHack.Definition.Ability.Flag
instance GHC.Internal.Enum.Enum Game.LambdaHack.Definition.Ability.Skill
instance GHC.Classes.Eq Game.LambdaHack.Definition.Ability.ActivationFlag
instance GHC.Classes.Eq Game.LambdaHack.Definition.Ability.Doctrine
instance GHC.Classes.Eq Game.LambdaHack.Definition.Ability.EqpSlot
instance GHC.Classes.Eq Game.LambdaHack.Definition.Ability.Flag
instance GHC.Classes.Eq Game.LambdaHack.Definition.Ability.Flags
instance GHC.Classes.Eq Game.LambdaHack.Definition.Ability.Skill
instance GHC.Classes.Eq Game.LambdaHack.Definition.Ability.Skills
instance GHC.Internal.Generics.Generic Game.LambdaHack.Definition.Ability.Doctrine
instance GHC.Internal.Generics.Generic Game.LambdaHack.Definition.Ability.EqpSlot
instance GHC.Internal.Generics.Generic Game.LambdaHack.Definition.Ability.Flag
instance GHC.Internal.Generics.Generic Game.LambdaHack.Definition.Ability.Skill
instance Data.Hashable.Class.Hashable Game.LambdaHack.Definition.Ability.Doctrine
instance Data.Hashable.Class.Hashable Game.LambdaHack.Definition.Ability.EqpSlot
instance Data.Hashable.Class.Hashable Game.LambdaHack.Definition.Ability.Flag
instance Data.Hashable.Class.Hashable Game.LambdaHack.Definition.Ability.Flags
instance Data.Hashable.Class.Hashable Game.LambdaHack.Definition.Ability.Skill
instance Data.Hashable.Class.Hashable Game.LambdaHack.Definition.Ability.Skills
instance GHC.Classes.Ord Game.LambdaHack.Definition.Ability.EqpSlot
instance GHC.Classes.Ord Game.LambdaHack.Definition.Ability.Flags
instance GHC.Classes.Ord Game.LambdaHack.Definition.Ability.Skills
instance GHC.Internal.Show.Show Game.LambdaHack.Definition.Ability.ActivationFlag
instance GHC.Internal.Show.Show Game.LambdaHack.Definition.Ability.Doctrine
instance GHC.Internal.Show.Show Game.LambdaHack.Definition.Ability.EqpSlot
instance GHC.Internal.Show.Show Game.LambdaHack.Definition.Ability.Flag
instance GHC.Internal.Show.Show Game.LambdaHack.Definition.Ability.Flags
instance GHC.Internal.Show.Show Game.LambdaHack.Definition.Ability.Skill
instance GHC.Internal.Show.Show Game.LambdaHack.Definition.Ability.Skills

-- | Colours and text attributes.
module Game.LambdaHack.Definition.Color

-- | Colours supported by the major frontends.
data Color
Black :: Color
Red :: Color
Green :: Color
Brown :: Color
Blue :: Color
Magenta :: Color
Cyan :: Color
White :: Color
AltWhite :: Color
BrBlack :: Color
BrRed :: Color
BrGreen :: Color
BrYellow :: Color
BrBlue :: Color
BrMagenta :: Color
BrCyan :: Color
BrWhite :: Color

-- | The default colours, to optimize attribute setting.
defFG :: Color

-- | A helper for the terminal frontends that display bright via bold.
isBright :: Color -> Bool

-- | Colour sets. Sorted.
darkCol :: [Color]

-- | Colour sets. Sorted.
brightCol :: [Color]

-- | Colour sets. Sorted.
stdCol :: [Color]

-- | Colour sets. Sorted.
legalFgCol :: [Color]
cVeryBadEvent :: Color
cBadEvent :: Color
cRisk :: Color
cGraveRisk :: Color
cVeryGoodEvent :: Color
cGoodEvent :: Color
cVista :: Color
cSleep :: Color
cWakeUp :: Color
cGreed :: Color
cNeutralEvent :: Color
cRareNeutralEvent :: Color
cIdentification :: Color
cMeta :: Color
cBoring :: Color
cGameOver :: Color
cTutorialHint :: Color

-- | Translationg to heavily modified Linux console color RGB values.
--   
--   Warning: SDL frontend sadly duplicates this code.
colorToRGB :: Color -> Text

-- | Additional map cell highlight, e.g., a colorful square around the cell
--   or a colorful background.
--   
--   Warning: the highlight underscored by the terminal cursor is the
--   maximal element of this type present on a screen, so don't add new
--   highlights to the end.
data Highlight
HighlightNone :: Highlight
HighlightBackground :: Highlight
HighlightGreen :: Highlight
HighlightBlue :: Highlight
HighlightBrown :: Highlight
HighlightCyan :: Highlight
HighlightGrey :: Highlight
HighlightWhite :: Highlight
HighlightMagenta :: Highlight
HighlightRed :: Highlight
HighlightYellow :: Highlight
HighlightYellowAim :: Highlight
HighlightRedAim :: Highlight
HighlightNoneCursor :: Highlight

-- | Text attributes: foreground color and highlight.
data Attr
Attr :: Color -> Highlight -> Attr

-- | foreground colour
[fg] :: Attr -> Color

-- | highlight
[bg] :: Attr -> Highlight
highlightToColor :: Highlight -> Color

-- | The default attribute, to optimize attribute setting.
defAttr :: Attr

-- | Character to display, with its attribute.
data AttrChar
AttrChar :: Attr -> Char -> AttrChar
[acAttr] :: AttrChar -> Attr
[acChar] :: AttrChar -> Char

-- | Optimized representation of AttrChar.
newtype AttrCharW32
AttrCharW32 :: Word32 -> AttrCharW32
[attrCharW32] :: AttrCharW32 -> Word32
attrCharToW32 :: AttrChar -> AttrCharW32
attrCharFromW32 :: AttrCharW32 -> AttrChar
fgFromW32 :: AttrCharW32 -> Color
bgFromW32 :: AttrCharW32 -> Highlight
charFromW32 :: AttrCharW32 -> Char
attrFromW32 :: AttrCharW32 -> Attr
spaceAttrW32 :: AttrCharW32
nbspAttrW32 :: AttrCharW32
trimmedLineAttrW32 :: AttrCharW32
attrChar2ToW32 :: Color -> Char -> AttrCharW32
attrChar1ToW32 :: Char -> AttrCharW32
instance Data.Binary.Class.Binary Game.LambdaHack.Definition.Color.AttrCharW32
instance Data.Binary.Class.Binary Game.LambdaHack.Definition.Color.Color
instance GHC.Internal.Enum.Bounded Game.LambdaHack.Definition.Color.Highlight
instance GHC.Internal.Enum.Enum Game.LambdaHack.Definition.Color.AttrCharW32
instance GHC.Internal.Enum.Enum Game.LambdaHack.Definition.Color.Color
instance GHC.Internal.Enum.Enum Game.LambdaHack.Definition.Color.Highlight
instance GHC.Classes.Eq Game.LambdaHack.Definition.Color.Attr
instance GHC.Classes.Eq Game.LambdaHack.Definition.Color.AttrChar
instance GHC.Classes.Eq Game.LambdaHack.Definition.Color.AttrCharW32
instance GHC.Classes.Eq Game.LambdaHack.Definition.Color.Color
instance GHC.Classes.Eq Game.LambdaHack.Definition.Color.Highlight
instance GHC.Internal.Generics.Generic Game.LambdaHack.Definition.Color.Color
instance Control.DeepSeq.NFData Game.LambdaHack.Definition.Color.Color
instance GHC.Classes.Ord Game.LambdaHack.Definition.Color.AttrCharW32
instance GHC.Classes.Ord Game.LambdaHack.Definition.Color.Color
instance GHC.Classes.Ord Game.LambdaHack.Definition.Color.Highlight
instance GHC.Internal.Read.Read Game.LambdaHack.Definition.Color.Color
instance GHC.Internal.Show.Show Game.LambdaHack.Definition.Color.Attr
instance GHC.Internal.Show.Show Game.LambdaHack.Definition.Color.AttrChar
instance GHC.Internal.Show.Show Game.LambdaHack.Definition.Color.AttrCharW32
instance GHC.Internal.Show.Show Game.LambdaHack.Definition.Color.Color
instance GHC.Internal.Show.Show Game.LambdaHack.Definition.Color.Highlight

-- | Very basic types for content definitions with their internals exposed.
module Game.LambdaHack.Definition.DefsInternal
newtype GroupName c
GroupName :: Text -> GroupName c
[fromGroupName] :: GroupName c -> Text

-- | This does not need to be 1-1, so should not be used in place of the
--   Eq instance, etc.
displayGroupName :: GroupName c -> Text

-- | Content identifiers for the content type c.
data ContentId c
toContentId :: Word16 -> ContentId c
fromContentId :: ContentId c -> Word16
contentIdIndex :: ContentId c -> Int
type ContentSymbol c = Char
toContentSymbol :: Char -> ContentSymbol c
displayContentSymbol :: ContentSymbol c -> Char
instance Data.Binary.Class.Binary (Game.LambdaHack.Definition.DefsInternal.ContentId c)
instance Data.Binary.Class.Binary (Game.LambdaHack.Definition.DefsInternal.GroupName c)
instance GHC.Internal.Enum.Enum (Game.LambdaHack.Definition.DefsInternal.ContentId c)
instance GHC.Classes.Eq (Game.LambdaHack.Definition.DefsInternal.ContentId c)
instance GHC.Classes.Eq (Game.LambdaHack.Definition.DefsInternal.GroupName c)
instance Data.Hashable.Class.Hashable (Game.LambdaHack.Definition.DefsInternal.ContentId c)
instance Data.Hashable.Class.Hashable (Game.LambdaHack.Definition.DefsInternal.GroupName c)
instance Control.DeepSeq.NFData (Game.LambdaHack.Definition.DefsInternal.GroupName c)
instance GHC.Classes.Ord (Game.LambdaHack.Definition.DefsInternal.ContentId c)
instance GHC.Classes.Ord (Game.LambdaHack.Definition.DefsInternal.GroupName c)
instance GHC.Internal.Show.Show (Game.LambdaHack.Definition.DefsInternal.ContentId c)
instance GHC.Internal.Show.Show (Game.LambdaHack.Definition.DefsInternal.GroupName c)

-- | Basic types for content definitions.
module Game.LambdaHack.Definition.Defs
data GroupName c

-- | This does not need to be 1-1, so should not be used in place of the
--   Eq instance, etc.
displayGroupName :: GroupName c -> Text

-- | Content identifiers for the content type c.
data ContentId c
contentIdIndex :: ContentId c -> Int
type ContentSymbol c = Char
displayContentSymbol :: ContentSymbol c -> Char

-- | X spacial dimension for points and vectors.
type X = Int

-- | Y xpacial dimension for points and vectors.
type Y = Int

-- | For each group that the kind belongs to, denoted by a
--   GroupName in the first component of a pair, the second
--   component of a pair shows how common the kind is within the group.
type Freqs c = [(GroupName c, Int)]
renameFreqs :: (Text -> Text) -> Freqs c -> Freqs c

-- | Rarity on given depths. The first element of the pair is normally in
--   (0, 10] interval and, e.g., if there are 20 levels, 0.5 represents the
--   first level and 10 the last. Exceptionally, it may be larger than 10,
--   meaning appearance in the dungeon is not possible under normal
--   circumstances and the value remains constant above the interval bound.
type Rarity = [(Double, Int)]
linearInterpolation :: Int -> Int -> Rarity -> Int

-- | Actor's item stores.
data CStore
CGround :: CStore
COrgan :: CStore
CEqp :: CStore
CStash :: CStore
ppCStore :: CStore -> (Text, Text)
ppCStoreIn :: CStore -> Text
verbCStore :: CStore -> Text

-- | Item slot and lore categories.
data SLore
SItem :: SLore
SOrgan :: SLore
STrunk :: SLore
SCondition :: SLore
SBlast :: SLore
SEmbed :: SLore
SBody :: SLore
data ItemDialogMode

-- | a leader's store
MStore :: CStore -> ItemDialogMode

-- | all party's items
MOwned :: ItemDialogMode

-- | not items, but determined by leader's items
MSkills :: ItemDialogMode

-- | not party's items, but all known generalized items
MLore :: SLore -> ItemDialogMode

-- | places; not items at all, but definitely a lore
MPlaces :: ItemDialogMode

-- | factions in this game, with some data from previous
MFactions :: ItemDialogMode

-- | scenarios; not items at all, but definitely a lore
MModes :: ItemDialogMode
ppSLore :: SLore -> Text
headingSLore :: SLore -> Text
ppItemDialogMode :: ItemDialogMode -> (Text, Text)
ppItemDialogModeIn :: ItemDialogMode -> Text
ppItemDialogModeFrom :: ItemDialogMode -> Text
loreFromMode :: ItemDialogMode -> SLore
data Direction
Forward :: Direction
Backward :: Direction
instance Data.Binary.Class.Binary Game.LambdaHack.Definition.Defs.CStore
instance Data.Binary.Class.Binary Game.LambdaHack.Definition.Defs.Direction
instance Data.Binary.Class.Binary Game.LambdaHack.Definition.Defs.ItemDialogMode
instance Data.Binary.Class.Binary Game.LambdaHack.Definition.Defs.SLore
instance GHC.Internal.Enum.Bounded Game.LambdaHack.Definition.Defs.CStore
instance GHC.Internal.Enum.Bounded Game.LambdaHack.Definition.Defs.SLore
instance GHC.Internal.Enum.Enum Game.LambdaHack.Definition.Defs.CStore
instance GHC.Internal.Enum.Enum Game.LambdaHack.Definition.Defs.SLore
instance GHC.Classes.Eq Game.LambdaHack.Definition.Defs.CStore
instance GHC.Classes.Eq Game.LambdaHack.Definition.Defs.Direction
instance GHC.Classes.Eq Game.LambdaHack.Definition.Defs.ItemDialogMode
instance GHC.Classes.Eq Game.LambdaHack.Definition.Defs.SLore
instance GHC.Internal.Generics.Generic Game.LambdaHack.Definition.Defs.CStore
instance GHC.Internal.Generics.Generic Game.LambdaHack.Definition.Defs.Direction
instance GHC.Internal.Generics.Generic Game.LambdaHack.Definition.Defs.ItemDialogMode
instance GHC.Internal.Generics.Generic Game.LambdaHack.Definition.Defs.SLore
instance Control.DeepSeq.NFData Game.LambdaHack.Definition.Defs.CStore
instance Control.DeepSeq.NFData Game.LambdaHack.Definition.Defs.Direction
instance Control.DeepSeq.NFData Game.LambdaHack.Definition.Defs.ItemDialogMode
instance Control.DeepSeq.NFData Game.LambdaHack.Definition.Defs.SLore
instance GHC.Classes.Ord Game.LambdaHack.Definition.Defs.CStore
instance GHC.Classes.Ord Game.LambdaHack.Definition.Defs.Direction
instance GHC.Classes.Ord Game.LambdaHack.Definition.Defs.ItemDialogMode
instance GHC.Classes.Ord Game.LambdaHack.Definition.Defs.SLore
instance GHC.Internal.Read.Read Game.LambdaHack.Definition.Defs.CStore
instance GHC.Internal.Read.Read Game.LambdaHack.Definition.Defs.Direction
instance GHC.Internal.Read.Read Game.LambdaHack.Definition.Defs.ItemDialogMode
instance GHC.Internal.Read.Read Game.LambdaHack.Definition.Defs.SLore
instance GHC.Internal.Show.Show Game.LambdaHack.Definition.Defs.CStore
instance GHC.Internal.Show.Show Game.LambdaHack.Definition.Defs.Direction
instance GHC.Internal.Show.Show Game.LambdaHack.Definition.Defs.ItemDialogMode
instance GHC.Internal.Show.Show Game.LambdaHack.Definition.Defs.SLore

-- | Basic operations on 2D points represented as linear offsets.
module Game.LambdaHack.Common.Point

-- | 2D points in cartesian representation. Coordinates grow to the right
--   and down, so that the (0, 0) point is in the top-left corner of the
--   screen. Coordinates are never negative (unlike for Vector) and
--   the X coordinate never reaches the screen width as read from
--   speedupHackXSize.
data Point
Point :: X -> Y -> Point
[px] :: Point -> X
[py] :: Point -> Y

-- | Enumeration representation of Point.
type PointI = Int

-- | The distance between two points in the chessboard metric.
--   
--   
--   >>> chessDist (Point 0 0) (Point 0 0)
--   0
--   
--   >>> chessDist (Point (-1) 0) (Point 0 0)
--   1
--   
--   >>> chessDist (Point (-1) 0) (Point (-1) 1)
--   1
--   
--   >>> chessDist (Point (-1) 0) (Point 0 1)
--   1
--   
--   >>> chessDist (Point (-1) 0) (Point 1 1)
--   2
--   
--   
--   
--   chessDist p1 p2 >= 0
--   
--   
--   
--   chessDist p1 p2 ^ (2 :: Int) <= euclidDistSq p1 p2
--   
chessDist :: Point -> Point -> Int

-- | Squared euclidean distance between two points.
euclidDistSq :: Point -> Point -> Int

-- | Checks whether two points are adjacent on the map (horizontally,
--   vertically or diagonally).
adjacent :: Point -> Point -> Bool

-- | Bresenham's line algorithm generalized to arbitrary starting
--   eps (eps value of 0 gives the standard BLA). Skips
--   the source point and goes through the second point to infinity. Gives
--   Nothing if the points are equal. The target is given as
--   Point, not PointI, to permit aiming out of the
--   level, e.g., to get uniform distributions of directions for explosions
--   close to the edge of the level.
--   
--   
--   >>> bresenhamsLineAlgorithm 0 (Point 0 0) (Point 0 0)
--   Nothing
--   
--   >>> take 3 $ fromJust $ bresenhamsLineAlgorithm 0 (Point 0 0) (Point 1 0)
--   [(1,0),(2,0),(3,0)]
--   
--   >>> take 3 $ fromJust $ bresenhamsLineAlgorithm 0 (Point 0 0) (Point 0 1)
--   [(0,1),(0,2),(0,3)]
--   
--   >>> take 3 $ fromJust $ bresenhamsLineAlgorithm 0 (Point 0 0) (Point 1 1)
--   [(1,1),(2,2),(3,3)]
--   
bresenhamsLineAlgorithm :: Int -> Point -> Point -> Maybe [Point]

-- | A list of all points on a straight vertical or straight horizontal
--   line between two points. Fails if no such line exists.
--   
--   
--   >>> fromTo (Point 0 0) (Point 2 0)
--   [(0,0),(1,0),(2,0)]
--   
fromTo :: Point -> Point -> [Point]
originPoint :: Point

-- | Checks that a point belongs to an area.
insideP :: (X, Y, X, Y) -> Point -> Bool

-- | This is a hack to pass the X size of the dungeon, defined in game
--   content, to the Enum instances of Point and
--   Vector. This is already slower and has higher allocation than
--   hardcoding the value, so passing the value explicitly to a
--   generalization of the Enum conversions is out of the
--   question. Perhaps this can be done cleanly and efficiently at
--   link-time via Backpack, but it's probably not supported yet by GHCJS
--   (not verified). For now, we need to be careful never to modify this
--   array, except for setting it at program start before it's used for the
--   first time. Which is easy, because Point is never mentioned
--   in content definitions. The PrimArray has much smaller
--   overhead than IORef and reading from it looks cleaner, hence
--   its use.
speedupHackXSize :: PrimArray X

-- | Bresenham's line algorithm generalized to arbitrary starting
--   eps (eps value of 0 gives the standard BLA).
--   Includes the source point and goes through the target point to
--   infinity.
--   
--   
--   >>> take 4 $ bresenhamsLineAlgorithmBegin 0 (Point 0 0) (Point 2 0)
--   [(0,0),(1,0),(2,0),(3,0)]
--   
bresenhamsLineAlgorithmBegin :: Int -> Point -> Point -> [Point]

-- | See
--   http://roguebasin.roguelikedevelopment.org/index.php/index.php?title=Digital_lines.
balancedWord :: Int -> Int -> Int -> [Int]
instance Test.QuickCheck.Arbitrary.Arbitrary Game.LambdaHack.Common.Point.Point
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Point.Point
instance GHC.Internal.Enum.Enum Game.LambdaHack.Common.Point.Point
instance GHC.Classes.Eq Game.LambdaHack.Common.Point.Point
instance GHC.Internal.Generics.Generic Game.LambdaHack.Common.Point.Point
instance GHC.Classes.Ord Game.LambdaHack.Common.Point.Point
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Point.Point

-- | Basic operations on bounded 2D vectors, with an efficient, but not 1-1
--   and not monotonic Enum instance.
module Game.LambdaHack.Common.Vector

-- | 2D vectors in cartesian representation. Coordinates grow to the right
--   and down, so that the (1, 1) vector points to the bottom-right corner
--   of the screen.
data Vector
Vector :: X -> Y -> Vector
[vx] :: Vector -> X
[vy] :: Vector -> Y

-- | Enumeration representation of Vector.
type VectorI = Int

-- | Tells if a vector has length 1 in the chessboard metric.
isUnit :: Vector -> Bool

-- | Reverse an arbirary vector.
neg :: Vector -> Vector

-- | The lenght of a vector in the chessboard metric, where diagonal moves
--   cost 1.
chessDistVector :: Vector -> Int

-- | Squared euclidean distance between two vectors.
euclidDistSqVector :: Vector -> Vector -> Int

-- | Vectors of all unit moves in the chessboard metric, clockwise,
--   starting north-west.
moves :: [Vector]

-- | Vectors of all cardinal direction unit moves, clockwise, starting
--   north.
movesCardinal :: [Vector]
movesCardinalI :: [VectorI]

-- | Vectors of all diagonal direction unit moves, clockwise, starting
--   north.
movesDiagonal :: [Vector]
movesDiagonalI :: [VectorI]
compassText :: Vector -> Text

-- | All (8 at most) closest neighbours of a point within an area.
vicinityBounded :: X -> Y -> Point -> [Point]
vicinityUnsafe :: Point -> [Point]

-- | All (4 at most) cardinal direction neighbours of a point within an
--   area.
vicinityCardinal :: X -> Y -> Point -> [Point]
vicinityCardinalUnsafe :: Point -> [Point]
squareUnsafeSet :: Point -> EnumSet Point

-- | Translate a point by a vector.
shift :: Point -> Vector -> Point

-- | Translate a point by a vector, but only if the result fits in an area.
shiftBounded :: X -> Y -> Point -> Vector -> Point

-- | A list of points that a list of vectors leads to.
trajectoryToPath :: Point -> [Vector] -> [Point]

-- | A list of points that a list of vectors leads to, bounded by level
--   size.
trajectoryToPathBounded :: X -> Y -> Point -> [Vector] -> [Point]

-- | The vector between the second point and the first. We have
--   
--   
--   shift pos1 (pos2 `vectorToFrom` pos1) == pos2
--   
--   
--   The arguments are in the same order as in the underlying scalar
--   subtraction.
vectorToFrom :: Point -> Point -> Vector
computeTrajectory :: Int -> Int -> Int -> [Point] -> ([Vector], (Speed, Int))
type RadianAngle = Double

-- | Rotate a vector by the given angle (expressed in radians)
--   counterclockwise and return a unit vector approximately in the
--   resulting direction.
rotate :: RadianAngle -> Vector -> Vector

-- | Given two distinct positions, determine the direction (a unit vector)
--   in which one should move from the first in order to get closer to the
--   second. Ignores obstacles. Of several equally good directions (in the
--   chessboard metric) it picks one of those that visually (in the
--   euclidean metric) maximally align with the vector between the two
--   points.
towards :: Point -> Point -> Vector
longMoveTexts :: [Text]
movesSquare :: [VectorI]

-- | A list of vectors between a list of points.
pathToTrajectory :: [Point] -> [Vector]

-- | Given a vector of arbitrary non-zero length, produce a unit vector
--   that points in the same direction (in the chessboard metric). Of
--   several equally good directions it picks one of those that visually
--   (in the euclidean metric) maximally align with the original vector.
normalize :: Double -> Double -> Vector
normalizeVector :: Vector -> Vector
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Vector.Vector
instance GHC.Internal.Enum.Enum Game.LambdaHack.Common.Vector.Vector
instance GHC.Classes.Eq Game.LambdaHack.Common.Vector.Vector
instance GHC.Internal.Generics.Generic Game.LambdaHack.Common.Vector.Vector
instance Control.DeepSeq.NFData Game.LambdaHack.Common.Vector.Vector
instance GHC.Classes.Ord Game.LambdaHack.Common.Vector.Vector
instance GHC.Internal.Read.Read Game.LambdaHack.Common.Vector.Vector
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Vector.Vector

-- | Abstract identifiers for the main types in the engine. This is
--   imported by modules that don't need to know the internal structure of
--   the types. As a side effect, this prevents mutual dependencies among
--   modules.
module Game.LambdaHack.Common.Types

-- | A unique identifier of an item in the dungeon.
data ItemId

-- | A unique identifier of a faction in a game. It's assigned in the order
--   from game mode roster, starting from one. We keep the
--   FactionId and TeamContinuity types separate mostly
--   to let FactionId reflect the order, which influences starting
--   faction positions, etc. We use TeamContinuity for
--   dictionaries containing teams that may or may not be active factions
--   in the current game, while FactionId are used only for
--   factions in the game (in particular, because they vary depending on
--   order in game mode roster, while TeamContinuity are stable).
data FactionId

-- | Abstract level identifiers.
data LevelId

-- | A unique identifier of an actor in the dungeon.
data ActorId

-- | Item container type.
data Container
CFloor :: LevelId -> Point -> Container
CEmbed :: LevelId -> Point -> Container
CActor :: ActorId -> CStore -> Container

-- | for bootstrapping actor bodies
CTrunk :: FactionId -> LevelId -> Point -> Container
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Types.ActorId
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Types.Container
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Types.FactionId
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Types.ItemId
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Types.LevelId
instance GHC.Internal.Enum.Enum Game.LambdaHack.Common.Types.ActorId
instance GHC.Internal.Enum.Enum Game.LambdaHack.Common.Types.FactionId
instance GHC.Internal.Enum.Enum Game.LambdaHack.Common.Types.ItemId
instance GHC.Internal.Enum.Enum Game.LambdaHack.Common.Types.LevelId
instance GHC.Classes.Eq Game.LambdaHack.Common.Types.ActorId
instance GHC.Classes.Eq Game.LambdaHack.Common.Types.Container
instance GHC.Classes.Eq Game.LambdaHack.Common.Types.FactionId
instance GHC.Classes.Eq Game.LambdaHack.Common.Types.ItemId
instance GHC.Classes.Eq Game.LambdaHack.Common.Types.LevelId
instance GHC.Internal.Generics.Generic Game.LambdaHack.Common.Types.Container
instance Data.Hashable.Class.Hashable Game.LambdaHack.Common.Types.FactionId
instance Data.Hashable.Class.Hashable Game.LambdaHack.Common.Types.LevelId
instance GHC.Classes.Ord Game.LambdaHack.Common.Types.ActorId
instance GHC.Classes.Ord Game.LambdaHack.Common.Types.Container
instance GHC.Classes.Ord Game.LambdaHack.Common.Types.FactionId
instance GHC.Classes.Ord Game.LambdaHack.Common.Types.ItemId
instance GHC.Classes.Ord Game.LambdaHack.Common.Types.LevelId
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Types.ActorId
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Types.Container
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Types.FactionId
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Types.ItemId
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Types.LevelId

-- | Actors perceiving other actors and the dungeon level.
--   
--   Visibility works according to KISS. Everything that player sees is
--   real. There are no unmarked hidden tiles and only solid tiles can be
--   marked, so there are no invisible walls and to pass through an
--   illusory wall, you have to use a turn bumping into it first. Only
--   tiles marked with Suspect can turn out to be another tile. (So, if all
--   tiles are marked with Suspect, the player knows nothing for sure, but
--   this should be avoided, because searching becomes too time-consuming.)
--   Each actor sees adjacent tiles, even when blind, so adjacent tiles are
--   known, so the actor can decide accurately whether to pass thorugh or
--   alter, etc.
--   
--   Items are always real and visible. Actors are real, but can be
--   invisible. Invisible actors in walls can't be hit, but are hinted at
--   when altering the tile, so the player can flee or block. Invisible
--   actors in open space can be hit.
module Game.LambdaHack.Common.Perception

-- | Visible positions.
newtype PerVisible
PerVisible :: EnumSet Point -> PerVisible
[pvisible] :: PerVisible -> EnumSet Point

-- | Smelled positions.
newtype PerSmelled
PerSmelled :: EnumSet Point -> PerSmelled
[psmelled] :: PerSmelled -> EnumSet Point

-- | The type representing the perception of a faction on a level.
data Perception
Perception :: PerVisible -> PerSmelled -> Perception
[psight] :: Perception -> PerVisible
[psmell] :: Perception -> PerSmelled

-- | Perception of a single faction, indexed by level identifier.
type PerLid = EnumMap LevelId Perception

-- | Perception indexed by faction identifier. This can't be added to
--   FactionDict, because clients can't see it for other factions.
type PerFid = EnumMap FactionId PerLid

-- | The set of tiles visible by at least one hero.
totalVisible :: Perception -> EnumSet Point

-- | The set of tiles smelt by at least one hero.
totalSmelled :: Perception -> EnumSet Point
emptyPer :: Perception
nullPer :: Perception -> Bool
addPer :: Perception -> Perception -> Perception
diffPer :: Perception -> Perception -> Perception
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Perception.PerSmelled
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Perception.PerVisible
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Perception.Perception
instance GHC.Classes.Eq Game.LambdaHack.Common.Perception.PerSmelled
instance GHC.Classes.Eq Game.LambdaHack.Common.Perception.PerVisible
instance GHC.Classes.Eq Game.LambdaHack.Common.Perception.Perception
instance GHC.Internal.Generics.Generic Game.LambdaHack.Common.Perception.Perception
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Perception.PerSmelled
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Perception.PerVisible
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Perception.Perception

-- | UI screen coordinates.
module Game.LambdaHack.Client.UI.PointUI

-- | UI screen coordinates, independent of whether square or monospace
--   fonts are being placed on the screen (though square fonts are never
--   placed on odd coordinates). These are not game map coordinates, becuse
--   UI is larger and more fine-grained than just the game map.
data PointUI
PointUI :: Int -> Int -> PointUI

-- | Coordinates of the big square fonts. These are not game map
--   coordinates, because the latter are offset by mapStartY and
--   represented by Point.
--   
--   However, confusingly, Point is also used for square font
--   glyph coordinates, though exclusively in context of rendered frames to
--   be sent to a frontend, namely PointArray.Array, which is
--   indexed by Point and is a vector, and so traditionally
--   indexed starting from zero and not from minus one, as would be needed
--   for consistency.
data PointSquare
PointSquare :: Int -> Int -> PointSquare
squareToUI :: PointSquare -> PointUI
uiToSquare :: PointUI -> PointSquare
squareToMap :: PointSquare -> Point
mapToSquare :: Point -> PointSquare

-- | The row where the dungeon map starts, both in PointUI and
--   PointSquare coordinates.
mapStartY :: Int
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.PointUI.PointSquare
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.PointUI.PointUI
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.PointUI.PointSquare
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.PointUI.PointUI

-- | Screen overlays.
module Game.LambdaHack.Client.UI.Overlay

-- | Three types of fonts used in the UI. Overlays (layers, more or less)
--   in proportional font are overwritten by layers in square font, which
--   are overwritten by layers in mono font. All overlays overwrite the
--   rendering of the game map, which is the underlying basic UI frame,
--   comprised of square font glyps.
--   
--   This type needs to be kept abstract to ensure that frontend-enforced
--   or user config-enforced font assignments in FontSetup (e.g.,
--   stating that the supposedly proportional font is overriden to be the
--   square font) can't be ignored. Otherwise a programmer could use
--   arbirary DisplayFont, instead of the one taken from
--   FontSetup, and so, e.g., calculating the width of an overlay so
--   constructed in order to decide where another overlay can start would
--   be inconsistent what what font is really eventually used when
--   rendering.
--   
--   Note that the order of constructors has limited effect, but it
--   illustrates how overwriting is explicitly implemented in frontends
--   that support all fonts.
data DisplayFont
isPropFont :: DisplayFont -> Bool
isSquareFont :: DisplayFont -> Bool
isMonoFont :: DisplayFont -> Bool
textSize :: DisplayFont -> [a] -> Int
data FontSetup
FontSetup :: DisplayFont -> DisplayFont -> DisplayFont -> FontSetup
[squareFont] :: FontSetup -> DisplayFont
[monoFont] :: FontSetup -> DisplayFont
[propFont] :: FontSetup -> DisplayFont
multiFontSetup :: FontSetup
singleFontSetup :: FontSetup

-- | String of colourful text. End of line characters permitted.
type AttrString = [AttrCharW32]
blankAttrString :: Int -> AttrString
textToAS :: Text -> AttrString
textFgToAS :: Color -> Text -> AttrString
stringToAS :: String -> AttrString

-- | Transform AttrString type to String.
attrStringToString :: AttrString -> String
(<+:>) :: AttrString -> AttrString -> AttrString
infixr 6 <+:>
(<\:>) :: AttrString -> AttrString -> AttrString
infixr 6 <\:>

-- | Line of colourful text. End of line characters forbidden. Trailing
--   White space forbidden.
data AttrLine
attrLine :: AttrLine -> AttrString
emptyAttrLine :: AttrLine
attrStringToAL :: AttrString -> AttrLine
firstParagraph :: AttrString -> AttrLine
textToAL :: Text -> AttrLine
textFgToAL :: Color -> Text -> AttrLine
stringToAL :: String -> AttrLine
linesAttr :: AttrString -> [AttrLine]

-- | Split a string into lines. Avoid breaking the line at a character
--   other than space. Remove the spaces on which lines are broken, keep
--   other spaces. In expensive assertions mode (dev debug mode) fail at
--   trailing spaces, but keep leading spaces, e.g., to make distance from
--   a text in another font. Newlines are respected.
--   
--   Note that we only split wrt White space, nothing else, and
--   the width, in the first argument, is calculated in characters, not in
--   UI (mono font) coordinates, so that taking and dropping characters is
--   performed correctly.
splitAttrString :: Int -> Int -> AttrString -> [AttrLine]
indentSplitAttrString :: DisplayFont -> Int -> AttrString -> [AttrLine]

-- | A series of screen lines with start positions at which they should be
--   overlayed over the base frame or a blank screen, depending on context.
--   The position point is represented as in integer that is an index into
--   the frame character array. The lines either fit the width of the
--   screen or are intended for truncation when displayed. The start
--   positions of lines may fall outside the length of the screen, too,
--   unlike in SingleFrame. Then they are simply not shown.
type Overlay = [(PointUI, AttrLine)]
xytranslateOverlay :: Int -> Int -> Overlay -> Overlay
xtranslateOverlay :: Int -> Overlay -> Overlay
ytranslateOverlay :: Int -> Overlay -> Overlay
offsetOverlay :: [AttrLine] -> Overlay
offsetOverlayX :: [(Int, AttrLine)] -> Overlay
typesetXY :: (Int, Int) -> [AttrLine] -> Overlay
updateLine :: Int -> (Int -> AttrString -> AttrString) -> Overlay -> Overlay
rectangleOfSpaces :: Int -> Int -> Overlay
maxYofOverlay :: Overlay -> Int
labDescOverlay :: DisplayFont -> Int -> AttrString -> (Overlay, Overlay)
nonbreakableRev :: [String]
isPrefixOfNonbreakable :: AttrString -> Bool
breakAtSpace :: AttrString -> (AttrString, AttrString)
splitAttrPhrase :: Int -> Int -> AttrLine -> [AttrLine]
instance GHC.Internal.Enum.Enum Game.LambdaHack.Client.UI.Overlay.DisplayFont
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.Overlay.AttrLine
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.Overlay.DisplayFont
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.Overlay.FontSetup
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.Overlay.AttrLine
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.Overlay.DisplayFont
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.Overlay.FontSetup

-- | Game messages displayed on top of the screen for the player to read
--   and then saved to player history.
module Game.LambdaHack.Client.UI.Msg

-- | The type of a single game message.
data Msg
class MsgShared a
toMsgShared :: MsgShared a => [(String, Color)] -> a -> Text -> Msg
toMsgDistinct :: [(String, Color)] -> MsgClassDistinct -> Text -> Text -> Msg
data MsgClassShowAndSave
MsgBookKeeping :: MsgClassShowAndSave
MsgStatusWakeup :: MsgClassShowAndSave
MsgStatusStopUs :: MsgClassShowAndSave
MsgStatusStopThem :: MsgClassShowAndSave
MsgItemCreation :: MsgClassShowAndSave
MsgItemRuination :: MsgClassShowAndSave
MsgDeathVictory :: MsgClassShowAndSave
MsgDeathDeafeat :: MsgClassShowAndSave
MsgDeathBoring :: MsgClassShowAndSave
MsgRiskOfDeath :: MsgClassShowAndSave
MsgPointmanSwap :: MsgClassShowAndSave
MsgFactionIntel :: MsgClassShowAndSave
MsgFinalOutcome :: MsgClassShowAndSave
MsgBackdropInfo :: MsgClassShowAndSave
MsgTerrainReveal :: MsgClassShowAndSave
MsgItemDiscovery :: MsgClassShowAndSave
MsgSpottedActor :: MsgClassShowAndSave
MsgItemMovement :: MsgClassShowAndSave
MsgActionMajor :: MsgClassShowAndSave
MsgActionMinor :: MsgClassShowAndSave
MsgEffectMajor :: MsgClassShowAndSave
MsgEffectMedium :: MsgClassShowAndSave
MsgEffectMinor :: MsgClassShowAndSave
MsgMiscellanous :: MsgClassShowAndSave
MsgHeardOutside :: MsgClassShowAndSave
MsgHeardNearby :: MsgClassShowAndSave
MsgHeardFaraway :: MsgClassShowAndSave
MsgBackdropFocus :: MsgClassShowAndSave
MsgActionWarning :: MsgClassShowAndSave
MsgRangedMightyWe :: MsgClassShowAndSave
MsgRangedMightyUs :: MsgClassShowAndSave
MsgRangedOthers :: MsgClassShowAndSave
MsgRangedNormalUs :: MsgClassShowAndSave
MsgGoodMiscEvent :: MsgClassShowAndSave
MsgBadMiscEvent :: MsgClassShowAndSave
MsgNeutralEvent :: MsgClassShowAndSave
MsgSpecialEvent :: MsgClassShowAndSave
MsgMeleeMightyWe :: MsgClassShowAndSave
MsgMeleeMightyUs :: MsgClassShowAndSave
MsgMeleeComplexWe :: MsgClassShowAndSave
MsgMeleeComplexUs :: MsgClassShowAndSave
MsgMeleeOthers :: MsgClassShowAndSave
MsgMeleeNormalUs :: MsgClassShowAndSave
MsgActionComplete :: MsgClassShowAndSave
MsgAtFeetMajor :: MsgClassShowAndSave
MsgAtFeetMinor :: MsgClassShowAndSave
MsgTutorialHint :: MsgClassShowAndSave
data MsgClassShow
MsgPromptGeneric :: MsgClassShow
MsgPromptFocus :: MsgClassShow
MsgPromptMention :: MsgClassShow
MsgPromptModify :: MsgClassShow
MsgPromptActors :: MsgClassShow
MsgPromptItems :: MsgClassShow
MsgPromptAction :: MsgClassShow
MsgActionAlert :: MsgClassShow
MsgSpottedThreat :: MsgClassShow
data MsgClassSave
MsgInnerWorkSpam :: MsgClassSave
MsgNumericReport :: MsgClassSave
data MsgClassIgnore
MsgMacroOperation :: MsgClassIgnore
MsgRunStopReason :: MsgClassIgnore
MsgStopPlayback :: MsgClassIgnore
data MsgClassDistinct
MsgSpottedItem :: MsgClassDistinct
MsgStatusSleep :: MsgClassDistinct
MsgStatusGoodUs :: MsgClassDistinct
MsgStatusBadUs :: MsgClassDistinct
MsgStatusOthers :: MsgClassDistinct
MsgStatusBenign :: MsgClassDistinct
MsgStatusWarning :: MsgClassDistinct
MsgStatusLongerUs :: MsgClassDistinct
MsgStatusLongThem :: MsgClassDistinct
data MsgClass
interruptsRunning :: MsgClass -> Bool
disturbsResting :: MsgClass -> Bool

-- | The set of messages, with repetitions, to show at the screen at once.
data Report

-- | Test if the list of non-whitespace messages is empty.
nullVisibleReport :: Report -> Bool

-- | Add a message to the start of report.
consReport :: Msg -> Report -> Report

-- | Render a report as a (possibly very long) list of AttrString.
renderReport :: Bool -> Report -> [AttrString]
anyInReport :: (MsgClass -> Bool) -> Report -> Bool

-- | The history of reports. This is a ring buffer of the given length
--   containing old archived history and two most recent reports stored
--   separately.
data History
newReport :: History -> Report

-- | Empty history of the given maximal length.
emptyHistory :: Int -> History

-- | Add a message to the new report of history, eliminating a possible
--   duplicate and noting its existence in the result.
addToReport :: Set Msg -> Bool -> Bool -> History -> Msg -> Time -> (Set Msg, History, Bool)

-- | Add a newline to end of the new report of history, unless empty.
addEolToNewReport :: History -> History

-- | Archive old report to history, filtering out messages with 0
--   duplicates and prompts. Set up new report with a new timestamp.
archiveReport :: History -> History
lengthHistory :: History -> Int

-- | Render history as many lines of text. New report is not rendered. It's
--   expected to be empty when history is shown.
renderHistory :: History -> [AttrString]
type UAttrString = Vector Word32
uToAttrString :: UAttrString -> AttrString
attrStringToU :: AttrString -> UAttrString
toMsg :: [(String, Color)] -> MsgPrototype -> Msg
data MsgPrototype
tripleFromProto :: MsgPrototype -> (Text, Text, MsgClass)
scrapsRepeats :: MsgClass -> Bool
isTutorialHint :: MsgClass -> Bool
msgColor :: MsgClass -> Color
data RepMsgNK

-- | If only one of the message components is non-empty and non-whitespace,
--   but its count is zero, the message is considered empty.
nullRepMsgNK :: RepMsgNK -> Bool

-- | Empty set of messages.
emptyReport :: Report
renderRepetition :: (AttrString, Int) -> AttrString
scrapRepetitionSingle :: (AttrString, Int) -> [(AttrString, Int)] -> [(AttrString, Int)] -> (Bool, [(AttrString, Int)], [(AttrString, Int)])
scrapRepetition :: History -> Maybe History
renderTimeReport :: Time -> Report -> [AttrString]
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.Msg.History
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.Msg.Msg
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.Msg.MsgClass
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.Msg.MsgClassDistinct
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.Msg.MsgClassIgnore
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.Msg.MsgClassSave
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.Msg.MsgClassShow
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.Msg.MsgClassShowAndSave
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.Msg.RepMsgNK
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.Msg.Report
instance GHC.Internal.Enum.Bounded Game.LambdaHack.Client.UI.Msg.MsgClassDistinct
instance GHC.Internal.Enum.Bounded Game.LambdaHack.Client.UI.Msg.MsgClassIgnore
instance GHC.Internal.Enum.Bounded Game.LambdaHack.Client.UI.Msg.MsgClassSave
instance GHC.Internal.Enum.Bounded Game.LambdaHack.Client.UI.Msg.MsgClassShow
instance GHC.Internal.Enum.Bounded Game.LambdaHack.Client.UI.Msg.MsgClassShowAndSave
instance GHC.Internal.Enum.Enum Game.LambdaHack.Client.UI.Msg.MsgClassDistinct
instance GHC.Internal.Enum.Enum Game.LambdaHack.Client.UI.Msg.MsgClassIgnore
instance GHC.Internal.Enum.Enum Game.LambdaHack.Client.UI.Msg.MsgClassSave
instance GHC.Internal.Enum.Enum Game.LambdaHack.Client.UI.Msg.MsgClassShow
instance GHC.Internal.Enum.Enum Game.LambdaHack.Client.UI.Msg.MsgClassShowAndSave
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.Msg.Msg
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.Msg.MsgClass
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.Msg.MsgClassDistinct
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.Msg.MsgClassIgnore
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.Msg.MsgClassSave
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.Msg.MsgClassShow
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.Msg.MsgClassShowAndSave
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.UI.Msg.History
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.UI.Msg.Msg
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.UI.Msg.MsgClass
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.UI.Msg.MsgClassDistinct
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.UI.Msg.MsgClassIgnore
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.UI.Msg.MsgClassSave
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.UI.Msg.MsgClassShow
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.UI.Msg.MsgClassShowAndSave
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.UI.Msg.RepMsgNK
instance Game.LambdaHack.Client.UI.Msg.MsgShared Game.LambdaHack.Client.UI.Msg.MsgClassIgnore
instance Game.LambdaHack.Client.UI.Msg.MsgShared Game.LambdaHack.Client.UI.Msg.MsgClassSave
instance Game.LambdaHack.Client.UI.Msg.MsgShared Game.LambdaHack.Client.UI.Msg.MsgClassShow
instance Game.LambdaHack.Client.UI.Msg.MsgShared Game.LambdaHack.Client.UI.Msg.MsgClassShowAndSave
instance GHC.Classes.Ord Game.LambdaHack.Client.UI.Msg.Msg
instance GHC.Classes.Ord Game.LambdaHack.Client.UI.Msg.MsgClass
instance GHC.Classes.Ord Game.LambdaHack.Client.UI.Msg.MsgClassDistinct
instance GHC.Classes.Ord Game.LambdaHack.Client.UI.Msg.MsgClassIgnore
instance GHC.Classes.Ord Game.LambdaHack.Client.UI.Msg.MsgClassSave
instance GHC.Classes.Ord Game.LambdaHack.Client.UI.Msg.MsgClassShow
instance GHC.Classes.Ord Game.LambdaHack.Client.UI.Msg.MsgClassShowAndSave
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.Msg.History
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.Msg.Msg
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.Msg.MsgClass
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.Msg.MsgClassDistinct
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.Msg.MsgClassIgnore
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.Msg.MsgClassSave
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.Msg.MsgClassShow
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.Msg.MsgClassShowAndSave
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.Msg.RepMsgNK
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.Msg.Report

-- | Frontend-independent keyboard input operations.
module Game.LambdaHack.Client.UI.Key

-- | Frontend-independent datatype to represent keys.
data Key
Esc :: Key
Return :: Key
Space :: Key
Tab :: Key
BackTab :: Key
BackSpace :: Key
PgUp :: Key
PgDn :: Key
Left :: Key
Right :: Key
Up :: Key
Down :: Key
End :: Key
Begin :: Key
Insert :: Key
Delete :: Key
PrintScreen :: Key
Home :: Key

-- | a keypad key for a character (digits and operators)
KP :: Char -> Key

-- | a single printable character
Char :: Char -> Key

-- | function key
Fun :: Int -> Key

-- | left mouse button pressed
LeftButtonPress :: Key

-- | middle mouse button pressed
MiddleButtonPress :: Key

-- | right mouse button pressed
RightButtonPress :: Key

-- | left mouse button released
LeftButtonRelease :: Key

-- | middle mouse button released
MiddleButtonRelease :: Key

-- | right mouse button released
RightButtonRelease :: Key

-- | mouse wheel rotated north
WheelNorth :: Key

-- | mouse wheel rotated south
WheelSouth :: Key

-- | an unknown key, registered to warn the user
Unknown :: String -> Key
DeadKey :: Key

-- | Our own encoding of modifiers.
data Modifier
NoModifier :: Modifier
ControlShift :: Modifier
AltShift :: Modifier
Shift :: Modifier
Control :: Modifier
Alt :: Modifier

-- | Key and modifier.
data KM
KM :: Modifier -> Key -> KM
[modifier] :: KM -> Modifier
[key] :: KM -> Key

-- | Key, modifier and position of mouse pointer.
data KMP
KMP :: KM -> PointUI -> KMP
[kmpKeyMod] :: KMP -> KM
[kmpPointer] :: KMP -> PointUI

-- | Common and terse names for keys.
showKey :: Key -> String

-- | Show a key with a modifier, if any.
showKM :: KM -> String
escKM :: KM
controlEscKM :: KM
spaceKM :: KM
safeSpaceKM :: KM
undefinedKM :: KM
returnKM :: KM
pgupKM :: KM
pgdnKM :: KM
wheelNorthKM :: KM
wheelSouthKM :: KM
upKM :: KM
downKM :: KM
leftKM :: KM
rightKM :: KM
homeKM :: KM
endKM :: KM
backspaceKM :: KM
controlP :: KM
leftButtonReleaseKM :: KM
middleButtonReleaseKM :: KM
rightButtonReleaseKM :: KM
cardinalAllKM :: Bool -> Bool -> [KM]
dirAllKey :: Bool -> Bool -> [Key]
handleCardinal :: [KM] -> KM -> Maybe Vector

-- | Configurable event handler for the direction keys. Used for directed
--   commands such as close door.
handleDir :: [Key] -> KM -> Maybe Vector

-- | Binding of both sets of movement keys, vi and laptop.
moveBinding :: Bool -> Bool -> (Vector -> a) -> (Vector -> a) -> [(KM, a)]
mkKM :: String -> KM
mkChar :: Char -> KM

-- | Translate key from a GTK string description to our internal key type.
--   To be used, in particular, for the command bindings and macros in the
--   config file.
--   
--   See https://github.com/twobob/gtk-/blob/master/gdk/keynames.txt
keyTranslate :: String -> Key

-- | Translate key from a Web API string description
--   (https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key#Key_values)
--   to our internal key type. To be used in web frontends. The argument
--   says whether Shift is pressed.
keyTranslateWeb :: String -> Bool -> Key
dirMoveNoModifier :: Bool -> Bool -> [Key]
dirRunNoModifier :: Bool -> Bool -> [Key]
dirRunControl :: [Key]
dirRunShift :: [Key]
dirKeypadKey :: [Key]
dirKeypadShiftChar :: [Char]
dirKeypadShiftKey :: [Key]
dirLeftHandKey :: [Key]
dirLeftHandShiftKey :: [Key]
dirViChar :: [Char]
dirViKey :: [Key]
dirViShiftKey :: [Key]
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.Key.KM
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.Key.Key
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.Key.Modifier
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.Key.KM
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.Key.Key
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.Key.Modifier
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.UI.Key.KM
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.UI.Key.Key
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.UI.Key.Modifier
instance Control.DeepSeq.NFData Game.LambdaHack.Client.UI.Key.KM
instance Control.DeepSeq.NFData Game.LambdaHack.Client.UI.Key.Key
instance Control.DeepSeq.NFData Game.LambdaHack.Client.UI.Key.Modifier
instance GHC.Classes.Ord Game.LambdaHack.Client.UI.Key.KM
instance GHC.Classes.Ord Game.LambdaHack.Client.UI.Key.Key
instance GHC.Classes.Ord Game.LambdaHack.Client.UI.Key.Modifier
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.Key.KM
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.Key.Modifier

-- | Rectangular areas of levels and their basic operations.
module Game.LambdaHack.Common.Area

-- | The type of areas. The bottom left and the top right points.
data Area

-- | Checks if it's an area with at least one field.
toArea :: (X, Y, X, Y) -> Maybe Area
fromArea :: Area -> (X, Y, X, Y)
spanArea :: Area -> (Point, X, Y)
trivialArea :: Point -> Area
isTrivialArea :: Area -> Bool

-- | Checks that a point belongs to an area.
inside :: Area -> Point -> Bool

-- | Shrink the given area on all fours sides by the amount.
shrink :: Area -> Maybe Area
expand :: Area -> Area
middlePoint :: Area -> Point
areaInnerBorder :: Area -> [Point]
sumAreas :: Area -> Area -> Area
punindex :: X -> Int -> Point
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Area.Area
instance GHC.Classes.Eq Game.LambdaHack.Common.Area.Area
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Area.Area

-- | Per-actor analytics of personal feats.
module Game.LambdaHack.Common.Analytics

-- | Summary analytics data for each faction.
type FactionAnalytics = EnumMap FactionId Analytics

-- | Analytics data for each live actor.
type ActorAnalytics = EnumMap ActorId Analytics

-- | Statistics of possible and actual generation of items for each lore
--   kind.
type GenerationAnalytics = EnumMap SLore EnumMap ItemId Int
type KillMap = EnumMap FactionId EnumMap ItemId Int

-- | Statistics of past events concerning an actor.
newtype Analytics
Analytics :: EnumMap KillHow KillMap -> Analytics
[akillCounts] :: Analytics -> EnumMap KillHow KillMap

-- | Labels of individual kill count analytics.
data KillHow
KillKineticMelee :: KillHow
KillKineticRanged :: KillHow
KillKineticBlast :: KillHow
KillKineticPush :: KillHow
KillOtherMelee :: KillHow
KillOtherRanged :: KillHow
KillOtherBlast :: KillHow
KillOtherPush :: KillHow
KillActorLaunch :: KillHow
KillTileLaunch :: KillHow
KillDropLaunch :: KillHow
KillCatch :: KillHow
emptyAnalytics :: Analytics
addFactionKill :: FactionId -> KillHow -> FactionId -> ItemId -> FactionAnalytics -> FactionAnalytics
addActorKill :: ActorId -> KillHow -> FactionId -> ItemId -> ActorAnalytics -> ActorAnalytics
addKill :: KillHow -> FactionId -> ItemId -> Maybe Analytics -> Analytics
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Analytics.Analytics
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Analytics.KillHow
instance GHC.Internal.Enum.Enum Game.LambdaHack.Common.Analytics.KillHow
instance GHC.Classes.Eq Game.LambdaHack.Common.Analytics.Analytics
instance GHC.Classes.Eq Game.LambdaHack.Common.Analytics.KillHow
instance GHC.Internal.Generics.Generic Game.LambdaHack.Common.Analytics.KillHow
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Analytics.Analytics
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Analytics.KillHow

-- | A game requires the engine provided by the library, perhaps
--   customized, and game content, defined completely afresh for the
--   particular game. The possible kinds of content are fixed in the
--   library and all defined within the library source code directory. On
--   the other hand, game content, is defined in the directory hosting the
--   particular game definition.
--   
--   Content of a given kind is just a list of content items. After the
--   list is verified and the data preprocessed, it's held in the
--   ContentData datatype.
module Game.LambdaHack.Definition.ContentData

-- | Verified and preprocessed content data of a particular kind.
data ContentData c
validateRarity :: Rarity -> [Text]
validFreqs :: Freqs a -> Bool
emptyContentData :: ContentData a
makeContentData :: Show c => String -> (c -> Text) -> (c -> Freqs c) -> (c -> [Text]) -> ([c] -> ContentData c -> [Text]) -> [c] -> [GroupName c] -> [GroupName c] -> ContentData c

-- | Content element at given id.
okind :: ContentData a -> ContentId a -> a
omemberGroup :: ContentData a -> GroupName a -> Bool
oexistsGroup :: ContentData a -> GroupName a -> Bool
oisSingletonGroup :: ContentData a -> GroupName a -> Bool

-- | The id of the unique member of a singleton content group.
ouniqGroup :: Show a => ContentData a -> GroupName a -> ContentId a

-- | Pick a random id belonging to a group and satisfying a predicate.
opick :: Show a => ContentData a -> GroupName a -> (a -> Bool) -> Rnd (Maybe (ContentId a))

-- | Fold strictly over all content a.
ofoldlWithKey' :: ContentData a -> (b -> ContentId a -> a -> b) -> b -> b

-- | Fold over the given group only.
ofoldlGroup' :: ContentData a -> GroupName a -> (b -> Int -> ContentId a -> a -> b) -> b -> b
omapVector :: ContentData a -> (a -> b) -> Vector b
oimapVector :: ContentData a -> (ContentId a -> a -> b) -> Vector b

-- | Size of content a.
olength :: ContentData a -> Int

-- | Arrays, based on Data.Vector.Unboxed, indexed by Point.
module Game.LambdaHack.Common.PointArray
class (Ord c, Eq UnboxRep c, Ord UnboxRep c, Bounded UnboxRep c, Binary UnboxRep c, Unbox UnboxRep c) => UnboxRepClass c where {
    type UnboxRep c;
    type UnboxRep c = c;
}
toUnboxRepUnsafe :: UnboxRepClass c => c -> UnboxRep c
fromUnboxRep :: UnboxRepClass c => UnboxRep c -> c

-- | Arrays indexed by Point.
data Array c
Array :: X -> Y -> Vector (UnboxRep c) -> Array c
[axsize] :: Array c -> X
[aysize] :: Array c -> Y
[avector] :: Array c -> Vector (UnboxRep c)
empty :: UnboxRepClass c => Array c

-- | Array lookup.
(!) :: UnboxRepClass c => Array c -> Point -> c
accessI :: UnboxRepClass c => Array c -> Int -> UnboxRep c

-- | Construct an array updated with the association list.
(//) :: UnboxRepClass c => Array c -> [(Point, c)] -> Array c

-- | Create an array from a replicated element.
replicateA :: UnboxRepClass c => X -> Y -> c -> Array c
unfoldrNA :: UnboxRepClass c => X -> Y -> (b -> (c, b)) -> b -> Array c

-- | Fold right over an array.
foldrA :: UnboxRepClass c => (c -> a -> a) -> a -> Array c -> a

-- | Fold right strictly over an array.
foldrA' :: UnboxRepClass c => (c -> a -> a) -> a -> Array c -> a

-- | Fold left strictly over an array.
foldlA' :: UnboxRepClass c => (a -> c -> a) -> a -> Array c -> a

-- | Fold left strictly over an array (function applied to each element and
--   its index).
ifoldlA' :: UnboxRepClass c => (a -> Point -> c -> a) -> a -> Array c -> a

-- | Fold right strictly over an array (function applied to each element
--   and its index).
ifoldrA' :: UnboxRepClass c => (Point -> c -> a -> a) -> a -> Array c -> a

-- | Fold monadically strictly over an array.
foldMA' :: (Monad m, UnboxRepClass c) => (a -> c -> m a) -> a -> Array c -> m a

-- | Map over an array.
mapA :: (UnboxRepClass c, UnboxRepClass d) => (c -> d) -> Array c -> Array d

-- | Map over an array (function applied to each element and its index).
imapA :: (UnboxRepClass c, UnboxRepClass d) => (Point -> c -> d) -> Array c -> Array d

-- | Map monadically over an array (function applied to each element and
--   its index) and ignore the results.
imapMA_ :: (Monad m, UnboxRepClass c) => (Point -> c -> m ()) -> Array c -> m ()

-- | Yield the point coordinates of all the minimum elements of the array.
--   The array may not be empty.
minIndexesA :: UnboxRepClass c => Array c -> [Point]

-- | Yield the point coordinates of the first maximum element of the array.
--   The array may not be empty.
maxIndexA :: UnboxRepClass c => Array c -> Point

-- | Yield the point coordinates of the first maximum element of the array.
--   The array may not be empty.
maxIndexByA :: UnboxRepClass c => (c -> c -> Ordering) -> Array c -> Point

-- | Yield the point coordinates of the last maximum element of the array.
--   The array may not be empty.
maxLastIndexA :: UnboxRepClass c => Array c -> Point
toListA :: UnboxRepClass c => Array c -> [c]
toUnboxRep :: UnboxRepClass c => c -> UnboxRep c
instance Game.LambdaHack.Common.PointArray.UnboxRepClass c => Data.Binary.Class.Binary (Game.LambdaHack.Common.PointArray.Array c)
instance Game.LambdaHack.Common.PointArray.UnboxRepClass c => GHC.Classes.Eq (Game.LambdaHack.Common.PointArray.Array c)
instance GHC.Internal.Show.Show (Game.LambdaHack.Common.PointArray.Array c)
instance Game.LambdaHack.Common.PointArray.UnboxRepClass Game.LambdaHack.Definition.Color.AttrCharW32
instance Game.LambdaHack.Common.PointArray.UnboxRepClass GHC.Types.Bool
instance Game.LambdaHack.Common.PointArray.UnboxRepClass (Game.LambdaHack.Definition.DefsInternal.ContentId k)
instance Game.LambdaHack.Common.PointArray.UnboxRepClass GHC.Internal.Word.Word8

-- | Breadth first search algorithm.
module Game.LambdaHack.Client.Bfs

-- | Weighted distance between points along shortest paths.
data BfsDistance

-- | State of legality of moves between adjacent points.
data MoveLegal
MoveBlocked :: MoveLegal
MoveToOpen :: MoveLegal
MoveToClosed :: MoveLegal
MoveToUnknown :: MoveLegal
subtractBfsDistance :: BfsDistance -> BfsDistance -> Int

-- | The minimal distance value assigned to paths that don't enter any
--   unknown tiles.
minKnownBfs :: BfsDistance

-- | The distance value that denotes no legal path between points, either
--   due to blocked tiles or pathfinding aborted at earlier tiles, e.g.,
--   due to unknown tiles.
apartBfs :: BfsDistance

-- | Maximum value of the type.
maxBfsDistance :: BfsDistance

-- | Create and fill a BFS array for the given level. Unsafe array
--   operations are OK here, because the intermediate values of the vector
--   don't leak anywhere outside nor are kept unevaluated and so they can't
--   be overwritten by the unsafe side-effect.
--   
--   When computing move cost, we assume doors openable at no cost, because
--   other actors use them, too, so the cost is shared and the extra
--   visiblity is valuable, too. We treat unknown tiles specially. Whether
--   suspect tiles are considered openable depends on
--   smarkSuspect.
--   
--   Instead of a BFS queue (list) we use the two tabs (arrays), for (JS)
--   speed.
fillBfs :: Array Word8 -> Word8 -> Point -> (PrimArray PointI, PrimArray PointI) -> Array BfsDistance
data AndPath
AndPath :: Point -> [Point] -> Point -> Int -> AndPath
[pathSource] :: AndPath -> Point
[pathList] :: AndPath -> [Point]
[pathGoal] :: AndPath -> Point
[pathLen] :: AndPath -> Int

-- | Find a path, without the source position, with the smallest length.
--   The eps coefficient determines which direction (of the
--   closest directions available) that path should prefer, where 0 means
--   north-west and 1 means north. The path tries hard to avoid actors and
--   tries to avoid tiles that need altering and ambient light. Actors are
--   avoided only close to the start of the path, because elsewhere they
--   are likely to move before they are reached. Even projectiles are
--   avoided, which sometimes has the effect of choosing a safer route
--   (regardless if the projectiles are friendly fire or not).
--   
--   An unwelcome side effect of avoiding actors is that friends will
--   sometimes avoid displacing and instead perform two separate moves,
--   wasting 1 turn in total (only if they had opposed direction of their
--   goals; unlikely). But in corridors they will still displace and
--   elsewhere this scenario was quite rare already.
findPathBfs :: EnumSet Point -> Array Word8 -> (PointI -> Bool) -> Point -> Point -> Int -> Array BfsDistance -> Maybe AndPath

-- | Access a BFS array and interpret the looked up distance value.
accessBfs :: Array BfsDistance -> Point -> Maybe Int
succBfsDistance :: BfsDistance -> BfsDistance
predBfsDistance :: BfsDistance -> BfsDistance

-- | The distance value that denotes that path search was aborted at this
--   tile due to too large actual distance and that the tile was unknown.
--   It is also a true distance value for this tile.
abortedUnknownBfs :: BfsDistance
maskBfs :: BfsDistance -> BfsDistance
distanceBfs :: BfsDistance -> Maybe Int
instance Data.Binary.Class.Binary Game.LambdaHack.Client.Bfs.AndPath
instance GHC.Internal.Bits.Bits Game.LambdaHack.Client.Bfs.BfsDistance
instance GHC.Classes.Eq Game.LambdaHack.Client.Bfs.BfsDistance
instance GHC.Classes.Eq Game.LambdaHack.Client.Bfs.MoveLegal
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.Bfs.AndPath
instance GHC.Classes.Ord Game.LambdaHack.Client.Bfs.BfsDistance
instance GHC.Internal.Show.Show Game.LambdaHack.Client.Bfs.AndPath
instance GHC.Internal.Show.Show Game.LambdaHack.Client.Bfs.BfsDistance
instance Game.LambdaHack.Common.PointArray.UnboxRepClass Game.LambdaHack.Client.Bfs.BfsDistance

-- | The appearance of in-game items, as communicated to the player.
module Game.LambdaHack.Definition.Flavour

-- | The type of item flavours.
data Flavour

-- | Turn a colour set into a flavour set.
zipPlain :: [Color] -> [Flavour]

-- | Turn a colour set into a flavour set.
zipFancy :: [Color] -> [Flavour]

-- | Turn a colour set into a flavour set.
zipLiquid :: [Color] -> [Flavour]

-- | Turn a colour set into a flavour set.
zipGlassPlain :: [Color] -> [Flavour]

-- | Turn a colour set into a flavour set.
zipGlassFancy :: [Color] -> [Flavour]

-- | Turn a colour set into a flavour set.
zipStory :: [Color] -> [Flavour]
dummyFlavour :: Flavour
stdFlavList :: [Flavour]

-- | Get the underlying base colour of a flavour.
flavourToColor :: Flavour -> Color

-- | Construct the full name of a flavour.
flavourToName :: Flavour -> Text

-- | Human-readable names for item colors. The plain set.
colorToPlainName :: Color -> Text

-- | Human-readable names for item colors. The fancy set.
colorToFancyName :: Color -> Text

-- | Simple names for team colors (bright colours preferred).
colorToTeamName :: Color -> Text
data FancyName

-- | Human-readable names for item colors. The liquid set.
colorToLiquidName :: Color -> Text

-- | Human-readable names for item colors. The plain glass set.
colorToGlassPlainName :: Color -> Text

-- | Human-readable names for item colors. The fancy glass set.
colorToGlassFancyName :: Color -> Text
instance Data.Binary.Class.Binary Game.LambdaHack.Definition.Flavour.Flavour
instance GHC.Internal.Enum.Bounded Game.LambdaHack.Definition.Flavour.FancyName
instance GHC.Internal.Enum.Enum Game.LambdaHack.Definition.Flavour.FancyName
instance GHC.Internal.Enum.Enum Game.LambdaHack.Definition.Flavour.Flavour
instance GHC.Classes.Eq Game.LambdaHack.Definition.Flavour.FancyName
instance GHC.Classes.Eq Game.LambdaHack.Definition.Flavour.Flavour
instance GHC.Internal.Generics.Generic Game.LambdaHack.Definition.Flavour.FancyName
instance GHC.Internal.Generics.Generic Game.LambdaHack.Definition.Flavour.Flavour
instance GHC.Classes.Ord Game.LambdaHack.Definition.Flavour.FancyName
instance GHC.Classes.Ord Game.LambdaHack.Definition.Flavour.Flavour
instance GHC.Internal.Show.Show Game.LambdaHack.Definition.Flavour.FancyName
instance GHC.Internal.Show.Show Game.LambdaHack.Definition.Flavour.Flavour

-- | The type of kinds of weapons, treasure, organs, blasts, etc.
module Game.LambdaHack.Content.ItemKind
pattern CONDITION :: GroupName ItemKind
pattern COMMON_ITEM :: GroupName ItemKind
pattern S_BONUS_HP :: GroupName ItemKind
pattern S_BRACED :: GroupName ItemKind
pattern S_ASLEEP :: GroupName ItemKind
pattern S_IMPRESSED :: GroupName ItemKind
pattern S_CURRENCY :: GroupName ItemKind
pattern MOBILE :: GroupName ItemKind
pattern CRAWL_ITEM :: GroupName ItemKind
pattern TREASURE :: GroupName ItemKind
pattern ANY_SCROLL :: GroupName ItemKind
pattern ANY_GLASS :: GroupName ItemKind
pattern ANY_POTION :: GroupName ItemKind
pattern ANY_FLASK :: GroupName ItemKind
pattern EXPLOSIVE :: GroupName ItemKind
pattern ANY_JEWELRY :: GroupName ItemKind
pattern S_SINGLE_SPARK :: GroupName ItemKind
pattern S_SPARK :: GroupName ItemKind
pattern S_FRAGRANCE :: GroupName ItemKind
pattern HORROR :: GroupName ItemKind
pattern VALUABLE :: GroupName ItemKind
pattern UNREPORTED_INVENTORY :: GroupName ItemKind
pattern AQUATIC :: GroupName ItemKind

-- | Item properties that are fixed for a given kind of items. Of these,
--   aspects and effects are jointly called item powers. Note that this
--   type is mutually recursive with Effect and Aspect.
data ItemKind
ItemKind :: ContentSymbol ItemKind -> Text -> Freqs ItemKind -> [Flavour] -> Dice -> Rarity -> Text -> Int -> Dice -> [Aspect] -> [Effect] -> [(GroupName ItemKind, CStore)] -> Text -> ItemKind

-- | map symbol
[isymbol] :: ItemKind -> ContentSymbol ItemKind

-- | generic name; is pluralized if needed
[iname] :: ItemKind -> Text

-- | frequency within groups
[ifreq] :: ItemKind -> Freqs ItemKind

-- | possible flavours
[iflavour] :: ItemKind -> [Flavour]

-- | created in that quantity
[icount] :: ItemKind -> Dice

-- | rarity on given depths
[irarity] :: ItemKind -> Rarity

-- | the verb for hitting
[iverbHit] :: ItemKind -> Text

-- | weight in grams
[iweight] :: ItemKind -> Int

-- | basic kinetic damage
[idamage] :: ItemKind -> Dice

-- | affect the actor continuously
[iaspects] :: ItemKind -> [Aspect]

-- | cause the effects when triggered
[ieffects] :: ItemKind -> [Effect]

-- | accompanying organs and equipment
[ikit] :: ItemKind -> [(GroupName ItemKind, CStore)]

-- | description
[idesc] :: ItemKind -> Text
makeData :: ItemSymbolsUsedInEngine -> [ItemKind] -> [GroupName ItemKind] -> [GroupName ItemKind] -> ContentData ItemKind

-- | Aspects of items. Aspect AddSkill is additive (starting at 0)
--   for all items wielded by an actor and it affects the actor. The others
--   affect only the item in question, not the actor carrying it, and so
--   are not additive in any sense.
data Aspect

-- | specifies the cooldown before an item may be applied again; if a copy
--   of an item is applied manually (not via periodic activation), all
--   effects on a single copy of the item are disabled until the copy
--   recharges for the given time expressed in game turns; all copies
--   recharge concurrently
Timeout :: Dice -> Aspect

-- | bonus to a skill; in content, avoid boosting skills such as SkApply
--   via permanent equipment, to avoid micromanagement through swapping
--   items among party members before each skill use
AddSkill :: Skill -> Dice -> Aspect

-- | item feature
SetFlag :: Flag -> Aspect

-- | extra label of the item; it's not pluralized
ELabel :: Text -> Aspect

-- | parameters modifying a throw
ToThrow :: ThrowMod -> Aspect

-- | until identified, presents as this unique kind
PresentAs :: GroupName ItemKind -> Aspect

-- | AI and UI flag that leaks item intended use
EqpSlot :: EqpSlot -> Aspect

-- | if level-scaled dice roll > 50, pick the former aspects, otherwise
--   the latter
Odds :: Dice -> [Aspect] -> [Aspect] -> Aspect

-- | Effects of items. Can be invoked by the item wielder to affect another
--   actor or the wielder himself.
--   
--   Various effects of an item kind are all groupped in one list, at the
--   cost of conditionals, sequences, etc., to ensure brevity and
--   simplicity of content definitions. Most effects fire regardless of
--   activation kind (the only exceptions are OnSmash and
--   OnCombine effects) so the deviations, handled via the
--   conditionals, are rare and the definitions remain simple. Whether an
--   item can be activated in any particular way, OTOH, is specified via
--   simple flags elsewhere, again, by default, assuming that most
--   activations are possible for all.
data Effect

-- | burn with this damage
Burn :: Dice -> Effect

-- | explode producing this group of blasts
Explode :: GroupName ItemKind -> Effect

-- | modify HP of the actor by this amount
RefillHP :: Int -> Effect

-- | modify Calm of the actor by this amount
RefillCalm :: Int -> Effect

-- | change actor's allegiance
Dominate :: Effect

-- | make actor susceptible to domination
Impress :: Effect

-- | put actor to sleep, also calming him
PutToSleep :: Effect

-- | make the actor yell/yawn, waking him and others up
Yell :: Effect

-- | summon the given number of actors of this group
Summon :: GroupName ItemKind -> Dice -> Effect

-- | ascend to another level of the dungeon
Ascend :: Bool -> Effect

-- | escape from the dungeon
Escape :: Effect

-- | paralyze for this many game clips
Paralyze :: Dice -> Effect

-- | paralyze for this many game clips due to water
ParalyzeInWater :: Dice -> Effect

-- | give actor this many extra tenths of actor move
InsertMove :: Dice -> Effect

-- | teleport actor across rougly this distance
Teleport :: Dice -> Effect

-- | create an item of the group and insert into the store with the given
--   random timer; it cardinality not specified, roll it
CreateItem :: Maybe Int -> CStore -> GroupName ItemKind -> TimerDice -> Effect

-- | destroy some items of the group from the store; see below about Ints
DestroyItem :: Int -> Int -> CStore -> GroupName ItemKind -> Effect

-- | ConsumeItems toUse toDestroy uses items matching
--   toUse (destroys non-durable, without invoking OnSmash
--   effects; applies normal effects of durable, without destroying them;
--   the same behaviour as when transforming terrain using items) and
--   destroys items matching toDestroy, invoking no effects,
--   regardless of durability; the items are taken from CGround
--   (but not from CEqp), preferring non-durable (since durable
--   can harm when used and may be more vauable when destroyed); if not all
--   required items are present, no item are destroyed; if an item belongs
--   to many groups in the sum of toUse and toDestroy, it
--   counts for all (otherwise, some orders of destroying would succeed,
--   while others would not); even if item durable, as many copies are
--   needed as specified, not just one applied many times; items are first
--   destroyed and then, if any copies left, applied
ConsumeItems :: [(Int, GroupName ItemKind)] -> [(Int, GroupName ItemKind)] -> Effect

-- | make the actor drop items of the given group from the given store; the
--   first integer says how many item kinds to drop, the second, how many
--   copies of each kind to drop; for non-organs, beware of not dropping
--   all kinds, or cluttering store with rubbish becomes beneficial
DropItem :: Int -> Int -> CStore -> GroupName ItemKind -> Effect

-- | reduce the cooldown period of this number of discharged items in the
--   victim's equipment and organs by this dice of game clips; if the
--   result is negative, set to 0, instantly recharging the item; starts
--   with weapons with highest raw damage in equipment, then among organs,
--   then non-weapons in equipment and among organs; beware of exploiting
--   for healing periodic items
Recharge :: Int -> Dice -> Effect

-- | increase the cooldown period of this number of fully recharged items
--   in the victim's equipment and organs by this dice of game clips;
--   starts with weapons with highest raw damage in equipment, then among
--   organs, then non-weapons in equipment and among organs; beware of
--   exploiting for hunger inducing and similar organs
Discharge :: Int -> Dice -> Effect

-- | get a suitable (i.e., numerous enough) non-unique common item stack on
--   the floor and polymorph it to a stack of random common items, with
--   current depth coefficient
PolyItem :: Effect

-- | get a suitable (i.e., with any random aspects) single item (even
--   unique) on the floor and change the random bonuses of the items
--   randomly, with maximal depth coefficient
RerollItem :: Effect

-- | exactly duplicate a single non-unique, non-valuable item on the floor
DupItem :: Effect

-- | find a suitable (i.e., not identified) item, starting from the floor,
--   and identify it
Identify :: Effect

-- | detect something on the map in the given radius
Detect :: DetectKind -> Int -> Effect

-- | send an actor flying (push or pull, depending)
SendFlying :: ThrowMod -> Effect

-- | push an actor
PushActor :: ThrowMod -> Effect

-- | pull an actor
PullActor :: ThrowMod -> Effect

-- | remove all smell on the level
ApplyPerfume :: Effect

-- | try to trigger a single random effect of the list
AtMostOneOf :: [Effect] -> Effect

-- | trigger, with equal probability, one of the effects that don't end
--   with UseDud
OneOf :: [Effect] -> Effect

-- | trigger the effect when item smashed (not when applied nor meleed)
OnSmash :: Effect -> Effect

-- | trigger the effect only when the actor explicitly desires to combine
--   items or otherwise subtly tinker with an item or a tile, e.g., craft
--   items from other items in a workshop; in particular, don't trigger the
--   effects when entering a tile; trigger exclusively the effects when
--   activating walkable terrain
OnCombine :: Effect -> Effect

-- | apply the effect to the user, not the victim
OnUser :: Effect -> Effect

-- | nothing happens, UseDud, no description
NopEffect :: Effect

-- | only fire second effect if first activated
AndEffect :: Effect -> Effect -> Effect

-- | only fire second effect if first not activated
OrEffect :: Effect -> Effect -> Effect

-- | fire all effects in order; always suceed
SeqEffect :: [Effect] -> Effect

-- | if condition not met, fail without a message; better avoided, since AI
--   can't value it well
When :: Condition -> Effect -> Effect

-- | if condition met, fail without a message; better avoided, since AI
--   can't value it well
Unless :: Condition -> Effect -> Effect

-- | conditional effect; better avoided, since AI can't value it well
IfThenElse :: Condition -> Effect -> Effect -> Effect

-- | a sentence with the actor causing the effect as subject, the given
--   texts as the verb and the ending of the sentence (that may be ignored
--   when the message is cited, e.g., as heard by someone) that is emitted
--   when an activation causes an item to expire; no spam is emitted if a
--   projectile; the ending is appended without a space in-between
VerbNoLonger :: Text -> Text -> Effect

-- | as VerbNoLonger but that is emitted whenever the item is
--   activated;
VerbMsg :: Text -> Text -> Effect

-- | as VerbMsg, but a failed effect (returns UseId)
VerbMsgFail :: Text -> Text -> Effect
data Condition
HpLeq :: Int -> Condition
HpGeq :: Int -> Condition
CalmLeq :: Int -> Condition
CalmGeq :: Int -> Condition
TriggeredBy :: ActivationFlag -> Condition
data DetectKind
DetectAll :: DetectKind
DetectActor :: DetectKind
DetectLoot :: DetectKind
DetectExit :: DetectKind
DetectHidden :: DetectKind
DetectEmbed :: DetectKind
DetectStash :: DetectKind

-- | Specification of how to randomly roll a timer at item creation to
--   obtain a fixed timer for the item's lifetime.
data TimerDice

-- | Parameters modifying a throw of a projectile or flight of pushed
--   actor. Not additive and don't start at 0.
data ThrowMod
ThrowMod :: Int -> Int -> Int -> ThrowMod

-- | fly with this percentage of base throw speed
[throwVelocity] :: ThrowMod -> Int

-- | fly for this percentage of 2 turns
[throwLinger] :: ThrowMod -> Int

-- | start flight with this many HP
[throwHP] :: ThrowMod -> Int
data ItemSymbolsUsedInEngine
ItemSymbolsUsedInEngine :: ContentSymbol ItemKind -> ContentSymbol ItemKind -> ContentSymbol ItemKind -> ContentSymbol ItemKind -> ContentSymbol ItemKind -> ContentSymbol ItemKind -> ContentSymbol ItemKind -> ContentSymbol ItemKind -> ContentSymbol ItemKind -> ContentSymbol ItemKind -> ContentSymbol ItemKind -> ContentSymbol ItemKind -> ContentSymbol ItemKind -> ContentSymbol ItemKind -> ContentSymbol ItemKind -> ContentSymbol ItemKind -> ContentSymbol ItemKind -> ContentSymbol ItemKind -> ContentSymbol ItemKind -> ItemSymbolsUsedInEngine
[rsymbolProjectile] :: ItemSymbolsUsedInEngine -> ContentSymbol ItemKind
[rsymbolLight] :: ItemSymbolsUsedInEngine -> ContentSymbol ItemKind
[rsymbolTool] :: ItemSymbolsUsedInEngine -> ContentSymbol ItemKind
[rsymbolSpecial] :: ItemSymbolsUsedInEngine -> ContentSymbol ItemKind
[rsymbolGold] :: ItemSymbolsUsedInEngine -> ContentSymbol ItemKind
[rsymbolNecklace] :: ItemSymbolsUsedInEngine -> ContentSymbol ItemKind
[rsymbolRing] :: ItemSymbolsUsedInEngine -> ContentSymbol ItemKind
[rsymbolPotion] :: ItemSymbolsUsedInEngine -> ContentSymbol ItemKind
[rsymbolFlask] :: ItemSymbolsUsedInEngine -> ContentSymbol ItemKind
[rsymbolScroll] :: ItemSymbolsUsedInEngine -> ContentSymbol ItemKind
[rsymbolTorsoArmor] :: ItemSymbolsUsedInEngine -> ContentSymbol ItemKind
[rsymbolMiscArmor] :: ItemSymbolsUsedInEngine -> ContentSymbol ItemKind
[rsymbolClothes] :: ItemSymbolsUsedInEngine -> ContentSymbol ItemKind
[rsymbolShield] :: ItemSymbolsUsedInEngine -> ContentSymbol ItemKind
[rsymbolPolearm] :: ItemSymbolsUsedInEngine -> ContentSymbol ItemKind
[rsymbolEdged] :: ItemSymbolsUsedInEngine -> ContentSymbol ItemKind
[rsymbolHafted] :: ItemSymbolsUsedInEngine -> ContentSymbol ItemKind
[rsymbolWand] :: ItemSymbolsUsedInEngine -> ContentSymbol ItemKind
[rsymbolFood] :: ItemSymbolsUsedInEngine -> ContentSymbol ItemKind
emptyItemSymbolsUsedInEngine :: ItemSymbolsUsedInEngine
boostItemKindList :: SMGen -> [ItemKind] -> [ItemKind]

-- | Whether the effect has a chance of exhibiting any potentially
--   noticeable behaviour, except when the item is destroyed or combined.
--   We assume at least one of OneOf effects must be noticeable.
forApplyEffect :: Effect -> Bool

-- | Whether a non-nested effect always applies raw damage.
forDamageEffect :: Effect -> Bool

-- | Whether an item is damaging. Such items may trigger embedded items and
--   may collide with bursting items mid-air.
isDamagingKind :: ItemKind -> Bool
strengthOnCombine :: ItemKind -> [Effect]
strengthOnSmash :: ItemKind -> [Effect]
getDropOrgans :: ItemKind -> [GroupName ItemKind]
getMandatoryPresentAsFromKind :: ItemKind -> Maybe (GroupName ItemKind)
isEffEscape :: Effect -> Bool
isEffEscapeOrAscend :: Effect -> Bool
timeoutAspect :: Aspect -> Bool
orEffect :: Effect -> Bool
onSmashEffect :: Effect -> Bool
onCombineEffect :: Effect -> Bool
alwaysDudEffect :: Effect -> Bool
damageUsefulness :: ItemKind -> Double
verbMsgNoLonger :: Text -> Effect
verbMsgLess :: Text -> Effect
toVelocity :: Int -> Aspect
toLinger :: Int -> Aspect
timerNone :: TimerDice
isTimerNone :: TimerDice -> Bool
foldTimer :: a -> (Dice -> a) -> (Dice -> a) -> TimerDice -> a
toOrganBad :: GroupName ItemKind -> Dice -> Effect
toOrganGood :: GroupName ItemKind -> Dice -> Effect
toOrganNoTimer :: GroupName ItemKind -> Effect

-- | Catch invalid item kind definitions.
validateSingle :: ItemSymbolsUsedInEngine -> ItemKind -> [Text]
mandatoryGroups :: [GroupName ItemKind]
mandatoryGroupsSingleton :: [GroupName ItemKind]
boostItemKind :: ItemKind -> ItemKind
onSmashOrCombineEffect :: Effect -> Bool

-- | Validate all item kinds.
validateAll :: [ItemKind] -> ContentData ItemKind -> [Text]
validateDups :: ItemKind -> Aspect -> [Text]
validateDamage :: Dice -> [Text]
instance Data.Binary.Class.Binary Game.LambdaHack.Content.ItemKind.ThrowMod
instance GHC.Classes.Eq Game.LambdaHack.Content.ItemKind.Aspect
instance GHC.Classes.Eq Game.LambdaHack.Content.ItemKind.Condition
instance GHC.Classes.Eq Game.LambdaHack.Content.ItemKind.DetectKind
instance GHC.Classes.Eq Game.LambdaHack.Content.ItemKind.Effect
instance GHC.Classes.Eq Game.LambdaHack.Content.ItemKind.ThrowMod
instance GHC.Classes.Eq Game.LambdaHack.Content.ItemKind.TimerDice
instance GHC.Internal.Generics.Generic Game.LambdaHack.Content.ItemKind.ThrowMod
instance Data.Hashable.Class.Hashable Game.LambdaHack.Content.ItemKind.ThrowMod
instance GHC.Classes.Ord Game.LambdaHack.Content.ItemKind.ThrowMod
instance GHC.Internal.Show.Show Game.LambdaHack.Content.ItemKind.Aspect
instance GHC.Internal.Show.Show Game.LambdaHack.Content.ItemKind.Condition
instance GHC.Internal.Show.Show Game.LambdaHack.Content.ItemKind.DetectKind
instance GHC.Internal.Show.Show Game.LambdaHack.Content.ItemKind.Effect
instance GHC.Internal.Show.Show Game.LambdaHack.Content.ItemKind.ItemKind
instance GHC.Internal.Show.Show Game.LambdaHack.Content.ItemKind.ThrowMod
instance GHC.Internal.Show.Show Game.LambdaHack.Content.ItemKind.TimerDice

-- | The type of tile kinds. Every terrain tile in the game is an
--   instantiated tile kind.
module Game.LambdaHack.Content.TileKind
pattern S_UNKNOWN_SPACE :: GroupName TileKind
pattern S_UNKNOWN_OUTER_FENCE :: GroupName TileKind
pattern S_BASIC_OUTER_FENCE :: GroupName TileKind
pattern AQUATIC :: GroupName TileKind

-- | The type of kinds of terrain tiles. See Tile.hs for
--   explanation of the absence of a corresponding type Tile that
--   would hold particular concrete tiles in the dungeon. Note that tile
--   names (and any other content names) should not be plural (that would
--   lead to "a stairs"), so "road with cobblestones" is fine, but "granite
--   cobblestones" is wrong.
--   
--   Tile kind for unknown space has the minimal ContentId index.
--   The talter for unknown space is 1 and no other tile
--   kind has that value.
data TileKind
TileKind :: Char -> Text -> Freqs TileKind -> Color -> Color -> Word8 -> [Feature] -> TileKind

-- | map symbol
[tsymbol] :: TileKind -> Char

-- | short description
[tname] :: TileKind -> Text

-- | frequency within groups
[tfreq] :: TileKind -> Freqs TileKind

-- | map color
[tcolor] :: TileKind -> Color

-- | map color when not in FOV
[tcolor2] :: TileKind -> Color

-- | minimal skill needed to activate embeds and, in case of big actors not
--   standing on the tile, to alter the tile in any way
[talter] :: TileKind -> Word8

-- | properties; order matters
[tfeature] :: TileKind -> [Feature]

-- | Marks whether projectiles are permitted to trigger the tile
--   transformation action.
data ProjectileTriggers
ProjYes :: ProjectileTriggers
ProjNo :: ProjectileTriggers

-- | All possible terrain tile features.
data Feature

-- | initially an item of this group is embedded; we assume the item has
--   effects and is supposed to be triggered
Embed :: GroupName ItemKind -> Feature

-- | goes from a closed to closed or open tile when altered
OpenTo :: GroupName TileKind -> Feature

-- | goes from an open to open or closed tile when altered
CloseTo :: GroupName TileKind -> Feature

-- | alters tile, but does not change walkability
ChangeTo :: GroupName TileKind -> Feature

-- | alters tile, as before, using up all listed items from the ground and
--   equipment; the list never empty; for simplicity, such tiles are never
--   taken into account when pathfinding
OpenWith :: ProjectileTriggers -> [(Int, GroupName ItemKind)] -> GroupName TileKind -> Feature
CloseWith :: ProjectileTriggers -> [(Int, GroupName ItemKind)] -> GroupName TileKind -> Feature
ChangeWith :: ProjectileTriggers -> [(Int, GroupName ItemKind)] -> GroupName TileKind -> Feature

-- | when hidden, looks as the unique tile of the group
HideAs :: GroupName TileKind -> Feature

-- | when generating, may be transformed to the unique tile of the group
BuildAs :: GroupName TileKind -> Feature

-- | when generating in opening, can be revealed to belong to the group
RevealAs :: GroupName TileKind -> Feature

-- | when generating in solid wall, can be revealed to belong to the group
ObscureAs :: GroupName TileKind -> Feature

-- | actors can walk through
Walkable :: Feature

-- | actors can see through
Clear :: Feature

-- | is not lit with an ambient light
Dark :: Feature

-- | initial items often generated there
OftenItem :: Feature

-- | initial items very often generated there
VeryOftenItem :: Feature

-- | initial actors often generated there; counterpart of
--   VeryOftenItem for dark places
OftenActor :: Feature

-- | no items ever generated there
NoItem :: Feature

-- | no actors ever generated there
NoActor :: Feature

-- | even if otherwise uninteresting, taken into account for triggering by
--   AI
ConsideredByAI :: Feature

-- | used for visible trails throughout the level
Trail :: Feature

-- | in place normal legend and in override, don't roll a tile kind only
--   once per place, but roll for each position; one non-spicy (according
--   to frequencies of non-spicy) and at most one spicy (according to their
--   frequencies) is rolled per place and then, once for each position, one
--   of the two is semi-randomly chosen (according to their individual
--   frequencies only)
Spice :: Feature
makeData :: [TileKind] -> [GroupName TileKind] -> [GroupName TileKind] -> ContentData TileKind
isUknownSpace :: ContentId TileKind -> Bool
unknownId :: ContentId TileKind
isSuspectKind :: TileKind -> Bool
isOpenableKind :: TileKind -> Bool
isClosableKind :: TileKind -> Bool
talterForStairs :: Word8
floorSymbol :: Char
mandatoryGroups :: [GroupName TileKind]
mandatoryGroupsSingleton :: [GroupName TileKind]

-- | Validate a single tile kind.
validateSingle :: TileKind -> [Text]

-- | Validate all tile kinds.
--   
--   We don't check it any more, but if tiles look the same on the map
--   (symbol and color), their substantial features should be the same,
--   too, unless there is a good reason they shouldn't. Otherwise the
--   player has to inspect manually all the tiles with this look to see if
--   any is special. This tends to be tedious. Note that tiles may freely
--   differ wrt text blurb, dungeon generation rules, AI preferences, etc.,
--   whithout causing the tedium.
validateAll :: [TileKind] -> ContentData TileKind -> [Text]
validateDups :: TileKind -> Feature -> [Text]
instance GHC.Classes.Eq Game.LambdaHack.Content.TileKind.Feature
instance GHC.Classes.Eq Game.LambdaHack.Content.TileKind.ProjectileTriggers
instance GHC.Internal.Show.Show Game.LambdaHack.Content.TileKind.Feature
instance GHC.Internal.Show.Show Game.LambdaHack.Content.TileKind.ProjectileTriggers
instance GHC.Internal.Show.Show Game.LambdaHack.Content.TileKind.TileKind

-- | The type of place kinds. Every room in the game is an instantiated
--   place kind.
module Game.LambdaHack.Content.PlaceKind

-- | Parameters for the generation of small areas within a dungeon level.
data PlaceKind
PlaceKind :: Text -> Freqs PlaceKind -> Rarity -> Cover -> Fence -> [Text] -> EnumMap Char (GroupName TileKind) -> EnumMap Char (GroupName TileKind) -> PlaceKind

-- | short description, singular or plural
[pname] :: PlaceKind -> Text

-- | frequency within groups
[pfreq] :: PlaceKind -> Freqs PlaceKind

-- | rarity on given depths
[prarity] :: PlaceKind -> Rarity

-- | how to fill whole place using the corner
[pcover] :: PlaceKind -> Cover

-- | whether to fence place with solid border
[pfence] :: PlaceKind -> Fence

-- | plan of the top-left corner of the place
[ptopLeft] :: PlaceKind -> [Text]

-- | dark legend
[plegendDark] :: PlaceKind -> EnumMap Char (GroupName TileKind)

-- | lit legend
[plegendLit] :: PlaceKind -> EnumMap Char (GroupName TileKind)
makeData :: ContentData TileKind -> [PlaceKind] -> [GroupName PlaceKind] -> [GroupName PlaceKind] -> ContentData PlaceKind

-- | A method of filling the whole area (except for CVerbatim and CMirror,
--   which are just placed in the middle of the area) by transforming a
--   given corner.
data Cover

-- | reflect every other corner, overlapping 1 row and column
CAlternate :: Cover

-- | fill symmetrically 4 corners and stretch their borders
CStretch :: Cover

-- | tile separately and symmetrically quarters of the place
CReflect :: Cover

-- | just build the given interior, without filling the area
CVerbatim :: Cover

-- | build the given interior in one of 4 mirrored variants
CMirror :: Cover

-- | The choice of a fence type for the place.
data Fence

-- | put a solid wall fence around the place
FWall :: Fence

-- | leave an empty space, like the room's floor
FFloor :: Fence

-- | leave an empty space, like the cave's ground
FGround :: Fence

-- | skip the fence and fill all with the place proper
FNone :: Fence

-- | Places are rooms and other dungeon features, their names can be seen
--   on a level map by aiming at a position that is an entry to the place
--   (an individual entrance point, an approach area around the place or a
--   phantom entry not on the map, but only used for statistics to witness
--   the place exists). Entries are proxies for initial places created on
--   the level (which may be otherwise eradicated by burrowing the walls,
--   etc.) and so used for dungeon statistics. The statistics are presented
--   in the Dashboard/displace place lore menu.
data PlaceEntry
PEntry :: ContentId PlaceKind -> PlaceEntry
PAround :: ContentId PlaceKind -> PlaceEntry
PExists :: ContentId PlaceKind -> PlaceEntry
deadEndId :: ContentId PlaceKind
overridePlaceKind :: [(Char, GroupName TileKind)] -> PlaceKind -> PlaceKind
override2PlaceKind :: [(Char, GroupName TileKind)] -> [(Char, GroupName TileKind)] -> PlaceKind -> PlaceKind

-- | Catch invalid place kind definitions. In particular, verify that the
--   top-left corner map is rectangular and not empty.
validateSingle :: ContentData TileKind -> PlaceKind -> [Text]

-- | Validate all place kinds.
validateAll :: [PlaceKind] -> ContentData PlaceKind -> [Text]
instance Data.Binary.Class.Binary Game.LambdaHack.Content.PlaceKind.PlaceEntry
instance GHC.Classes.Eq Game.LambdaHack.Content.PlaceKind.Cover
instance GHC.Classes.Eq Game.LambdaHack.Content.PlaceKind.Fence
instance GHC.Classes.Eq Game.LambdaHack.Content.PlaceKind.PlaceEntry
instance GHC.Internal.Generics.Generic Game.LambdaHack.Content.PlaceKind.PlaceEntry
instance GHC.Internal.Show.Show Game.LambdaHack.Content.PlaceKind.Cover
instance GHC.Internal.Show.Show Game.LambdaHack.Content.PlaceKind.Fence
instance GHC.Internal.Show.Show Game.LambdaHack.Content.PlaceKind.PlaceEntry
instance GHC.Internal.Show.Show Game.LambdaHack.Content.PlaceKind.PlaceKind

-- | The type of game rules and assorted game data.
module Game.LambdaHack.Content.RuleKind

-- | The type of game rules and assorted game data.
data RuleContent
RuleContent :: String -> X -> Y -> Version -> FilePath -> (Text, Config) -> Int -> Int -> FilePath -> Int -> [Text] -> ItemSymbolsUsedInEngine -> RuleContent

-- | title of the game (not lib)
[rtitle] :: RuleContent -> String

-- | maximum level width
[rWidthMax] :: RuleContent -> X

-- | maximum level height
[rHeightMax] :: RuleContent -> Y

-- | version of the game
[rexeVersion] :: RuleContent -> Version

-- | name of the UI config file
[rcfgUIName] :: RuleContent -> FilePath

-- | the default UI settings config file
[rcfgUIDefault] :: RuleContent -> (Text, Config)

-- | game saved that often (not on browser)
[rwriteSaveClips] :: RuleContent -> Int

-- | server switches leader level that often
[rleadLevelClips] :: RuleContent -> Int

-- | name of the scores file
[rscoresFileName] :: RuleContent -> FilePath

-- | what is a close distance between actors
[rnearby] :: RuleContent -> Int

-- | words that can't be dropped from stair name as it goes through levels
[rstairWordCarried] :: RuleContent -> [Text]

-- | item symbols treated specially in engine
[ritemSymbols] :: RuleContent -> ItemSymbolsUsedInEngine
emptyRuleContent :: RuleContent
makeData :: RuleContent -> RuleContent
emptyRuleContentRaw :: RuleContent

-- | Catch invalid rule kind definitions.
validateSingle :: RuleContent -> [Text]

-- | The type of kinds of factions present in a game, both human and
--   computer-controlled.
module Game.LambdaHack.Content.FactionKind

-- | Properties of a particular faction.
data FactionKind
FactionKind :: Text -> Freqs FactionKind -> TeamContinuity -> Freqs ItemKind -> Skills -> Bool -> Bool -> HiCondPoly -> Bool -> Doctrine -> Bool -> Bool -> Bool -> Bool -> [TeamContinuity] -> [TeamContinuity] -> FactionKind

-- | name of the faction
[fname] :: FactionKind -> Text

-- | frequency within groups
[ffreq] :: FactionKind -> Freqs FactionKind

-- | the team the faction identifies with across games and modes
[fteam] :: FactionKind -> TeamContinuity

-- | names of actor groups that may naturally fall under faction's control,
--   e.g., upon spawning; make sure all groups that may ever continuousely
--   generate actors, e.g., through spawning or summoning, are mentioned in
--   at least one faction kind; groups of initial faction actors don't need
--   to be included
[fgroups] :: FactionKind -> Freqs ItemKind

-- | fixed skill modifiers to the non-leader actors; also summed with
--   skills implied by fdoctrine (which is not fixed)
[fskillsOther] :: FactionKind -> Skills

-- | the faction can escape the dungeon
[fcanEscape] :: FactionKind -> Bool

-- | the faction declared killed if no actors
[fneverEmpty] :: FactionKind -> Bool

-- | score formula (conditional polynomial)
[fhiCondPoly] :: FactionKind -> HiCondPoly

-- | whether actors have gender
[fhasGender] :: FactionKind -> Bool

-- | initial faction's non-leaders doctrine
[finitDoctrine] :: FactionKind -> Doctrine

-- | spawns fast enough that switching pointman to another level to
--   optimize spawning is a winning tactics, which would spoil the fun, so
--   switching is disabled in UI and AI clients
[fspawnsFast] :: FactionKind -> Bool

-- | whether the faction can have a pointman
[fhasPointman] :: FactionKind -> Bool

-- | does the faction have a UI client (for control or passive observation)
[fhasUI] :: FactionKind -> Bool

-- | is the faction initially under AI control
[finitUnderAI] :: FactionKind -> Bool

-- | teams starting at war with the faction
[fenemyTeams] :: FactionKind -> [TeamContinuity]

-- | teams starting allied with the faction
[falliedTeams] :: FactionKind -> [TeamContinuity]
makeData :: [FactionKind] -> [GroupName FactionKind] -> [GroupName FactionKind] -> ContentData FactionKind

-- | Conditional polynomial representing score calculation for this
--   faction.
type HiCondPoly = [HiSummand]
type HiSummand = (HiPolynomial, [Outcome])
type HiPolynomial = [(HiIndeterminant, Double)]
data HiIndeterminant
HiConst :: HiIndeterminant
HiLoot :: HiIndeterminant
HiSprint :: HiIndeterminant
HiBlitz :: HiIndeterminant
HiSurvival :: HiIndeterminant
HiKill :: HiIndeterminant
HiLoss :: HiIndeterminant

-- | Team continuity index. Starting with 1. See the comment for
--   FactionId.
newtype TeamContinuity
TeamContinuity :: Int -> TeamContinuity

-- | Outcome of a game.
data Outcome

-- | the faction escaped the dungeon alive
Escape :: Outcome

-- | the faction won by eliminating all rivals
Conquer :: Outcome

-- | the faction lost the game in another way
Defeated :: Outcome

-- | the faction was eliminated
Killed :: Outcome

-- | game is restarted; the quitter quit
Restart :: Outcome

-- | game is supended
Camping :: Outcome
teamExplorer :: TeamContinuity
hiHeroLong :: HiCondPoly
hiHeroMedium :: HiCondPoly
hiHeroShort :: HiCondPoly
hiDweller :: HiCondPoly
victoryOutcomes :: [Outcome]
deafeatOutcomes :: [Outcome]
nameOutcomePast :: Outcome -> Text
nameOutcomeVerb :: Outcome -> Text
endMessageOutcome :: Outcome -> Text
validateSingle :: FactionKind -> [Text]

-- | Validate game faction kinds together.
validateAll :: [FactionKind] -> ContentData FactionKind -> [Text]
instance Data.Binary.Class.Binary Game.LambdaHack.Content.FactionKind.FactionKind
instance Data.Binary.Class.Binary Game.LambdaHack.Content.FactionKind.HiIndeterminant
instance Data.Binary.Class.Binary Game.LambdaHack.Content.FactionKind.Outcome
instance Data.Binary.Class.Binary Game.LambdaHack.Content.FactionKind.TeamContinuity
instance GHC.Internal.Enum.Bounded Game.LambdaHack.Content.FactionKind.Outcome
instance GHC.Internal.Enum.Enum Game.LambdaHack.Content.FactionKind.Outcome
instance GHC.Internal.Enum.Enum Game.LambdaHack.Content.FactionKind.TeamContinuity
instance GHC.Classes.Eq Game.LambdaHack.Content.FactionKind.FactionKind
instance GHC.Classes.Eq Game.LambdaHack.Content.FactionKind.HiIndeterminant
instance GHC.Classes.Eq Game.LambdaHack.Content.FactionKind.Outcome
instance GHC.Classes.Eq Game.LambdaHack.Content.FactionKind.TeamContinuity
instance GHC.Internal.Generics.Generic Game.LambdaHack.Content.FactionKind.FactionKind
instance GHC.Internal.Generics.Generic Game.LambdaHack.Content.FactionKind.HiIndeterminant
instance GHC.Internal.Generics.Generic Game.LambdaHack.Content.FactionKind.Outcome
instance GHC.Internal.Generics.Generic Game.LambdaHack.Content.FactionKind.TeamContinuity
instance GHC.Classes.Ord Game.LambdaHack.Content.FactionKind.Outcome
instance GHC.Classes.Ord Game.LambdaHack.Content.FactionKind.TeamContinuity
instance GHC.Internal.Show.Show Game.LambdaHack.Content.FactionKind.FactionKind
instance GHC.Internal.Show.Show Game.LambdaHack.Content.FactionKind.HiIndeterminant
instance GHC.Internal.Show.Show Game.LambdaHack.Content.FactionKind.Outcome
instance GHC.Internal.Show.Show Game.LambdaHack.Content.FactionKind.TeamContinuity

-- | The type of cave kinds. Every level in the game is an instantiated
--   cave kind.
module Game.LambdaHack.Content.CaveKind
pattern DEFAULT_RANDOM :: GroupName CaveKind

-- | Parameters for the generation of dungeon levels. Warning: for
--   efficiency, avoid embedded items in any of the common tiles.
data CaveKind
CaveKind :: Text -> Freqs CaveKind -> X -> Y -> DiceXY -> DiceXY -> DiceXY -> Dice -> Dice -> Rational -> Rational -> Chance -> Chance -> Int -> Int -> Freqs ItemKind -> Dice -> Freqs ItemKind -> Freqs PlaceKind -> Bool -> Bool -> GroupName TileKind -> GroupName TileKind -> GroupName TileKind -> GroupName TileKind -> GroupName TileKind -> GroupName TileKind -> GroupName TileKind -> GroupName TileKind -> GroupName TileKind -> Bool -> Int -> Dice -> Freqs PlaceKind -> Freqs PlaceKind -> Freqs PlaceKind -> [Int] -> InitSleep -> Text -> CaveKind

-- | short description
[cname] :: CaveKind -> Text

-- | frequency within groups
[cfreq] :: CaveKind -> Freqs CaveKind

-- | minimal X size of the whole cave
[cXminSize] :: CaveKind -> X

-- | minimal Y size of the whole cave
[cYminSize] :: CaveKind -> Y

-- | size of a map cell holding a place
[ccellSize] :: CaveKind -> DiceXY

-- | minimal size of places; for merging
[cminPlaceSize] :: CaveKind -> DiceXY

-- | maximal size of places; for growing
[cmaxPlaceSize] :: CaveKind -> DiceXY

-- | the odds a place is dark (level-scaled dice roll > 50)
[cdarkOdds] :: CaveKind -> Dice

-- | the odds the cave is dark (level-scaled dice roll > 50)
[cnightOdds] :: CaveKind -> Dice

-- | a proportion of extra connections
[cauxConnects] :: CaveKind -> Rational

-- | at most this proportion of rooms may be void
[cmaxVoid] :: CaveKind -> Rational

-- | the chance of a door in an opening
[cdoorChance] :: CaveKind -> Chance

-- | if there's a door, is it open?
[copenChance] :: CaveKind -> Chance

-- | if not open, hidden one in n times
[chidden] :: CaveKind -> Int

-- | the lower, the more monsters spawn
[cactorCoeff] :: CaveKind -> Int

-- | actor groups to consider
[cactorFreq] :: CaveKind -> Freqs ItemKind

-- | number of initial items in the cave
[citemNum] :: CaveKind -> Dice

-- | item groups to consider; note that the groups are flattened; e.g., if
--   an item is moved to another included group with the same weight, the
--   outcome doesn't change
[citemFreq] :: CaveKind -> Freqs ItemKind

-- | place groups to consider
[cplaceFreq] :: CaveKind -> Freqs PlaceKind

-- | are passable default tiles permitted
[cpassable] :: CaveKind -> Bool

-- | waste of time for AI to explore
[clabyrinth] :: CaveKind -> Bool

-- | the default cave tile
[cdefTile] :: CaveKind -> GroupName TileKind

-- | the dark cave corridor tile
[cdarkCorTile] :: CaveKind -> GroupName TileKind

-- | the lit cave corridor tile
[clitCorTile] :: CaveKind -> GroupName TileKind

-- | the tile used for FWall fence
[cwallTile] :: CaveKind -> GroupName TileKind

-- | tile used for the fence corners
[ccornerTile] :: CaveKind -> GroupName TileKind

-- | the outer fence N wall
[cfenceTileN] :: CaveKind -> GroupName TileKind

-- | the outer fence E wall
[cfenceTileE] :: CaveKind -> GroupName TileKind

-- | the outer fence S wall
[cfenceTileS] :: CaveKind -> GroupName TileKind

-- | the outer fence W wall
[cfenceTileW] :: CaveKind -> GroupName TileKind

-- | are places touching fence banned
[cfenceApart] :: CaveKind -> Bool

-- | minimal distance between stairs
[cminStairDist] :: CaveKind -> Int

-- | maximum number of stairs
[cmaxStairsNum] :: CaveKind -> Dice

-- | escape groups, if any
[cescapeFreq] :: CaveKind -> Freqs PlaceKind

-- | place groups for created stairs
[cstairFreq] :: CaveKind -> Freqs PlaceKind

-- | extra groups for inherited
[cstairAllowed] :: CaveKind -> Freqs PlaceKind

-- | which faction starting positions to skip
[cskip] :: CaveKind -> [Int]

-- | whether actors spawn sleeping
[cinitSleep] :: CaveKind -> InitSleep

-- | full cave description
[cdesc] :: CaveKind -> Text
data InitSleep
InitSleepAlways :: InitSleep
InitSleepPermitted :: InitSleep
InitSleepBanned :: InitSleep
makeData :: RuleContent -> [CaveKind] -> [GroupName CaveKind] -> [GroupName CaveKind] -> ContentData CaveKind

-- | Catch caves with not enough space for all the places. Check the size
--   of the cave descriptions to make sure they fit on screen. Etc.
validateSingle :: RuleContent -> CaveKind -> [Text]

-- | Validate all cave kinds. Note that names don't have to be unique: we
--   can have several variants of a cave with a given name.
validateAll :: [CaveKind] -> ContentData CaveKind -> [Text]
mandatoryGroups :: [GroupName CaveKind]
instance GHC.Classes.Eq Game.LambdaHack.Content.CaveKind.InitSleep
instance GHC.Internal.Show.Show Game.LambdaHack.Content.CaveKind.CaveKind
instance GHC.Internal.Show.Show Game.LambdaHack.Content.CaveKind.InitSleep

-- | The type of game modes.
module Game.LambdaHack.Content.ModeKind
pattern CAMPAIGN_SCENARIO :: GroupName ModeKind
pattern INSERT_COIN :: GroupName ModeKind

-- | Game mode specification.
data ModeKind
ModeKind :: Text -> Freqs ModeKind -> Bool -> Bool -> Roster -> Caves -> [(Outcome, Text)] -> Text -> Text -> Text -> Text -> ModeKind

-- | short description
[mname] :: ModeKind -> Text

-- | frequency within groups
[mfreq] :: ModeKind -> Freqs ModeKind

-- | whether to show tutorial messages, etc.
[mtutorial] :: ModeKind -> Bool

-- | whether this is an attract mode
[mattract] :: ModeKind -> Bool

-- | factions taking part in the game
[mroster] :: ModeKind -> Roster

-- | arena of the game
[mcaves] :: ModeKind -> Caves

-- | messages displayed at each particular game ends; if message empty, the
--   screen is skipped
[mendMsg] :: ModeKind -> [(Outcome, Text)]

-- | rules note
[mrules] :: ModeKind -> Text

-- | description
[mdesc] :: ModeKind -> Text

-- | why/when the mode should be played
[mreason] :: ModeKind -> Text

-- | hints in case player faces difficulties
[mhint] :: ModeKind -> Text
makeData :: ContentData FactionKind -> [ModeKind] -> [GroupName ModeKind] -> [GroupName ModeKind] -> ContentData ModeKind

-- | Requested cave groups for particular level intervals.
type Caves = [([Int], [GroupName CaveKind])]

-- | The specification of factions and of levels, numbers and groups of
--   their initial members.
type Roster = [(GroupName FactionKind, [(Int, Dice, GroupName ItemKind)])]
mandatoryGroups :: [GroupName ModeKind]

-- | Catch invalid game mode kind definitions.
validateSingle :: ContentData FactionKind -> ModeKind -> [Text]

-- | Validate game mode kinds together.
validateAll :: [ModeKind] -> ContentData ModeKind -> [Text]

-- | Checks, in particular, that there is at least one faction with
--   fneverEmpty or the game would get stuck as soon as the dungeon is
--   devoid of actors.
validateSingleRoster :: ContentData FactionKind -> Caves -> Roster -> [Text]
instance GHC.Internal.Show.Show Game.LambdaHack.Content.ModeKind.ModeKind

-- | Operations concerning dungeon level tiles.
--   
--   Unlike for many other content types, there is no type Tile,
--   of particular concrete tiles in the dungeon, corresponding to
--   TileKind (the type of kinds of terrain tiles). This is because
--   the tiles are too numerous and there's not enough storage space for a
--   well-rounded Tile type, on one hand, and on the other hand,
--   tiles are accessed too often in performance critical code to try to
--   compress their representation and/or recompute them. Instead, of
--   defining a Tile type, we express various properties of
--   concrete tiles by arrays or sparse EnumMaps, as appropriate.
--   
--   Actors at normal speed (2 m/s) take one turn to move one tile (1 m by
--   1 m).
module Game.LambdaHack.Common.Tile

-- | A lot of tabulated maps from tile kind identifier to a property of the
--   tile kind.
data TileSpeedup
TileSpeedup :: Tab Bool -> Tab Bool -> Tab Bool -> Tab Bool -> Tab Bool -> Tab Bool -> Tab Bool -> Tab Bool -> Tab Bool -> Tab Bool -> Tab Bool -> Tab Bool -> Tab Bool -> Tab Bool -> Tab Bool -> Tab Bool -> Tab Bool -> Tab Bool -> Tab Bool -> Tab Bool -> Tab Word8 -> Tab Word8 -> TileSpeedup
[isClearTab] :: TileSpeedup -> Tab Bool
[isLitTab] :: TileSpeedup -> Tab Bool
[isHideoutTab] :: TileSpeedup -> Tab Bool
[isWalkableTab] :: TileSpeedup -> Tab Bool
[isDoorTab] :: TileSpeedup -> Tab Bool
[isOpenableTab] :: TileSpeedup -> Tab Bool
[isClosableTab] :: TileSpeedup -> Tab Bool
[isChangableTab] :: TileSpeedup -> Tab Bool
[isModifiableWithTab] :: TileSpeedup -> Tab Bool
[isSuspectTab] :: TileSpeedup -> Tab Bool
[isHideAsTab] :: TileSpeedup -> Tab Bool
[consideredByAITab] :: TileSpeedup -> Tab Bool
[isVeryOftenItemTab] :: TileSpeedup -> Tab Bool
[isCommonItemTab] :: TileSpeedup -> Tab Bool
[isOftenActorTab] :: TileSpeedup -> Tab Bool
[isNoItemTab] :: TileSpeedup -> Tab Bool
[isNoActorTab] :: TileSpeedup -> Tab Bool
[isEasyOpenTab] :: TileSpeedup -> Tab Bool
[isEmbedTab] :: TileSpeedup -> Tab Bool
[isAquaticTab] :: TileSpeedup -> Tab Bool
[alterMinSkillTab] :: TileSpeedup -> Tab Word8
[alterMinWalkTab] :: TileSpeedup -> Tab Word8

-- | A map morally indexed by ContentId TileKind.
newtype Tab a
Tab :: Vector a -> Tab a
speedupTile :: Bool -> ContentData TileKind -> TileSpeedup

-- | Whether a tile does not block vision. Essential for efficiency of
--   FOV, hence tabulated.
isClear :: TileSpeedup -> ContentId TileKind -> Bool

-- | Whether a tile has ambient light --- is lit on its own. Essential for
--   efficiency of Perception, hence tabulated.
isLit :: TileSpeedup -> ContentId TileKind -> Bool

-- | Whether a tile is a good hideout: walkable and dark.
isHideout :: TileSpeedup -> ContentId TileKind -> Bool

-- | Whether actors can walk into a tile. Essential for efficiency of
--   pathfinding, hence tabulated.
isWalkable :: TileSpeedup -> ContentId TileKind -> Bool

-- | Whether a tile is a door, open or closed. Essential for efficiency of
--   pathfinding, hence tabulated.
isDoor :: TileSpeedup -> ContentId TileKind -> Bool

-- | Whether a tile is changable.
isChangable :: TileSpeedup -> ContentId TileKind -> Bool

-- | Whether a tile is suspect. Essential for efficiency of pathfinding,
--   hence tabulated.
isSuspect :: TileSpeedup -> ContentId TileKind -> Bool
isHideAs :: TileSpeedup -> ContentId TileKind -> Bool
consideredByAI :: TileSpeedup -> ContentId TileKind -> Bool

-- | Whether one can easily explore a tile, possibly finding a treasure,
--   either spawned there or dropped there by a (dying from poison) foe.
--   Doors can't be explorable since revealing a secret tile should not
--   change it's explorable status. Also, door explorable status should not
--   depend on whether they are open or not, so that a foe opening a door
--   doesn't force us to backtrack to explore it. Still, a foe that digs
--   through a wall will affect our exploration counter and if content lets
--   walls contain threasure, such backtraking makes sense.
isExplorable :: TileSpeedup -> ContentId TileKind -> Bool
isVeryOftenItem :: TileSpeedup -> ContentId TileKind -> Bool
isCommonItem :: TileSpeedup -> ContentId TileKind -> Bool
isOftenActor :: TileSpeedup -> ContentId TileKind -> Bool
isNoItem :: TileSpeedup -> ContentId TileKind -> Bool
isNoActor :: TileSpeedup -> ContentId TileKind -> Bool

-- | Whether a tile kind (specified by its id) has an OpenTo
--   feature or is walkable even without opening.
isEasyOpen :: TileSpeedup -> ContentId TileKind -> Bool
isEmbed :: TileSpeedup -> ContentId TileKind -> Bool
isAquatic :: TileSpeedup -> ContentId TileKind -> Bool
alterMinSkill :: TileSpeedup -> ContentId TileKind -> Int
alterMinWalk :: TileSpeedup -> ContentId TileKind -> Int

-- | Whether a tile kind has the given feature.
kindHasFeature :: Feature -> TileKind -> Bool
openTo :: ContentData TileKind -> ContentId TileKind -> Rnd (ContentId TileKind)
closeTo :: ContentData TileKind -> ContentId TileKind -> Rnd (ContentId TileKind)
embeddedItems :: ContentData TileKind -> ContentId TileKind -> [GroupName ItemKind]
revealAs :: ContentData TileKind -> ContentId TileKind -> Rnd (ContentId TileKind)
obscureAs :: ContentData TileKind -> ContentId TileKind -> Rnd (ContentId TileKind)
hideAs :: ContentData TileKind -> ContentId TileKind -> Maybe (ContentId TileKind)
buildAs :: ContentData TileKind -> ContentId TileKind -> ContentId TileKind
isEasyOpenKind :: TileKind -> Bool

-- | Whether a tile kind (specified by its id) has an OpenTo
--   feature.
isOpenable :: TileSpeedup -> ContentId TileKind -> Bool

-- | Whether a tile kind (specified by its id) has a CloseTo
--   feature.
isClosable :: TileSpeedup -> ContentId TileKind -> Bool
isModifiable :: TileSpeedup -> ContentId TileKind -> Bool
createTab :: Unbox a => ContentData TileKind -> (TileKind -> a) -> Tab a
createTabWithKey :: Unbox a => ContentData TileKind -> (ContentId TileKind -> TileKind -> a) -> Tab a
accessTab :: Unbox a => Tab a -> ContentId TileKind -> a
alterMinSkillKind :: ContentId TileKind -> TileKind -> Word8
alterMinWalkKind :: ContentId TileKind -> TileKind -> Word8

-- | The type of item aspects and its operations.
module Game.LambdaHack.Common.ItemAspect

-- | Record of skills conferred by an item as well as of item flags and
--   other item aspects.
data AspectRecord
AspectRecord :: Int -> Skills -> Flags -> Text -> ThrowMod -> Maybe (GroupName ItemKind) -> Maybe EqpSlot -> AspectRecord
[aTimeout] :: AspectRecord -> Int
[aSkills] :: AspectRecord -> Skills
[aFlags] :: AspectRecord -> Flags
[aELabel] :: AspectRecord -> Text
[aToThrow] :: AspectRecord -> ThrowMod
[aPresentAs] :: AspectRecord -> Maybe (GroupName ItemKind)
[aEqpSlot] :: AspectRecord -> Maybe EqpSlot

-- | Partial information about an item, deduced from its item kind. These
--   are assigned to each ItemKind. The kmConst flag says
--   whether the item's aspect record is constant rather than random or
--   dependent on item creation dungeon level.
data KindMean
KindMean :: Bool -> AspectRecord -> KindMean

-- | whether the item doesn't need second identification
[kmConst] :: KindMean -> Bool

-- | mean value of item's possible aspect records
[kmMean] :: KindMean -> AspectRecord
emptyAspectRecord :: AspectRecord
addMeanAspect :: AspectRecord -> Aspect -> AspectRecord
castAspect :: AbsDepth -> AbsDepth -> AspectRecord -> Aspect -> Rnd AspectRecord
aspectsRandom :: [Aspect] -> Bool
aspectRecordToList :: AspectRecord -> [Aspect]
rollAspectRecord :: [Aspect] -> AbsDepth -> AbsDepth -> Rnd AspectRecord
getSkill :: Skill -> AspectRecord -> Int
checkFlag :: Flag -> AspectRecord -> Bool
meanAspect :: ItemKind -> AspectRecord
onlyMinorEffects :: AspectRecord -> ItemKind -> Bool
itemTrajectory :: AspectRecord -> ItemKind -> [Point] -> ([Vector], (Speed, Int))
totalRange :: AspectRecord -> ItemKind -> Int
isHumanTrinket :: ItemKind -> Bool
goesIntoEqp :: AspectRecord -> Bool
loreFromContainer :: AspectRecord -> Container -> SLore
ceilingMeanDice :: Dice -> Int
instance Data.Binary.Class.Binary Game.LambdaHack.Common.ItemAspect.AspectRecord
instance GHC.Classes.Eq Game.LambdaHack.Common.ItemAspect.AspectRecord
instance GHC.Classes.Eq Game.LambdaHack.Common.ItemAspect.KindMean
instance GHC.Internal.Generics.Generic Game.LambdaHack.Common.ItemAspect.AspectRecord
instance Data.Hashable.Class.Hashable Game.LambdaHack.Common.ItemAspect.AspectRecord
instance GHC.Classes.Ord Game.LambdaHack.Common.ItemAspect.AspectRecord
instance GHC.Classes.Ord Game.LambdaHack.Common.ItemAspect.KindMean
instance GHC.Internal.Show.Show Game.LambdaHack.Common.ItemAspect.AspectRecord
instance GHC.Internal.Show.Show Game.LambdaHack.Common.ItemAspect.KindMean

-- | Factions taking part in the game, e.g., a hero faction, a monster
--   faction and an animal faction.
module Game.LambdaHack.Common.Faction

-- | All factions in the game, indexed by faction identifier.
type FactionDict = EnumMap FactionId Faction

-- | The faction datatype.
data Faction
Faction :: FactionKind -> Text -> Color -> Doctrine -> Bool -> [(Int, Int, GroupName ItemKind)] -> Dipl -> Maybe Status -> Maybe ActorId -> Maybe (LevelId, Point) -> EnumMap (ContentId ItemKind) Int -> Faction

-- | the player spec for this faction, do not update! it is morally
--   read-only, but not represented as ContentId FactionKind,
--   because it's very small and it's looked up often enough in the code
--   and during runtime; a side-effect is that if content changes mid-game,
--   this stays; if we ever have thousands of factions in a single game,
--   e.g., one for each separately spawned herd of animals, change this
[gkind] :: Faction -> FactionKind

-- | individual name
[gname] :: Faction -> Text

-- | color of numbered actors
[gcolor] :: Faction -> Color

-- | non-pointmen behave according to this
[gdoctrine] :: Faction -> Doctrine

-- | whether the faction is under AI control
[gunderAI] :: Faction -> Bool

-- | initial actors
[ginitial] :: Faction -> [(Int, Int, GroupName ItemKind)]

-- | diplomatic standing
[gdipl] :: Faction -> Dipl

-- | cause of game end/exit
[gquit] :: Faction -> Maybe Status

-- | the leader of the faction; don't use in place of sleader on clients
[_gleader] :: Faction -> Maybe ActorId

-- | level and position of faction's shared inventory stash
[gstash] :: Faction -> Maybe (LevelId, Point)

-- | members killed
[gvictims] :: Faction -> EnumMap (ContentId ItemKind) Int

-- | Diplomacy states. Higher overwrite lower in case of asymmetric
--   content.
data Diplomacy
Unknown :: Diplomacy
Neutral :: Diplomacy
Alliance :: Diplomacy
War :: Diplomacy

-- | Current game status.
data Status
Status :: Outcome -> Int -> Maybe (GroupName ModeKind) -> Status

-- | current game outcome
[stOutcome] :: Status -> Outcome

-- | depth of the final encounter
[stDepth] :: Status -> Int

-- | new game group to start, if any
[stNewGame] :: Status -> Maybe (GroupName ModeKind)

-- | The difficulty level influencess HP of either the human player or the
--   AI. The challenges restrict some abilities of the human player only.
data Challenge
Challenge :: Int -> Bool -> Bool -> Bool -> Bool -> Challenge

-- | game difficulty level (HP bonus or malus)
[cdiff] :: Challenge -> Int

-- | cold fish challenge (no healing from enemies)
[cfish] :: Challenge -> Bool

-- | ready goods challenge (crafting disabled)
[cgoods] :: Challenge -> Bool

-- | lone wolf challenge (only one starting character)
[cwolf] :: Challenge -> Bool

-- | finder keeper challenge (ranged attacks disabled)
[ckeeper] :: Challenge -> Bool
tshowDiplomacy :: Diplomacy -> Text
tshowChallenge :: Challenge -> Text
gleader :: Faction -> Maybe ActorId

-- | Tell whether the faction consists of summoned horrors only.
--   
--   Horror player is special, for summoned actors that don't belong to any
--   of the main players of a given game. E.g., animals summoned during a
--   skirmish game between two hero factions land in the horror faction. In
--   every game, either all factions for which summoning items exist should
--   be present or a horror player should be added to host them.
isHorrorFact :: Faction -> Bool
noRunWithMulti :: Faction -> Bool
bannedPointmanSwitchBetweenLevels :: Faction -> Bool

-- | Check if factions are at war. Assumes symmetry.
isFoe :: FactionId -> Faction -> FactionId -> Bool

-- | Check if factions are allied or are the same faction. Assumes
--   symmetry.
isFriend :: FactionId -> Faction -> FactionId -> Bool
difficultyBound :: Int
difficultyDefault :: Int
difficultyCoeff :: Int -> Int
defaultChallenge :: Challenge
possibleActorFactions :: [GroupName ItemKind] -> ItemKind -> FactionDict -> Frequency (FactionId, Faction)
ppContainer :: FactionDict -> Container -> Text
type Dipl = EnumMap FactionId Diplomacy
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Faction.Challenge
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Faction.Diplomacy
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Faction.Faction
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Faction.Status
instance GHC.Internal.Enum.Enum Game.LambdaHack.Common.Faction.Diplomacy
instance GHC.Classes.Eq Game.LambdaHack.Common.Faction.Challenge
instance GHC.Classes.Eq Game.LambdaHack.Common.Faction.Diplomacy
instance GHC.Classes.Eq Game.LambdaHack.Common.Faction.Faction
instance GHC.Classes.Eq Game.LambdaHack.Common.Faction.Status
instance GHC.Internal.Generics.Generic Game.LambdaHack.Common.Faction.Challenge
instance GHC.Internal.Generics.Generic Game.LambdaHack.Common.Faction.Diplomacy
instance GHC.Internal.Generics.Generic Game.LambdaHack.Common.Faction.Faction
instance GHC.Internal.Generics.Generic Game.LambdaHack.Common.Faction.Status
instance GHC.Classes.Ord Game.LambdaHack.Common.Faction.Challenge
instance GHC.Classes.Ord Game.LambdaHack.Common.Faction.Diplomacy
instance GHC.Classes.Ord Game.LambdaHack.Common.Faction.Status
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Faction.Challenge
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Faction.Diplomacy
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Faction.Faction
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Faction.Status

-- | High score table operations.
module Game.LambdaHack.Common.HighScore

-- | The list of scores, in decreasing order.
data ScoreTable

-- | A dictionary from game mode IDs to scores tables.
type ScoreDict = EnumMap ContentId ModeKind ScoreTable

-- | Empty score table
empty :: ScoreDict

-- | Register a new score in a score table.
register :: ScoreTable -> Int -> Int -> Time -> Status -> POSIXTime -> Challenge -> Text -> EnumMap (ContentId ItemKind) Int -> EnumMap (ContentId ItemKind) Int -> HiCondPoly -> (Bool, (ScoreTable, Int))

-- | Show a single high score, from the given ranking in the high score
--   table.
showScore :: TimeZone -> Int -> ScoreRecord -> [Text]
showAward :: Int -> ScoreTable -> Int -> Text -> Text
getTable :: ContentId ModeKind -> ScoreDict -> ScoreTable
unTable :: ScoreTable -> [ScoreRecord]
getRecord :: Int -> ScoreTable -> ScoreRecord
getStatus :: ScoreRecord -> Status
getDate :: ScoreRecord -> POSIXTime

-- | A single score record. Records are ordered in the highscore table,
--   from the best to the worst, in lexicographic ordering wrt the fields
--   below.
data ScoreRecord

-- | Insert a new score into the table, Return new table and the ranking.
--   Make sure the table doesn't grow too large.
insertPos :: ScoreRecord -> ScoreTable -> (ScoreTable, Int)
instance Data.Binary.Class.Binary Game.LambdaHack.Common.HighScore.ScoreRecord
instance Data.Binary.Class.Binary Game.LambdaHack.Common.HighScore.ScoreTable
instance GHC.Classes.Eq Game.LambdaHack.Common.HighScore.ScoreRecord
instance GHC.Classes.Eq Game.LambdaHack.Common.HighScore.ScoreTable
instance GHC.Internal.Generics.Generic Game.LambdaHack.Common.HighScore.ScoreRecord
instance GHC.Classes.Ord Game.LambdaHack.Common.HighScore.ScoreRecord
instance GHC.Internal.Show.Show Game.LambdaHack.Common.HighScore.ScoreTable

-- | Slideshows.
module Game.LambdaHack.Client.UI.Slideshow
type FontOverlayMap = EnumMap DisplayFont Overlay
maxYofFontOverlayMap :: FontOverlayMap -> Int
type KeyOrSlot = Either KM MenuSlot
data MenuSlot
natSlots :: [MenuSlot]

-- | Width of on-screen button text, expressed in characters, and so UI
--   (mono font) width is deduced from the used font.
data ButtonWidth
ButtonWidth :: DisplayFont -> Int -> ButtonWidth
[buttonFont] :: ButtonWidth -> DisplayFont
[buttonWidth] :: ButtonWidth -> Int

-- | A key or a menu slot at a given position on the screen.
type KYX = (KeyOrSlot, (PointUI, ButtonWidth))
xytranslateKXY :: Int -> Int -> KYX -> KYX
xtranslateKXY :: Int -> KYX -> KYX
ytranslateKXY :: Int -> KYX -> KYX
yrenumberKXY :: Int -> KYX -> KYX

-- | An Overlay of text with an associated list of keys or slots that
--   activate when the specified screen position is pointed at. The list
--   should be sorted wrt rows and then columns.
type OKX = (FontOverlayMap, [KYX])
emptyOKX :: OKX
xytranslateOKX :: Int -> Int -> OKX -> OKX
sideBySideOKX :: Int -> Int -> OKX -> OKX -> OKX
labDescOKX :: DisplayFont -> DisplayFont -> [(AttrString, AttrString, KeyOrSlot)] -> OKX

-- | A list of active screenfulls to be shown one after another. Each
--   screenful has an independent numbering of rows and columns.
data Slideshow
emptySlideshow :: Slideshow
unsnocSlideshow :: Slideshow -> Maybe (Slideshow, OKX)
toSlideshow :: FontSetup -> Bool -> [OKX] -> Slideshow

-- | This appends vertically a list of blurbs into a single font overlay
--   map. Not to be used if some blurbs need to be places overlapping
--   vertically, e.g., when the square font symbol needs to be in the same
--   line as the start of the descritpion of the denoted item or when mono
--   font buttons need to be after a prompt.
attrLinesToFontMap :: [(DisplayFont, [AttrLine])] -> FontOverlayMap
menuToSlideshow :: OKX -> Slideshow
wrapOKX :: DisplayFont -> Int -> Int -> Int -> [(KM, String)] -> (Overlay, [KYX])
splitOverlay :: FontSetup -> Bool -> Int -> Int -> Int -> Report -> [KM] -> OKX -> Slideshow
splitOKX :: FontSetup -> Bool -> Int -> Int -> Int -> AttrString -> [KM] -> OKX -> [OKX]

-- | Generate a slideshow with the current and previous scores.
highSlideshow :: FontSetup -> Bool -> Int -> Int -> ScoreTable -> Int -> Text -> TimeZone -> Slideshow
keysOKX :: DisplayFont -> Int -> Int -> Int -> [KM] -> (Overlay, [KYX])

-- | Show a screenful of the high scores table. Parameter entries
--   is the number of (3-line) scores to be shown.
showTable :: TimeZone -> Int -> ScoreTable -> Int -> Int -> [AttrLine]

-- | Produce a couple of renderings of the high scores table.
showNearbyScores :: TimeZone -> Int -> ScoreTable -> Int -> [[AttrLine]]
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.Slideshow.MenuSlot
instance GHC.Internal.Enum.Enum Game.LambdaHack.Client.UI.Slideshow.MenuSlot
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.Slideshow.ButtonWidth
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.Slideshow.MenuSlot
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.Slideshow.Slideshow
instance GHC.Classes.Ord Game.LambdaHack.Client.UI.Slideshow.MenuSlot
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.Slideshow.ButtonWidth
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.Slideshow.MenuSlot
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.Slideshow.Slideshow

-- | Abstract syntax of requests.
--   
--   See
--   https://github.com/LambdaHack/LambdaHack/wiki/Client-server-architecture.
module Game.LambdaHack.Client.Request

-- | Requests sent by AI clients to the server. If faction leader is to be
--   changed, it's included as the second component.
type RequestAI = (ReqAI, Maybe ActorId)

-- | Possible forms of requests sent by AI clients.
data ReqAI
ReqAINop :: ReqAI
ReqAITimed :: RequestTimed -> ReqAI

-- | Requests sent by UI clients to the server. If faction leader is to be
--   changed, it's included as the second component.
type RequestUI = (ReqUI, Maybe ActorId)

-- | Possible forms of requests sent by UI clients.
data ReqUI
ReqUINop :: ReqUI
ReqUITimed :: RequestTimed -> ReqUI
ReqUIGameRestart :: GroupName ModeKind -> Challenge -> ReqUI
ReqUIGameDropAndExit :: ReqUI
ReqUIGameSaveAndExit :: ReqUI
ReqUIGameSave :: ReqUI
ReqUIDoctrine :: Doctrine -> ReqUI
ReqUIAutomate :: ReqUI

-- | Requests that take game time.
data RequestTimed
ReqMove :: Vector -> RequestTimed
ReqMelee :: ActorId -> ItemId -> CStore -> RequestTimed
ReqDisplace :: ActorId -> RequestTimed
ReqAlter :: Point -> RequestTimed
ReqWait :: RequestTimed
ReqWait10 :: RequestTimed
ReqYell :: RequestTimed
ReqMoveItems :: [(ItemId, Int, CStore, CStore)] -> RequestTimed
ReqProject :: Point -> Int -> ItemId -> CStore -> RequestTimed
ReqApply :: ItemId -> CStore -> RequestTimed
instance GHC.Internal.Show.Show Game.LambdaHack.Client.Request.ReqAI
instance GHC.Internal.Show.Show Game.LambdaHack.Client.Request.ReqUI
instance GHC.Internal.Show.Show Game.LambdaHack.Client.Request.RequestTimed

-- | Abstract syntax of human player commands.
module Game.LambdaHack.Client.UI.HumanCmd
data CmdCategory
CmdDashboard :: CmdCategory
CmdItemMenu :: CmdCategory
CmdMove :: CmdCategory
CmdItem :: CmdCategory
CmdAim :: CmdCategory
CmdMeta :: CmdCategory
CmdMouse :: CmdCategory
CmdInternal :: CmdCategory
CmdDebug :: CmdCategory
CmdMinimal :: CmdCategory
categoryDescription :: CmdCategory -> Text

-- | Symbolic representation of areas of the screen used to define the
--   meaning of mouse button presses relative to where the mouse points to.
data CmdArea
CaMessage :: CmdArea
CaMapLeader :: CmdArea
CaMapParty :: CmdArea
CaMap :: CmdArea
CaLevelNumber :: CmdArea
CaArenaName :: CmdArea
CaPercentSeen :: CmdArea
CaXhairDesc :: CmdArea
CaSelected :: CmdArea
CaCalmGauge :: CmdArea
CaCalmValue :: CmdArea
CaHPGauge :: CmdArea
CaHPValue :: CmdArea
CaLeaderDesc :: CmdArea
areaDescription :: CmdArea -> Text

-- | This triple of command categories, description and the command term
--   itself defines the meaning of a human command as entered via a
--   keypress, mouse click or chosen from a menu.
type CmdTriple = ([CmdCategory], Text, HumanCmd)
data AimModeCmd
AimModeCmd :: HumanCmd -> HumanCmd -> AimModeCmd
[exploration] :: AimModeCmd -> HumanCmd
[aiming] :: AimModeCmd -> HumanCmd

-- | Abstract syntax of human player commands.
data HumanCmd
Macro :: [String] -> HumanCmd
ByArea :: [(CmdArea, HumanCmd)] -> HumanCmd
ByAimMode :: AimModeCmd -> HumanCmd
ComposeIfLocal :: HumanCmd -> HumanCmd -> HumanCmd
ComposeUnlessError :: HumanCmd -> HumanCmd -> HumanCmd
Compose2ndLocal :: HumanCmd -> HumanCmd -> HumanCmd
LoopOnNothing :: HumanCmd -> HumanCmd
ExecuteIfClear :: HumanCmd -> HumanCmd
Wait :: HumanCmd
Wait10 :: HumanCmd
Yell :: HumanCmd
MoveDir :: Vector -> HumanCmd
RunDir :: Vector -> HumanCmd
RunOnceAhead :: HumanCmd
MoveOnceToXhair :: HumanCmd
RunOnceToXhair :: HumanCmd
ContinueToXhair :: HumanCmd
MoveItem :: [CStore] -> CStore -> Maybe Text -> Bool -> HumanCmd
Project :: HumanCmd
Apply :: HumanCmd
AlterDir :: HumanCmd
AlterWithPointer :: HumanCmd
CloseDir :: HumanCmd
Help :: HumanCmd
Hint :: HumanCmd
ItemMenu :: HumanCmd
MainMenu :: HumanCmd
MainMenuAutoOn :: HumanCmd
MainMenuAutoOff :: HumanCmd
Dashboard :: HumanCmd
GameDifficultyIncr :: Int -> HumanCmd
GameFishToggle :: HumanCmd
GameGoodsToggle :: HumanCmd
GameWolfToggle :: HumanCmd
GameKeeperToggle :: HumanCmd
GameScenarioIncr :: Int -> HumanCmd
GameRestart :: HumanCmd
GameQuit :: HumanCmd
GameDrop :: HumanCmd
GameExit :: HumanCmd
GameSave :: HumanCmd
Doctrine :: HumanCmd
Automate :: HumanCmd
AutomateToggle :: HumanCmd
AutomateBack :: HumanCmd
ChooseItem :: ItemDialogMode -> HumanCmd
ChooseItemMenu :: ItemDialogMode -> HumanCmd
ChooseItemProject :: [TriggerItem] -> HumanCmd
ChooseItemApply :: [TriggerItem] -> HumanCmd
PickLeader :: Int -> HumanCmd
PickLeaderWithPointer :: HumanCmd
PointmanCycle :: Direction -> HumanCmd
PointmanCycleLevel :: Direction -> HumanCmd
SelectActor :: HumanCmd
SelectNone :: HumanCmd
SelectWithPointer :: HumanCmd
Repeat :: Int -> HumanCmd
RepeatLast :: Int -> HumanCmd
Record :: HumanCmd
AllHistory :: HumanCmd
MarkVision :: Int -> HumanCmd
MarkSmell :: HumanCmd
MarkSuspect :: Int -> HumanCmd
MarkAnim :: HumanCmd
OverrideTut :: Int -> HumanCmd
SettingsMenu :: HumanCmd
ChallengeMenu :: HumanCmd
PrintScreen :: HumanCmd
Cancel :: HumanCmd
Accept :: HumanCmd
DetailCycle :: HumanCmd
ClearTargetIfItemClear :: HumanCmd
ItemClear :: HumanCmd
MoveXhair :: Vector -> Int -> HumanCmd
AimTgt :: HumanCmd
AimFloor :: HumanCmd
AimEnemy :: HumanCmd
AimItem :: HumanCmd
AimAscend :: Int -> HumanCmd
EpsIncr :: Direction -> HumanCmd
XhairUnknown :: HumanCmd
XhairItem :: HumanCmd
XhairStair :: Bool -> HumanCmd
XhairPointerFloor :: HumanCmd
XhairPointerMute :: HumanCmd
XhairPointerEnemy :: HumanCmd
AimPointerFloor :: HumanCmd
AimPointerEnemy :: HumanCmd

-- | Description of how item manipulation is triggered and communicated to
--   the player.
data TriggerItem
TriggerItem :: Part -> Part -> [ContentSymbol ItemKind] -> TriggerItem
[tiverb] :: TriggerItem -> Part
[tiobject] :: TriggerItem -> Part
[tisymbols] :: TriggerItem -> [ContentSymbol ItemKind]
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.HumanCmd.AimModeCmd
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.HumanCmd.CmdArea
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.HumanCmd.CmdCategory
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.HumanCmd.HumanCmd
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.HumanCmd.TriggerItem
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.HumanCmd.AimModeCmd
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.HumanCmd.CmdArea
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.HumanCmd.CmdCategory
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.HumanCmd.HumanCmd
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.HumanCmd.TriggerItem
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.UI.HumanCmd.AimModeCmd
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.UI.HumanCmd.CmdArea
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.UI.HumanCmd.CmdCategory
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.UI.HumanCmd.HumanCmd
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.UI.HumanCmd.TriggerItem
instance Control.DeepSeq.NFData Game.LambdaHack.Client.UI.HumanCmd.AimModeCmd
instance Control.DeepSeq.NFData Game.LambdaHack.Client.UI.HumanCmd.CmdArea
instance Control.DeepSeq.NFData Game.LambdaHack.Client.UI.HumanCmd.CmdCategory
instance Control.DeepSeq.NFData Game.LambdaHack.Client.UI.HumanCmd.HumanCmd
instance Control.DeepSeq.NFData Game.LambdaHack.Client.UI.HumanCmd.TriggerItem
instance GHC.Classes.Ord Game.LambdaHack.Client.UI.HumanCmd.AimModeCmd
instance GHC.Classes.Ord Game.LambdaHack.Client.UI.HumanCmd.CmdArea
instance GHC.Classes.Ord Game.LambdaHack.Client.UI.HumanCmd.HumanCmd
instance GHC.Classes.Ord Game.LambdaHack.Client.UI.HumanCmd.TriggerItem
instance GHC.Internal.Read.Read Game.LambdaHack.Client.UI.HumanCmd.AimModeCmd
instance GHC.Internal.Read.Read Game.LambdaHack.Client.UI.HumanCmd.CmdArea
instance GHC.Internal.Read.Read Game.LambdaHack.Client.UI.HumanCmd.CmdCategory
instance GHC.Internal.Read.Read Game.LambdaHack.Client.UI.HumanCmd.HumanCmd
instance GHC.Internal.Read.Read Game.LambdaHack.Client.UI.HumanCmd.TriggerItem
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.HumanCmd.AimModeCmd
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.HumanCmd.CmdArea
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.HumanCmd.CmdCategory
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.HumanCmd.HumanCmd
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.HumanCmd.TriggerItem

-- | UI client options specified in the config file.
module Game.LambdaHack.Client.UI.UIOptions

-- | Options that affect the UI of the client, specified in the config
--   file. More documentation is in the default config file.
data UIOptions
UIOptions :: [(KM, CmdTriple)] -> [(Int, (Text, Text))] -> Bool -> Bool -> Text -> Double -> FullscreenMode -> Int -> X -> Int -> Double -> Bool -> [String] -> [(Text, FontDefinition)] -> [(Text, FontSet)] -> [(String, Color)] -> UIOptions
[uCommands] :: UIOptions -> [(KM, CmdTriple)]
[uHeroNames] :: UIOptions -> [(Int, (Text, Text))]
[uVi] :: UIOptions -> Bool
[uLeftHand] :: UIOptions -> Bool
[uChosenFontset] :: UIOptions -> Text
[uAllFontsScale] :: UIOptions -> Double
[uFullscreenMode] :: UIOptions -> FullscreenMode
[uhpWarningPercent] :: UIOptions -> Int
[uMsgWrapColumn] :: UIOptions -> X
[uHistoryMax] :: UIOptions -> Int
[uMaxFps] :: UIOptions -> Double
[uNoAnim] :: UIOptions -> Bool
[uOverrideCmdline] :: UIOptions -> [String]
[uFonts] :: UIOptions -> [(Text, FontDefinition)]
[uFontsets] :: UIOptions -> [(Text, FontSet)]
[uMessageColors] :: UIOptions -> [(String, Color)]
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.UIOptions.UIOptions
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.UI.UIOptions.UIOptions
instance Control.DeepSeq.NFData Game.LambdaHack.Client.UI.UIOptions.UIOptions
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.UIOptions.UIOptions

-- | The type of definitions of key-command mappings to be used for the UI
--   and shorthands for specifying command triples in the content files.
module Game.LambdaHack.Client.UI.Content.Input

-- | Key-command mappings to be specified in content and used for the UI.
newtype InputContentRaw
InputContentRaw :: [(KM, CmdTriple)] -> InputContentRaw

-- | Bindings and other information about human player commands.
data InputContent
InputContent :: Map KM CmdTriple -> [(KM, CmdTriple)] -> Map HumanCmd [KM] -> InputContent

-- | binding of keys to commands
[bcmdMap] :: InputContent -> Map KM CmdTriple

-- | the properly ordered list of commands for the help menu
[bcmdList] :: InputContent -> [(KM, CmdTriple)]

-- | and from commands to their keys
[brevMap] :: InputContent -> Map HumanCmd [KM]

-- | Create binding of keys to movement and other standard commands, as
--   well as commands defined in the config file.
makeData :: Maybe UIOptions -> InputContentRaw -> InputContent
evalKeyDef :: (String, CmdTriple) -> (KM, CmdTriple)
addCmdCategory :: CmdCategory -> CmdTriple -> CmdTriple
replaceDesc :: Text -> CmdTriple -> CmdTriple
moveItemTriple :: [CStore] -> CStore -> Part -> Bool -> CmdTriple
repeatTriple :: Int -> [CmdCategory] -> CmdTriple
repeatLastTriple :: Int -> [CmdCategory] -> CmdTriple
mouseLMB :: HumanCmd -> Text -> CmdTriple
mouseMMB :: CmdTriple
mouseMMBMute :: CmdTriple
mouseRMB :: CmdTriple
goToCmd :: HumanCmd
runToAllCmd :: HumanCmd
autoexploreCmd :: HumanCmd
autoexplore25Cmd :: HumanCmd
aimFlingCmd :: HumanCmd
projectI :: [TriggerItem] -> CmdTriple
projectA :: [TriggerItem] -> CmdTriple

-- | flingTs - list containing one flingable projectile >>>
--   flingTs [TriggerItem {tiverb = Text "fling", tiobject = Text "in-range
--   projectile", tisymbols = ""}]
--   
--   I question the value of that test. But would Bob Martin like it on the
--   grounds it's like double-bookkeeping?
flingTs :: [TriggerItem]
applyIK :: [TriggerItem] -> CmdTriple
applyI :: [TriggerItem] -> CmdTriple
grabItems :: Text -> CmdTriple
dropItems :: Text -> CmdTriple
descIs :: [TriggerItem] -> Text
defaultHeroSelect :: Int -> (String, CmdTriple)
macroRun25 :: [String]
memberCycle :: Direction -> [CmdCategory] -> CmdTriple
memberCycleLevel :: Direction -> [CmdCategory] -> CmdTriple
replaceCmd :: HumanCmd -> CmdTriple -> CmdTriple
projectICmd :: [TriggerItem] -> HumanCmd
grabCmd :: HumanCmd
dropCmd :: HumanCmd

-- | The default game key-command mapping to be used for UI. Can be
--   overridden via macros in the config file.
module Client.UI.Content.Input

-- | Description of default key-command bindings.
--   
--   In addition to these commands, mouse and keys have a standard meaning
--   when navigating various menus.
standardKeysAndMouse :: InputContentRaw
applyTs :: [TriggerItem]

-- | The type of definitions of screen layout and features.
module Game.LambdaHack.Client.UI.Content.Screen

-- | Screen layout and features definition.
--   
--   Warning: this type is not abstract, but its values should not be
--   created ad hoc, even for unit tests, but should be constructed with
--   makeData, which includes validation,
--   
--   The emptyScreenContent is one such valid by construction
--   value of this type. It's suitable for bootstrapping and for testing.
data ScreenContent
ScreenContent :: X -> Y -> String -> ([String], [[String]]) -> EnumMap (ContentSymbol ItemKind) Text -> [(FilePath, ByteString)] -> ScreenContent

-- | screen width
[rwidth] :: ScreenContent -> X

-- | screen height
[rheight] :: ScreenContent -> Y

-- | an extra blurb line for the main menu
[rwebAddress] :: ScreenContent -> String

-- | the intro screen (first help screen) text and the rest of the manual
[rintroScreen] :: ScreenContent -> ([String], [[String]])

-- | verbs to use for apply actions
[rapplyVerbMap] :: ScreenContent -> EnumMap (ContentSymbol ItemKind) Text

-- | embedded game-supplied font files
[rFontFiles] :: ScreenContent -> [(FilePath, ByteString)]
emptyScreenContent :: ScreenContent
makeData :: RuleContent -> ScreenContent -> ScreenContent
emptyScreenContentRaw :: ScreenContent

-- | Catch invalid rule kind definitions.
validateSingle :: RuleContent -> ScreenContent -> [Text]

-- | Screen frames.
--   
--   Note that PointArray.Array here represents a screen frame and
--   so screen positions are denoted by Point, contrary to the
--   convention that Point refers to game map coordinates, as
--   outlined in description of PointSquare that should normally be
--   used in that role.
module Game.LambdaHack.Client.UI.Frame

-- | Color mode for the display.
data ColorMode

-- | normal, with full colours
ColorFull :: ColorMode

-- | black and white only
ColorBW :: ColorMode
type FrameST s = Mutable Vector s Word32 -> ST s ()

-- | Efficiently composable representation of an operation on a frame, that
--   is, on a mutable vector. When the composite operation is eventually
--   performed, the vector is frozen to become a SingleFrame.
newtype FrameForall
FrameForall :: (forall s. () => FrameST s) -> FrameForall
[unFrameForall] :: FrameForall -> forall s. () => FrameST s

-- | Action that results in a base frame, to be modified further.
newtype FrameBase
FrameBase :: (forall s. () => ST s (Mutable Vector s Word32)) -> FrameBase
[unFrameBase] :: FrameBase -> forall s. () => ST s (Mutable Vector s Word32)

-- | A frame, that is, a base frame and all its modifications.
type Frame = ((FrameBase, FrameForall), (OverlaySpace, OverlaySpace, OverlaySpace))

-- | Components of a frame, before it's decided if the first can be
--   overwritten in-place or needs to be copied.
type PreFrame3 = (PreFrame, (OverlaySpace, OverlaySpace, OverlaySpace))

-- | Sequence of screen frames, including delays. Potentially based on a
--   single base frame.
type PreFrames3 = [Maybe PreFrame3]

-- | A simpler variant of PreFrame3.
type PreFrame = (Vector Word32, FrameForall)

-- | A simpler variant of PreFrames3.
type PreFrames = [Maybe PreFrame]

-- | A frame that is padded to fill the whole screen with optional overlays
--   to display in proportional, square and monospace fonts.
--   
--   Note that we don't provide a list of color-highlighed box positions to
--   be drawn separately, because overlays need to obscure not only map,
--   but the highlights as well, so highlights need to be included earlier.
--   
--   See the description of PointSquare for explanation of why
--   screen coordinates in singleArray are Point even
--   though they should be PointSquare.
data SingleFrame
SingleFrame :: Array AttrCharW32 -> OverlaySpace -> OverlaySpace -> OverlaySpace -> SingleFrame
[singleArray] :: SingleFrame -> Array AttrCharW32
[singlePropOverlay] :: SingleFrame -> OverlaySpace
[singleSquareOverlay] :: SingleFrame -> OverlaySpace
[singleMonoOverlay] :: SingleFrame -> OverlaySpace
type OverlaySpace = [(PointUI, AttrString)]
blankSingleFrame :: ScreenContent -> SingleFrame

-- | Truncate the overlay: for each line, if it's too long, it's truncated
--   and if there are too many lines, excess is dropped and warning is
--   appended. The width, in the second argument, is calculated in
--   characters, not in UI (mono font) coordinates, so that taking and
--   dropping characters is performed correctly.
truncateOverlay :: Bool -> Int -> Int -> Bool -> Int -> Bool -> Overlay -> OverlaySpace

-- | Overlays either the game map only or the whole empty screen frame. We
--   assume the lines of the overlay are not too long nor too many.
overlayFrame :: Int -> OverlaySpace -> PreFrame -> PreFrame

-- | Add a space at the message end, for display overlayed over the level
--   map. Also trim (do not wrap!) too long lines. Also add many spaces
--   when under longer lines.
truncateAttrLine :: Bool -> Int -> Int -> AttrLine -> AttrString
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.Frame.ColorMode
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.Frame.SingleFrame
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.Frame.SingleFrame

-- | Screen frames and animations.
module Game.LambdaHack.Client.UI.Frontend.Common

-- | Raw frontend definition. The minimal closed set of values that need to
--   depend on the specifics of the chosen frontend.
data RawFrontend
RawFrontend :: (SingleFrame -> IO ()) -> IO () -> MVar () -> TQueue KMP -> IO () -> ScreenContent -> RawFrontend
[fdisplay] :: RawFrontend -> SingleFrame -> IO ()
[fshutdown] :: RawFrontend -> IO ()
[fshowNow] :: RawFrontend -> MVar ()
[fchanKey] :: RawFrontend -> TQueue KMP
[fprintScreen] :: RawFrontend -> IO ()
[fcoscreen] :: RawFrontend -> ScreenContent

-- | Start up a frontend on a bound thread.
--   
--   In fact, it is started on the very main thread, via a hack, because
--   apparently some SDL backends are not thread-safe
--   (https://wiki.libsdl.org/FAQDevelopment; "this should only be
--   run in the thread that initialized the video subsystem, and for extra
--   safety, you should consider only doing those things on the main thread
--   in any case") and at least the newer OS X obtusely requires the main
--   thread, see
--   https://github.com/AllureOfTheStars/Allure/issues/79 In case
--   any other exotic architecture requires the main thread, we make the
--   hack the default for all (on frontends that require a bound thread,
--   e.g., SLD2).
startupBound :: (MVar RawFrontend -> IO ()) -> IO RawFrontend
createRawFrontend :: ScreenContent -> (SingleFrame -> IO ()) -> IO () -> IO RawFrontend

-- | Empty the keyboard channel.
resetChanKey :: TQueue KMP -> IO ()
saveKMP :: RawFrontend -> Modifier -> Key -> PointUI -> IO ()

-- | Translates modifiers to our own encoding.
modifierTranslate :: Bool -> Bool -> Bool -> Bool -> Modifier

-- | Line terminal text frontend based on stdin/stdout, intended for
--   logging tests, but may be used on a teletype terminal, or with
--   keyboard and printer.
module Game.LambdaHack.Client.UI.Frontend.Teletype

-- | Set up the frontend input and output.
startup :: ScreenContent -> IO RawFrontend

-- | The name of the frontend.
frontendName :: String

-- | Text frontend based on SDL2.
module Game.LambdaHack.Client.UI.Frontend.Sdl

-- | Set up and start the main loop providing input and output.
--   
--   Because of Windows and OS X, SDL2 needs to be on a bound thread, so we
--   can't avoid the communication overhead of bound threads.
startup :: ScreenContent -> ClientOptions -> IO RawFrontend

-- | The name of the frontend.
frontendName :: String
type FontAtlas = EnumMap AttrCharW32 Texture

-- | Session data maintained by the frontend.
data FrontendSession
FrontendSession :: Window -> Renderer -> Font -> Int -> Bool -> Maybe Font -> Maybe Font -> Maybe Font -> IORef FontAtlas -> IORef FontAtlas -> IORef Texture -> IORef Texture -> IORef SingleFrame -> IORef Bool -> IORef Bool -> MVar SingleFrame -> MVar () -> FrontendSession
[swindow] :: FrontendSession -> Window
[srenderer] :: FrontendSession -> Renderer
[squareFont] :: FrontendSession -> Font
[squareFontSize] :: FrontendSession -> Int
[mapFontIsBitmap] :: FrontendSession -> Bool
[spropFont] :: FrontendSession -> Maybe Font
[sboldFont] :: FrontendSession -> Maybe Font
[smonoFont] :: FrontendSession -> Maybe Font
[squareAtlas] :: FrontendSession -> IORef FontAtlas
[smonoAtlas] :: FrontendSession -> IORef FontAtlas
[sbasicTexture] :: FrontendSession -> IORef Texture
[stexture] :: FrontendSession -> IORef Texture
[spreviousFrame] :: FrontendSession -> IORef SingleFrame
[sforcedShutdown] :: FrontendSession -> IORef Bool
[scontinueSdlLoop] :: FrontendSession -> IORef Bool
[sframeQueue] :: FrontendSession -> MVar SingleFrame
[sframeDrawn] :: FrontendSession -> MVar ()
startupFun :: ScreenContent -> ClientOptions -> MVar RawFrontend -> IO ()
shutdown :: FrontendSession -> IO ()
forceShutdown :: FrontendSession -> IO ()

-- | Add a frame to be drawn.
display :: FrontendSession -> SingleFrame -> IO ()
drawFrame :: ScreenContent -> ClientOptions -> FrontendSession -> SingleFrame -> IO ()
printScreen :: FrontendSession -> IO ()

-- | Translates modifiers to our own encoding.
modTranslate :: KeyModifier -> Modifier
keyTranslate :: Bool -> Keycode -> Key
colorToRGBA :: Color -> V4 Word8

-- | Text frontend based on ANSI (via ansi-terminal).
module Game.LambdaHack.Client.UI.Frontend.ANSI

-- | Starts the main program loop using the frontend input and output.
startup :: ScreenContent -> IO RawFrontend

-- | The name of the frontend.
frontendName :: String

-- | Display game data on the screen and receive user input using one of
--   the available raw frontends and derived operations.
module Game.LambdaHack.Client.UI.Frontend

-- | The instructions sent by clients to the raw frontend, indexed by the
--   returned value.
data FrontReq a

-- | Show a frame.
[FrontFrame] :: Frame -> FrontReq ()

-- | Perform an explicit delay of the given length.
[FrontDelay] :: Int -> FrontReq ()

-- | Flush frames, display a frame and ask for a keypress.
[FrontKey] :: [KM] -> Frame -> FrontReq KMP

-- | Tell if a keypress is pending.
[FrontPressed] :: FrontReq Bool

-- | Discard a single key in the queue, if any.
[FrontDiscardKey] :: FrontReq ()

-- | Discard all keys in the queue.
[FrontResetKeys] :: FrontReq ()

-- | Shut the frontend down.
[FrontShutdown] :: FrontReq ()

-- | Take screenshot.
[FrontPrintScreen] :: FrontReq ()

-- | Connection channel between a frontend and a client. Frontend acts as a
--   server, serving keys, etc., when given frames to display.
newtype ChanFrontend
ChanFrontend :: (forall a. () => FrontReq a -> IO a) -> ChanFrontend

-- | Initialize the frontend chosen by the player via client options.
chanFrontendIO :: ScreenContent -> ClientOptions -> IO ChanFrontend

-- | The name of the chosen frontend.
frontendName :: ClientOptions -> String

-- | Machinery allocated for an individual frontend at its startup,
--   unchanged for its lifetime.
data FrontSetup
getKey :: FrontSetup -> RawFrontend -> [KM] -> Frame -> IO KMP
fchanFrontend :: FrontSetup -> RawFrontend -> ChanFrontend
display :: RawFrontend -> Frame -> IO ()
defaultMaxFps :: Double
microInSec :: Int
frameTimeoutThread :: Int -> MVar Int -> RawFrontend -> IO ()
lazyStartup :: ScreenContent -> IO RawFrontend
nullStartup :: ScreenContent -> IO RawFrontend
seqFrame :: SingleFrame -> IO ()

-- | General content types and operations.
module Game.LambdaHack.Client.UI.ContentClientUI

-- | Operations for all UI content types, gathered together.
data CCUI
CCUI :: InputContent -> ScreenContent -> CCUI
[coinput] :: CCUI -> InputContent
[coscreen] :: CCUI -> ScreenContent
emptyCCUI :: CCUI

-- | Verifying, aggregating and displaying binding of keys to commands.
module Game.LambdaHack.Client.UI.KeyBindings

-- | Produce a set of help/menu screens from the key bindings.
--   
--   When the intro screen mentions KP_5, this really is KP_Begin, but
--   since that is harder to understand we assume a different, non-default
--   state of NumLock in the help text than in the code that handles keys.
keyHelp :: CCUI -> FontSetup -> [(Text, OKX)]

-- | Turn the specified portion of bindings into a menu.
--   
--   The length of the button may be wrong if the two supplied fonts have
--   very different widths.
okxsN :: InputContent -> DisplayFont -> DisplayFont -> Int -> (HumanCmd -> Bool) -> Bool -> CmdCategory -> ([Text], [Text], [Text]) -> ([Text], [Text]) -> OKX

-- | Screen frames and animations.
module Game.LambdaHack.Client.UI.Animation

-- | Animation is a list of frame modifications to play one by one, where
--   each modification if a map from positions to level map symbols.
data Animation

-- | Render animations on top of a screen frame.
--   
--   Located in this module to keep Animation abstract.
renderAnim :: Int -> PreFrame -> Animation -> PreFrames

-- | Empty animation with a frame of delay, to be used to momentarily
--   display something for the player to see, e.g., the aiming line when
--   swerving it. Don't use this if there are multi-line messages on the
--   screen, because the text blinking is going to be distracting.
pushAndDelay :: Animation

-- | Attack animation. A part of it also reused for self-damage and
--   healing.
twirlSplash :: (Point, Point) -> Color -> Color -> Animation

-- | Short attack animation.
twirlSplashShort :: (Point, Point) -> Color -> Color -> Animation

-- | Attack that hits through a block.
blockHit :: (Point, Point) -> Color -> Color -> Animation

-- | Attack that is blocked.
blockMiss :: (Point, Point) -> Animation

-- | Attack that is subtle (e.g., damage dice 0).
subtleHit :: (Point, Point) -> Animation

-- | Death animation for an organic body.
deathBody :: Point -> Animation

-- | Death animation for an organic body, short version (e.g., for
--   enemies).
shortDeathBody :: Point -> Animation

-- | Mark actor location animation.
actorX :: Point -> Animation

-- | Actor teleport animation.
teleport :: (Point, Point) -> Animation

-- | Terrain feature vanishing animation.
vanish :: Point -> Animation

-- | Swap-places animation, both hostile and friendly.
swapPlaces :: (Point, Point) -> Animation
fadeout :: ScreenContent -> Bool -> Int -> Rnd Animation
blank :: Maybe AttrCharW32
cSym :: Color -> Char -> Maybe AttrCharW32
mapPosToOffset :: (Point, AttrCharW32) -> (PointUI, AttrString)
mzipSingleton :: Point -> Maybe AttrCharW32 -> OverlaySpace
mzipPairs :: (Point, Point) -> (Maybe AttrCharW32, Maybe AttrCharW32) -> OverlaySpace
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.Animation.Animation
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.Animation.Animation

-- | The default screen layout and features definition.
module Client.UI.Content.Screen

-- | Description of default screen layout and features.
standardLayoutAndFeatures :: ScreenContent

-- | General content types and operations.
module Game.LambdaHack.Common.Kind

-- | Verified and preprocessed content data of a particular kind.
data ContentData c

-- | Operations for all content types, gathered together.
--   
--   Warning: this type is not abstract, but its values should not be
--   created ad hoc, even for unit tests, but should be constructed with
--   makeData for each particular content kind, which includes
--   validation, and with speedupItem, etc., to ensure internal
--   consistency.
--   
--   The emptyCOps is one such valid by construction value of this
--   type, except for the cocave field. It's suitable for
--   bootstrapping and for tests not involving dungeon generation from cave
--   templates.
data COps
COps :: ContentData CaveKind -> ContentData FactionKind -> ContentData ItemKind -> ContentData ModeKind -> ContentData PlaceKind -> RuleContent -> ContentData TileKind -> ItemSpeedup -> TileSpeedup -> COps
[cocave] :: COps -> ContentData CaveKind
[cofact] :: COps -> ContentData FactionKind
[coitem] :: COps -> ContentData ItemKind
[comode] :: COps -> ContentData ModeKind
[coplace] :: COps -> ContentData PlaceKind
[corule] :: COps -> RuleContent
[cotile] :: COps -> ContentData TileKind
[coItemSpeedup] :: COps -> ItemSpeedup
[coTileSpeedup] :: COps -> TileSpeedup

-- | This is as empty, as possible, but still valid content, except for
--   cocave which is empty and not valid (making it valid would
--   require bloating most other contents).
emptyCOps :: COps

-- | Map from an item kind identifier to the mean aspect value for the
--   kind.
data ItemSpeedup
getKindMean :: ContentId ItemKind -> ItemSpeedup -> KindMean
speedupItem :: ContentData ItemKind -> ItemSpeedup

-- | Content element at given id.
okind :: ContentData a -> ContentId a -> a
omemberGroup :: ContentData a -> GroupName a -> Bool
oisSingletonGroup :: ContentData a -> GroupName a -> Bool

-- | The id of the unique member of a singleton content group.
ouniqGroup :: Show a => ContentData a -> GroupName a -> ContentId a

-- | Pick a random id belonging to a group and satisfying a predicate.
opick :: Show a => ContentData a -> GroupName a -> (a -> Bool) -> Rnd (Maybe (ContentId a))

-- | Fold strictly over all content a.
ofoldlWithKey' :: ContentData a -> (b -> ContentId a -> a -> b) -> b -> b

-- | Fold over the given group only.
ofoldlGroup' :: ContentData a -> GroupName a -> (b -> Int -> ContentId a -> a -> b) -> b -> b
omapVector :: ContentData a -> (a -> b) -> Vector b
oimapVector :: ContentData a -> (ContentId a -> a -> b) -> Vector b

-- | Size of content a.
olength :: ContentData a -> Int
linearInterpolation :: Int -> Int -> Rarity -> Int
emptyMultiGroupMode :: ModeKind
emptyMultiGroupItem :: ItemKind
emptyUnknownTile :: TileKind
emptyUIFactionGroupName :: GroupName FactionKind
emptyUIFaction :: FactionKind
instance GHC.Classes.Eq Game.LambdaHack.Common.Kind.COps
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Kind.COps

-- | Saving and restoring game state, used by both server and clients.
module Game.LambdaHack.Common.Save
type ChanSave a = MVar Maybe a
saveToChan :: ChanSave a -> a -> IO ()
wrapInSaves :: Binary a => COps -> (a -> FilePath) -> (ChanSave a -> IO ()) -> IO ()

-- | Restore a saved game, if it exists. Initialize directory structure and
--   copy over data files, if needed.
restoreGame :: Binary a => RuleContent -> ClientOptions -> FilePath -> IO (Maybe a)
compatibleVersion :: Version -> Version -> Bool
delayPrint :: Text -> IO ()
saveNameCli :: RuleContent -> FactionId -> String
saveNameSer :: RuleContent -> String
bkpAllSaves :: RuleContent -> ClientOptions -> IO Bool

-- | Repeatedly save serialized snapshots of current state.
--   
--   Running with -N2 ca reduce Max pause from 0.2s to
--   0.01s and bytes copied during GC 10-fold, but framerate nor
--   the frequency of not making a backup save are unaffected (at standard
--   backup settings), even with null frontend, because saving takes so few
--   resources. So, generally, backup save settings are relevant only due
--   to latency impact on very slow computers or in JS.
loopSave :: Binary a => COps -> (a -> FilePath) -> ChanSave a -> IO ()

-- | UI client options.
module Game.LambdaHack.Client.UI.UIOptionsParse

-- | Read and parse UI config file.
mkUIOptions :: RuleContent -> ClientOptions -> IO UIOptions

-- | Modify client options with UI options.
applyUIOptions :: COps -> UIOptions -> ClientOptions -> ClientOptions
configError :: String -> a
readError :: Read a => String -> a
parseConfig :: Config -> UIOptions

-- | Weapons, treasure and all the other items in the game.
module Game.LambdaHack.Common.Item

-- | Game items in actor possesion or strewn around the dungeon. The
--   information contained in this time is available to the player from the
--   moment the item is first seen and is never mutated.
--   
--   Some items are not created identified (IdentityCovered). Then
--   they are presented as having a template kind that is really not their
--   own, though usually close. Full kind information about item's kind is
--   available through the ItemKindIx index once the item is
--   identified and full information about the value of item's aspect
--   record is available elsewhere (both IdentityObvious and
--   IdentityCovered items may or may not need identification of
--   their aspect record).
data Item
Item :: ItemIdentity -> Maybe FactionId -> Flavour -> Item

-- | the kind of the item, or an indirection
[jkind] :: Item -> ItemIdentity

-- | the faction that created the item, if any
[jfid] :: Item -> Maybe FactionId

-- | flavour, always the real one, it's not hidden; people may not
--   recognize shape, but they remember colour and old vs fancy look
[jflavour] :: Item -> Flavour

-- | Either the explicit obvious kind of the item or the kind it's hidden
--   under, with the details covered under the index indirection.
data ItemIdentity
IdentityObvious :: ContentId ItemKind -> ItemIdentity
IdentityCovered :: ItemKindIx -> ContentId ItemKind -> ItemIdentity

-- | An index of the kind identifier of an item. Clients have partial
--   knowledge how these idexes map to kind ids. They gain knowledge by
--   identifying items. The indexes and kind identifiers are 1-1.
data ItemKindIx

-- | The secret part of the information about an item. If a faction knows
--   the aspect record of the item, this is the complete secret
--   information. Items that don't need second identification (the
--   kmConst flag is set) may be identified or not and both cases
--   are OK (their display flavour will differ and that may be the point).
data ItemDisco
ItemDiscoFull :: AspectRecord -> ItemDisco
ItemDiscoMean :: KindMean -> ItemDisco

-- | Full information about an item.
data ItemFull
ItemFull :: Item -> ContentId ItemKind -> ItemKind -> ItemDisco -> Bool -> ItemFull
[itemBase] :: ItemFull -> Item
[itemKindId] :: ItemFull -> ContentId ItemKind
[itemKind] :: ItemFull -> ItemKind
[itemDisco] :: ItemFull -> ItemDisco
[itemSuspect] :: ItemFull -> Bool
type ItemFullKit = (ItemFull, ItemQuant)

-- | The map of item kind indexes to item kind ids. The full map, as known
--   by the server, is 1-1. Because it's sparse and changes, we don't
--   represent it as an (unboxed) vector, until it becomes a bottleneck (if
--   ever, likely on JS, where only vectors are fast).
type DiscoveryKind = EnumMap ItemKindIx ContentId ItemKind

-- | The map of item ids to item aspect record. The full map is known by
--   the server.
type DiscoveryAspect = EnumMap ItemId AspectRecord

-- | The map of item kind indexes to identifiers of items that have that
--   kind. Used to update data about items when their kinds become known,
--   e.g., AI item use benefit data.
type ItemIxMap = EnumMap ItemKindIx EnumSet ItemId

-- | The fields are, in order: 1. whether the item should be kept in
--   equipment (not in stash) 2. the total benefit from picking the item up
--   (to use or to put in equipment) 3. the benefit of applying the item to
--   self 4. the (usually negative, for him) value of hitting a foe in
--   melee with it 5. the (usually negative, for him) value of flinging the
--   item at an opponent
data Benefit
Benefit :: Bool -> Double -> Double -> Double -> Double -> Benefit
[benInEqp] :: Benefit -> Bool
[benPickup] :: Benefit -> Double
[benApply] :: Benefit -> Double
[benMelee] :: Benefit -> Double
[benFling] :: Benefit -> Double
type DiscoveryBenefit = EnumMap ItemId Benefit

-- | The absolute level's local time at which an item's copy becomes
--   operational again. Even if item is not identified and so its timeout
--   unknown, it's enough to compare this to the local level time to learn
--   whether an item is recharged.
--   
--   This schema causes timeout jumps for items in stash, but timeout is
--   reset when items move, so this is a minor problem. Global time can't
--   be used even only for items in stash, or exploit would be possible
--   when an actor on a desolate level waits to recharge items for actors
--   on a busy level. It's probably impossible to avoid such exploits or,
--   otherwise, timeout jumps, particularly for faction where many actors
--   move on many levels and so an item in stash is not used by a single
--   actor at a time.
data ItemTimer
type ItemTimers = [ItemTimer]

-- | Number of items in a bag, together with recharging timer, in case of
--   items that need recharging, exists only temporarily or auto-activate
--   at regular intervals. Data invariant: the length of the timer should
--   be less or equal to the number of items.
type ItemQuant = (Int, ItemTimers)

-- | A bag of items, e.g., one of the stores of an actor or the items on a
--   particular floor position or embedded in a particular map tile.
type ItemBag = EnumMap ItemId ItemQuant

-- | All items in the dungeon (including those carried by actors), indexed
--   by item identifier.
type ItemDict = EnumMap ItemId Item
toItemKindIx :: Word16 -> ItemKindIx
quantSingle :: ItemQuant
itemToFull6 :: COps -> DiscoveryKind -> DiscoveryAspect -> ItemId -> Item -> ItemFull
aspectRecordFull :: ItemFull -> AspectRecord
strongestSlot :: DiscoveryBenefit -> EqpSlot -> [(ItemId, ItemFullKit)] -> [(Int, (ItemId, ItemFullKit))]
itemTimerZero :: ItemTimer
createItemTimer :: Time -> Delta Time -> ItemTimer
shiftItemTimer :: Delta Time -> ItemTimer -> ItemTimer
deltaOfItemTimer :: Time -> ItemTimer -> Delta Time
charging :: Time -> ItemTimer -> Bool
ncharges :: Time -> ItemQuant -> Int
hasCharge :: Time -> ItemQuant -> Bool
strongestMelee :: Bool -> Maybe DiscoveryBenefit -> Time -> [(ItemId, ItemFullKit)] -> [(Double, Bool, Int, Int, ItemId, ItemFullKit)]
unknownMeleeBonus :: [ItemFull] -> Bool
unknownSpeedBonus :: [ItemFull] -> Bool
conditionMeleeBonus :: [ItemFullKit] -> Int
conditionSpeedBonus :: [ItemFullKit] -> Int

-- | Damage calculation. The armor and hurt skills are additive. They can't
--   be multiplicative, because then 100% armor would minimize damage
--   regardless of even 200% hurt skill. However, additive skills make the
--   relative effectiveness of weapons dependent on the enemy, so even with
--   -100% hurt skill a kinetic weapon can't be removed from the list,
--   because an enemy may have negative armor skill. This is bad, but also
--   KISS.
armorHurtCalculation :: Bool -> Skills -> Skills -> Int
mergeItemQuant :: ItemQuant -> ItemQuant -> ItemQuant
listToolsToConsume :: [(ItemId, ItemFullKit)] -> [(ItemId, ItemFullKit)] -> [((CStore, Bool), (ItemId, ItemFullKit))]
subtractIidfromGrps :: (EnumMap CStore ItemBag, [(CStore, (ItemId, ItemFull))], [(Bool, Int, GroupName ItemKind)]) -> ((CStore, Bool), (ItemId, ItemFullKit)) -> (EnumMap CStore ItemBag, [(CStore, (ItemId, ItemFull))], [(Bool, Int, GroupName ItemKind)])
sortIids :: (ItemId -> ItemFull) -> [(ItemId, ItemQuant)] -> [(ItemId, ItemQuant)]
data TileAction
EmbedAction :: (ItemId, ItemQuant) -> TileAction
ToAction :: GroupName TileKind -> TileAction
WithAction :: [(Int, GroupName ItemKind)] -> GroupName TileKind -> TileAction
parseTileAction :: Bool -> Bool -> [(ItemKind, (ItemId, ItemQuant))] -> Feature -> Maybe TileAction
valueAtEqpSlot :: EqpSlot -> AspectRecord -> Int
unknownAspect :: (Aspect -> [Dice]) -> ItemFull -> Bool
countIidConsumed :: ItemFullKit -> [(Bool, Int, GroupName ItemKind)] -> (Int, Int, [(Bool, Int, GroupName ItemKind)])
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Item.Benefit
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Item.Item
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Item.ItemIdentity
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Item.ItemKindIx
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Item.ItemTimer
instance GHC.Internal.Enum.Enum Game.LambdaHack.Common.Item.ItemKindIx
instance GHC.Classes.Eq Game.LambdaHack.Common.Item.Item
instance GHC.Classes.Eq Game.LambdaHack.Common.Item.ItemDisco
instance GHC.Classes.Eq Game.LambdaHack.Common.Item.ItemIdentity
instance GHC.Classes.Eq Game.LambdaHack.Common.Item.ItemKindIx
instance GHC.Classes.Eq Game.LambdaHack.Common.Item.ItemTimer
instance GHC.Internal.Generics.Generic Game.LambdaHack.Common.Item.Benefit
instance GHC.Internal.Generics.Generic Game.LambdaHack.Common.Item.Item
instance GHC.Internal.Generics.Generic Game.LambdaHack.Common.Item.ItemIdentity
instance Data.Hashable.Class.Hashable Game.LambdaHack.Common.Item.ItemIdentity
instance Data.Hashable.Class.Hashable Game.LambdaHack.Common.Item.ItemKindIx
instance GHC.Internal.Ix.Ix Game.LambdaHack.Common.Item.ItemKindIx
instance GHC.Classes.Ord Game.LambdaHack.Common.Item.ItemDisco
instance GHC.Classes.Ord Game.LambdaHack.Common.Item.ItemKindIx
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Item.Benefit
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Item.Item
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Item.ItemDisco
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Item.ItemFull
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Item.ItemIdentity
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Item.ItemKindIx
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Item.ItemTimer
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Item.TileAction

-- | Possible causes of failure of request.
module Game.LambdaHack.Common.ReqFailure

-- | Possible causes of failure of request.
data ReqFailure
MoveUnskilled :: ReqFailure
MoveUnskilledAsleep :: ReqFailure
MoveNothing :: ReqFailure
MeleeUnskilled :: ReqFailure
MeleeSelf :: ReqFailure
MeleeDistant :: ReqFailure
MeleeNotWeapon :: ReqFailure
DisplaceUnskilled :: ReqFailure
DisplaceDistant :: ReqFailure
DisplaceAccess :: ReqFailure
DisplaceMultiple :: ReqFailure
DisplaceDying :: ReqFailure
DisplaceBraced :: ReqFailure
DisplaceImmobile :: ReqFailure
DisplaceSupported :: ReqFailure
AlterUnskilled :: ReqFailure
AlterUnwalked :: ReqFailure
AlterDistant :: ReqFailure
AlterBlockActor :: ReqFailure
AlterBlockItem :: ReqFailure
AlterNothing :: ReqFailure
CloseDistant :: ReqFailure
CloseClosed :: ReqFailure
CloseNothing :: ReqFailure
CloseNonClosable :: ReqFailure
WaitUnskilled :: ReqFailure
YellUnskilled :: ReqFailure
MoveItemUnskilled :: ReqFailure
EqpOverfull :: ReqFailure
EqpStackFull :: ReqFailure
ApplyUnskilled :: ReqFailure
ApplyFood :: ReqFailure
ApplyRead :: ReqFailure
ApplyPeriodic :: ReqFailure
ApplyOutOfReach :: ReqFailure
ApplyCharging :: ReqFailure
ApplyNoEffects :: ReqFailure
ItemNothing :: ReqFailure
ItemNotCalm :: ReqFailure
ItemOverStash :: ReqFailure
NotCalmPrecious :: ReqFailure
ProjectUnskilled :: ReqFailure
ProjectAimOnself :: ReqFailure
ProjectBlockTerrain :: ReqFailure
ProjectBlockActor :: ReqFailure
ProjectLobable :: ReqFailure
ProjectOutOfReach :: ReqFailure
ProjectFinderKeeper :: ReqFailure
NoChangeDunLeader :: ReqFailure
impossibleReqFailure :: ReqFailure -> Bool
showReqFailure :: ReqFailure -> Text
permittedPrecious :: Bool -> Bool -> ItemFull -> Either ReqFailure Bool
permittedProject :: Bool -> Int -> Bool -> ItemFull -> Either ReqFailure Bool
permittedProjectAI :: Int -> Bool -> ItemFull -> Bool
permittedApply :: RuleContent -> Time -> Int -> Bool -> Maybe CStore -> ItemFull -> ItemQuant -> Either ReqFailure Bool
instance GHC.Classes.Eq Game.LambdaHack.Common.ReqFailure.ReqFailure
instance GHC.Internal.Show.Show Game.LambdaHack.Common.ReqFailure.ReqFailure

-- | Inhabited dungeon levels and the operations to query and change them
--   as the game progresses.
module Game.LambdaHack.Common.Level

-- | The complete dungeon is a map from level identifiers to levels.
type Dungeon = EnumMap LevelId Level
dungeonBounds :: Dungeon -> (LevelId, LevelId)

-- | Levels in the current branch, one level up (or down) from the current.
ascendInBranch :: Dungeon -> Bool -> LevelId -> [LevelId]

-- | Compute the level identifier and stair position on the new level,
--   after a level change.
--   
--   We assume there is never a staircase up and down at the same position.
whereTo :: LevelId -> Point -> Bool -> Dungeon -> [(LevelId, Point)]

-- | Items located on map tiles.
type ItemFloor = EnumMap Point ItemBag

-- | Big actors located on map tiles.
type BigActorMap = EnumMap Point ActorId

-- | Collections of projectiles located on map tiles.
type ProjectileMap = EnumMap Point [ActorId]

-- | Tile kinds on the map.
type TileMap = Array ContentId TileKind

-- | Current smell on map tiles.
type SmellMap = EnumMap Point Time

-- | A view on single, inhabited dungeon level. Remembered fields
--   carry a subset of the info in the client copies of levels.
data Level
Level :: ContentId CaveKind -> AbsDepth -> ItemFloor -> ItemFloor -> BigActorMap -> ProjectileMap -> TileMap -> EntryMap -> Area -> SmellMap -> ([Point], [Point]) -> [Point] -> Int -> Int -> Time -> Bool -> Level

-- | the kind of cave the level is an instance of
[lkind] :: Level -> ContentId CaveKind

-- | absolute depth of the level
[ldepth] :: Level -> AbsDepth

-- | remembered items lying on the floor
[lfloor] :: Level -> ItemFloor

-- | remembered items embedded in the tile
[lembed] :: Level -> ItemFloor

-- | seen big (non-projectile) actors at positions on the level; could be
--   recomputed at resume, but small enough
[lbig] :: Level -> BigActorMap

-- | seen projectiles at positions on the level; could be recomputed at
--   resume
[lproj] :: Level -> ProjectileMap

-- | remembered level map
[ltile] :: Level -> TileMap

-- | room entrances on the level
[lentry] :: Level -> EntryMap

-- | area of the level
[larea] :: Level -> Area

-- | remembered smells on the level
[lsmell] :: Level -> SmellMap

-- | positions of (up, down) stairs
[lstair] :: Level -> ([Point], [Point])

-- | positions of IK.Escape tiles
[lescape] :: Level -> [Point]

-- | currently remembered clear tiles
[lseen] :: Level -> Int

-- | total number of explorable tiles
[lexpl] :: Level -> Int

-- | local time on the level (possibly frozen)
[ltime] :: Level -> Time

-- | whether the level is covered in darkness
[lnight] :: Level -> Bool
updateFloor :: (ItemFloor -> ItemFloor) -> Level -> Level
updateEmbed :: (ItemFloor -> ItemFloor) -> Level -> Level
updateBigMap :: (BigActorMap -> BigActorMap) -> Level -> Level
updateProjMap :: (ProjectileMap -> ProjectileMap) -> Level -> Level
updateTile :: (TileMap -> TileMap) -> Level -> Level
updateEntry :: (EntryMap -> EntryMap) -> Level -> Level
updateSmell :: (SmellMap -> SmellMap) -> Level -> Level

-- | Query for tile kinds on the map.
at :: Level -> Point -> ContentId TileKind
posToBigLvl :: Point -> Level -> Maybe ActorId
occupiedBigLvl :: Point -> Level -> Bool
posToProjsLvl :: Point -> Level -> [ActorId]
occupiedProjLvl :: Point -> Level -> Bool
posToAidsLvl :: Point -> Level -> [ActorId]

-- | Try to find a random position on the map satisfying conjunction of the
--   mandatory and an optional predicate. If the permitted number of
--   attempts is not enough, try again the same number of times without the
--   next optional predicate, and fall back to trying with only the
--   mandatory predicate.
findPosTry :: Int -> Level -> (Point -> ContentId TileKind -> Bool) -> [Point -> ContentId TileKind -> Bool] -> Rnd (Maybe Point)
findPosTry2 :: Int -> Level -> (Point -> ContentId TileKind -> Bool) -> [Point -> ContentId TileKind -> Bool] -> (Point -> ContentId TileKind -> Bool) -> [Point -> ContentId TileKind -> Bool] -> Rnd (Maybe Point)

-- | Generate a list of all passable points on (connected component of) the
--   level in the order of path distance from the starting position (BFS).
--   The starting position needn't be passable and is always included.
nearbyPassablePoints :: COps -> Level -> Point -> [Point]
nearbyFreePoints :: COps -> Level -> (ContentId TileKind -> Bool) -> Point -> [Point]
sortEmbeds :: COps -> ContentId TileKind -> [(ItemKind, (ItemId, ItemQuant))] -> [(ItemId, ItemQuant)]

-- | Entries of places on the map.
type EntryMap = EnumMap Point PlaceEntry
assertSparseItems :: ItemFloor -> ItemFloor
assertSparseProjectiles :: ProjectileMap -> ProjectileMap
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Level.Level
instance GHC.Classes.Eq Game.LambdaHack.Common.Level.Level
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Level.Level

-- | Actors in the game: heroes, monsters, etc.
module Game.LambdaHack.Common.Actor

-- | Actor attributes that are changing throughout the game. If they appear
--   to be dublets of aspects from actor kinds, e.g. HP, they may be
--   results of casting the dice specified in their respective actor kind
--   and/or may be modified temporarily, but return to the original value
--   from their respective kind over time.
--   
--   Other properties of an actor, in particular its current aspects, are
--   derived from the actor's trunk, organs and equipment. A class of the
--   aspects, the boolean ones, are called flags. Another class are skills.
--   Stats are a subclass that determines if particular actions are
--   permitted for the actor (or faction).
data Actor
Actor :: ItemId -> Maybe Int -> Int64 -> ResDelta -> Int64 -> ResDelta -> Point -> Maybe Point -> LevelId -> FactionId -> Maybe ([Vector], Speed) -> ItemBag -> ItemBag -> Int -> Int -> Watchfulness -> Bool -> Actor

-- | the trunk organ of the actor's body
[btrunk] :: Actor -> ItemId

-- | continued team character identity index number in this game
[bnumber] :: Actor -> Maybe Int

-- | current hit points * 1M
[bhp] :: Actor -> Int64

-- | HP delta this turn * 1M
[bhpDelta] :: Actor -> ResDelta

-- | current calm * 1M
[bcalm] :: Actor -> Int64

-- | calm delta this turn * 1M
[bcalmDelta] :: Actor -> ResDelta

-- | current position
[bpos] :: Actor -> Point

-- | previous position, if any
[boldpos] :: Actor -> Maybe Point

-- | current level
[blid] :: Actor -> LevelId

-- | faction the actor currently belongs to
[bfid] :: Actor -> FactionId

-- | trajectory the actor must travel and his travel speed
[btrajectory] :: Actor -> Maybe ([Vector], Speed)

-- | organs
[borgan] :: Actor -> ItemBag

-- | personal equipment
[beqp] :: Actor -> ItemBag

-- | number of weapons among eqp and organs
[bweapon] :: Actor -> Int

-- | number of benign items among weapons
[bweapBenign] :: Actor -> Int

-- | state of the actor's watchfulness
[bwatch] :: Actor -> Watchfulness

-- | is a projectile? affects being able to fly through other projectiles,
--   etc.
[bproj] :: Actor -> Bool

-- | Representation of recent changes to HP of Calm of an actor. This is
--   reset every time the actor perfoms an action, so this is aggregated
--   over actor turn (move), not time turn. The resource changes recorded
--   in the tuple are, respectively, negative and positive.
data ResDelta
ResDelta :: (Int64, Int64) -> (Int64, Int64) -> ResDelta

-- | resource change this move
[resCurrentTurn] :: ResDelta -> (Int64, Int64)

-- | resource change previous move
[resPreviousTurn] :: ResDelta -> (Int64, Int64)
type ActorMaxSkills = EnumMap ActorId Skills
data Watchfulness
WWatch :: Watchfulness
WWait :: Int -> Watchfulness
WSleep :: Watchfulness
WWake :: Watchfulness
deltasSerious :: ResDelta -> Bool
deltasSeriousThisTurn :: ResDelta -> Bool
deltasHears :: ResDelta -> Bool
deltaBenign :: ResDelta -> Bool
deltaWasBenign :: ResDelta -> Bool
actorCanMelee :: ActorMaxSkills -> ActorId -> Actor -> Bool
actorCanMeleeToHarm :: ActorMaxSkills -> ActorId -> Actor -> Bool
actorWorthChasing :: ActorMaxSkills -> ActorId -> Actor -> Bool
actorWorthKilling :: ActorMaxSkills -> ActorId -> Actor -> Bool

-- | The speed from organs and gear; being pushed is ignored.
gearSpeed :: Skills -> Speed
actorTemplate :: ItemId -> Maybe Int -> Int64 -> Int64 -> Point -> LevelId -> FactionId -> Bool -> Actor
actorWaits :: Actor -> Bool
actorWaitsOrSleeps :: Actor -> Bool

-- | Projectile that ran out of steam or collided with obstacle, dies. Even
--   if it pierced through an obstacle, but lost its payload while altering
--   the obstacle during piercing, it dies, too.
actorDying :: Actor -> Bool
hpTooLow :: Actor -> Skills -> Bool

-- | Check if actor calm enough to perform some actions.
--   
--   If max Calm is zero, always holds, to permit removing disastrous
--   equipped items, which would otherwise be stuck forever.
calmEnough :: Actor -> Skills -> Bool
calmFull :: Actor -> Skills -> Bool
hpFull :: Actor -> Skills -> Bool

-- | Has the skill and can wake up easily, so can sleep safely.
canSleep :: Skills -> Bool

-- | Can't loot, not too aggresive, so sometimes prefers to sleep instead
--   of exploring.
prefersSleep :: Skills -> Bool
checkAdjacent :: Actor -> Actor -> Bool
eqpOverfull :: Actor -> Int -> Bool
eqpFreeN :: Actor -> Int
getCarriedIidsAndTrunk :: Actor -> [ItemId]
getCarriedIidCStore :: Actor -> [(ItemId, CStore)]

-- | All actors on the level, indexed by actor identifier.
type ActorDict = EnumMap ActorId Actor

-- | Chance, in parts per million, that a new monster is generated. Depends
--   on the number of monsters already present, and on the level depth and
--   its cave kind.
--   
--   Note that sometimes monsters spawn in groups, increasing danger, but
--   many monsters are generated asleep, decreasing initial danger.
monsterGenChance :: AbsDepth -> AbsDepth -> Int -> Int -> Int

-- | How long until an actor's smell vanishes from a tile.
smellTimeout :: Delta Time
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Actor.Actor
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Actor.ResDelta
instance Data.Binary.Class.Binary Game.LambdaHack.Common.Actor.Watchfulness
instance GHC.Classes.Eq Game.LambdaHack.Common.Actor.Actor
instance GHC.Classes.Eq Game.LambdaHack.Common.Actor.ResDelta
instance GHC.Classes.Eq Game.LambdaHack.Common.Actor.Watchfulness
instance GHC.Internal.Generics.Generic Game.LambdaHack.Common.Actor.Actor
instance GHC.Internal.Generics.Generic Game.LambdaHack.Common.Actor.ResDelta
instance GHC.Internal.Generics.Generic Game.LambdaHack.Common.Actor.Watchfulness
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Actor.Actor
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Actor.ResDelta
instance GHC.Internal.Show.Show Game.LambdaHack.Common.Actor.Watchfulness

-- | The common, for server and clients, main game state type and its
--   operations.
module Game.LambdaHack.Common.State

-- | The main game state, the basic one, pertaining to a single game, not
--   to a single playing session or an intersection of both. This state
--   persists between playing sessions, until the particular game ends.
--   Anything that persists between games is stored in server state, client
--   state or client UI session state.
--   
--   Another differentiating property of this state is that it's kept
--   separately on the server and each of the clients (players, human or
--   AI) and separately updated, according to what each player can observe.
--   It's never updated directly, but always through atomic commands
--   (CmdAtomic) that are filtered and interpreted differently on
--   server and on each client. Therefore, the type is a view on the game
--   state, not the real game state, except on the server that alone stores
--   the full game information.
data State
sdungeon :: State -> Dungeon
stotalDepth :: State -> AbsDepth
sactorD :: State -> ActorDict
sitemD :: State -> ItemDict
sitemIxMap :: State -> ItemIxMap
sfactionD :: State -> FactionDict
stime :: State -> Time
scops :: State -> COps
sgold :: State -> Int
shigh :: State -> ScoreDict
sgameModeId :: State -> ContentId ModeKind
sdiscoKind :: State -> DiscoveryKind
sdiscoAspect :: State -> DiscoveryAspect
sactorMaxSkills :: State -> ActorMaxSkills

-- | Initial complete global game state.
defStateGlobal :: Dungeon -> AbsDepth -> FactionDict -> COps -> ScoreDict -> ContentId ModeKind -> DiscoveryKind -> State

-- | Initial empty state.
emptyState :: State

-- | Local state created by removing secret information from global state
--   components.
localFromGlobal :: State -> State

-- | Update dungeon data within state.
updateDungeon :: (Dungeon -> Dungeon) -> State -> State

-- | Update dungeon depth.
updateDepth :: (AbsDepth -> AbsDepth) -> State -> State

-- | Update the actor dictionary.
updateActorD :: (ActorDict -> ActorDict) -> State -> State

-- | Update the item dictionary.
updateItemD :: (ItemDict -> ItemDict) -> State -> State

-- | Update the item kind index map.
updateItemIxMap :: (ItemIxMap -> ItemIxMap) -> State -> State

-- | Update faction data within state.
updateFactionD :: (FactionDict -> FactionDict) -> State -> State

-- | Update global time within state.
updateTime :: (Time -> Time) -> State -> State

-- | Update content data within state and recompute the cached data.
updateCOpsAndCachedData :: (COps -> COps) -> State -> State

-- | Update total gold value in the dungeon.
updateGold :: (Int -> Int) -> State -> State
updateDiscoKind :: (DiscoveryKind -> DiscoveryKind) -> State -> State
updateDiscoAspect :: (DiscoveryAspect -> DiscoveryAspect) -> State -> State
updateActorMaxSkills :: (ActorMaxSkills -> ActorMaxSkills) -> State -> State
getItemBody :: ItemId -> State -> Item
aspectRecordFromItem :: ItemId -> Item -> State -> AspectRecord
aspectRecordFromIid :: ItemId -> State -> AspectRecord
maxSkillsFromActor :: Actor -> State -> Skills
maxSkillsInDungeon :: State -> ActorMaxSkills
unknownLevel :: COps -> ContentId CaveKind -> AbsDepth -> Area -> ([Point], [Point]) -> [Point] -> Int -> Bool -> Level

-- | Create a map full of unknown tiles.
--   
--   
--   >>> unknownTileMap (fromJust (toArea (0,0,0,0))) TK.unknownId 2 2
--   PointArray.Array with size (2,2)
--   
unknownTileMap :: Area -> ContentId TileKind -> X -> Y -> TileMap
instance Data.Binary.Class.Binary Game.LambdaHack.Common.State.State
instance GHC.Classes.Eq Game.LambdaHack.Common.State.State
instance GHC.Internal.Show.Show Game.LambdaHack.Common.State.State

-- | Operations on the Actor type, and related, that need the
--   State type, but not our custom monad types.
module Game.LambdaHack.Common.ActorState
fidActorNotProjGlobalAssocs :: FactionId -> State -> [(ActorId, Actor)]
actorAssocs :: (FactionId -> Bool) -> LevelId -> State -> [(ActorId, Actor)]
fidActorRegularAssocs :: FactionId -> LevelId -> State -> [(ActorId, Actor)]
fidActorRegularIds :: FactionId -> LevelId -> State -> [ActorId]
foeRegularAssocs :: FactionId -> LevelId -> State -> [(ActorId, Actor)]
foeRegularList :: FactionId -> LevelId -> State -> [Actor]
friendRegularAssocs :: FactionId -> LevelId -> State -> [(ActorId, Actor)]
friendRegularList :: FactionId -> LevelId -> State -> [Actor]
bagAssocs :: State -> ItemBag -> [(ItemId, Item)]
bagAssocsK :: State -> ItemBag -> [(ItemId, (Item, ItemQuant))]
posToBig :: Point -> LevelId -> State -> Maybe ActorId
posToBigAssoc :: Point -> LevelId -> State -> Maybe (ActorId, Actor)
posToProjs :: Point -> LevelId -> State -> [ActorId]
posToProjAssocs :: Point -> LevelId -> State -> [(ActorId, Actor)]
posToAids :: Point -> LevelId -> State -> [ActorId]
posToAidAssocs :: Point -> LevelId -> State -> [(ActorId, Actor)]

-- | Calculate loot's worth for a given faction.
calculateTotal :: FactionId -> State -> (ItemBag, Int)

-- | Price an item, taking count into consideration.
itemPrice :: Int -> ItemKind -> Int
findIid :: ActorId -> FactionId -> ItemId -> State -> [(ActorId, (Actor, CStore))]
combinedItems :: FactionId -> State -> ItemBag
getActorBody :: ActorId -> State -> Actor
getActorMaxSkills :: ActorId -> State -> Skills
actorCurrentSkills :: Maybe ActorId -> ActorId -> State -> Skills
canTraverse :: ActorId -> State -> Bool
getCarriedAssocsAndTrunk :: Actor -> State -> [(ItemId, Item)]
getContainerBag :: Container -> State -> ItemBag
getFloorBag :: LevelId -> Point -> State -> ItemBag
getEmbedBag :: LevelId -> Point -> State -> ItemBag
getBodyStoreBag :: Actor -> CStore -> State -> ItemBag
getFactionStashBag :: FactionId -> State -> ItemBag
mapActorItems_ :: Monad m => (CStore -> ItemId -> ItemQuant -> m ()) -> Actor -> State -> m ()
getActorAssocs :: ActorId -> CStore -> State -> [(ItemId, (Item, ItemQuant))]

-- | Checks if the actor is present on the current level. The order of
--   argument here and in other functions is set to allow
--   
--   
--   b <- getsState (memActor a)
--   
memActor :: ActorId -> LevelId -> State -> Bool

-- | Get current time from the dungeon data.
getLocalTime :: LevelId -> State -> Time
regenCalmDelta :: ActorId -> Actor -> State -> Int64
actorInAmbient :: Actor -> State -> Bool
dispEnemy :: ActorId -> ActorId -> Skills -> State -> Bool
itemToFull :: ItemId -> State -> ItemFull
fullAssocs :: ActorId -> [CStore] -> State -> [(ItemId, ItemFull)]
kitAssocs :: ActorId -> [CStore] -> State -> [(ItemId, ItemFullKit)]
getItemKindId :: Item -> State -> ContentId ItemKind
getIidKindId :: ItemId -> State -> ContentId ItemKind
getItemKind :: Item -> State -> ItemKind
getIidKind :: ItemId -> State -> ItemKind
getItemKindIdServer :: Item -> State -> ContentId ItemKind
getIidKindIdServer :: ItemId -> State -> ContentId ItemKind
getItemKindServer :: Item -> State -> ItemKind
getIidKindServer :: ItemId -> State -> ItemKind
tileAlterable :: LevelId -> Point -> State -> Bool

-- | Determine the dungeon level of the container. If the item is in the
--   shared stash, the level depends on which actor asks, not where the
--   stash is located physically.
lidFromC :: Container -> State -> LevelId
posFromC :: Container -> State -> Point

-- | Require that any non-dying foe is adjacent. We include even
--   projectiles that explode when stricken down, because they can be
--   caught and then they don't explode, so it makes sense to focus on
--   handling them. If there are many projectiles in a single adjacent
--   position, we only test the first one, the one that would be hit in
--   melee (this is not optimal if the actor would need to flee instead of
--   meleeing, but fleeing with *many* projectiles adjacent is a possible
--   waste of a move anyway).
anyFoeAdj :: ActorId -> State -> Bool
anyHarmfulFoeAdj :: ActorMaxSkills -> ActorId -> State -> Bool
adjacentBigAssocs :: Actor -> State -> [(ActorId, Actor)]
adjacentProjAssocs :: Actor -> State -> [(ActorId, Actor)]
armorHurtBonus :: ActorId -> ActorId -> State -> Int

-- | Check if any non-dying foe is adjacent to any of our normal actors and
--   either can harm them via melee or can attack from a distance.
--   Otherwise no point meleeing him. Projectiles are ignored, because they
--   are not actively attempted to melee, see meleeAny. This is
--   regardless of whether our actor can melee or just needs to flee, in
--   which case alert is needed so that he is not slowed down by others.
--   However, if our actor can't move nor melee, no real combat is taking
--   place. This is needed only by AI and computed as lazily as possible.
inMelee :: ActorMaxSkills -> FactionId -> LevelId -> State -> Bool

-- | Game state reading monad and basic operations.
module Game.LambdaHack.Common.MonadStateRead

-- | Monad for reading game state. A state monad with state modification
--   disallowed (another constraint is needed to permit that). The basic
--   server and client monads are like that, because server and clients
--   freely modify their internal session data, but don't modify the main
--   game state, except in very restricted and synchronized way.
class (Monad m, Functor m, Applicative m) => MonadStateRead (m :: Type -> Type)
getsState :: MonadStateRead m => (State -> a) -> m a
getState :: MonadStateRead m => m State
getLevel :: MonadStateRead m => LevelId -> m Level
getGameMode :: MonadStateRead m => m ModeKind
isNoConfirmsGame :: MonadStateRead m => m Bool
getEntryArena :: MonadStateRead m => Faction -> m LevelId
pickWeaponM :: MonadStateRead m => Bool -> Maybe DiscoveryBenefit -> [(ItemId, ItemFullKit)] -> Skills -> ActorId -> m [(Double, Bool, Int, Int, ItemId, ItemFullKit)]
displayTaunt :: MonadStateRead m => Bool -> (Rnd (Text, Text) -> m (Text, Text)) -> ActorId -> m (Text, Text)

-- | Description of effects.
module Game.LambdaHack.Client.UI.EffectDescription
data DetailLevel
DetailLow :: DetailLevel
DetailMedium :: DetailLevel
DetailHigh :: DetailLevel
DetailAll :: DetailLevel
defaultDetailLevel :: DetailLevel

-- | Suffix to append to a basic content name if the content causes the
--   effect.
--   
--   We show absolute time in seconds, not moves, because actors
--   can have different speeds (and actions can potentially take different
--   time intervals). We call the time taken by one player move, when
--   walking, a move. Turn and clip are used
--   mostly internally, the former as an absolute time unit. We show
--   distances in steps, because one step, from a tile to another
--   tile, is always 1 meter. We don't call steps tiles, reserving
--   that term for the context of terrain kinds or units of area.
effectToSuffix :: DetailLevel -> Effect -> Text
detectToObject :: DetectKind -> Text
detectToVerb :: DetectKind -> Text
skillName :: Skill -> Text
skillDesc :: Skill -> Text
skillToDecorator :: Skill -> Actor -> Int -> Text
skillsInDisplayOrder :: [Skill]
kindAspectToSuffix :: Aspect -> Text
aspectToSentence :: Aspect -> Maybe Text
affixDice :: Dice -> Text
describeToolsAlternative :: [[(Int, GroupName ItemKind)]] -> Text
describeCrafting :: [(Int, GroupName ItemKind)] -> [(Int, GroupName ItemKind)] -> Effect -> (Text, Text, Text)
wrapInParens :: Text -> Text
conditionToObject :: Condition -> Text
activationFlagToObject :: ActivationFlag -> Text
slotToSentence :: EqpSlot -> Text
tmodToSuff :: Text -> ThrowMod -> Text
affixBonus :: Int -> Text
wrapInChevrons :: Text -> Text
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.EffectDescription.DetailLevel
instance GHC.Internal.Enum.Bounded Game.LambdaHack.Client.UI.EffectDescription.DetailLevel
instance GHC.Internal.Enum.Enum Game.LambdaHack.Client.UI.EffectDescription.DetailLevel
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.EffectDescription.DetailLevel
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.UI.EffectDescription.DetailLevel
instance GHC.Classes.Ord Game.LambdaHack.Client.UI.EffectDescription.DetailLevel
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.EffectDescription.DetailLevel

-- | UI aspects of actors.
module Game.LambdaHack.Client.UI.ActorUI
data ActorUI
ActorUI :: Char -> Text -> Text -> Color -> ActorUI

-- | individual map symbol
[bsymbol] :: ActorUI -> Char

-- | individual name
[bname] :: ActorUI -> Text

-- | individual pronoun
[bpronoun] :: ActorUI -> Text

-- | individual map color
[bcolor] :: ActorUI -> Color
type ActorDictUI = EnumMap ActorId ActorUI
keySelected :: (ActorId, Actor, ActorUI) -> (Bool, Bool, Bool, Char, Color, ActorId)

-- | The part of speech describing the actor.
partActor :: ActorUI -> Part

-- | The part of speech containing the actor's pronoun.
partPronoun :: ActorUI -> Part
tryFindActor :: State -> (ActorId -> Actor -> Bool) -> Maybe (ActorId, Actor)
tryFindHeroK :: ActorDictUI -> FactionId -> Int -> State -> Maybe (ActorId, Actor)
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.ActorUI.ActorUI
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.ActorUI.ActorUI
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.UI.ActorUI.ActorUI
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.ActorUI.ActorUI

-- | Client-specific game state components.
module Game.LambdaHack.Client.State

-- | Client state, belonging to a single faction.
data StateClient
StateClient :: Int -> EnumMap ActorId TgtAndPath -> EnumMap ActorId (Point, Time) -> EnumSet LevelId -> EnumMap ActorId BfsAndPath -> () -> DiscoveryBenefit -> PerLid -> AlterLid -> SMGen -> Maybe ActorId -> FactionId -> Bool -> EnumSet LevelId -> ClientOptions -> (PrimArray PointI, PrimArray PointI) -> Challenge -> Challenge -> Int -> StateClient

-- | a parameter of the aiming digital line
[seps] :: StateClient -> Int

-- | targets of our actors in the dungeon; this is only useful for AI and
--   for directing non-pointmen, in particular with following doctrines,
--   where non-pointmen go to the pointman's target
[stargetD] :: StateClient -> EnumMap ActorId TgtAndPath

-- | the position and time of last fleeing attempt (regardless if
--   succeeded)
[sfleeD] :: StateClient -> EnumMap ActorId (Point, Time)

-- | the set of fully explored levels
[sexplored] :: StateClient -> EnumSet LevelId

-- | pathfinding data for our actors
[sbfsD] :: StateClient -> EnumMap ActorId BfsAndPath
[sundo] :: StateClient -> ()

-- | remembered AI benefits of items; could be recomputed at resume, but
--   they are costly to generate and not too large
[sdiscoBenefit] :: StateClient -> DiscoveryBenefit

-- | faction perception indexed by level
[sfper] :: StateClient -> PerLid

-- | cached alter skill data for positions (actually,
--   Tile.alterMinWalk instead)
[salter] :: StateClient -> AlterLid

-- | current random generator
[srandom] :: StateClient -> SMGen

-- | candidate new leader of the faction; Faction.gleader is the old leader
[_sleader] :: StateClient -> Maybe ActorId

-- | faction controlled by the client
[_sside] :: StateClient -> FactionId

-- | exit the game loop
[squit] :: StateClient -> Bool

-- | whether we are in melee, per level
[scondInMelee] :: StateClient -> EnumSet LevelId

-- | client options
[soptions] :: StateClient -> ClientOptions

-- | Instead of a BFS queue (list) we use these two arrays, for (JS) speed.
--   They need to be per-client distinct, because sometimes multiple
--   clients interleave BFS computation.
[stabs] :: StateClient -> (PrimArray PointI, PrimArray PointI)

-- | current game challenge setup
[scurChal] :: StateClient -> Challenge

-- | next game challenge setup
[snxtChal] :: StateClient -> Challenge

-- | whether to mark suspect features
[smarkSuspect] :: StateClient -> Int
type AlterLid = EnumMap LevelId Array Word8

-- | Pathfinding distances to all reachable positions of an actor and a
--   shortest paths to some of the positions.
data BfsAndPath
BfsInvalid :: BfsAndPath
BfsAndPath :: Array BfsDistance -> EnumMap Point AndPath -> BfsAndPath

-- | Actor's target and a path to it, if any.
data TgtAndPath
TgtAndPath :: Target -> Maybe AndPath -> TgtAndPath
[tapTgt] :: TgtAndPath -> Target
[tapPath] :: TgtAndPath -> Maybe AndPath

-- | The type of na actor target.
data Target

-- | target an enemy
TEnemy :: ActorId -> Target

-- | target a friend or neutral
TNonEnemy :: ActorId -> Target

-- | target a concrete spot
TPoint :: TGoal -> LevelId -> Point -> Target

-- | target position relative to actor
TVector :: Vector -> Target

-- | The goal of an actor.
data TGoal

-- | shared inventory stash of our or an enemy faction
TStash :: FactionId -> TGoal

-- | last seen position of the targeted actor
TEnemyPos :: ActorId -> TGoal

-- | embedded item that can be triggered; in TPoint (TEmbed bag p) _
--   q usually bag is embbedded in p and q
--   is an adjacent open tile
TEmbed :: ItemBag -> Point -> TGoal

-- | item lying on the ground
TItem :: ItemBag -> TGoal

-- | smell potentially left by enemies
TSmell :: TGoal

-- | a blocking tile to be approached (and, e.g., revealed to be walkable
--   or altered or searched)
TBlock :: TGoal

-- | an unknown tile to be explored
TUnknown :: TGoal

-- | a known tile to be patrolled
TKnown :: TGoal

-- | a hideout to either flee to or find a hidden enemy sniper in
THideout :: TGoal

-- | Initial empty game client state.
emptyStateClient :: FactionId -> StateClient

-- | Cycle the smarkSuspect setting.
cycleMarkSuspect :: Int -> StateClient -> StateClient

-- | Update target parameters within client state.
updateTarget :: ActorId -> (Maybe Target -> Maybe Target) -> StateClient -> StateClient

-- | Get target parameters from client state.
getTarget :: ActorId -> StateClient -> Maybe Target

-- | Update picked leader within state. Verify actor's faction.
updateLeader :: ActorId -> State -> StateClient -> StateClient
sside :: StateClient -> FactionId
sleader :: StateClient -> Maybe ActorId
instance Data.Binary.Class.Binary Game.LambdaHack.Client.State.StateClient
instance Data.Binary.Class.Binary Game.LambdaHack.Client.State.TGoal
instance Data.Binary.Class.Binary Game.LambdaHack.Client.State.Target
instance Data.Binary.Class.Binary Game.LambdaHack.Client.State.TgtAndPath
instance GHC.Classes.Eq Game.LambdaHack.Client.State.TGoal
instance GHC.Classes.Eq Game.LambdaHack.Client.State.Target
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.State.TGoal
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.State.Target
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.State.TgtAndPath
instance GHC.Internal.Show.Show Game.LambdaHack.Client.State.BfsAndPath
instance GHC.Internal.Show.Show Game.LambdaHack.Client.State.TGoal
instance GHC.Internal.Show.Show Game.LambdaHack.Client.State.Target
instance GHC.Internal.Show.Show Game.LambdaHack.Client.State.TgtAndPath

-- | The client UI session state.
module Game.LambdaHack.Client.UI.SessionUI

-- | The information that is used across a human player playing session,
--   including many consecutive games in a single session, including
--   playing different teams. Some of it is saved, some is reset when a new
--   playing session starts. Nothing is tied to a faction/team, but instead
--   all to UI configuration and UI input and display history. An important
--   component is the frontend session.
data SessionUI
SessionUI :: Maybe RequestUI -> ReqDelay -> Bool -> Bool -> Maybe Target -> Maybe Target -> ActorDictUI -> ItemDictUI -> ItemRoles -> Maybe (CStore, CStore) -> ChanFrontend -> CCUI -> UIOptions -> Maybe AimMode -> Bool -> Maybe (ItemId, CStore, Bool) -> EnumSet ActorId -> Maybe RunParams -> History -> EnumMap (ContentId ModeKind) (Map Challenge Int) -> EnumSet (ContentId ModeKind) -> EnumSet (ContentId ModeKind) -> PointUI -> Bool -> KeyMacroFrame -> [KeyMacroFrame] -> EnumSet ActorId -> Int -> Bool -> Int -> Bool -> Int -> Bool -> Bool -> Maybe Bool -> Set Msg -> Bool -> Map String Int -> ChosenLore -> Bool -> Bool -> Bool -> POSIXTime -> POSIXTime -> Time -> Int -> Int -> SMGen -> SessionUI

-- | request created by a UI query but not yet sent to the server
[sreqPending] :: SessionUI -> Maybe RequestUI

-- | server delayed sending query to client or receiving request from
--   client
[sreqDelay] :: SessionUI -> ReqDelay

-- | player is now queried for a command
[sreqQueried] :: SessionUI -> Bool

-- | player requested to regain control from AI ASAP
[sregainControl] :: SessionUI -> Bool

-- | the common xhair
[sxhair] :: SessionUI -> Maybe Target

-- | xhair set for last GoTo
[sxhairGoTo] :: SessionUI -> Maybe Target

-- | assigned actor UI presentations
[sactorUI] :: SessionUI -> ActorDictUI

-- | assigned item first seen level
[sitemUI] :: SessionUI -> ItemDictUI

-- | assignment of roles to items
[sroles] :: SessionUI -> ItemRoles

-- | last item move stores
[slastItemMove] :: SessionUI -> Maybe (CStore, CStore)

-- | connection with the frontend
[schanF] :: SessionUI -> ChanFrontend

-- | UI client content
[sccui] :: SessionUI -> CCUI

-- | UI options as set by the player
[sUIOptions] :: SessionUI -> UIOptions

-- | aiming mode
[saimMode] :: SessionUI -> Maybe AimMode

-- | last mouse aiming not vacuus
[sxhairMoused] :: SessionUI -> Bool

-- | selected item, if any, it's store and whether to override suitability
--   check
[sitemSel] :: SessionUI -> Maybe (ItemId, CStore, Bool)

-- | the set of currently selected actors
[sselected] :: SessionUI -> EnumSet ActorId

-- | parameters of the current run, if any
[srunning] :: SessionUI -> Maybe RunParams

-- | history of messages
[shistory] :: SessionUI -> History

-- | the number of games won by the UI faction per game mode and per
--   difficulty level
[svictories] :: SessionUI -> EnumMap (ContentId ModeKind) (Map Challenge Int)

-- | camped games
[scampings] :: SessionUI -> EnumSet (ContentId ModeKind)

-- | restarted games
[srestarts] :: SessionUI -> EnumSet (ContentId ModeKind)

-- | mouse pointer position
[spointer] :: SessionUI -> PointUI

-- | whether to auto-clear prompts
[sautoYes] :: SessionUI -> Bool

-- | the head of the key macro stack
[smacroFrame] :: SessionUI -> KeyMacroFrame

-- | the tail of the key macro stack
[smacroStack] :: SessionUI -> [KeyMacroFrame]

-- | actors that just got out of sight
[slastLost] :: SessionUI -> EnumSet ActorId

-- | player just waited this many times
[swaitTimes] :: SessionUI -> Int

-- | the player just exited AI automation
[swasAutomated] :: SessionUI -> Bool

-- | mark leader and party FOV
[smarkVision] :: SessionUI -> Int

-- | mark smell, if the leader can smell
[smarkSmell] :: SessionUI -> Bool

-- | next game scenario number
[snxtScenario] :: SessionUI -> Int

-- | whether current game is a tutorial
[scurTutorial] :: SessionUI -> Bool

-- | whether next game is to be tutorial
[snxtTutorial] :: SessionUI -> Bool

-- | override display of tutorial hints
[soverrideTut] :: SessionUI -> Maybe Bool

-- | tutorial hints already shown this game
[susedHints] :: SessionUI -> Set Msg

-- | whether to mute all new messages
[smuteMessages] :: SessionUI -> Bool

-- | indices of last used menu items
[smenuIxMap] :: SessionUI -> Map String Int

-- | last lore chosen to display
[schosenLore] :: SessionUI -> ChosenLore

-- | current level needs displaying
[sdisplayNeeded] :: SessionUI -> Bool

-- | a frame was already displayed this turn
[sturnDisplayed] :: SessionUI -> Bool

-- | whether no visible report created last UI faction turn or the report
--   wiped out from screen since
[sreportNull] :: SessionUI -> Bool

-- | this session start time
[sstart] :: SessionUI -> POSIXTime

-- | this game start time
[sgstart] :: SessionUI -> POSIXTime

-- | clips from start of session to current game start
[sallTime] :: SessionUI -> Time

-- | this game current frame count
[snframes] :: SessionUI -> Int

-- | frame count from start of session to current game start
[sallNframes] :: SessionUI -> Int

-- | current random generator for UI
[srandomUI] :: SessionUI -> SMGen
data ReqDelay
ReqDelayNot :: ReqDelay
ReqDelayHandled :: ReqDelay
ReqDelayAlarm :: ReqDelay
type ItemDictUI = EnumMap ItemId LevelId

-- | A collection of item identifier sets indicating what roles (possibly
--   many) an item has assigned.
newtype ItemRoles
ItemRoles :: EnumMap SLore (EnumSet ItemId) -> ItemRoles

-- | Current aiming mode of a client.
data AimMode
AimMode :: LevelId -> DetailLevel -> AimMode
[aimLevelId] :: AimMode -> LevelId
[detailLevel] :: AimMode -> DetailLevel

-- | In-game macros. We record menu navigation keystrokes and keystrokes
--   bound to commands with one exception --- we exclude keys that invoke
--   the Record command, to avoid surprises. Keys are kept in the
--   same order in which they're meant to be replayed, i.e. the first
--   element of the list is replayed also as the first one.
newtype KeyMacro
KeyMacro :: [KM] -> KeyMacro
[unKeyMacro] :: KeyMacro -> [KM]

-- | Local macro buffer frame. Predefined macros have their own in-game
--   macro buffer, allowing them to record in-game macro, queue actions and
--   repeat the last macro's action. Running predefined macro pushes new
--   KeyMacroFrame onto the stack. We pop buffers from the stack
--   if locally there are no actions pending to be handled.
data KeyMacroFrame
KeyMacroFrame :: Either [KM] KeyMacro -> KeyMacro -> Maybe KM -> KeyMacroFrame

-- | record keystrokes in Left; repeat from Right
[keyMacroBuffer] :: KeyMacroFrame -> Either [KM] KeyMacro

-- | actions pending to be handled
[keyPending] :: KeyMacroFrame -> KeyMacro

-- | last pressed key
[keyLast] :: KeyMacroFrame -> Maybe KM

-- | Parameters of the current run.
data RunParams
RunParams :: ActorId -> [ActorId] -> Bool -> Maybe Text -> Int -> RunParams

-- | the original leader from run start
[runLeader] :: RunParams -> ActorId

-- | the list of actors that take part
[runMembers] :: RunParams -> [ActorId]

-- | initial run continuation by any run participant, including run leader
[runInitial] :: RunParams -> Bool

-- | message with the next stop reason
[runStopMsg] :: RunParams -> Maybe Text

-- | waiting for others to move out of the way
[runWaiting] :: RunParams -> Int

-- | Last lore being aimed at.
data ChosenLore
ChosenLore :: [(ActorId, Actor)] -> [(ItemId, ItemQuant)] -> ChosenLore
ChosenNothing :: ChosenLore
emptySessionUI :: UIOptions -> SessionUI
emptyMacroFrame :: KeyMacroFrame
cycleMarkVision :: Int -> SessionUI -> SessionUI
toggleMarkSmell :: SessionUI -> SessionUI
cycleOverrideTut :: Int -> SessionUI -> SessionUI
getActorUI :: ActorId -> SessionUI -> ActorUI
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.SessionUI.AimMode
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.SessionUI.ItemRoles
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.SessionUI.KeyMacro
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.SessionUI.RunParams
instance Data.Binary.Class.Binary Game.LambdaHack.Client.UI.SessionUI.SessionUI
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.SessionUI.AimMode
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.SessionUI.KeyMacro
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.SessionUI.ReqDelay
instance GHC.Internal.Generics.Generic Game.LambdaHack.Client.UI.SessionUI.AimMode
instance GHC.Internal.Base.Monoid Game.LambdaHack.Client.UI.SessionUI.KeyMacro
instance GHC.Internal.Base.Semigroup Game.LambdaHack.Client.UI.SessionUI.KeyMacro
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.SessionUI.AimMode
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.SessionUI.ItemRoles
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.SessionUI.KeyMacro
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.SessionUI.KeyMacroFrame
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.SessionUI.RunParams

-- | Basic client monad and related operations.
module Game.LambdaHack.Client.MonadClient

-- | Monad for reading client state.
class MonadStateRead m => MonadClientRead (m :: Type -> Type)
getsClient :: MonadClientRead m => (StateClient -> a) -> m a
liftIO :: MonadClientRead m => IO a -> m a

-- | Monad for writing to client state.
class MonadClientRead m => MonadClient (m :: Type -> Type)
modifyClient :: MonadClient m => (StateClient -> StateClient) -> m ()
getClient :: MonadClientRead m => m StateClient
putClient :: MonadClient m => StateClient -> m ()
debugPossiblyPrint :: MonadClient m => Text -> m ()
createTabBFS :: MonadClient m => m (PrimArray PointI)
dumpTextFile :: MonadClientRead m => Text -> FilePath -> m FilePath

-- | Invoke pseudo-random computation with the generator kept in the state.
rndToAction :: MonadClient m => Rnd a -> m a
condInMeleeM :: MonadClientRead m => LevelId -> m Bool
insertInMeleeM :: MonadClient m => LevelId -> m ()

-- | Common client monad operations.
module Game.LambdaHack.Client.CommonM

-- | Get the current perception of a client.
getPerFid :: MonadClientRead m => LevelId -> m Perception

-- | Calculate the position of an actor's target. This matches
--   pathGoal, but sometimes path is not defined.
aidTgtToPos :: Maybe ActorId -> LevelId -> Maybe Target -> State -> Maybe Point

-- | Counts the number of steps until the projectile would hit a
--   non-projectile actor or obstacle. Starts searching with the given eps
--   and returns the first found eps for which the number reaches the
--   distance between actor and target position, or Nothing if none can be
--   found. Treats unknown tiles as walkable, but prefers known.
makeLine :: Bool -> Actor -> Point -> Int -> COps -> Level -> Maybe Int
currentSkillsClient :: MonadClientRead m => ActorId -> m Skills
pickWeaponClient :: MonadClient m => ActorId -> ActorId -> m (Maybe RequestTimed)
updateSalter :: MonadClient m => LevelId -> [(Point, ContentId TileKind)] -> m ()
createSalter :: State -> AlterLid

-- | Client monad for interacting with a human through UI.
module Game.LambdaHack.Client.UI.MonadClientUI

-- | The monad that gives the client access to UI operations, but not to
--   modifying client state, except for the client-side pointman (as
--   opposed to pointman stores in faction data in main game state), which
--   is more of a UI concept, but is shared with AI to be able to keep it
--   when switching AI on/off and to save on typing.
class MonadClientRead m => MonadClientUI (m :: Type -> Type)
getsSession :: MonadClientUI m => (SessionUI -> a) -> m a
modifySession :: MonadClientUI m => (SessionUI -> SessionUI) -> m ()
updateClientLeader :: MonadClientUI m => ActorId -> m ()
getCacheBfs :: MonadClientUI m => ActorId -> m (Array BfsDistance)
getCachePath :: MonadClientUI m => ActorId -> Point -> m (Maybe AndPath)
clientPrintUI :: MonadClientUI m => Text -> m ()
debugPossiblyPrintUI :: MonadClientUI m => Text -> m ()
getSession :: MonadClientUI m => m SessionUI
putSession :: MonadClientUI m => SessionUI -> m ()

-- | Push frames or delays to the frame queue. The frames depict the
--   lid level.
displayFrames :: MonadClientUI m => LevelId -> PreFrames3 -> m ()

-- | Write FrontKey UI request to the frontend, read the reply, set
--   pointer, return key.
connFrontendFrontKey :: MonadClientUI m => [KM] -> PreFrame3 -> m KM
setFrontAutoYes :: MonadClientUI m => Bool -> m ()
frontendShutdown :: MonadClientUI m => m ()
printScreen :: MonadClientUI m => m ()

-- | Initialize the frontend chosen by the player via client options.
chanFrontend :: MonadClientUI m => ScreenContent -> ClientOptions -> m ChanFrontend
anyKeyPressed :: MonadClientUI m => m Bool
discardPressedKey :: MonadClientUI m => m ()
resetPressedKeys :: MonadClientUI m => m ()
revCmdMap :: MonadClientUI m => m (HumanCmd -> KM)
getReportUI :: MonadClientUI m => Bool -> m Report
getMiniHintAiming :: MonadClientUI m => m Text
computeChosenLore :: MonadClientUI m => m ([(ActorId, Actor)], [(ItemId, ItemQuant)])
getArenaUI :: MonadClientUI m => m LevelId
viewedLevelUI :: MonadClientUI m => m LevelId
mxhairToPos :: MonadClientUI m => m (Maybe Point)
xhairToPos :: MonadClientUI m => m Point
setXHairFromGUI :: MonadClientUI m => Maybe Target -> m ()
clearAimMode :: MonadClientUI m => m ()
getFontSetup :: MonadClientUI m => m FontSetup
scoreToSlideshow :: MonadClientUI m => Int -> Status -> m Slideshow
defaultHistory :: MonadClientUI m => m History
tellAllClipPS :: MonadClientUI m => m ()
tellGameClipPS :: MonadClientUI m => m ()
elapsedSessionTimeGT :: MonadClientRead m => POSIXTime -> Int -> m Bool
resetSessionStart :: MonadClientUI m => m ()
resetGameStart :: MonadClientUI m => m ()

-- | The part of speech describing the actor or the "you" pronoun if he is
--   the leader of the observer's faction.
partActorLeader :: MonadClientUI m => ActorId -> m Part

-- | The part of speech with the actor's pronoun or "you" if a leader of
--   the client's faction.
partPronounLeader :: MonadClientUI m => ActorId -> m Part

-- | Try to read saved client game state from the file system.
tryRestore :: MonadClientUI m => m (Maybe (StateClient, Maybe SessionUI))

-- | Invoke pseudo-random computation with the generator kept in the
--   session.
rndToActionUI :: MonadClientUI m => Rnd a -> m a
tryOpenBrowser :: MonadClientUI m => String -> m Bool

-- | Write a UI request to the frontend and read a corresponding reply.
connFrontend :: MonadClientUI m => FrontReq a -> m a
displayFrame :: MonadClientUI m => Maybe Frame -> m ()

-- | Running and disturbance.
--   
--   The general rule is: whatever is behind you (and so ignored
--   previously), determines what you ignore moving forward. This is
--   calcaulated separately for the tiles to the left, to the right and in
--   the middle along the running direction. So, if you want to ignore
--   something start running when you stand on it (or to the right or left,
--   respectively) or by entering it (or passing to the right or left,
--   respectively).
--   
--   Some things are never ignored, such as: enemies seen, imporant
--   messages heard, solid tiles and actors in the way.
module Game.LambdaHack.Client.UI.RunM

-- | Continue running in the given direction.
continueRun :: MonadClientUI m => LevelId -> RunParams -> m (Either Text RequestTimed)

-- | This function implements the actual logic of running. It checks if we
--   have to stop running because something interesting cropped up, it
--   ajusts the direction given by the vector if we reached a corridor's
--   corner (we never change direction except in corridors) and it
--   increments the counter of traversed tiles.
--   
--   Note that while goto-xhair commands ignore items on the way, here we
--   stop wnenever we touch an item. Running is more cautious to compensate
--   that the player cannot specify the end-point of running. It's also
--   more suited to open, already explored terrain. Goto-xhair works better
--   with unknown terrain, e.g., it stops whenever an item is spotted, but
--   then ignores the item, leaving it to the player to mark the item
--   position as a goal of the next goto.
continueRunDir :: MonadClientUI m => RunParams -> m (Either Text Vector)
walkableDir :: COps -> Level -> Point -> Vector -> Bool
tryTurning :: MonadClientRead m => ActorId -> m (Either Text Vector)
checkAndRun :: MonadClientRead m => ActorId -> Vector -> m (Either Text Vector)

-- | Monadic operations on game messages.
module Game.LambdaHack.Client.UI.MsgM

-- | Add a shared message to the current report. Say if it was a duplicate.
msgAddDuplicate :: (MonadClientUI m, MsgShared a) => a -> Text -> m Bool

-- | Add a message comprising of two different texts, one to show, the
--   other to save to messages log, to the current report.
msgAddDistinct :: MonadClientUI m => MsgClassDistinct -> (Text, Text) -> m ()

-- | Add a message to the current report.
msgAdd :: (MonadClientUI m, MsgShared a) => a -> Text -> m ()

-- | Add a message to the current report. End previously collected report,
--   if any, with newline.
msgLnAdd :: (MonadClientUI m, MsgShared a) => a -> Text -> m ()

-- | Add a prompt with basic keys description.
promptMainKeys :: MonadClientUI m => m ()

-- | Store new report in the history and archive old report.
recordHistory :: MonadClientUI m => m ()

-- | Add a tutorial hint message to the current report.
tutorialHintMsgAdd :: MonadClientUI m => TutorialHints -> m ()

-- | Breadth first search and related algorithms using the client monad.
module Game.LambdaHack.Client.BfsM
invalidateBfsAid :: MonadClient m => ActorId -> m ()
invalidateBfsPathAid :: MonadClient m => ActorId -> m ()
invalidateBfsLid :: MonadClient m => LevelId -> m ()
invalidateBfsPathLid :: MonadClient m => Actor -> m ()
invalidateBfsAll :: MonadClient m => m ()
invalidateBfsPathAll :: MonadClient m => m ()
createBfs :: MonadClientRead m => Bool -> Word8 -> ActorId -> m (Array BfsDistance)

-- | Get cached BFS array and path or, if not stored, generate and store
--   first.
getCacheBfsAndPath :: MonadClient m => ActorId -> Point -> m (Array BfsDistance, Maybe AndPath)

-- | Get cached BFS array or, if not stored, generate and store first.
getCacheBfs :: MonadClient m => ActorId -> m (Array BfsDistance)

-- | Get cached BFS path or, if not stored, generate and store first.
getCachePath :: MonadClient m => ActorId -> Point -> m (Maybe AndPath)
createPath :: MonadClient m => ActorId -> Target -> m TgtAndPath
condBFS :: MonadClientRead m => ActorId -> m (Bool, Word8)

-- | Furthest (wrt paths) known position.
furthestKnown :: MonadClient m => ActorId -> m Point

-- | Closest reachable unknown tile position, if any.
--   
--   Note: some of these tiles are behind suspect tiles and they are chosen
--   in preference to more distant directly accessible unknown tiles. This
--   is in principle OK, but in dungeons with few hidden doors AI is at a
--   disadvantage (and with many hidden doors, it fares as well as a human
--   that deduced the dungeon properties). Changing Bfs to accomodate all
--   dungeon styles would be complex and would slow down the engine.
--   
--   If the level has inaccessible open areas (at least from the stairs AI
--   used) the level will be nevertheless here finally labeled as explored,
--   to enable transition to other levels. We should generally avoid such
--   levels, because digging and/or trying to find other stairs leading to
--   disconnected areas is not KISS so we don't do this in AI, so AI is at
--   a disadvantage.
--   
--   If the closest unknown is more than 126 tiles away from the targeting
--   actor, the level will marked as explored. We could complicate the code
--   and not mark if the unknown is too far as opposed to inaccessible, but
--   then if it is both too distant and inaccessible, AI would be
--   permanently stuck on such levels. To cope with this, escapes need to
--   be placed on open or small levels, or in dispersed enough that they
--   don't appear in such potentially unexplored potions of caves. Other
--   than that, this is rather harmless and hard to exploit, so let it be.
--   The principled way to fix this would be to extend BFS to
--   Word16, but then it takes too long to compute on maze levels,
--   so we'd need to optimize hard for JS.
closestUnknown :: MonadClient m => ActorId -> m (Maybe Point)

-- | Finds smells closest to the actor, except under the actor, because
--   actors consume smell only moving over them, not standing. Of the
--   closest, prefers the newest smell.
closestSmell :: MonadClient m => ActorId -> m [(Int, (Point, Time))]
data FleeViaStairsOrEscape
ViaStairs :: FleeViaStairsOrEscape
ViaStairsUp :: FleeViaStairsOrEscape
ViaStairsDown :: FleeViaStairsOrEscape
ViaEscape :: FleeViaStairsOrEscape
ViaExit :: FleeViaStairsOrEscape
ViaNothing :: FleeViaStairsOrEscape
ViaAnything :: FleeViaStairsOrEscape
embedBenefit :: MonadClientRead m => FleeViaStairsOrEscape -> ActorId -> [(Point, ItemBag)] -> m [(Double, (Point, ItemBag))]

-- | Closest (wrt paths) AI-triggerable tiles with embedded items. In AI,
--   the level the actor is on is either explored or the actor already has
--   a weapon equipped, so no need to explore further, he tries to find
--   enemies on other levels, but before that, he triggers other tiles in
--   hope of some loot or beneficial effect to enter next level with.
closestTriggers :: MonadClient m => FleeViaStairsOrEscape -> ActorId -> m [(Int, (Point, (Point, ItemBag)))]

-- | Check whether the actor has enough gear to go look for enemies. We
--   assume weapons in equipment are better than any among organs or at
--   least provide some essential diversity. Disabled if, due to doctrine,
--   actors follow leader and so would repeatedly move towards and away
--   from stairs at leader change, depending on current leader's gear.
--   Number of items of a single kind is ignored, because variety is
--   needed.
condEnoughGearM :: MonadClientRead m => ActorId -> m Bool

-- | Closest (wrt paths) items.
closestItems :: MonadClient m => ActorId -> m [(Int, (Point, ItemBag))]

-- | Closest (wrt paths) enemy actors.
closestFoes :: MonadClient m => [(ActorId, Actor)] -> ActorId -> m [(Int, (ActorId, Actor))]

-- | Closest (wrt paths) enemy or our unguarded stash locations. If it's
--   ours, we want to guard it, it enemy, loot it. Neutral and friendly
--   stashes not chased to avoid loops of bloodless takeovers.
closestStashes :: MonadClient m => ActorId -> m [(Int, (FactionId, Point))]
oursExploringAssocs :: FactionId -> State -> [(ActorId, Actor)]

-- | Find the nearest walkable position in dark, if any. Deterministic, to
--   let all friends gather up and defend in the same shelter. Ignore
--   position underfoot.
closestHideout :: MonadClient m => ActorId -> m (Maybe (Point, Int))
unexploredDepth :: MonadClientRead m => Bool -> LevelId -> m Bool
updatePathFromBfs :: MonadClient m => Bool -> BfsAndPath -> ActorId -> Point -> m (Array BfsDistance, Maybe AndPath)
instance GHC.Classes.Eq Game.LambdaHack.Client.BfsM.FleeViaStairsOrEscape
instance GHC.Internal.Show.Show Game.LambdaHack.Client.BfsM.FleeViaStairsOrEscape

-- | Assorted conditions used later on in AI logic.
module Game.LambdaHack.Client.AI.ConditionM

-- | Require that a target enemy is visible by the party.
condAimEnemyTargetedM :: MonadClientRead m => ActorId -> m Bool

-- | Require that a target enemy or enemy stash is visible by the party.
condAimEnemyOrStashM :: MonadClientRead m => ActorId -> m Bool

-- | Require that a target enemy is remembered on the actor's level.
condAimEnemyOrRememberedM :: MonadClientRead m => ActorId -> m Bool

-- | Require that a target non-enemy is visible by the party.
condAimNonEnemyPresentM :: MonadClientRead m => ActorId -> m Bool

-- | Require that the target is crucial to success, e.g., an item, or that
--   it's not too far away and so the changes to get it are high.
condAimCrucialM :: MonadClientRead m => ActorId -> m Bool

-- | Check if the target is a nonmoving enemy.
condTgtNonmovingEnemyM :: MonadClientRead m => ActorId -> m Bool

-- | Require the actor stands on or adjacent to a triggerable tile (e.g.,
--   stairs).
condAdjTriggerableM :: MonadStateRead m => Skills -> ActorId -> m Bool

-- | Produce the chess-distance-sorted list of non-low-HP, melee-cabable
--   foes on the level. We don't consider path-distance, because we are
--   interested in how soon the foe can close in to hit us, which can
--   diverge greately from path distance for short distances, e.g., when
--   terrain gets revealed. We don't consider non-moving actors, because
--   they can't chase us and also because they can't be aggresive so to
--   resolve the stalemate, the opposing AI has to be aggresive by ignoring
--   them and closing in to melee distance.
meleeThreatDistList :: [(ActorId, Actor)] -> ActorId -> State -> [(Int, (ActorId, Actor))]

-- | Require the actor blocks the paths of any of his party members.
condBlocksFriendsM :: MonadClientRead m => ActorId -> m Bool

-- | Require the actor stands over a weapon that would be auto-equipped, if
--   only it was a desirable item (checked elsewhere).
condFloorWeaponM :: MonadStateRead m => ActorId -> m Bool

-- | Check whether the actor has no weapon in equipment.
condNoEqpWeaponM :: MonadStateRead m => ActorId -> m Bool

-- | Require that the actor can project any items.
condCanProjectM :: MonadClientRead m => Int -> ActorId -> m Bool
condProjectListM :: MonadClientRead m => Int -> ActorId -> m [(Double, CStore, ItemId, ItemFull, ItemQuant)]

-- | Produce the list of items from the given stores available to the actor
--   and the items' values.
benAvailableItems :: DiscoveryBenefit -> ActorId -> [CStore] -> State -> [(Benefit, CStore, ItemId, ItemFull, ItemQuant)]
hinders :: Bool -> Bool -> Skills -> ItemFull -> Bool

-- | Require that the actor stands over a desirable item.
condDesirableFloorItemM :: MonadClientRead m => ActorId -> m Bool

-- | Produce the list of items on the ground beneath the actor that are
--   worth picking up.
benGroundItems :: MonadClientRead m => ActorId -> m [(Benefit, CStore, ItemId, ItemFull, ItemQuant)]
desirableItem :: COps -> Bool -> Double -> AspectRecord -> ItemKind -> Int -> Bool
condSupport :: MonadClientRead m => [(ActorId, Actor)] -> Int -> ActorId -> m Bool
condAloneM :: MonadStateRead m => [(ActorId, Actor)] -> ActorId -> m Bool

-- | Require that the actor stands in the dark and so would be betrayed by
--   his own equipped light,
condShineWouldBetrayM :: MonadStateRead m => ActorId -> m Bool

-- | Produce a list of acceptable adjacent points to flee to.
fleeList :: MonadClientRead m => [(ActorId, Actor)] -> ActorId -> m ([(Int, Point)], [(Int, Point)])

-- | Let AI pick the best target for an actor.
module Game.LambdaHack.Client.AI.PickTargetM

-- | Verify and possibly change the target of an actor. This function both
--   updates the target in the client state and returns the new target
--   explicitly.
refreshTarget :: MonadClient m => [(ActorId, Actor)] -> [(ActorId, Actor)] -> (ActorId, Actor) -> m (Maybe TgtAndPath)
computeTarget :: MonadClient m => [(ActorId, Actor)] -> [(ActorId, Actor)] -> ActorId -> m (Maybe TgtAndPath)

-- | Picking the AI actor to move and refreshing leader and non-leader
--   targets.
module Game.LambdaHack.Client.AI.PickActorM

-- | Pick a new leader from among the actors on the current level. Refresh
--   the target of the new leader, even if unchanged.
pickActorToMove :: MonadClient m => [(ActorId, Actor)] -> [(ActorId, Actor)] -> Maybe ActorId -> m ActorId

-- | Inspect the doctrines of the actor and set his target according to it.
setTargetFromDoctrines :: MonadClient m => [(ActorId, Actor)] -> [(ActorId, Actor)] -> ActorId -> m ()

-- | AI procedure for picking the best action for an actor.
module Game.LambdaHack.Client.AI.PickActionM

-- | Pick the most desirable AI ation for the actor.
pickAction :: MonadClient m => [(ActorId, Actor)] -> [(ActorId, Actor)] -> ActorId -> Bool -> m RequestTimed
actionStrategy :: MonadClient m => [(ActorId, Actor)] -> [(ActorId, Actor)] -> LevelId -> ActorId -> Bool -> m (Strategy RequestTimed)
waitBlockNow :: MonadClientRead m => m (Strategy RequestTimed)
yellNow :: MonadClientRead m => m (Strategy RequestTimed)
pickup :: MonadClientRead m => ActorId -> Bool -> m (Strategy RequestTimed)
equipItems :: MonadClientRead m => ActorId -> m (Strategy RequestTimed)
yieldUnneeded :: MonadClientRead m => ActorId -> m (Strategy RequestTimed)
unEquipItems :: MonadClientRead m => ActorId -> m (Strategy RequestTimed)
groupByEqpSlot :: [(ItemId, ItemFullKit)] -> EnumMap EqpSlot [(ItemId, ItemFullKit)]
bestByEqpSlot :: DiscoveryBenefit -> [(ItemId, ItemFullKit)] -> [(ItemId, ItemFullKit)] -> [([(Int, (ItemId, ItemFullKit))], [(Int, (ItemId, ItemFullKit))])]
harmful :: DiscoveryBenefit -> ItemId -> Bool
meleeBlocker :: MonadClient m => Skills -> ActorId -> m (Strategy RequestTimed)
meleeAny :: MonadClient m => ActorId -> m (Strategy RequestTimed)
trigger :: MonadClientRead m => ActorId -> FleeViaStairsOrEscape -> m (Strategy RequestTimed)
projectItem :: MonadClientRead m => Skills -> ActorId -> m (Strategy RequestTimed)
data ApplyItemGroup
applyItem :: MonadClientRead m => Skills -> ActorId -> ApplyItemGroup -> m (Strategy RequestTimed)
flee :: MonadClient m => Skills -> ActorId -> Bool -> [(Int, Point)] -> m (Strategy RequestTimed)
displaceFoe :: MonadClientRead m => ActorId -> m (Strategy RequestTimed)
displaceBlocker :: MonadClientRead m => ActorId -> Bool -> m (Strategy RequestTimed)
displaceTgt :: MonadClientRead m => ActorId -> Point -> Bool -> m (Strategy RequestTimed)
chase :: MonadClientRead m => Skills -> ActorId -> Bool -> Bool -> m (Strategy RequestTimed)
moveTowards :: MonadClientRead m => Skills -> ActorId -> Bool -> Point -> Point -> Bool -> m (Strategy Vector)
moveOrRunAid :: MonadClientRead m => Skills -> ActorId -> Vector -> m (Maybe RequestTimed)
instance GHC.Classes.Eq Game.LambdaHack.Client.AI.PickActionM.ApplyItemGroup

-- | Ways for the client to use AI to produce server requests, based on the
--   client's view of the game state.
module Game.LambdaHack.Client.AI

-- | Handle the move of an actor under AI control (regardless if the whole
--   faction is under human or computer control).
queryAI :: MonadClient m => ActorId -> m RequestAI

-- | Pick an actor to move and an action for him to perform, given an
--   optional previous candidate actor and action and the server-proposed
--   actor.
pickActorAndAction :: MonadClient m => [(ActorId, Actor)] -> [(ActorId, Actor)] -> Maybe ActorId -> ActorId -> m (ActorId, RequestTimed, Maybe (Point, Time))

-- | The monad for writing to the main game state.
module Game.LambdaHack.Atomic.MonadStateWrite

-- | The monad for writing to the main game state. Atomic updates
--   (UpdAtomic) are given semantics in this monad.
class MonadStateRead m => MonadStateWrite (m :: Type -> Type)
modifyState :: MonadStateWrite m => (State -> State) -> m ()
putState :: MonadStateWrite m => State -> m ()

-- | Exception signifying that atomic action failed because the information
--   it carries is inconsistent with the client's state, (e.g., because the
--   client knows too little to understand the command or already deduced
--   the state change from earlier commands or is confused, amnesiac or
--   sees illusory actors or tiles). Whenever we know the failure is
--   logically impossible, we don't throw the AtomicFail
--   exception, but insert a normal assertion or error call, which
--   are never caught nor handled.
newtype AtomicFail
AtomicFail :: String -> AtomicFail
atomicFail :: String -> a
updateLevel :: MonadStateWrite m => LevelId -> (Level -> Level) -> m ()
updateActor :: MonadStateWrite m => ActorId -> (Actor -> Actor) -> m ()
updateFaction :: MonadStateWrite m => FactionId -> (Faction -> Faction) -> m ()
moveActorMap :: MonadStateWrite m => ActorId -> Actor -> Actor -> m ()
swapActorMap :: MonadStateWrite m => ActorId -> Actor -> ActorId -> Actor -> m ()
insertBagContainer :: MonadStateWrite m => ItemBag -> Container -> m ()
insertItemContainer :: MonadStateWrite m => ItemId -> ItemQuant -> Container -> m ()
insertItemActor :: MonadStateWrite m => ItemId -> ItemQuant -> ActorId -> CStore -> m ()
deleteBagContainer :: MonadStateWrite m => ItemBag -> Container -> m ()
deleteItemContainer :: MonadStateWrite m => ItemId -> ItemQuant -> Container -> m ()
deleteItemActor :: MonadStateWrite m => ItemId -> ItemQuant -> ActorId -> CStore -> m ()
itemsMatch :: Item -> Item -> Bool
addItemToActorMaxSkills :: MonadStateWrite m => ItemId -> Item -> Int -> ActorId -> m ()
resetActorMaxSkills :: MonadStateWrite m => m ()
insertItemFloor :: MonadStateWrite m => ItemId -> ItemQuant -> LevelId -> Point -> m ()
insertItemEmbed :: MonadStateWrite m => ItemId -> ItemQuant -> LevelId -> Point -> m ()
insertItemOrgan :: MonadStateWrite m => ItemId -> ItemQuant -> ActorId -> m ()
insertItemEqp :: MonadStateWrite m => ItemId -> ItemQuant -> ActorId -> m ()
insertItemStash :: MonadStateWrite m => ItemId -> ItemQuant -> FactionId -> m ()
deleteItemFloor :: MonadStateWrite m => ItemId -> ItemQuant -> LevelId -> Point -> m ()
deleteItemEmbed :: MonadStateWrite m => ItemId -> ItemQuant -> LevelId -> Point -> m ()
deleteItemOrgan :: MonadStateWrite m => ItemId -> ItemQuant -> ActorId -> m ()
deleteItemEqp :: MonadStateWrite m => ItemId -> ItemQuant -> ActorId -> m ()
deleteItemStash :: MonadStateWrite m => ItemId -> ItemQuant -> FactionId -> m ()
rmFromBag :: ItemQuant -> ItemId -> ItemBag -> ItemBag
instance GHC.Internal.Exception.Type.Exception Game.LambdaHack.Atomic.MonadStateWrite.AtomicFail
instance GHC.Internal.Show.Show Game.LambdaHack.Atomic.MonadStateWrite.AtomicFail

-- | A set of atomic commands shared by client and server. These are the
--   largest building blocks that have no components that can be observed
--   in isolation.
--   
--   We try to make atomic commands respect the laws of energy and mass
--   conservation, unless they really can't, e.g., monster spawning. For
--   example item removal from equipment, in isolation, is not an atomic
--   command, but item dropped from equipment to the ground is. This makes
--   it easier to undo the commands. In principle, the commands are the
--   only way to affect the basic game state (State).
--   
--   See
--   https://github.com/LambdaHack/LambdaHack/wiki/Client-server-architecture.
module Game.LambdaHack.Atomic.CmdAtomic

-- | Abstract syntax of atomic commands, that is, atomic game state
--   transformations.
data CmdAtomic

-- | atomic updates
UpdAtomic :: UpdAtomic -> CmdAtomic

-- | atomic special effects
SfxAtomic :: SfxAtomic -> CmdAtomic

-- | Abstract syntax of atomic updates, that is, atomic commands that
--   really change the State. Most of them are an encoding of a game
--   state diff, though they also carry some intentional hints that help
--   clients determine whether and how to communicate it to players.
data UpdAtomic
UpdRegisterItems :: [(ItemId, Item)] -> UpdAtomic
UpdCreateActor :: ActorId -> Actor -> [(ItemId, Item)] -> UpdAtomic
UpdDestroyActor :: ActorId -> Actor -> [(ItemId, Item)] -> UpdAtomic
UpdCreateItem :: Bool -> ItemId -> Item -> ItemQuant -> Container -> UpdAtomic
UpdDestroyItem :: Bool -> ItemId -> Item -> ItemQuant -> Container -> UpdAtomic
UpdSpotActor :: ActorId -> Actor -> UpdAtomic
UpdLoseActor :: ActorId -> Actor -> UpdAtomic
UpdSpotItem :: Bool -> ItemId -> ItemQuant -> Container -> UpdAtomic
UpdLoseItem :: Bool -> ItemId -> ItemQuant -> Container -> UpdAtomic
UpdSpotItemBag :: Bool -> Container -> ItemBag -> UpdAtomic
UpdLoseItemBag :: Bool -> Container -> ItemBag -> UpdAtomic
UpdMoveActor :: ActorId -> Point -> Point -> UpdAtomic
UpdWaitActor :: ActorId -> Watchfulness -> Watchfulness -> UpdAtomic
UpdDisplaceActor :: ActorId -> ActorId -> UpdAtomic
UpdMoveItem :: ItemId -> Int -> ActorId -> CStore -> CStore -> UpdAtomic
UpdRefillHP :: ActorId -> Int64 -> UpdAtomic
UpdRefillCalm :: ActorId -> Int64 -> UpdAtomic
UpdTrajectory :: ActorId -> Maybe ([Vector], Speed) -> Maybe ([Vector], Speed) -> UpdAtomic
UpdQuitFaction :: FactionId -> Maybe Status -> Maybe Status -> Maybe (FactionAnalytics, GenerationAnalytics) -> UpdAtomic
UpdSpotStashFaction :: Bool -> FactionId -> LevelId -> Point -> UpdAtomic
UpdLoseStashFaction :: Bool -> FactionId -> LevelId -> Point -> UpdAtomic
UpdLeadFaction :: FactionId -> Maybe ActorId -> Maybe ActorId -> UpdAtomic
UpdDiplFaction :: FactionId -> FactionId -> Diplomacy -> Diplomacy -> UpdAtomic
UpdDoctrineFaction :: FactionId -> Doctrine -> Doctrine -> UpdAtomic
UpdAutoFaction :: FactionId -> Bool -> UpdAtomic
UpdRecordKill :: ActorId -> ContentId ItemKind -> Int -> UpdAtomic
UpdAlterTile :: LevelId -> Point -> ContentId TileKind -> ContentId TileKind -> UpdAtomic
UpdAlterExplorable :: LevelId -> Int -> UpdAtomic
UpdAlterGold :: Int -> UpdAtomic
UpdSearchTile :: ActorId -> Point -> ContentId TileKind -> UpdAtomic
UpdHideTile :: ActorId -> Point -> ContentId TileKind -> UpdAtomic
UpdSpotTile :: LevelId -> [(Point, ContentId TileKind)] -> UpdAtomic
UpdLoseTile :: LevelId -> [(Point, ContentId TileKind)] -> UpdAtomic
UpdSpotEntry :: LevelId -> [(Point, PlaceEntry)] -> UpdAtomic
UpdLoseEntry :: LevelId -> [(Point, PlaceEntry)] -> UpdAtomic
UpdAlterSmell :: LevelId -> Point -> Time -> Time -> UpdAtomic
UpdSpotSmell :: LevelId -> [(Point, Time)] -> UpdAtomic
UpdLoseSmell :: LevelId -> [(Point, Time)] -> UpdAtomic
UpdTimeItem :: ItemId -> Container -> ItemTimers -> ItemTimers -> UpdAtomic
UpdAgeGame :: EnumSet LevelId -> UpdAtomic
UpdUnAgeGame :: EnumSet LevelId -> UpdAtomic
UpdDiscover :: Container -> ItemId -> ContentId ItemKind -> AspectRecord -> UpdAtomic
UpdCover :: Container -> ItemId -> ContentId ItemKind -> AspectRecord -> UpdAtomic
UpdDiscoverKind :: Container -> ItemKindIx -> ContentId ItemKind -> UpdAtomic
UpdCoverKind :: Container -> ItemKindIx -> ContentId ItemKind -> UpdAtomic
UpdDiscoverAspect :: Container -> ItemId -> AspectRecord -> UpdAtomic
UpdCoverAspect :: Container -> ItemId -> AspectRecord -> UpdAtomic
UpdDiscoverServer :: ItemId -> AspectRecord -> UpdAtomic
UpdCoverServer :: ItemId -> AspectRecord -> UpdAtomic
UpdPerception :: LevelId -> Perception -> Perception -> UpdAtomic
UpdRestart :: FactionId -> PerLid -> State -> Challenge -> ClientOptions -> SMGen -> UpdAtomic
UpdRestartServer :: State -> UpdAtomic
UpdResume :: FactionId -> PerLid -> UpdAtomic
UpdResumeServer :: State -> UpdAtomic
UpdKillExit :: FactionId -> UpdAtomic
UpdWriteSave :: UpdAtomic
UpdHearFid :: FactionId -> Maybe Int -> HearMsg -> UpdAtomic
UpdMuteMessages :: FactionId -> Bool -> UpdAtomic

-- | Symbolic representation of text messages about heard noises, sent by
--   server to clients and shown to players and used by AI.
data HearMsg
HearUpd :: UpdAtomic -> HearMsg
HearStrike :: ContentId ItemKind -> HearMsg
HearSummon :: Bool -> GroupName ItemKind -> Dice -> HearMsg
HearCollideTile :: HearMsg
HearTaunt :: Text -> HearMsg

-- | Abstract syntax of atomic special effects, that is, atomic commands
--   that only display special effects and don't change State nor
--   client state.
data SfxAtomic
SfxStrike :: ActorId -> ActorId -> ItemId -> SfxAtomic
SfxRecoil :: ActorId -> ActorId -> ItemId -> SfxAtomic
SfxSteal :: ActorId -> ActorId -> ItemId -> SfxAtomic
SfxRelease :: ActorId -> ActorId -> ItemId -> SfxAtomic
SfxProject :: ActorId -> ItemId -> SfxAtomic
SfxReceive :: ActorId -> ItemId -> SfxAtomic
SfxApply :: ActorId -> ItemId -> SfxAtomic
SfxCheck :: ActorId -> ItemId -> SfxAtomic
SfxTrigger :: ActorId -> LevelId -> Point -> ContentId TileKind -> SfxAtomic
SfxShun :: ActorId -> LevelId -> Point -> ContentId TileKind -> SfxAtomic
SfxEffect :: FactionId -> ActorId -> ItemId -> Effect -> Int64 -> SfxAtomic
SfxItemApplied :: Bool -> ItemId -> Container -> SfxAtomic
SfxMsgFid :: FactionId -> SfxMsg -> SfxAtomic
SfxRestart :: SfxAtomic
SfxCollideTile :: ActorId -> Point -> SfxAtomic
SfxTaunt :: Bool -> ActorId -> SfxAtomic

-- | Symbolic representation of text messages sent by server to clients and
--   shown to players.
data SfxMsg
SfxUnexpected :: ReqFailure -> SfxMsg
SfxExpected :: Text -> ReqFailure -> SfxMsg
SfxExpectedEmbed :: ItemId -> LevelId -> ReqFailure -> SfxMsg
SfxFizzles :: ItemId -> Container -> SfxMsg
SfxNothingHappens :: ItemId -> Container -> SfxMsg
SfxNoItemsForTile :: [[(Int, GroupName ItemKind)]] -> SfxMsg
SfxVoidDetection :: DetectKind -> SfxMsg
SfxUnimpressed :: ActorId -> SfxMsg
SfxSummonLackCalm :: ActorId -> SfxMsg
SfxSummonTooManyOwn :: ActorId -> SfxMsg
SfxSummonTooManyAll :: ActorId -> SfxMsg
SfxSummonFailure :: ActorId -> SfxMsg
SfxLevelNoMore :: SfxMsg
SfxLevelPushed :: SfxMsg
SfxBracedImmune :: ActorId -> SfxMsg
SfxEscapeImpossible :: SfxMsg
SfxStasisProtects :: SfxMsg
SfxWaterParalysisResisted :: SfxMsg
SfxTransImpossible :: SfxMsg
SfxIdentifyNothing :: SfxMsg
SfxPurposeNothing :: SfxMsg
SfxPurposeTooFew :: Int -> Int -> SfxMsg
SfxPurposeUnique :: SfxMsg
SfxPurposeNotCommon :: SfxMsg
SfxRerollNothing :: SfxMsg
SfxRerollNotRandom :: SfxMsg
SfxDupNothing :: SfxMsg
SfxDupUnique :: SfxMsg
SfxDupValuable :: SfxMsg
SfxColdFish :: SfxMsg
SfxReadyGoods :: SfxMsg
SfxTimerExtended :: ActorId -> ItemId -> CStore -> Delta Time -> SfxMsg
SfxCollideActor :: ActorId -> ActorId -> SfxMsg
SfxItemYield :: ItemId -> Int -> LevelId -> SfxMsg
undoUpdAtomic :: UpdAtomic -> Maybe UpdAtomic
undoSfxAtomic :: SfxAtomic -> SfxAtomic
undoCmdAtomic :: CmdAtomic -> Maybe CmdAtomic
instance GHC.Internal.Show.Show Game.LambdaHack.Atomic.CmdAtomic.CmdAtomic
instance GHC.Internal.Show.Show Game.LambdaHack.Atomic.CmdAtomic.HearMsg
instance GHC.Internal.Show.Show Game.LambdaHack.Atomic.CmdAtomic.SfxAtomic
instance GHC.Internal.Show.Show Game.LambdaHack.Atomic.CmdAtomic.SfxMsg
instance GHC.Internal.Show.Show Game.LambdaHack.Atomic.CmdAtomic.UpdAtomic

-- | Representation and computation of visiblity of atomic commands by
--   clients.
--   
--   See
--   https://github.com/LambdaHack/LambdaHack/wiki/Client-server-architecture.
module Game.LambdaHack.Atomic.PosAtomicRead

-- | The type representing visibility of atomic commands to factions, based
--   on the position of the command, etc. Note that the server sees and
--   smells all positions. Also note that hearing is not covered because it
--   gives very restricted information, so hearing doesn't equal seeing
--   (and we assume smelling actors get lots of data from smells).
data PosAtomic

-- | whomever sees all the positions, notices
PosSight :: LevelId -> [Point] -> PosAtomic

-- | observers and the faction notice
PosFidAndSight :: FactionId -> LevelId -> [Point] -> PosAtomic

-- | whomever smells all the positions, notices
PosSmell :: LevelId -> [Point] -> PosAtomic

-- | whomever sees all the positions, notices
PosSightLevels :: [(LevelId, Point)] -> PosAtomic

-- | only the faction notices, server doesn't
PosFid :: FactionId -> PosAtomic

-- | faction and server notices
PosFidAndSer :: FactionId -> PosAtomic

-- | only the server notices
PosSer :: PosAtomic

-- | everybody notices
PosAll :: PosAtomic

-- | never broadcasted, but sent manually
PosNone :: PosAtomic

-- | Produce the positions where the atomic update takes place or, more
--   generally, the conditions under which the update can be noticed by a
--   client.
--   
--   The goal of this mechanics is to ensure that atomic commands involving
--   some positions visible by a client convey similar information as the
--   client would get by directly observing the changes of the portion of
--   server state limited to the visible positions. Consequently, when the
--   visible commands are later applied to the client's state, the state
--   stays consistent --- in sync with the server state and correctly
--   limited by visiblity. There is some wiggle room both in what "in sync"
--   and "visible" means and how they propagate through time.
--   
--   E.g., UpdDisplaceActor in a black room between two enemy
--   actors, with only one actor carrying a 0-radius light would not be
--   distinguishable by looking at the state (or the screen) from
--   UpdMoveActor of the illuminated actor, hence such
--   UpdDisplaceActor should not be observable, but
--   UpdMoveActor in similar cotext would be (or the former should
--   be perceived as the latter). However, to simplify, we assign as strict
--   visibility requirements to UpdMoveActor as to
--   UpdDisplaceActor and fall back to UpdSpotActor
--   (which provides minimal information that does not contradict state) if
--   the visibility is lower.
posUpdAtomic :: MonadStateRead m => UpdAtomic -> m PosAtomic

-- | Produce the positions where the atomic special effect takes place.
posSfxAtomic :: MonadStateRead m => SfxAtomic -> m PosAtomic

-- | All items introduced by the atomic command, to be used in it.
iidUpdAtomic :: UpdAtomic -> [ItemId]

-- | All items introduced by the atomic special effect, to be used in it.
iidSfxAtomic :: SfxAtomic -> [ItemId]

-- | Decompose an atomic action that is outside a client's visiblity. The
--   decomposed actions give less information that the original command,
--   but some of them may fall within the visibility range of the client.
--   The original action may give more information than even the total sum
--   of all actions it's broken into. E.g., UpdMoveActor informs
--   about the continued existence of the actor between moves vs popping
--   out of existence and then back in.
--   
--   This is computed in server's State from before performing the
--   command.
breakUpdAtomic :: MonadStateRead m => UpdAtomic -> m [UpdAtomic]

-- | What is the main map level the PosAtomic refers to, if any.
lidOfPos :: PosAtomic -> Maybe LevelId

-- | Given the client, its perception and an atomic command, determine if
--   the client notices the command.
seenAtomicCli :: Bool -> FactionId -> PerLid -> PosAtomic -> Bool

-- | Determine whether the server would see a command that has the given
--   visibilty conditions.
seenAtomicSer :: PosAtomic -> Bool
pointsProjBody :: Actor -> [Point] -> PosAtomic
posProjBody :: Actor -> PosAtomic
singleAid :: MonadStateRead m => ActorId -> m PosAtomic
doubleAid :: MonadStateRead m => ActorId -> ActorId -> m PosAtomic
singleContainerStash :: MonadStateRead m => Container -> m PosAtomic
singleContainerActor :: MonadStateRead m => Container -> m PosAtomic
instance GHC.Classes.Eq Game.LambdaHack.Atomic.PosAtomicRead.PosAtomic
instance GHC.Internal.Show.Show Game.LambdaHack.Atomic.PosAtomicRead.PosAtomic

-- | Semantics of atomic commands shared by client and server.
--   
--   See
--   https://github.com/LambdaHack/LambdaHack/wiki/Client-server-architecture.
module Game.LambdaHack.Atomic.HandleAtomicWrite

-- | The game-state semantics of atomic game commands. There is no
--   corresponding definition for special effects (SfxAtomic),
--   because they don't modify State.
--   
--   For each of the commands, we are guaranteed that the client, the
--   command is addressed to, perceives all the positions the command
--   affects (as computed by posUpdAtomic). In the code for each
--   semantic function we additonally verify the client is aware of any
--   relevant items and/or actors and we throw the AtomicFail
--   exception if it's not. The server keeps copies of all clients' states
--   and, before sending a command to a client, applies it to the client's
--   state copy. If AtomicFail is signalled, the command is
--   ignored for that client. This enables simpler server code that
--   addresses commands to all clients that can see it, even though not all
--   are able to process it.
handleUpdAtomic :: MonadStateWrite m => UpdAtomic -> m ()
updRegisterItems :: MonadStateWrite m => [(ItemId, Item)] -> m ()
updCreateActor :: MonadStateWrite m => ActorId -> Actor -> [(ItemId, Item)] -> m ()
updDestroyActor :: MonadStateWrite m => ActorId -> Actor -> [(ItemId, Item)] -> m ()
updCreateItem :: MonadStateWrite m => ItemId -> Item -> ItemQuant -> Container -> m ()
updDestroyItem :: MonadStateWrite m => ItemId -> Item -> ItemQuant -> Container -> m ()
updSpotItemBag :: MonadStateWrite m => Container -> ItemBag -> m ()
updLoseItemBag :: MonadStateWrite m => Container -> ItemBag -> m ()
updMoveActor :: MonadStateWrite m => ActorId -> Point -> Point -> m ()
updWaitActor :: MonadStateWrite m => ActorId -> Watchfulness -> Watchfulness -> m ()
updDisplaceActor :: MonadStateWrite m => ActorId -> ActorId -> m ()
updMoveItem :: MonadStateWrite m => ItemId -> Int -> ActorId -> CStore -> CStore -> m ()
updRefillHP :: MonadStateWrite m => ActorId -> Int64 -> m ()
updRefillCalm :: MonadStateWrite m => ActorId -> Int64 -> m ()
updTrajectory :: MonadStateWrite m => ActorId -> Maybe ([Vector], Speed) -> Maybe ([Vector], Speed) -> m ()
updQuitFaction :: MonadStateWrite m => FactionId -> Maybe Status -> Maybe Status -> m ()
updSpotStashFaction :: MonadStateWrite m => FactionId -> LevelId -> Point -> m ()
updLoseStashFaction :: MonadStateWrite m => FactionId -> LevelId -> Point -> m ()
updLeadFaction :: MonadStateWrite m => FactionId -> Maybe ActorId -> Maybe ActorId -> m ()
updDiplFaction :: MonadStateWrite m => FactionId -> FactionId -> Diplomacy -> Diplomacy -> m ()
updDoctrineFaction :: MonadStateWrite m => FactionId -> Doctrine -> Doctrine -> m ()
updAutoFaction :: MonadStateWrite m => FactionId -> Bool -> m ()
updRecordKill :: MonadStateWrite m => ActorId -> ContentId ItemKind -> Int -> m ()
updAlterTile :: MonadStateWrite m => LevelId -> Point -> ContentId TileKind -> ContentId TileKind -> m ()
updAlterExplorable :: MonadStateWrite m => LevelId -> Int -> m ()
updSearchTile :: MonadStateWrite m => ActorId -> Point -> ContentId TileKind -> m ()
updSpotTile :: MonadStateWrite m => LevelId -> [(Point, ContentId TileKind)] -> m ()
updLoseTile :: MonadStateWrite m => LevelId -> [(Point, ContentId TileKind)] -> m ()
updAlterSmell :: MonadStateWrite m => LevelId -> Point -> Time -> Time -> m ()
updSpotSmell :: MonadStateWrite m => LevelId -> [(Point, Time)] -> m ()
updLoseSmell :: MonadStateWrite m => LevelId -> [(Point, Time)] -> m ()
updTimeItem :: MonadStateWrite m => ItemId -> Container -> ItemTimers -> ItemTimers -> m ()
updAgeGame :: MonadStateWrite m => EnumSet LevelId -> m ()
updUnAgeGame :: MonadStateWrite m => EnumSet LevelId -> m ()
ageLevel :: MonadStateWrite m => Delta Time -> LevelId -> m ()
updDiscover :: MonadStateWrite m => Container -> ItemId -> ContentId ItemKind -> AspectRecord -> m ()
updCover :: Container -> ItemId -> ContentId ItemKind -> AspectRecord -> m ()
updDiscoverKind :: MonadStateWrite m => Container -> ItemKindIx -> ContentId ItemKind -> m ()
discoverKind :: MonadStateWrite m => ItemKindIx -> ContentId ItemKind -> m ()
updCoverKind :: Container -> ItemKindIx -> ContentId ItemKind -> m ()
updDiscoverAspect :: MonadStateWrite m => Container -> ItemId -> AspectRecord -> m ()
discoverAspect :: MonadStateWrite m => ItemId -> AspectRecord -> m ()
updCoverAspect :: Container -> ItemId -> AspectRecord -> m ()
updDiscoverServer :: MonadStateWrite m => ItemId -> AspectRecord -> m ()
updCoverServer :: MonadStateWrite m => ItemId -> AspectRecord -> m ()
updRestart :: MonadStateWrite m => State -> m ()
updRestartServer :: MonadStateWrite m => State -> m ()
updResumeServer :: MonadStateWrite m => State -> m ()

-- | Atomic game state transformations, their representation and semantics.
--   
--   See
--   https://github.com/LambdaHack/LambdaHack/wiki/Client-server-architecture.
module Game.LambdaHack.Atomic

-- | Abstract syntax of atomic commands, that is, atomic game state
--   transformations.
data CmdAtomic

-- | atomic updates
UpdAtomic :: UpdAtomic -> CmdAtomic

-- | atomic special effects
SfxAtomic :: SfxAtomic -> CmdAtomic

-- | Abstract syntax of atomic updates, that is, atomic commands that
--   really change the State. Most of them are an encoding of a game
--   state diff, though they also carry some intentional hints that help
--   clients determine whether and how to communicate it to players.
data UpdAtomic
UpdRegisterItems :: [(ItemId, Item)] -> UpdAtomic
UpdCreateActor :: ActorId -> Actor -> [(ItemId, Item)] -> UpdAtomic
UpdDestroyActor :: ActorId -> Actor -> [(ItemId, Item)] -> UpdAtomic
UpdCreateItem :: Bool -> ItemId -> Item -> ItemQuant -> Container -> UpdAtomic
UpdDestroyItem :: Bool -> ItemId -> Item -> ItemQuant -> Container -> UpdAtomic
UpdSpotActor :: ActorId -> Actor -> UpdAtomic
UpdLoseActor :: ActorId -> Actor -> UpdAtomic
UpdSpotItem :: Bool -> ItemId -> ItemQuant -> Container -> UpdAtomic
UpdLoseItem :: Bool -> ItemId -> ItemQuant -> Container -> UpdAtomic
UpdSpotItemBag :: Bool -> Container -> ItemBag -> UpdAtomic
UpdLoseItemBag :: Bool -> Container -> ItemBag -> UpdAtomic
UpdMoveActor :: ActorId -> Point -> Point -> UpdAtomic
UpdWaitActor :: ActorId -> Watchfulness -> Watchfulness -> UpdAtomic
UpdDisplaceActor :: ActorId -> ActorId -> UpdAtomic
UpdMoveItem :: ItemId -> Int -> ActorId -> CStore -> CStore -> UpdAtomic
UpdRefillHP :: ActorId -> Int64 -> UpdAtomic
UpdRefillCalm :: ActorId -> Int64 -> UpdAtomic
UpdTrajectory :: ActorId -> Maybe ([Vector], Speed) -> Maybe ([Vector], Speed) -> UpdAtomic
UpdQuitFaction :: FactionId -> Maybe Status -> Maybe Status -> Maybe (FactionAnalytics, GenerationAnalytics) -> UpdAtomic
UpdSpotStashFaction :: Bool -> FactionId -> LevelId -> Point -> UpdAtomic
UpdLoseStashFaction :: Bool -> FactionId -> LevelId -> Point -> UpdAtomic
UpdLeadFaction :: FactionId -> Maybe ActorId -> Maybe ActorId -> UpdAtomic
UpdDiplFaction :: FactionId -> FactionId -> Diplomacy -> Diplomacy -> UpdAtomic
UpdDoctrineFaction :: FactionId -> Doctrine -> Doctrine -> UpdAtomic
UpdAutoFaction :: FactionId -> Bool -> UpdAtomic
UpdRecordKill :: ActorId -> ContentId ItemKind -> Int -> UpdAtomic
UpdAlterTile :: LevelId -> Point -> ContentId TileKind -> ContentId TileKind -> UpdAtomic
UpdAlterExplorable :: LevelId -> Int -> UpdAtomic
UpdAlterGold :: Int -> UpdAtomic
UpdSearchTile :: ActorId -> Point -> ContentId TileKind -> UpdAtomic
UpdHideTile :: ActorId -> Point -> ContentId TileKind -> UpdAtomic
UpdSpotTile :: LevelId -> [(Point, ContentId TileKind)] -> UpdAtomic
UpdLoseTile :: LevelId -> [(Point, ContentId TileKind)] -> UpdAtomic
UpdSpotEntry :: LevelId -> [(Point, PlaceEntry)] -> UpdAtomic
UpdLoseEntry :: LevelId -> [(Point, PlaceEntry)] -> UpdAtomic
UpdAlterSmell :: LevelId -> Point -> Time -> Time -> UpdAtomic
UpdSpotSmell :: LevelId -> [(Point, Time)] -> UpdAtomic
UpdLoseSmell :: LevelId -> [(Point, Time)] -> UpdAtomic
UpdTimeItem :: ItemId -> Container -> ItemTimers -> ItemTimers -> UpdAtomic
UpdAgeGame :: EnumSet LevelId -> UpdAtomic
UpdUnAgeGame :: EnumSet LevelId -> UpdAtomic
UpdDiscover :: Container -> ItemId -> ContentId ItemKind -> AspectRecord -> UpdAtomic
UpdCover :: Container -> ItemId -> ContentId ItemKind -> AspectRecord -> UpdAtomic
UpdDiscoverKind :: Container -> ItemKindIx -> ContentId ItemKind -> UpdAtomic
UpdCoverKind :: Container -> ItemKindIx -> ContentId ItemKind -> UpdAtomic
UpdDiscoverAspect :: Container -> ItemId -> AspectRecord -> UpdAtomic
UpdCoverAspect :: Container -> ItemId -> AspectRecord -> UpdAtomic
UpdDiscoverServer :: ItemId -> AspectRecord -> UpdAtomic
UpdCoverServer :: ItemId -> AspectRecord -> UpdAtomic
UpdPerception :: LevelId -> Perception -> Perception -> UpdAtomic
UpdRestart :: FactionId -> PerLid -> State -> Challenge -> ClientOptions -> SMGen -> UpdAtomic
UpdRestartServer :: State -> UpdAtomic
UpdResume :: FactionId -> PerLid -> UpdAtomic
UpdResumeServer :: State -> UpdAtomic
UpdKillExit :: FactionId -> UpdAtomic
UpdWriteSave :: UpdAtomic
UpdHearFid :: FactionId -> Maybe Int -> HearMsg -> UpdAtomic
UpdMuteMessages :: FactionId -> Bool -> UpdAtomic

-- | Symbolic representation of text messages about heard noises, sent by
--   server to clients and shown to players and used by AI.
data HearMsg
HearUpd :: UpdAtomic -> HearMsg
HearStrike :: ContentId ItemKind -> HearMsg
HearSummon :: Bool -> GroupName ItemKind -> Dice -> HearMsg
HearCollideTile :: HearMsg
HearTaunt :: Text -> HearMsg

-- | Abstract syntax of atomic special effects, that is, atomic commands
--   that only display special effects and don't change State nor
--   client state.
data SfxAtomic
SfxStrike :: ActorId -> ActorId -> ItemId -> SfxAtomic
SfxRecoil :: ActorId -> ActorId -> ItemId -> SfxAtomic
SfxSteal :: ActorId -> ActorId -> ItemId -> SfxAtomic
SfxRelease :: ActorId -> ActorId -> ItemId -> SfxAtomic
SfxProject :: ActorId -> ItemId -> SfxAtomic
SfxReceive :: ActorId -> ItemId -> SfxAtomic
SfxApply :: ActorId -> ItemId -> SfxAtomic
SfxCheck :: ActorId -> ItemId -> SfxAtomic
SfxTrigger :: ActorId -> LevelId -> Point -> ContentId TileKind -> SfxAtomic
SfxShun :: ActorId -> LevelId -> Point -> ContentId TileKind -> SfxAtomic
SfxEffect :: FactionId -> ActorId -> ItemId -> Effect -> Int64 -> SfxAtomic
SfxItemApplied :: Bool -> ItemId -> Container -> SfxAtomic
SfxMsgFid :: FactionId -> SfxMsg -> SfxAtomic
SfxRestart :: SfxAtomic
SfxCollideTile :: ActorId -> Point -> SfxAtomic
SfxTaunt :: Bool -> ActorId -> SfxAtomic

-- | Symbolic representation of text messages sent by server to clients and
--   shown to players.
data SfxMsg
SfxUnexpected :: ReqFailure -> SfxMsg
SfxExpected :: Text -> ReqFailure -> SfxMsg
SfxExpectedEmbed :: ItemId -> LevelId -> ReqFailure -> SfxMsg
SfxFizzles :: ItemId -> Container -> SfxMsg
SfxNothingHappens :: ItemId -> Container -> SfxMsg
SfxNoItemsForTile :: [[(Int, GroupName ItemKind)]] -> SfxMsg
SfxVoidDetection :: DetectKind -> SfxMsg
SfxUnimpressed :: ActorId -> SfxMsg
SfxSummonLackCalm :: ActorId -> SfxMsg
SfxSummonTooManyOwn :: ActorId -> SfxMsg
SfxSummonTooManyAll :: ActorId -> SfxMsg
SfxSummonFailure :: ActorId -> SfxMsg
SfxLevelNoMore :: SfxMsg
SfxLevelPushed :: SfxMsg
SfxBracedImmune :: ActorId -> SfxMsg
SfxEscapeImpossible :: SfxMsg
SfxStasisProtects :: SfxMsg
SfxWaterParalysisResisted :: SfxMsg
SfxTransImpossible :: SfxMsg
SfxIdentifyNothing :: SfxMsg
SfxPurposeNothing :: SfxMsg
SfxPurposeTooFew :: Int -> Int -> SfxMsg
SfxPurposeUnique :: SfxMsg
SfxPurposeNotCommon :: SfxMsg
SfxRerollNothing :: SfxMsg
SfxRerollNotRandom :: SfxMsg
SfxDupNothing :: SfxMsg
SfxDupUnique :: SfxMsg
SfxDupValuable :: SfxMsg
SfxColdFish :: SfxMsg
SfxReadyGoods :: SfxMsg
SfxTimerExtended :: ActorId -> ItemId -> CStore -> Delta Time -> SfxMsg
SfxCollideActor :: ActorId -> ActorId -> SfxMsg
SfxItemYield :: ItemId -> Int -> LevelId -> SfxMsg

-- | The game-state semantics of atomic game commands. There is no
--   corresponding definition for special effects (SfxAtomic),
--   because they don't modify State.
--   
--   For each of the commands, we are guaranteed that the client, the
--   command is addressed to, perceives all the positions the command
--   affects (as computed by posUpdAtomic). In the code for each
--   semantic function we additonally verify the client is aware of any
--   relevant items and/or actors and we throw the AtomicFail
--   exception if it's not. The server keeps copies of all clients' states
--   and, before sending a command to a client, applies it to the client's
--   state copy. If AtomicFail is signalled, the command is
--   ignored for that client. This enables simpler server code that
--   addresses commands to all clients that can see it, even though not all
--   are able to process it.
handleUpdAtomic :: MonadStateWrite m => UpdAtomic -> m ()

-- | The type representing visibility of atomic commands to factions, based
--   on the position of the command, etc. Note that the server sees and
--   smells all positions. Also note that hearing is not covered because it
--   gives very restricted information, so hearing doesn't equal seeing
--   (and we assume smelling actors get lots of data from smells).
data PosAtomic

-- | whomever sees all the positions, notices
PosSight :: LevelId -> [Point] -> PosAtomic

-- | observers and the faction notice
PosFidAndSight :: FactionId -> LevelId -> [Point] -> PosAtomic

-- | whomever smells all the positions, notices
PosSmell :: LevelId -> [Point] -> PosAtomic

-- | whomever sees all the positions, notices
PosSightLevels :: [(LevelId, Point)] -> PosAtomic

-- | only the faction notices, server doesn't
PosFid :: FactionId -> PosAtomic

-- | faction and server notices
PosFidAndSer :: FactionId -> PosAtomic

-- | only the server notices
PosSer :: PosAtomic

-- | everybody notices
PosAll :: PosAtomic

-- | never broadcasted, but sent manually
PosNone :: PosAtomic

-- | Produce the positions where the atomic update takes place or, more
--   generally, the conditions under which the update can be noticed by a
--   client.
--   
--   The goal of this mechanics is to ensure that atomic commands involving
--   some positions visible by a client convey similar information as the
--   client would get by directly observing the changes of the portion of
--   server state limited to the visible positions. Consequently, when the
--   visible commands are later applied to the client's state, the state
--   stays consistent --- in sync with the server state and correctly
--   limited by visiblity. There is some wiggle room both in what "in sync"
--   and "visible" means and how they propagate through time.
--   
--   E.g., UpdDisplaceActor in a black room between two enemy
--   actors, with only one actor carrying a 0-radius light would not be
--   distinguishable by looking at the state (or the screen) from
--   UpdMoveActor of the illuminated actor, hence such
--   UpdDisplaceActor should not be observable, but
--   UpdMoveActor in similar cotext would be (or the former should
--   be perceived as the latter). However, to simplify, we assign as strict
--   visibility requirements to UpdMoveActor as to
--   UpdDisplaceActor and fall back to UpdSpotActor
--   (which provides minimal information that does not contradict state) if
--   the visibility is lower.
posUpdAtomic :: MonadStateRead m => UpdAtomic -> m PosAtomic

-- | Produce the positions where the atomic special effect takes place.
posSfxAtomic :: MonadStateRead m => SfxAtomic -> m PosAtomic

-- | All items introduced by the atomic command, to be used in it.
iidUpdAtomic :: UpdAtomic -> [ItemId]

-- | All items introduced by the atomic special effect, to be used in it.
iidSfxAtomic :: SfxAtomic -> [ItemId]

-- | Decompose an atomic action that is outside a client's visiblity. The
--   decomposed actions give less information that the original command,
--   but some of them may fall within the visibility range of the client.
--   The original action may give more information than even the total sum
--   of all actions it's broken into. E.g., UpdMoveActor informs
--   about the continued existence of the actor between moves vs popping
--   out of existence and then back in.
--   
--   This is computed in server's State from before performing the
--   command.
breakUpdAtomic :: MonadStateRead m => UpdAtomic -> m [UpdAtomic]

-- | What is the main map level the PosAtomic refers to, if any.
lidOfPos :: PosAtomic -> Maybe LevelId

-- | Given the client, its perception and an atomic command, determine if
--   the client notices the command.
seenAtomicCli :: Bool -> FactionId -> PerLid -> PosAtomic -> Bool

-- | Determine whether the server would see a command that has the given
--   visibilty conditions.
seenAtomicSer :: PosAtomic -> Bool

-- | The monad for writing to the main game state. Atomic updates
--   (UpdAtomic) are given semantics in this monad.
class MonadStateRead m => MonadStateWrite (m :: Type -> Type)
modifyState :: MonadStateWrite m => (State -> State) -> m ()
putState :: MonadStateWrite m => State -> m ()

-- | Exception signifying that atomic action failed because the information
--   it carries is inconsistent with the client's state, (e.g., because the
--   client knows too little to understand the command or already deduced
--   the state change from earlier commands or is confused, amnesiac or
--   sees illusory actors or tiles). Whenever we know the failure is
--   logically impossible, we don't throw the AtomicFail
--   exception, but insert a normal assertion or error call, which
--   are never caught nor handled.
newtype AtomicFail
AtomicFail :: String -> AtomicFail

-- | Abstract syntax of responses.
--   
--   See
--   https://github.com/LambdaHack/LambdaHack/wiki/Client-server-architecture.
module Game.LambdaHack.Client.Response

-- | Abstract syntax of responses sent by server to an AI or UI client (or
--   a universal client that can handle both roles, which is why this type
--   is not separated into distinct AI and UI types). A response tells a
--   client how to update game state or what information to send to the
--   server.
data Response

-- | change State by performing this atomic update
RespUpdAtomicNoState :: UpdAtomic -> Response

-- | put the given State, which results from performing the atomic
--   update
RespUpdAtomic :: State -> UpdAtomic -> Response

-- | compute an AI move for the actor and send (the semantics of) it
RespQueryAI :: ActorId -> Response

-- | perform special effects (animations, messages, etc.)
RespSfxAtomic :: SfxAtomic -> Response

-- | check if the UI client wants to regain control
RespQueryUIunderAI :: Response

-- | prompt the human player for a command and send (the semantics of) it
RespQueryUI :: Response
instance GHC.Internal.Show.Show Game.LambdaHack.Client.Response.Response

-- | Descriptions of items.
module Game.LambdaHack.Client.UI.ItemDescription

-- | The part of speech describing the item.
partItem :: Int -> FactionId -> FactionDict -> Time -> ItemFull -> ItemQuant -> (Part, Part)
partItemShort :: Int -> FactionId -> FactionDict -> Time -> ItemFull -> ItemQuant -> (Part, Part)
partItemShortest :: Int -> FactionId -> FactionDict -> Time -> ItemFull -> ItemQuant -> (Part, Part)
partItemHigh :: Int -> FactionId -> FactionDict -> Time -> ItemFull -> ItemQuant -> ([Text], Part, Part)
partItemWsDetail :: DetailLevel -> Int -> FactionId -> FactionDict -> Int -> Time -> ItemFull -> ItemQuant -> Part
partItemWs :: Int -> FactionId -> FactionDict -> Int -> Time -> ItemFull -> ItemQuant -> Part
partItemWsShortest :: Int -> FactionId -> FactionDict -> Int -> Time -> ItemFull -> ItemQuant -> Part
partItemWsShort :: Int -> FactionId -> FactionDict -> Int -> Time -> ItemFull -> ItemQuant -> Part
partItemWsLong :: Int -> FactionId -> FactionDict -> Int -> Time -> ItemFull -> ItemQuant -> Part
partItemWsRanged :: Int -> FactionId -> FactionDict -> Bool -> DetailLevel -> Int -> Int -> Time -> ItemFull -> ItemQuant -> Part
partItemShortAW :: Int -> FactionId -> FactionDict -> Time -> ItemFull -> ItemQuant -> Part
partItemMediumAW :: Int -> FactionId -> FactionDict -> Time -> ItemFull -> ItemQuant -> Part
partItemShortWownW :: Int -> FactionId -> FactionDict -> Part -> Time -> ItemFull -> ItemQuant -> Part
viewItem :: ItemFull -> AttrCharW32
viewItemBenefitColored :: DiscoveryBenefit -> ItemId -> ItemFull -> AttrCharW32
itemDesc :: Int -> Bool -> FactionId -> FactionDict -> Int -> ItemDialogMode -> Time -> LevelId -> ItemFull -> ItemQuant -> AttrString
partItemN :: Int -> FactionId -> FactionDict -> Bool -> DetailLevel -> Int -> Time -> ItemFull -> ItemQuant -> (Part, Part)
textAllPowers :: Int -> DetailLevel -> Bool -> ItemFull -> ([Text], [Text], [Text])

-- | Display game data on the screen using one of the available frontends
--   (determined at compile time with cabal flags).
module Game.LambdaHack.Client.UI.DrawM
targetDesc :: MonadClientUI m => Maybe Target -> m (Maybe Text, Maybe Text)
targetDescXhair :: MonadClientUI m => m (Maybe Text, Maybe Text, Maybe Watchfulness)

-- | Draw the whole screen: level map and status area.
drawHudFrame :: MonadClientUI m => ColorMode -> LevelId -> m PreFrame
checkWarningHP :: UIOptions -> ActorId -> Int64 -> State -> Bool
checkWarningCalm :: UIOptions -> ActorId -> Int64 -> State -> Bool
drawFrameTerrain :: MonadClientUI m => LevelId -> m (Vector Word32)
drawFrameContent :: MonadClientUI m => LevelId -> m FrameForall
drawFramePath :: MonadClientUI m => LevelId -> m (FrameForall, FrameForall)
drawFrameActor :: MonadClientUI m => LevelId -> m FrameForall
drawFrameExtra :: MonadClientUI m => ColorMode -> LevelId -> m FrameForall
drawFrameStatus :: MonadClientUI m => LevelId -> m AttrString
drawArenaStatus :: COps -> Level -> Int -> AttrString
drawLeaderStatus :: MonadClientUI m => Int -> m AttrString
drawLeaderDamage :: MonadClientUI m => Int -> ActorId -> m AttrString
drawSelected :: MonadClientUI m => LevelId -> Int -> EnumSet ActorId -> m (Int, AttrString)
checkWarnings :: UIOptions -> ActorId -> State -> (Bool, Bool)

-- | A set of Frame monad operations.
module Game.LambdaHack.Client.UI.FrameM

-- | Draw the current level with the overlay on top.
drawOverlay :: MonadClientUI m => ColorMode -> Bool -> FontOverlayMap -> LevelId -> m PreFrame3
promptGetKey :: MonadClientUI m => ColorMode -> FontOverlayMap -> Bool -> [KM] -> m KM
addToMacro :: Map KM CmdTriple -> KM -> KeyMacroFrame -> KeyMacroFrame
dropEmptyMacroFrames :: KeyMacroFrame -> [KeyMacroFrame] -> (KeyMacroFrame, [KeyMacroFrame])
lastMacroFrame :: KeyMacroFrame -> [KeyMacroFrame] -> KeyMacroFrame
stopPlayBack :: MonadClientUI m => m ()

-- | Render animations on top of the current screen frame.
renderAnimFrames :: MonadClientUI m => LevelId -> Animation -> Maybe Bool -> m PreFrames3

-- | Render and display animations on top of the current screen frame.
animate :: MonadClientUI m => LevelId -> Animation -> m ()

-- | We wipe any actions in progress, but keep the data needed to repeat
--   the last global macros and the last command.
resetPlayBack :: MonadClientUI m => m ()
restoreLeaderFromRun :: MonadClientUI m => m ()
basicFrameForAnimation :: MonadClientUI m => LevelId -> Maybe Bool -> m PreFrame3

-- | Monadic operations on slideshows and related data.
module Game.LambdaHack.Client.UI.SlideshowM

-- | Add current report to the overlay, split the result and produce,
--   possibly, many slides.
overlayToSlideshow :: MonadClientUI m => Int -> [KM] -> OKX -> m Slideshow

-- | Split current report into a slideshow.
reportToSlideshow :: MonadClientUI m => [KM] -> m Slideshow

-- | Split current report into a slideshow. Keep report unchanged. Assume
--   the game either halts waiting for a key after this is shown, or many
--   slides are produced, all but the last are displayed with player promts
--   between and the last is either shown in full or ignored if inside
--   macro (can be recovered from history, if important). Unless the
--   prompts interrupt the macro, which is as well.
reportToSlideshowKeepHalt :: MonadClientUI m => Bool -> [KM] -> m Slideshow

-- | Display a message. Return value indicates if the player wants to
--   continue. Feature: if many pages, only the last SPACE exits (but first
--   ESC).
displaySpaceEsc :: MonadClientUI m => ColorMode -> Text -> m Bool

-- | Display a message. Ignore keypresses. Feature: if many pages, only the
--   last SPACE exits (but first ESC).
displayMore :: MonadClientUI m => ColorMode -> Text -> m ()
displayMoreKeep :: MonadClientUI m => ColorMode -> Text -> m ()

-- | Print a yes/no question and return the player's answer. Use black and
--   white colours to turn player's attention to the choice.
displayYesNo :: MonadClientUI m => ColorMode -> Text -> m Bool
getConfirms :: MonadClientUI m => ColorMode -> [KM] -> Slideshow -> m KM

-- | Display a, potentially, multi-screen menu and return the chosen key or
--   menu slot (and save the index in the whole menu so that the cursor can
--   again be placed at that spot next time menu is displayed).
--   
--   This function is one of only two sources of menus and so, effectively,
--   UI modes.
displayChoiceScreen :: MonadClientUI m => String -> ColorMode -> Bool -> Slideshow -> [KM] -> m KeyOrSlot

-- | Display a, potentially, multi-screen menu and return the chosen key or
--   menu slot (and save the index in the whole menu so that the cursor can
--   again be placed at that spot next time menu is displayed).
--   Additionally, display something on the right half of the screen,
--   depending on which menu item is currently highlighted
--   
--   This function is one of only two sources of menus and so, effectively,
--   UI modes.
displayChoiceScreenWithRightPane :: MonadClientUI m => (KeyOrSlot -> m OKX) -> Bool -> String -> ColorMode -> Bool -> Slideshow -> [KM] -> m KeyOrSlot

-- | A specialized variant of displayChoiceScreenWithRightPane.
displayChoiceScreenWithDefItemKey :: MonadClientUI m => (Int -> MenuSlot -> m OKX) -> Slideshow -> [KM] -> String -> m KeyOrSlot

-- | A variant providing for a keypress the information about the label of
--   the menu slot which was selected during the keypress.
displayChoiceScreenWithRightPaneKMKM :: MonadClientUI m => (KeyOrSlot -> m OKX) -> Bool -> String -> ColorMode -> Bool -> Slideshow -> [KM] -> m (Either (KM, KeyOrSlot) MenuSlot)

-- | Push the frame depicting the current level to the frame queue. Only
--   one line of the report is shown, as in animations, because it may not
--   be our turn, so we can't clear the message to see what is underneath.
pushFrame :: MonadClientUI m => Bool -> m ()
pushReportFrame :: MonadClientUI m => m ()
getMenuIx :: MonadClientUI m => String -> Int -> Int -> Int -> m Int
saveMenuIx :: MonadClientUI m => String -> Int -> Int -> m ()

-- | This is one step of UI menu management user session.
--   
--   There is limited looping involved to return a changed position in the
--   menu each time so that the surrounding code has anything interesting
--   to do. The exception is when finally confirming a selection, in which
--   case it's usually not changed compared to last step, but it's
--   presented differently to indicate it was confirmed.
--   
--   Any extra keys in the OKX argument on top of the those in
--   Slideshow argument need to be contained in the
--   [K.KM] argument. Otherwise they are not accepted.
stepChoiceScreen :: MonadClientUI m => Bool -> ColorMode -> Bool -> Slideshow -> [KM] -> m (Int, Int, Int, Int -> OKX -> m (Bool, Either (KM, KeyOrSlot) MenuSlot, Int))
navigationKeys :: [KM]

-- | Find a position in a menu. The arguments go from first menu line and
--   menu page to the last, in order. Their indexing is from 0. We select
--   the nearest item with the index equal or less to the pointer.
findKYX :: Int -> [OKX] -> Maybe (OKX, KYX, Int)
drawHighlight :: Int -> ButtonWidth -> Int -> AttrString -> AttrString
basicFrameWithoutReport :: MonadClientUI m => LevelId -> Maybe Bool -> m PreFrame3

-- | Helper functions for both inventory management and human commands.
module Game.LambdaHack.Client.UI.HandleHelperM

-- | Message describing the cause of failure of human command.
data FailError
showFailError :: FailError -> Text
type MError = Maybe FailError
mergeMError :: MError -> MError -> MError
type FailOrCmd a = Either FailError a
failWith :: MonadClientUI m => Text -> m (FailOrCmd a)
failSer :: MonadClientUI m => ReqFailure -> m (FailOrCmd a)
failMsg :: MonadClientUI m => Text -> m MError
weaveJust :: FailOrCmd a -> Either MError a

-- | Switches current pointman to the previous in the whole dungeon,
--   wrapping.
pointmanCycle :: MonadClientUI m => ActorId -> Bool -> Direction -> m MError

-- | Switches current pointman to the next on the level, if any, wrapping.
pointmanCycleLevel :: MonadClientUI m => ActorId -> Bool -> Direction -> m MError
partyAfterLeader :: MonadClientUI m => ActorId -> m [(ActorId, Actor, ActorUI)]

-- | Select a faction leader. False, if nothing to do.
pickLeader :: MonadClientUI m => Bool -> ActorId -> m Bool

-- | Perform look around in the current position of the xhair. Does nothing
--   outside aiming mode.
doLook :: MonadClientUI m => m ()
pickLeaderWithPointer :: MonadClientUI m => ActorId -> m MError
itemOverlay :: MonadClientUI m => [(ItemId, ItemQuant)] -> ItemDialogMode -> m OKX
skillsOverlay :: MonadClientUI m => ActorId -> m OKX

-- | Extract whole-dungeon statistics for each place kind, counting the
--   number of occurrences of each type of PlaceEntry for the given
--   place kind and gathering the set of levels on which any entry for that
--   place kind can be found.
placesFromState :: ContentData PlaceKind -> Bool -> State -> EnumMap (ContentId PlaceKind) (EnumSet LevelId, Int, Int, Int)
placesOverlay :: MonadClientUI m => m OKX
factionsFromState :: ItemRoles -> State -> [(FactionId, Faction)]
factionsOverlay :: MonadClientUI m => m OKX
describeMode :: MonadClientUI m => Bool -> ContentId ModeKind -> m (EnumMap DisplayFont Overlay)
modesOverlay :: MonadClientUI m => m OKX
pickNumber :: MonadClientUI m => Bool -> Int -> m (Either MError Int)
guardItemSize :: Actor -> State -> Int

-- | Produces a textual description of items at a position.
lookAtItems :: MonadClientUI m => Bool -> Point -> LevelId -> Maybe ActorId -> Maybe (Part, Bool) -> m (Text, Maybe Person)
lookAtStash :: MonadClientUI m => Point -> LevelId -> m Text

-- | Produces a textual description of everything at the requested level's
--   position.
lookAtPosition :: MonadClientUI m => Point -> LevelId -> m [(MsgClassShow, Text)]
displayOneMenuItem :: MonadClientUI m => (MenuSlot -> m OKX) -> [KM] -> Int -> MenuSlot -> m KM
okxItemLoreInline :: MonadClientUI m => (ItemId -> ItemFull -> Int -> Text) -> Int -> ItemDialogMode -> [(ItemId, ItemQuant)] -> Int -> MenuSlot -> m OKX
okxItemLoreMsg :: MonadClientUI m => (ItemId -> ItemFull -> Int -> Text) -> Int -> ItemDialogMode -> [(ItemId, ItemQuant)] -> MenuSlot -> m OKX
itemDescOverlays :: MonadClientUI m => Bool -> Int -> ItemDialogMode -> ItemId -> ItemQuant -> ItemFull -> Int -> m (Overlay, Overlay)
cycleLore :: MonadClientUI m => [m KM] -> [m KM] -> m ()
spoilsBlurb :: Text -> Int -> Int -> Text
ppContainerWownW :: MonadClientUI m => (ActorId -> m Part) -> Bool -> Container -> m [Part]
nxtGameMode :: COps -> Int -> (ContentId ModeKind, ModeKind)
itemOverlayFromState :: LevelId -> [(ItemId, ItemQuant)] -> Bool -> CCUI -> FactionId -> DiscoveryBenefit -> FontSetup -> State -> OKX

-- | Produces a textual description of the tile at a position.
lookAtTile :: MonadClientUI m => Bool -> Point -> LevelId -> Maybe ActorId -> Maybe Person -> m (Text, Text, [(Int, Part)])

-- | Produces a textual description of actors at a position.
lookAtActors :: MonadClientUI m => Point -> LevelId -> m (Text, Maybe (Part, Bool), Text)
guardItemVerbs :: Actor -> State -> [Part]
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.HandleHelperM.FailError
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.HandleHelperM.FailError

-- | Display all the initial (not including high scores) screens at game
--   over.
module Game.LambdaHack.Client.UI.Watch.WatchQuitM
quitFactionUI :: MonadClientUI m => FactionId -> Maybe Status -> Maybe (FactionAnalytics, GenerationAnalytics) -> m ()
displayGameOverLoot :: MonadClientUI m => (ItemBag, Int) -> GenerationAnalytics -> m KM
displayGameOverAnalytics :: MonadClientUI m => FactionAnalytics -> GenerationAnalytics -> m KM
displayGameOverLore :: MonadClientUI m => SLore -> Bool -> GenerationAnalytics -> m KM
viewFinalLore :: MonadClientUI m => String -> ItemBag -> Text -> (ItemId -> ItemFull -> Int -> Text) -> ItemDialogMode -> m KM

-- | Common code for displaying atomic update and SFX commands.
module Game.LambdaHack.Client.UI.Watch.WatchCommonM
fadeOutOrIn :: MonadClientUI m => Bool -> m ()
markDisplayNeeded :: MonadClientUI m => LevelId -> m ()
lookAtMove :: MonadClientUI m => ActorId -> m ()
stopAtMove :: MonadClientUI m => ActorId -> m ()
aidVerbMU :: (MonadClientUI m, MsgShared a) => a -> ActorId -> Part -> m ()
aidVerbDuplicateMU :: (MonadClientUI m, MsgShared a) => a -> ActorId -> Part -> m Bool
itemVerbMUGeneral :: MonadClientUI m => Bool -> ItemId -> ItemQuant -> Part -> Container -> m Text
itemVerbMU :: (MonadClientUI m, MsgShared a) => a -> ItemId -> ItemQuant -> Part -> Container -> m ()
itemVerbMUShort :: (MonadClientUI m, MsgShared a) => a -> ItemId -> ItemQuant -> Part -> Container -> m ()
itemAidVerbMU :: (MonadClientUI m, MsgShared a) => a -> ActorId -> Part -> ItemId -> Either Int Int -> m ()
mitemAidVerbMU :: (MonadClientUI m, MsgShared a) => a -> ActorId -> Part -> ItemId -> Maybe Part -> m ()
itemAidDistinctMU :: MonadClientUI m => MsgClassDistinct -> ActorId -> Part -> Part -> ItemId -> m ()
manyItemsAidVerbMU :: (MonadClientUI m, MsgShared a) => a -> ActorId -> Part -> [(ItemId, ItemQuant)] -> (Int -> Either (Maybe Int) Int) -> m ()

-- | Display atomic update commands received by the client.
module Game.LambdaHack.Client.UI.Watch.WatchUpdAtomicM

-- | Visualize atomic updates sent to the client. This is done in the
--   global state after the command is executed and after the client state
--   is modified by the command. Doesn't modify client state (except a few
--   fields), but only client session (e.g., by displaying messages). This
--   is enforced by types.
watchRespUpdAtomicUI :: MonadClientUI m => UpdAtomic -> m ()
assignItemRole :: MonadClientUI m => Container -> ItemId -> m ()
data Threat
createActorUI :: MonadClientUI m => Bool -> ActorId -> Actor -> m ()
destroyActorUI :: MonadClientUI m => Bool -> ActorId -> Actor -> m ()
spotItemBag :: MonadClientUI m => Bool -> Container -> ItemBag -> m ()
recordItemLid :: MonadClientUI m => ItemId -> Container -> m ()
moveActor :: MonadClientUI m => ActorId -> Point -> Point -> m ()
displaceActorUI :: MonadClientUI m => ActorId -> ActorId -> m ()
moveItemUI :: MonadClientUI m => ItemId -> Int -> ActorId -> CStore -> CStore -> m ()
discover :: MonadClientUI m => Container -> ItemId -> m ()
ppHearMsg :: MonadClientUI m => Maybe Int -> HearMsg -> m Text
ppHearDistanceAdjective :: Maybe Int -> Text
ppHearDistanceAdverb :: Maybe Int -> Text
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.Watch.WatchUpdAtomicM.Threat

-- | Display atomic SFX commands received by the client.
module Game.LambdaHack.Client.UI.Watch.WatchSfxAtomicM

-- | Display special effects (text, animation) sent to the client. Don't
--   modify client state (except a few fields), but only client session
--   (e.g., by displaying messages). This is enforced by types.
watchRespSfxAtomicUI :: MonadClientUI m => SfxAtomic -> m ()
returnJustLeft :: MonadClientUI m => (MsgClassShowAndSave, Text) -> m (Maybe (Either (MsgClassShowAndSave, Text) (MsgClassDistinct, (Text, Text))))
ppSfxMsg :: MonadClientUI m => SfxMsg -> m (Maybe (Either (MsgClassShowAndSave, Text) (MsgClassDistinct, (Text, Text))))
strike :: MonadClientUI m => Bool -> ActorId -> ActorId -> ItemId -> m ()

-- | Display atomic commands received by the client.
module Game.LambdaHack.Client.UI.Watch

-- | Visualize atomic updates sent to the client. This is done in the
--   global state after the command is executed and after the client state
--   is modified by the command. Doesn't modify client state (except a few
--   fields), but only client session (e.g., by displaying messages). This
--   is enforced by types.
watchRespUpdAtomicUI :: MonadClientUI m => UpdAtomic -> m ()

-- | Display special effects (text, animation) sent to the client. Don't
--   modify client state (except a few fields), but only client session
--   (e.g., by displaying messages). This is enforced by types.
watchRespSfxAtomicUI :: MonadClientUI m => SfxAtomic -> m ()

-- | UI of inventory management.
module Game.LambdaHack.Client.UI.InventoryM
data Suitability
SuitsEverything :: Suitability
SuitsSomething :: (Maybe CStore -> ItemFull -> ItemQuant -> Bool) -> Suitability
data ResultItemDialogMode
RStore :: CStore -> [ItemId] -> ResultItemDialogMode
ROwned :: ItemId -> ResultItemDialogMode
RLore :: SLore -> MenuSlot -> [(ItemId, ItemQuant)] -> ResultItemDialogMode
RSkills :: MenuSlot -> ResultItemDialogMode
RPlaces :: MenuSlot -> ResultItemDialogMode
RFactions :: MenuSlot -> ResultItemDialogMode
RModes :: MenuSlot -> ResultItemDialogMode

-- | Let the human player choose a single, preferably suitable, item from a
--   list of items. Don't display stores empty for all actors. Start with a
--   non-empty store.
getFull :: MonadClientUI m => ActorId -> m Suitability -> (Actor -> ActorUI -> Skills -> ItemDialogMode -> State -> Text) -> (Actor -> ActorUI -> Skills -> ItemDialogMode -> State -> Text) -> [CStore] -> Bool -> Bool -> m (Either Text (CStore, [(ItemId, ItemQuant)]))

-- | Let a human player choose any item from a given group. Note that this
--   does not guarantee the chosen item belongs to the group, as the player
--   can override the choice. Used e.g., for applying and projecting.
getGroupItem :: MonadClientUI m => ActorId -> m Suitability -> Text -> Text -> Text -> Text -> [CStore] -> m (Either Text (CStore, ItemId))

-- | Display all items from a store and let the human player choose any or
--   switch to any other store. Used, e.g., for viewing inventory and item
--   descriptions.
getStoreItem :: MonadClientUI m => ActorId -> ItemDialogMode -> m (Either Text ResultItemDialogMode)
skillCloseUp :: MonadClientUI m => ActorId -> MenuSlot -> m (Text, AttrString)
placeCloseUp :: MonadClientUI m => [(ContentId PlaceKind, (EnumSet LevelId, Int, Int, Int))] -> Bool -> MenuSlot -> m (Text, [(DisplayFont, [AttrString])])
factionCloseUp :: MonadClientUI m => [(FactionId, Faction)] -> MenuSlot -> m (Text, [(DisplayFont, [AttrString])])
data ItemDialogState
ISuitable :: ItemDialogState
IAll :: ItemDialogState
accessModeBag :: ActorId -> State -> ItemDialogMode -> ItemBag
storeItemPrompt :: FactionId -> Actor -> ActorUI -> Skills -> ItemDialogMode -> State -> Text

-- | Let the human player choose a single, preferably suitable, item from a
--   list of items.
getItem :: MonadClientUI m => ActorId -> m Suitability -> (Actor -> ActorUI -> Skills -> ItemDialogMode -> State -> Text) -> (Actor -> ActorUI -> Skills -> ItemDialogMode -> State -> Text) -> ItemDialogMode -> [ItemDialogMode] -> Bool -> Bool -> m (Either Text ResultItemDialogMode)
data DefItemKey (m :: Type -> Type)
DefItemKey :: Either Text KM -> Bool -> ~m (Either Text ResultItemDialogMode) -> DefItemKey (m :: Type -> Type)
[defLabel] :: DefItemKey (m :: Type -> Type) -> Either Text KM
[defCond] :: DefItemKey (m :: Type -> Type) -> Bool
[defAction] :: DefItemKey (m :: Type -> Type) -> ~m (Either Text ResultItemDialogMode)
transition :: MonadClientUI m => ActorId -> m Suitability -> (Actor -> ActorUI -> Skills -> ItemDialogMode -> State -> Text) -> (Actor -> ActorUI -> Skills -> ItemDialogMode -> State -> Text) -> Bool -> ItemDialogMode -> [ItemDialogMode] -> ItemDialogState -> m (Either Text ResultItemDialogMode)
runDefMessage :: MonadClientUI m => [(KM, DefItemKey m)] -> Text -> m ()
runDefAction :: MonadClientUI m => [(KM, DefItemKey m)] -> (MenuSlot -> Either Text ResultItemDialogMode) -> KeyOrSlot -> m (Either Text ResultItemDialogMode)
runDefSkills :: MonadClientUI m => [(KM, DefItemKey m)] -> Text -> ActorId -> m (Either Text ResultItemDialogMode)
skillsInRightPane :: MonadClientUI m => ActorId -> Int -> MenuSlot -> m OKX
runDefPlaces :: MonadClientUI m => [(KM, DefItemKey m)] -> Text -> m (Either Text ResultItemDialogMode)
placesInRightPane :: MonadClientUI m => [(ContentId PlaceKind, (EnumSet LevelId, Int, Int, Int))] -> Int -> MenuSlot -> m OKX
runDefFactions :: MonadClientUI m => [(KM, DefItemKey m)] -> Text -> m (Either Text ResultItemDialogMode)
factionsInRightPane :: MonadClientUI m => [(FactionId, Faction)] -> Int -> MenuSlot -> m OKX
runDefModes :: MonadClientUI m => [(KM, DefItemKey m)] -> Text -> m (Either Text ResultItemDialogMode)
runDefInventory :: MonadClientUI m => [(KM, DefItemKey m)] -> Text -> ActorId -> ItemDialogMode -> [(ItemId, ItemQuant)] -> m (Either Text ResultItemDialogMode)
instance GHC.Classes.Eq Game.LambdaHack.Client.UI.InventoryM.ItemDialogState
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.InventoryM.ItemDialogState
instance GHC.Internal.Show.Show Game.LambdaHack.Client.UI.InventoryM.ResultItemDialogMode

-- | Semantics of Game.LambdaHack.Client.UI.HumanCmd client commands
--   that do not return server requests,, but only change internal client
--   state. None of such commands takes game time.
module Game.LambdaHack.Client.UI.HandleHumanLocalM
macroHuman :: MonadClientUI m => [String] -> m ()

-- | Push a new macro frame to the stack whenever repeating a macro.
macroHumanTransition :: [KM] -> KeyMacroFrame -> [KeyMacroFrame] -> (KeyMacroFrame, [KeyMacroFrame])

-- | Display items from a given container store and possibly let the user
--   chose one.
chooseItemHuman :: MonadClientUI m => ActorId -> ItemDialogMode -> m MError
chooseItemDialogMode :: MonadClientUI m => ActorId -> Bool -> ItemDialogMode -> m (FailOrCmd ActorId)
chooseItemProjectHuman :: (MonadClient m, MonadClientUI m) => ActorId -> [TriggerItem] -> m MError
chooseItemApplyHuman :: MonadClientUI m => ActorId -> [TriggerItem] -> m MError

-- | On top of permittedProjectClient, it also checks legality of
--   aiming at the target and projection range. It also modifies
--   eps.
psuitReq :: (MonadClient m, MonadClientUI m) => ActorId -> m (Either Text (ItemFull -> Either ReqFailure (Point, Bool)))

-- | 
--   >>> let trigger1 = HumanCmd.TriggerItem{tiverb="verb", tiobject="object", tisymbols=[toContentSymbol 'a', toContentSymbol 'b']}
--   
--   >>> let trigger2 = HumanCmd.TriggerItem{tiverb="verb2", tiobject="object2", tisymbols=[toContentSymbol 'c']}
--   
--   >>> triggerSymbols [trigger1, trigger2]
--   "abc"
--   
--   
--   
--   >>> triggerSymbols []
--   ""
--   
triggerSymbols :: [TriggerItem] -> [ContentSymbol ItemKind]
pickLeaderHuman :: MonadClientUI m => Int -> m MError
pickLeaderWithPointerHuman :: MonadClientUI m => ActorId -> m MError

-- | Switch current pointman to the previous in the whole dungeon,
--   wrapping.
pointmanCycleHuman :: MonadClientUI m => ActorId -> Direction -> m MError

-- | Switch current pointman to the next on the viewed level, if any,
--   wrapping.
pointmanCycleLevelHuman :: MonadClientUI m => ActorId -> Direction -> m MError
selectActorHuman :: MonadClientUI m => ActorId -> m ()
selectNoneHuman :: MonadClientUI m => m ()
selectWithPointerHuman :: MonadClientUI m => m MError
repeatHuman :: MonadClientUI m => Int -> m ()
repeatHumanTransition :: Int -> KeyMacroFrame -> [KeyMacroFrame] -> (KeyMacroFrame, [KeyMacroFrame])
repeatLastHuman :: MonadClientUI m => Int -> m ()
repeatLastHumanTransition :: Int -> KeyMacroFrame -> KeyMacroFrame

-- | Starts and stops recording of macros.
recordHuman :: MonadClientUI m => m ()
recordHumanTransition :: KeyMacroFrame -> (KeyMacroFrame, Text)
allHistoryHuman :: MonadClientUI m => m ()
markVisionHuman :: MonadClientUI m => Int -> m ()
markSmellHuman :: MonadClientUI m => m ()
markSuspectHuman :: MonadClient m => Int -> m ()
markAnimHuman :: MonadClient m => m ()
overrideTutHuman :: MonadClientUI m => Int -> m ()
printScreenHuman :: MonadClientUI m => m ()

-- | End aiming mode, rejecting the current position, unless when on remote
--   level, in which case, return to our level.
cancelHuman :: MonadClientUI m => m ()

-- | Accept the current crosshair position as target, ending aiming mode,
--   if active.
acceptHuman :: (MonadClient m, MonadClientUI m) => ActorId -> m ()

-- | Cycle detail level of aiming mode descriptions, starting up.
detailCycleHuman :: MonadClientUI m => m ()
clearTargetIfItemClearHuman :: (MonadClient m, MonadClientUI m) => ActorId -> m ()
itemClearHuman :: MonadClientUI m => m ()

-- | Move the xhair. Assumes aiming mode.
moveXhairHuman :: MonadClientUI m => Vector -> Int -> m MError

-- | Start aiming.
aimTgtHuman :: MonadClientUI m => m ()

-- | Cycle aiming mode. Do not change position of the xhair, switch target
--   to point at different things at that position.
aimFloorHuman :: MonadClientUI m => m ()
aimEnemyHuman :: MonadClientUI m => m ()
aimItemHuman :: MonadClientUI m => m ()

-- | Change the displayed level in aiming mode to (at most) k levels
--   shallower. Enters aiming mode, if not already in one.
aimAscendHuman :: MonadClientUI m => Int -> m MError

-- | Tweak the eps parameter of the aiming digital line.
epsIncrHuman :: (MonadClient m, MonadClientUI m) => Direction -> m ()
xhairUnknownHuman :: (MonadClient m, MonadClientUI m) => ActorId -> m MError
xhairItemHuman :: (MonadClient m, MonadClientUI m) => ActorId -> m MError
xhairStairHuman :: (MonadClient m, MonadClientUI m) => ActorId -> Bool -> m MError
xhairPointerFloorHuman :: MonadClientUI m => m ()
xhairPointerMuteHuman :: MonadClientUI m => m ()
xhairPointerEnemyHuman :: MonadClientUI m => m ()
aimPointerFloorHuman :: MonadClientUI m => m ()
aimPointerEnemyHuman :: MonadClientUI m => m ()
chooseItemDialogModeLore :: MonadClientUI m => m (Maybe ResultItemDialogMode)
projectCheck :: MonadClientUI m => ActorId -> Point -> m (Maybe ReqFailure)
posFromXhair :: (MonadClient m, MonadClientUI m) => ActorId -> m (Either Text Point)
permittedApplyClient :: MonadClientUI m => ActorId -> m (Maybe CStore -> ItemFull -> ItemQuant -> Either ReqFailure Bool)

-- | End aiming mode, accepting the current position.
endAiming :: (MonadClient m, MonadClientUI m) => ActorId -> m ()
endAimingMsg :: MonadClientUI m => ActorId -> m ()
flashAiming :: MonadClientUI m => m ()
permittedProjectClient :: MonadClientUI m => ActorId -> m (ItemFull -> Either ReqFailure Bool)

-- | Check whether one is permitted to aim (for projecting) at a target.
--   The check is stricter for actor targets, assuming the player simply
--   wants to hit a single actor. In order to fine tune trick-shots, e.g.,
--   piercing many actors, other aiming modes should be used. Returns a
--   different seps if needed to reach the target.
--   
--   Note: Simple Perception check is not enough for the check, e.g.,
--   because the target actor can be obscured by a glass wall.
xhairLegalEps :: MonadClientUI m => ActorId -> m (Either Text Int)

-- | Semantics of Game.LambdaHack.Client.UI.HumanCmd client commands
--   that return server requests. A couple of them do not take time, the
--   rest does. Here prompts and menus are displayed, but any feedback
--   resulting from the commands (e.g., from inventory manipulation) is
--   generated later on, by the server, for all clients that witness the
--   results of the commands.
module Game.LambdaHack.Client.UI.HandleHumanGlobalM

-- | Pick command depending on area the mouse pointer is in. The first
--   matching area is chosen. If none match, only interrupt.
byAreaHuman :: MonadClientUI m => (KM -> HumanCmd -> m (Either MError ReqUI)) -> [(CmdArea, HumanCmd)] -> m (Either MError ReqUI)
byAimModeHuman :: MonadClientUI m => m (Either MError ReqUI) -> m (Either MError ReqUI) -> m (Either MError ReqUI)
composeIfLocalHuman :: MonadClientUI m => m (Either MError ReqUI) -> m (Either MError ReqUI) -> m (Either MError ReqUI)
composeUnlessErrorHuman :: MonadClientUI m => m (Either MError ReqUI) -> m (Either MError ReqUI) -> m (Either MError ReqUI)
compose2ndLocalHuman :: MonadClientUI m => m (Either MError ReqUI) -> m (Either MError ReqUI) -> m (Either MError ReqUI)
loopOnNothingHuman :: MonadClientUI m => m (Either MError ReqUI) -> m (Either MError ReqUI)
executeIfClearHuman :: MonadClientUI m => m (Either MError ReqUI) -> m (Either MError ReqUI)

-- | Leader waits a turn (and blocks, etc.).
waitHuman :: MonadClientUI m => ActorId -> m (FailOrCmd RequestTimed)

-- | Leader waits a 1/10th of a turn (and doesn't block, etc.).
waitHuman10 :: MonadClientUI m => ActorId -> m (FailOrCmd RequestTimed)

-- | Leader yells or yawns, if sleeping.
yellHuman :: MonadClientUI m => ActorId -> m (FailOrCmd RequestTimed)
moveRunHuman :: (MonadClient m, MonadClientUI m) => ActorId -> Bool -> Bool -> Bool -> Bool -> Vector -> m (FailOrCmd RequestTimed)
runOnceAheadHuman :: MonadClientUI m => ActorId -> m (Either MError RequestTimed)
moveOnceToXhairHuman :: (MonadClient m, MonadClientUI m) => ActorId -> m (FailOrCmd RequestTimed)
runOnceToXhairHuman :: (MonadClient m, MonadClientUI m) => ActorId -> m (FailOrCmd RequestTimed)
continueToXhairHuman :: (MonadClient m, MonadClientUI m) => ActorId -> m (FailOrCmd RequestTimed)
moveItemHuman :: MonadClientUI m => ActorId -> [CStore] -> CStore -> Maybe Text -> Bool -> m (FailOrCmd RequestTimed)
projectHuman :: (MonadClient m, MonadClientUI m) => ActorId -> m (FailOrCmd RequestTimed)
applyHuman :: MonadClientUI m => ActorId -> m (FailOrCmd RequestTimed)

-- | Ask for a direction and alter a tile, if possible.
alterDirHuman :: MonadClientUI m => ActorId -> m (FailOrCmd RequestTimed)

-- | Try to alter a tile using a feature under the pointer.
alterWithPointerHuman :: MonadClientUI m => ActorId -> m (FailOrCmd RequestTimed)

-- | Close nearby open tile; ask for direction, if there is more than one.
closeDirHuman :: MonadClientUI m => ActorId -> m (FailOrCmd RequestTimed)

-- | Display command help.
helpHuman :: MonadClientUI m => (KM -> HumanCmd -> m (Either MError ReqUI)) -> m (Either MError ReqUI)

-- | Display hint or, if already displayed, display help.
hintHuman :: MonadClientUI m => (KM -> HumanCmd -> m (Either MError ReqUI)) -> m (Either MError ReqUI)

-- | Display the dashboard.
dashboardHuman :: MonadClientUI m => (KM -> HumanCmd -> m (Either MError ReqUI)) -> m (Either MError ReqUI)
itemMenuHuman :: MonadClientUI m => ActorId -> (KM -> HumanCmd -> m (Either MError ReqUI)) -> m (Either MError ReqUI)
chooseItemMenuHuman :: MonadClientUI m => ActorId -> (KM -> HumanCmd -> m (Either MError ReqUI)) -> ItemDialogMode -> m (Either MError ReqUI)

-- | Display the main menu.
mainMenuHuman :: MonadClientUI m => (KM -> HumanCmd -> m (Either MError ReqUI)) -> m (Either MError ReqUI)

-- | Display the main menu and set swasAutomated.
mainMenuAutoOnHuman :: MonadClientUI m => (KM -> HumanCmd -> m (Either MError ReqUI)) -> m (Either MError ReqUI)

-- | Display the main menu and unset swasAutomated.
mainMenuAutoOffHuman :: MonadClientUI m => (KM -> HumanCmd -> m (Either MError ReqUI)) -> m (Either MError ReqUI)

-- | Display the settings menu.
settingsMenuHuman :: MonadClientUI m => (KM -> HumanCmd -> m (Either MError ReqUI)) -> m (Either MError ReqUI)

-- | Display the challenge menu.
challengeMenuHuman :: MonadClientUI m => (KM -> HumanCmd -> m (Either MError ReqUI)) -> m (Either MError ReqUI)
gameDifficultyIncr :: MonadClient m => Int -> m ()
gameFishToggle :: MonadClient m => m ()
gameGoodsToggle :: MonadClient m => m ()
gameWolfToggle :: MonadClient m => m ()
gameKeeperToggle :: MonadClient m => m ()
gameScenarioIncr :: MonadClientUI m => Int -> m ()
gameExitWithHuman :: MonadClientUI m => ExitStrategy -> m (FailOrCmd ReqUI)
data ExitStrategy
Restart :: ExitStrategy
Quit :: ExitStrategy
gameDropHuman :: MonadClientUI m => m ReqUI
gameExitHuman :: Monad m => m ReqUI
gameSaveHuman :: MonadClientUI m => m ReqUI
doctrineHuman :: MonadClientUI m => m (FailOrCmd ReqUI)
automateHuman :: MonadClientUI m => m (FailOrCmd ReqUI)
automateToggleHuman :: MonadClientUI m => m (FailOrCmd ReqUI)
automateBackHuman :: MonadClientUI m => m (Either MError ReqUI)
areaToRectangles :: MonadClientUI m => CmdArea -> m [Maybe Area]

-- | Actor attacks an enemy actor or his own projectile.
meleeAid :: (MonadClient m, MonadClientUI m) => ActorId -> ActorId -> m (FailOrCmd RequestTimed)

-- | Actor swaps position with another.
displaceAid :: MonadClientUI m => ActorId -> ActorId -> m (FailOrCmd RequestTimed)

-- | Leader moves or searches or alters. No visible actor at the position.
moveSearchAlter :: MonadClientUI m => ActorId -> Bool -> Vector -> m (FailOrCmd RequestTimed)
alterCommon :: MonadClientUI m => ActorId -> Bool -> Point -> m (FailOrCmd RequestTimed)
goToXhair :: (MonadClient m, MonadClientUI m) => ActorId -> Bool -> Bool -> m (FailOrCmd RequestTimed)
goToXhairExplorationMode :: (MonadClient m, MonadClientUI m) => ActorId -> Bool -> Bool -> m (FailOrCmd RequestTimed)
goToXhairGoTo :: (MonadClient m, MonadClientUI m) => ActorId -> Bool -> Bool -> m (FailOrCmd RequestTimed)
multiActorGoTo :: (MonadClient m, MonadClientUI m) => LevelId -> Point -> RunParams -> m (FailOrCmd (Bool, Vector))
moveOrSelectItem :: MonadClientUI m => ActorId -> [CStore] -> CStore -> Maybe Text -> Bool -> m (FailOrCmd RequestTimed)
selectItemsToMove :: MonadClientUI m => ActorId -> [CStore] -> CStore -> Maybe Text -> Bool -> m (FailOrCmd (CStore, [(ItemId, ItemQuant)]))
moveItems :: MonadClientUI m => ActorId -> [CStore] -> (CStore, [(ItemId, ItemQuant)]) -> CStore -> m RequestTimed
projectItem :: (MonadClient m, MonadClientUI m) => ActorId -> (CStore, (ItemId, ItemFull)) -> m (FailOrCmd RequestTimed)
applyItem :: MonadClientUI m => ActorId -> (CStore, (ItemId, ItemFullKit)) -> m (FailOrCmd RequestTimed)

-- | Try to alter a tile using a feature at the given position.
--   
--   We don't check if the tile is interesting, e.g., if any embedded item
--   can be triggered, because the player explicitely requested the action.
--   Consequently, even if all embedded items are recharching, the time
--   will be wasted and the server will describe the failure in detail.
alterTileAtPos :: MonadClientUI m => ActorId -> Point -> m (FailOrCmd RequestTimed)

-- | Verify that the tile can be transformed or any embedded item effect
--   triggered and the player is aware if the effect is dangerous or grave,
--   such as ending the game.
verifyAlters :: MonadClientUI m => ActorId -> Bool -> Point -> m (FailOrCmd ())
processTileActions :: MonadClientUI m => ActorId -> Bool -> Point -> [TileAction] -> m (FailOrCmd ())
verifyEscape :: MonadClientUI m => m (FailOrCmd ())
verifyToolEffect :: MonadClientUI m => LevelId -> CStore -> ItemFull -> m (FailOrCmd ())

-- | Close tile at given position.
closeTileAtPos :: MonadClientUI m => ActorId -> Point -> m (FailOrCmd RequestTimed)

-- | Adds message with proper names.
msgAddDone :: MonadClientUI m => Bool -> ActorId -> Point -> Text -> m ()

-- | Prompts user to pick a point.
pickPoint :: MonadClientUI m => ActorId -> Text -> m (Maybe Point)
generateMenu :: MonadClientUI m => (KM -> HumanCmd -> m (Either MError ReqUI)) -> FontOverlayMap -> [(Text, HumanCmd, Maybe HumanCmd, Maybe FontOverlayMap)] -> [String] -> String -> m (Either MError ReqUI)

-- | Semantics of human player commands.
module Game.LambdaHack.Client.UI.HandleHumanM

-- | The semantics of human player commands in terms of the client monad,
--   in context of the given km as the last action.
--   
--   Some time cosuming commands are enabled even in aiming mode, but
--   cannot be invoked in aiming mode on a remote level (level different
--   than the level of the leader). Commands that require a pointman fail
--   when no leader is designated.
cmdSemInCxtOfKM :: (MonadClient m, MonadClientUI m) => KM -> HumanCmd -> m (Either MError ReqUI)
updateKeyLast :: KM -> HumanCmd -> KeyMacroFrame -> KeyMacroFrame

-- | Commands that are forbidden on a remote level, because they would
--   usually take time when invoked on one, but not necessarily do what the
--   player expects. Note that some commands that normally take time are
--   not included, because they don't take time in aiming mode or their
--   individual sanity conditions include a remote level check.
noRemoteHumanCmd :: HumanCmd -> Bool
data CmdLeaderNeed (m :: Type -> Type)
cmdSemantics :: (MonadClient m, MonadClientUI m) => HumanCmd -> m (Either MError ReqUI)
cmdSemanticsLeader :: forall (m :: Type -> Type). (MonadClient m, MonadClientUI m) => HumanCmd -> CmdLeaderNeed m
addNoError :: Monad m => m () -> CmdLeaderNeed m
addLeader :: Monad m => (ActorId -> m ()) -> CmdLeaderNeed m
weaveLeader :: Monad m => (ActorId -> m (FailOrCmd ReqUI)) -> CmdLeaderNeed m

-- | Ways for the client to use player input via UI to produce server
--   requests, based on the client's view (visualized for the player) of
--   the game state.
--   
--   This module is leaking quite a bit of implementation details for the
--   sake of Game.LambdaHack.Client.LoopM. After multiplayer is
--   enabled again and the new requirements sorted out, this should be
--   redesigned and some code moved down the module hierarhy tree, exposing
--   a smaller API here.
module Game.LambdaHack.Client.UI

-- | Handle the move of a human player.
queryUI :: (MonadClient m, MonadClientUI m) => m (Maybe RequestUI)
queryUIunderAI :: (MonadClient m, MonadClientUI m) => m RequestUI

-- | The monad that gives the client access to UI operations, but not to
--   modifying client state, except for the client-side pointman (as
--   opposed to pointman stores in faction data in main game state), which
--   is more of a UI concept, but is shared with AI to be able to keep it
--   when switching AI on/off and to save on typing.
class MonadClientRead m => MonadClientUI (m :: Type -> Type)
getsSession :: MonadClientUI m => (SessionUI -> a) -> m a
modifySession :: MonadClientUI m => (SessionUI -> SessionUI) -> m ()
updateClientLeader :: MonadClientUI m => ActorId -> m ()
getCacheBfs :: MonadClientUI m => ActorId -> m (Array BfsDistance)
getCachePath :: MonadClientUI m => ActorId -> Point -> m (Maybe AndPath)
putSession :: MonadClientUI m => SessionUI -> m ()
anyKeyPressed :: MonadClientUI m => m Bool
resetPressedKeys :: MonadClientUI m => m ()

-- | The information that is used across a human player playing session,
--   including many consecutive games in a single session, including
--   playing different teams. Some of it is saved, some is reset when a new
--   playing session starts. Nothing is tied to a faction/team, but instead
--   all to UI configuration and UI input and display history. An important
--   component is the frontend session.
data SessionUI
SessionUI :: Maybe RequestUI -> ReqDelay -> Bool -> Bool -> Maybe Target -> Maybe Target -> ActorDictUI -> ItemDictUI -> ItemRoles -> Maybe (CStore, CStore) -> ChanFrontend -> CCUI -> UIOptions -> Maybe AimMode -> Bool -> Maybe (ItemId, CStore, Bool) -> EnumSet ActorId -> Maybe RunParams -> History -> EnumMap (ContentId ModeKind) (Map Challenge Int) -> EnumSet (ContentId ModeKind) -> EnumSet (ContentId ModeKind) -> PointUI -> Bool -> KeyMacroFrame -> [KeyMacroFrame] -> EnumSet ActorId -> Int -> Bool -> Int -> Bool -> Int -> Bool -> Bool -> Maybe Bool -> Set Msg -> Bool -> Map String Int -> ChosenLore -> Bool -> Bool -> Bool -> POSIXTime -> POSIXTime -> Time -> Int -> Int -> SMGen -> SessionUI

-- | request created by a UI query but not yet sent to the server
[sreqPending] :: SessionUI -> Maybe RequestUI

-- | server delayed sending query to client or receiving request from
--   client
[sreqDelay] :: SessionUI -> ReqDelay

-- | player is now queried for a command
[sreqQueried] :: SessionUI -> Bool

-- | player requested to regain control from AI ASAP
[sregainControl] :: SessionUI -> Bool

-- | the common xhair
[sxhair] :: SessionUI -> Maybe Target

-- | xhair set for last GoTo
[sxhairGoTo] :: SessionUI -> Maybe Target

-- | assigned actor UI presentations
[sactorUI] :: SessionUI -> ActorDictUI

-- | assigned item first seen level
[sitemUI] :: SessionUI -> ItemDictUI

-- | assignment of roles to items
[sroles] :: SessionUI -> ItemRoles

-- | last item move stores
[slastItemMove] :: SessionUI -> Maybe (CStore, CStore)

-- | connection with the frontend
[schanF] :: SessionUI -> ChanFrontend

-- | UI client content
[sccui] :: SessionUI -> CCUI

-- | UI options as set by the player
[sUIOptions] :: SessionUI -> UIOptions

-- | aiming mode
[saimMode] :: SessionUI -> Maybe AimMode

-- | last mouse aiming not vacuus
[sxhairMoused] :: SessionUI -> Bool

-- | selected item, if any, it's store and whether to override suitability
--   check
[sitemSel] :: SessionUI -> Maybe (ItemId, CStore, Bool)

-- | the set of currently selected actors
[sselected] :: SessionUI -> EnumSet ActorId

-- | parameters of the current run, if any
[srunning] :: SessionUI -> Maybe RunParams

-- | history of messages
[shistory] :: SessionUI -> History

-- | the number of games won by the UI faction per game mode and per
--   difficulty level
[svictories] :: SessionUI -> EnumMap (ContentId ModeKind) (Map Challenge Int)

-- | camped games
[scampings] :: SessionUI -> EnumSet (ContentId ModeKind)

-- | restarted games
[srestarts] :: SessionUI -> EnumSet (ContentId ModeKind)

-- | mouse pointer position
[spointer] :: SessionUI -> PointUI

-- | whether to auto-clear prompts
[sautoYes] :: SessionUI -> Bool

-- | the head of the key macro stack
[smacroFrame] :: SessionUI -> KeyMacroFrame

-- | the tail of the key macro stack
[smacroStack] :: SessionUI -> [KeyMacroFrame]

-- | actors that just got out of sight
[slastLost] :: SessionUI -> EnumSet ActorId

-- | player just waited this many times
[swaitTimes] :: SessionUI -> Int

-- | the player just exited AI automation
[swasAutomated] :: SessionUI -> Bool

-- | mark leader and party FOV
[smarkVision] :: SessionUI -> Int

-- | mark smell, if the leader can smell
[smarkSmell] :: SessionUI -> Bool

-- | next game scenario number
[snxtScenario] :: SessionUI -> Int

-- | whether current game is a tutorial
[scurTutorial] :: SessionUI -> Bool

-- | whether next game is to be tutorial
[snxtTutorial] :: SessionUI -> Bool

-- | override display of tutorial hints
[soverrideTut] :: SessionUI -> Maybe Bool

-- | tutorial hints already shown this game
[susedHints] :: SessionUI -> Set Msg

-- | whether to mute all new messages
[smuteMessages] :: SessionUI -> Bool

-- | indices of last used menu items
[smenuIxMap] :: SessionUI -> Map String Int

-- | last lore chosen to display
[schosenLore] :: SessionUI -> ChosenLore

-- | current level needs displaying
[sdisplayNeeded] :: SessionUI -> Bool

-- | a frame was already displayed this turn
[sturnDisplayed] :: SessionUI -> Bool

-- | whether no visible report created last UI faction turn or the report
--   wiped out from screen since
[sreportNull] :: SessionUI -> Bool

-- | this session start time
[sstart] :: SessionUI -> POSIXTime

-- | this game start time
[sgstart] :: SessionUI -> POSIXTime

-- | clips from start of session to current game start
[sallTime] :: SessionUI -> Time

-- | this game current frame count
[snframes] :: SessionUI -> Int

-- | frame count from start of session to current game start
[sallNframes] :: SessionUI -> Int

-- | current random generator for UI
[srandomUI] :: SessionUI -> SMGen
data ReqDelay
ReqDelayNot :: ReqDelay
ReqDelayHandled :: ReqDelay
ReqDelayAlarm :: ReqDelay
emptySessionUI :: UIOptions -> SessionUI

-- | Visualize atomic updates sent to the client. This is done in the
--   global state after the command is executed and after the client state
--   is modified by the command. Doesn't modify client state (except a few
--   fields), but only client session (e.g., by displaying messages). This
--   is enforced by types.
watchRespUpdAtomicUI :: MonadClientUI m => UpdAtomic -> m ()

-- | Display special effects (text, animation) sent to the client. Don't
--   modify client state (except a few fields), but only client session
--   (e.g., by displaying messages). This is enforced by types.
watchRespSfxAtomicUI :: MonadClientUI m => SfxAtomic -> m ()

-- | Operations for all UI content types, gathered together.
data CCUI
CCUI :: InputContent -> ScreenContent -> CCUI
[coinput] :: CCUI -> InputContent
[coscreen] :: CCUI -> ScreenContent

-- | Options that affect the UI of the client, specified in the config
--   file. More documentation is in the default config file.
data UIOptions

-- | Modify client options with UI options.
applyUIOptions :: COps -> UIOptions -> ClientOptions -> ClientOptions
uOverrideCmdline :: UIOptions -> [String]

-- | Read and parse UI config file.
mkUIOptions :: RuleContent -> ClientOptions -> IO UIOptions

-- | Connection channel between a frontend and a client. Frontend acts as a
--   server, serving keys, etc., when given frames to display.
data ChanFrontend

-- | Initialize the frontend chosen by the player via client options.
chanFrontend :: MonadClientUI m => ScreenContent -> ClientOptions -> m ChanFrontend

-- | Try to read saved client game state from the file system.
tryRestore :: MonadClientUI m => m (Maybe (StateClient, Maybe SessionUI))
clientPrintUI :: MonadClientUI m => Text -> m ()
pushReportFrame :: MonadClientUI m => m ()

-- | Add a message to the current report.
msgAdd :: (MonadClientUI m, MsgShared a) => a -> Text -> m ()
data MsgClassShow
MsgPromptGeneric :: MsgClassShow
MsgPromptFocus :: MsgClassShow
MsgPromptMention :: MsgClassShow
MsgPromptModify :: MsgClassShow
MsgPromptActors :: MsgClassShow
MsgPromptItems :: MsgClassShow
MsgPromptAction :: MsgClassShow
MsgActionAlert :: MsgClassShow
MsgSpottedThreat :: MsgClassShow
stepQueryUIwithLeader :: (MonadClient m, MonadClientUI m) => m (Maybe RequestUI)

-- | Let the human player issue commands until any command takes time.
stepQueryUI :: (MonadClient m, MonadClientUI m) => m (Maybe ReqUI)

-- | Actor preferences for targets and actions, based on actor aspects.
module Game.LambdaHack.Client.Preferences

-- | Compute the whole Benefit structure, containing various facets
--   of AI item preference, for an item with the given effects and aspects.
totalUsefulness :: COps -> FactionId -> FactionDict -> ItemFull -> Benefit

-- | How much AI benefits from applying the effect. The first component is
--   benefit when applied to self, the second is benefit (preferably
--   negative) when applied to enemy (via melee). This represents benefit
--   from using the effect every avgItemDelay turns, so if the
--   item is not durable, the value is adjusted down elsewhere. The benefit
--   includes the drawback of having to use the actor's turn, except when
--   there is battle and item is a weapon and so there is usually nothing
--   better to do than to melee, or when the actor is stuck or idle or
--   laying in wait or luring an enemy from a safe distance. So there is
--   less than averageTurnValue included in each benefit, so in
--   case when turn is not spent, e.g, periodic activation or conditions,
--   the difference in value is only slight.
effectToBenefit :: COps -> FactionId -> FactionDict -> Effect -> (Double, Double)
averageTurnValue :: Double
avgItemDelay :: Double
avgItemLife :: Double
durabilityMult :: Double
organBenefit :: Double -> GroupName ItemKind -> COps -> FactionId -> FactionDict -> (Double, Int)
recBenefit :: GroupName ItemKind -> COps -> FactionId -> FactionDict -> (Double, Int)
fakeItem :: ContentId ItemKind -> ItemKind -> KindMean -> ItemFull
aspectToBenefit :: Aspect -> Double
capStat :: Double -> Double
aspectRecordToBenefit :: AspectRecord -> [Double]

-- | Handle atomic commands received by the client.
module Game.LambdaHack.Client.HandleAtomicM

-- | Client monad for saving a game.
class MonadClient m => MonadClientSetup (m :: Type -> Type)
saveClient :: MonadClientSetup m => m ()

-- | Effect of atomic actions on client state. It is calculated with the
--   global state from after the command is executed (except where the
--   supplied oldState is used).
cmdAtomicSemCli :: MonadClientSetup m => State -> UpdAtomic -> m ()
updateInMeleeDueToActor :: MonadClient m => Actor -> m ()
updateInMeleeDueToItem :: MonadClient m => ActorId -> CStore -> m ()
updateInMeleeInDungeon :: MonadClient m => m ()
wipeBfsIfItemAffectsSkills :: MonadClient m => CStore -> ActorId -> m ()
tileChangeAffectsBfs :: COps -> ContentId TileKind -> ContentId TileKind -> Bool
createActor :: MonadClient m => ActorId -> Actor -> [(ItemId, Item)] -> m ()
destroyActor :: MonadClient m => ActorId -> Actor -> Bool -> m ()
addItemToDiscoBenefit :: MonadClient m => ItemId -> m ()
perception :: MonadClient m => LevelId -> Perception -> Perception -> m ()
discoverKind :: MonadClient m => ItemKindIx -> m ()
discoverKindAndAspect :: MonadClient m => ItemKindIx -> m ()
coverKind :: ItemKindIx -> m ()
coverAspectAndKind :: ItemKindIx -> m ()
discoverAspect :: MonadClient m => ItemId -> m ()
coverAspect :: ItemId -> m ()
killExit :: MonadClient m => m ()

-- | Semantics of responses sent by the server to clients.
module Game.LambdaHack.Client.HandleResponseM

-- | Monad for executing atomic game state transformations on a client.
class MonadClient m => MonadClientAtomic (m :: Type -> Type)

-- | Execute an atomic update that changes the client's State.
execUpdAtomic :: MonadClientAtomic m => UpdAtomic -> m ()

-- | Put state that is intended to be the result of performing an atomic
--   update by the server on its copy of the client's State.
execPutState :: MonadClientAtomic m => State -> m ()

-- | Client monad in which one can send requests to the client.
class MonadClient m => MonadClientWriteRequest (m :: Type -> Type)
sendRequestAI :: MonadClientWriteRequest m => RequestAI -> m ()
sendRequestUI :: MonadClientWriteRequest m => RequestUI -> m ()
clientHasUI :: MonadClientWriteRequest m => m Bool

-- | Handle server responses.
--   
--   Note that for clients communicating with the server over the net,
--   RespUpdAtomicNoState should be used, because executing a
--   single command is cheaper than sending the whole state over the net.
--   However, for the standalone exe mode, with clients in the same process
--   as the server, a pointer to the state set with execPutState
--   is cheaper.
handleResponse :: (MonadClientSetup m, MonadClientUI m, MonadClientAtomic m, MonadClientWriteRequest m) => Response -> m ()

-- | The main loop of the client, processing human and computer player
--   moves turn by turn.
module Game.LambdaHack.Client.LoopM

-- | Client monad in which one can receive responses from the server.
class MonadClient m => MonadClientReadResponse (m :: Type -> Type)
receiveResponse :: MonadClientReadResponse m => m Response

-- | The main game loop for an AI or UI client. It receives responses from
--   the server, changes internal client state accordingly, analyzes
--   ensuing human or AI commands and sends resulting requests to the
--   server. Depending on whether it's an AI or UI client, it sends AI or
--   human player requests.
--   
--   The loop is started in client state that is empty except for the
--   sside and seps fields, see emptyStateClient.
loopCli :: (MonadClientSetup m, MonadClientUI m, MonadClientAtomic m, MonadClientReadResponse m, MonadClientWriteRequest m) => CCUI -> UIOptions -> ClientOptions -> Bool -> m ()
initAI :: MonadClient m => m ()
initUI :: (MonadClient m, MonadClientUI m) => CCUI -> m ()
loopAI :: (MonadClientSetup m, MonadClientUI m, MonadClientAtomic m, MonadClientReadResponse m, MonadClientWriteRequest m) => m ()

-- | Alarm after this many seconds without server querying us for a
--   command.
longestDelay :: POSIXTime

-- | The argument is the time of last UI query from the server. After
--   longestDelay seconds past this date, the client considers
--   itself ignored and displays a warning and, at a keypress, gives direct
--   control to the player, no longer waiting for the server to prompt it
--   to do so.
loopUI :: (MonadClientSetup m, MonadClientUI m, MonadClientAtomic m, MonadClientReadResponse m, MonadClientWriteRequest m) => POSIXTime -> m ()

-- | Semantics of responses that are sent from server to clients, in terms
--   of client state transformations, and semantics of human commands and
--   AI moves, in terms of requests to be sent from the client to the
--   server.
--   
--   See
--   https://github.com/LambdaHack/LambdaHack/wiki/Client-server-architecture.
module Game.LambdaHack.Client

-- | The main game loop for an AI or UI client. It receives responses from
--   the server, changes internal client state accordingly, analyzes
--   ensuing human or AI commands and sends resulting requests to the
--   server. Depending on whether it's an AI or UI client, it sends AI or
--   human player requests.
--   
--   The loop is started in client state that is empty except for the
--   sside and seps fields, see emptyStateClient.
loopCli :: (MonadClientSetup m, MonadClientUI m, MonadClientAtomic m, MonadClientReadResponse m, MonadClientWriteRequest m) => CCUI -> UIOptions -> ClientOptions -> Bool -> m ()

-- | Requests sent by AI clients to the server. If faction leader is to be
--   changed, it's included as the second component.
type RequestAI = (ReqAI, Maybe ActorId)

-- | Possible forms of requests sent by AI clients.
data ReqAI
ReqAINop :: ReqAI
ReqAITimed :: RequestTimed -> ReqAI

-- | Requests sent by UI clients to the server. If faction leader is to be
--   changed, it's included as the second component.
type RequestUI = (ReqUI, Maybe ActorId)

-- | Possible forms of requests sent by UI clients.
data ReqUI
ReqUINop :: ReqUI
ReqUITimed :: RequestTimed -> ReqUI
ReqUIGameRestart :: GroupName ModeKind -> Challenge -> ReqUI
ReqUIGameDropAndExit :: ReqUI
ReqUIGameSaveAndExit :: ReqUI
ReqUIGameSave :: ReqUI
ReqUIDoctrine :: Doctrine -> ReqUI
ReqUIAutomate :: ReqUI

-- | Requests that take game time.
data RequestTimed
ReqMove :: Vector -> RequestTimed
ReqMelee :: ActorId -> ItemId -> CStore -> RequestTimed
ReqDisplace :: ActorId -> RequestTimed
ReqAlter :: Point -> RequestTimed
ReqWait :: RequestTimed
ReqWait10 :: RequestTimed
ReqYell :: RequestTimed
ReqMoveItems :: [(ItemId, Int, CStore, CStore)] -> RequestTimed
ReqProject :: Point -> Int -> ItemId -> CStore -> RequestTimed
ReqApply :: ItemId -> CStore -> RequestTimed

-- | Abstract syntax of responses sent by server to an AI or UI client (or
--   a universal client that can handle both roles, which is why this type
--   is not separated into distinct AI and UI types). A response tells a
--   client how to update game state or what information to send to the
--   server.
data Response

-- | change State by performing this atomic update
RespUpdAtomicNoState :: UpdAtomic -> Response

-- | put the given State, which results from performing the atomic
--   update
RespUpdAtomic :: State -> UpdAtomic -> Response

-- | compute an AI move for the actor and send (the semantics of) it
RespQueryAI :: ActorId -> Response

-- | perform special effects (animations, messages, etc.)
RespSfxAtomic :: SfxAtomic -> Response

-- | check if the UI client wants to regain control
RespQueryUIunderAI :: Response

-- | prompt the human player for a command and send (the semantics of) it
RespQueryUI :: Response

-- | Operations for all UI content types, gathered together.
data CCUI

-- | Options that affect the UI of the client, specified in the config
--   file. More documentation is in the default config file.
data UIOptions

-- | Modify client options with UI options.
applyUIOptions :: COps -> UIOptions -> ClientOptions -> ClientOptions
uOverrideCmdline :: UIOptions -> [String]

-- | Read and parse UI config file.
mkUIOptions :: RuleContent -> ClientOptions -> IO UIOptions

-- | Temporary pseudo-organ (condition) definitions.
module Content.ItemKindTemporary
pattern S_IMMOBILE :: GroupName ItemKind
pattern S_PACIFIED :: GroupName ItemKind
pattern S_IRREPLACEABLE :: GroupName ItemKind
pattern S_RETAINING :: GroupName ItemKind
pattern S_IMPATIENT :: GroupName ItemKind
pattern S_DISPOSSESSED :: GroupName ItemKind
pattern S_WITHHOLDING :: GroupName ItemKind
pattern S_PARSIMONIOUS :: GroupName ItemKind
pattern S_MORE_MOBILE :: GroupName ItemKind
pattern S_MORE_COMBATIVE :: GroupName ItemKind
pattern S_MORE_DISPLACING :: GroupName ItemKind
pattern S_MORE_MODIFYING :: GroupName ItemKind
pattern S_MORE_PATIENT :: GroupName ItemKind
pattern S_MORE_TIDY :: GroupName ItemKind
pattern S_MORE_PROJECTING :: GroupName ItemKind
pattern S_MORE_PRACTICAL :: GroupName ItemKind
pattern S_STRENGTHENED :: GroupName ItemKind
pattern S_WEAKENED :: GroupName ItemKind
pattern S_PROTECTED_FROM_MELEE :: GroupName ItemKind
pattern S_PROTECTED_FROM_RANGED :: GroupName ItemKind
pattern S_DEFENSELESS :: GroupName ItemKind
pattern S_RESOLUTE :: GroupName ItemKind
pattern S_HASTED :: GroupName ItemKind
pattern S_SLOWED :: GroupName ItemKind
pattern S_FAR_SIGHTED :: GroupName ItemKind
pattern S_BLIND :: GroupName ItemKind
pattern S_KEEN_SMELLING :: GroupName ItemKind
pattern S_FOUL_SMELLING :: GroupName ItemKind
pattern S_ROSE_SMELLING :: GroupName ItemKind
pattern S_RANGED_DEFLECTING :: GroupName ItemKind
pattern S_MELEE_DEFLECTING :: GroupName ItemKind
pattern S_SHINY_EYED :: GroupName ItemKind
pattern S_DEAFENED :: GroupName ItemKind
pattern S_DEAF :: GroupName ItemKind
pattern S_DRUNK :: GroupName ItemKind
pattern S_FRENZIED :: GroupName ItemKind
pattern S_REGENERATING :: GroupName ItemKind
pattern S_POISONED :: GroupName ItemKind
pattern S_SLOW_RESISTANT :: GroupName ItemKind
pattern S_POISON_RESISTANT :: GroupName ItemKind
temporariesGNSingleton :: [GroupName ItemKind]
noStatGN :: [GroupName ItemKind]
bonusStatGN :: [GroupName ItemKind]
temporaries :: [ItemKind]

-- | Blast definitions.
module Content.ItemKindBlast
pattern S_FIRECRACKER :: GroupName ItemKind
pattern S_VIOLENT_FRAGMENTATION :: GroupName ItemKind
pattern S_FRAGMENTATION :: GroupName ItemKind
pattern S_FOCUSED_FRAGMENTATION :: GroupName ItemKind
pattern S_VIOLENT_CONCUSSION :: GroupName ItemKind
pattern S_CONCUSSION :: GroupName ItemKind
pattern S_FOCUSED_CONCUSSION :: GroupName ItemKind
pattern S_VIOLENT_FLASH :: GroupName ItemKind
pattern S_FOCUSED_FLASH :: GroupName ItemKind
pattern S_GLASS_HAIL :: GroupName ItemKind
pattern S_FOCUSED_GLASS_HAIL :: GroupName ItemKind
pattern S_PHEROMONE :: GroupName ItemKind
pattern S_CALMING_MIST :: GroupName ItemKind
pattern S_DISTRESSING_ODOR :: GroupName ItemKind
pattern S_HEALING_MIST :: GroupName ItemKind
pattern S_HEALING_MIST_2 :: GroupName ItemKind
pattern S_WOUNDING_MIST :: GroupName ItemKind
pattern S_DISTORTION :: GroupName ItemKind
pattern S_SMOKE :: GroupName ItemKind
pattern S_BOILING_WATER :: GroupName ItemKind
pattern S_GLUE :: GroupName ItemKind
pattern S_WASTE :: GroupName ItemKind
pattern S_ANTI_SLOW_MIST :: GroupName ItemKind
pattern S_ANTIDOTE_MIST :: GroupName ItemKind
pattern S_SLEEP_MIST :: GroupName ItemKind
pattern S_DENSE_SHOWER :: GroupName ItemKind
pattern S_SPARSE_SHOWER :: GroupName ItemKind
pattern S_MELEE_PROTECTIVE_BALM :: GroupName ItemKind
pattern S_RANGE_PROTECTIVE_BALM :: GroupName ItemKind
pattern S_DEFENSELESSNESS_RUNOUT :: GroupName ItemKind
pattern S_RESOLUTION_DUST :: GroupName ItemKind
pattern S_HASTE_SPRAY :: GroupName ItemKind
pattern S_VIOLENT_SLOWNESS_MIST :: GroupName ItemKind
pattern S_SLOWNESS_MIST :: GroupName ItemKind
pattern S_FOCUSED_SLOWNESS_MIST :: GroupName ItemKind
pattern S_EYE_DROP :: GroupName ItemKind
pattern S_IRON_FILING :: GroupName ItemKind
pattern S_SMELLY_DROPLET :: GroupName ItemKind
pattern S_EYE_SHINE :: GroupName ItemKind
pattern S_WHISKEY_SPRAY :: GroupName ItemKind
pattern S_YOUTH_SPRINKLE :: GroupName ItemKind
pattern S_POISON_CLOUD :: GroupName ItemKind
pattern S_PING_PLASH :: GroupName ItemKind
pattern S_VIOLENT_BURNING_OIL_2 :: GroupName ItemKind
pattern S_VIOLENT_BURNING_OIL_3 :: GroupName ItemKind
pattern S_VIOLENT_BURNING_OIL_4 :: GroupName ItemKind
pattern S_BURNING_OIL_2 :: GroupName ItemKind
pattern S_BURNING_OIL_3 :: GroupName ItemKind
pattern S_BURNING_OIL_4 :: GroupName ItemKind
pattern S_FOCUSED_BURNING_OIL_2 :: GroupName ItemKind
pattern S_FOCUSED_BURNING_OIL_3 :: GroupName ItemKind
pattern S_FOCUSED_BURNING_OIL_4 :: GroupName ItemKind
blastNoStatOf :: GroupName ItemKind -> GroupName ItemKind
blastBonusStatOf :: GroupName ItemKind -> GroupName ItemKind
pattern ARMOR_MISC :: GroupName ItemKind
blastsGNSingleton :: [GroupName ItemKind]
blastsGN :: [GroupName ItemKind]
blasts :: [ItemKind]

-- | Operations on the Area type that involve random numbers.
module Game.LambdaHack.Server.DungeonGen.AreaRnd
mkFixed :: (X, Y) -> Area -> Point -> Area

-- | Pick a random point within an area.
pointInArea :: Area -> Rnd Point

-- | Find a suitable position in the area, based on random points and a
--   preference predicate and fallback acceptability predicate.
findPointInArea :: Area -> (Point -> Maybe Point) -> Int -> (Point -> Maybe Point) -> Rnd (Maybe Point)

-- | Create a void room, i.e., a single point area within the designated
--   area.
mkVoidRoom :: Area -> Rnd Area

-- | Create a random room according to given parameters.
mkRoom :: (X, Y) -> (X, Y) -> Area -> Rnd Area

-- | Pick a subset of connections between adjacent areas within a grid
--   until there is only one connected component in the graph of all areas.
connectGrid :: EnumSet Point -> (X, Y) -> Rnd [(Point, Point)]

-- | Pick a single random connection between adjacent areas within a grid.
randomConnection :: (X, Y) -> Rnd (Point, Point)

-- | The choice of horizontal and vertical orientation.
data HV
Horiz :: HV
Vert :: HV

-- | The coordinates of consecutive fields of a corridor.
type Corridor = (Point, Point, Point, Point)

-- | Try to connect two interiors of places with a corridor. Choose
--   entrances some steps away from the edges, if the place is big enough.
--   Note that with pfence == FNone, the inner area considered is
--   the strict interior of the place, without the outermost tiles.
--   
--   The corridor connects (touches) the inner areas and the turning point
--   of the corridor (if any) is outside of the outer areas and inside the
--   grid areas.
connectPlaces :: (Area, Fence, Area) -> (Area, Fence, Area) -> Rnd (Maybe Corridor)
data SpecialArea
SpecialArea :: Area -> SpecialArea
SpecialFixed :: Point -> Freqs PlaceKind -> Area -> SpecialArea
SpecialMerged :: SpecialArea -> Point -> SpecialArea

-- | Divide uniformly a larger area into the given number of smaller areas
--   overlapping at the edges.
--   
--   The list of fixed centers (some important points inside) of
--   (non-overlapping) areas is given. Incorporate those, with as little
--   disruption, as possible. Assume each of four boundaries of the cave
--   are covered by a fixed centre.
grid :: EnumMap Point (Freqs PlaceKind) -> [Point] -> Area -> (X, Y) -> ((X, Y), EnumMap Point SpecialArea)
connectGrid' :: EnumSet Point -> (X, Y) -> EnumSet Point -> EnumSet Point -> [(Point, Point)] -> Rnd [(Point, Point)]

-- | Sort the sequence of two points, in the derived lexicographic order.
sortPoint :: (Point, Point) -> (Point, Point)

-- | Create a corridor, either horizontal or vertical, with a possible
--   intermediate part that is in the opposite direction. There might not
--   always exist a good intermediate point if the places are allowed to be
--   close together and then we let the intermediate part degenerate.
mkCorridor :: HV -> Point -> Bool -> Point -> Bool -> Area -> Rnd Corridor
borderPlace :: Area -> Fence -> (Area, Area, Bool)
instance GHC.Classes.Eq Game.LambdaHack.Server.DungeonGen.AreaRnd.HV
instance GHC.Internal.Show.Show Game.LambdaHack.Server.DungeonGen.AreaRnd.SpecialArea

-- | Generation of places from place kinds.
module Game.LambdaHack.Server.DungeonGen.Place

-- | The parameters of a place. All are immutable and rolled and fixed at
--   the time when a place is generated.
data Place
Place :: ContentId PlaceKind -> Area -> TileMapEM -> TileMapEM -> Place
[qkind] :: Place -> ContentId PlaceKind
[qarea] :: Place -> Area
[qmap] :: Place -> TileMapEM
[qfence] :: Place -> TileMapEM

-- | The map of tile kinds in a place (and generally anywhere in a cave).
--   The map is sparse. The default tile that eventually fills the empty
--   spaces is specified in the cave kind specification with
--   cdefTile.
type TileMapEM = EnumMap Point ContentId TileKind

-- | Given a few parameters, roll and construct a Place
--   datastructure and fill a cave section acccording to it.
buildPlace :: COps -> CaveKind -> Bool -> ContentId TileKind -> ContentId TileKind -> AbsDepth -> AbsDepth -> Word32 -> Area -> Maybe Area -> Freqs PlaceKind -> Rnd Place
isChancePos :: Int -> Int -> Word32 -> Point -> Bool

-- | Construct a fence around an area, with the given tile group.
buildFenceRnd :: COps -> GroupName TileKind -> GroupName TileKind -> GroupName TileKind -> GroupName TileKind -> Area -> Rnd TileMapEM

-- | For CAlternate tiling, require the place be comprised of an
--   even number of whole corners, with exactly one square overlap between
--   consecutive coners and no trimming. For other tiling methods, check
--   that the area is large enough for tiling the corner twice in each
--   direction, with a possible one row/column overlap.
placeCheck :: Area -> PlaceKind -> Bool

-- | Calculate interior room area according to fence type, based on the
--   total area for the room and it's fence. This is used for checking if
--   the room fits in the area, for digging up the place and the fence and
--   for deciding if the room is dark or lit later in the dungeon
--   generation process.
interiorArea :: PlaceKind -> Area -> Maybe Area
pover :: COps -> EnumMap Char (GroupName TileKind) -> Rnd (EnumMap Char (Maybe (Int, Int, ContentId TileKind), ContentId TileKind))

-- | Construct a fence around a place.
buildFence :: COps -> CaveKind -> Bool -> ContentId TileKind -> ContentId TileKind -> Bool -> Fence -> Area -> Rnd TileMapEM

-- | Construct a fence around an area, with the given tile kind. Corners
--   have a different kind, e.g., to avoid putting doors there.
buildFenceMap :: ContentId TileKind -> ContentId TileKind -> Area -> TileMapEM

-- | Create a place by tiling patterns.
tilePlace :: Area -> PlaceKind -> Rnd (EnumMap Point Char)
instance GHC.Internal.Show.Show Game.LambdaHack.Server.DungeonGen.Place.Place

-- | Generation of caves (not yet inhabited dungeon levels) from cave
--   kinds.
module Game.LambdaHack.Server.DungeonGen.Cave

-- | The type of caves (not yet inhabited dungeon levels).
data Cave
Cave :: ContentId CaveKind -> Area -> TileMapEM -> EnumMap Point Place -> EnumMap Point PlaceEntry -> Bool -> Cave

-- | the kind of the cave
[dkind] :: Cave -> ContentId CaveKind

-- | map area of the cave
[darea] :: Cave -> Area

-- | tile kinds in the cave
[dmap] :: Cave -> TileMapEM

-- | stair places indexed by their center
[dstairs] :: Cave -> EnumMap Point Place

-- | room entrances in the cave
[dentry] :: Cave -> EnumMap Point PlaceEntry

-- | whether the cave is dark
[dnight] :: Cave -> Bool

-- | Generate a cave using an algorithm inspired by the original Rogue, as
--   follows (in gross simplification):
--   
--   
--   
- The available area is divided into a grid, e.g, 3 by 3, where each
--   of the 9 grid cells has approximately the same size.
--   
- In some of the 9 grid cells a room is placed at a random position
--   and with a random size, but larger than the minimum size, e.g, 2 by 2
--   floor tiles.
--   
- Rooms that are on horizontally or vertically adjacent grid cells
--   may be connected by a corridor. Corridors consist of 3 segments of
--   straight lines (either "horizontal, vertical, horizontal" or
--   "vertical, horizontal, vertical"). They end in openings in the walls
--   of the room they connect. It is possible that one or two of the 3
--   segments have length 0, such that the resulting corridor is L-shaped
--   or even a single straight line.
--   
- Corridors are generated randomly in such a way that at least every
--   room on the grid is connected, and a few more might be. It is not
--   sufficient to always connect all adjacent rooms, because not each cell
--   holds a room.
--   
buildCave :: COps -> AbsDepth -> AbsDepth -> Area -> Word32 -> ContentId CaveKind -> (X, Y) -> EnumMap Point SpecialArea -> [Point] -> Rnd Cave
pickOpening :: COps -> CaveKind -> TileMapEM -> ContentId TileKind -> Word32 -> EnumMap Point (ContentId TileKind) -> (Point, (ContentId TileKind, ContentId TileKind, ContentId PlaceKind)) -> Rnd (EnumMap Point (ContentId TileKind))
instance GHC.Internal.Show.Show Game.LambdaHack.Server.DungeonGen.Cave.Cave

-- | DFOV (Digital Field of View) implemented according to specification at
--   http://roguebasin.roguelikedevelopment.org/index.php?title=Digital_field_of_view_implementation.
--   This fast version of the algorithm, based on PFOV, has AFAIK never
--   been described nor implemented before.
--   
--   The map is processed in depth-first-search manner, that is, as soon as
--   we detect on obstacle we move away from the viewer up to the FOV
--   radius and then restart on the other side of the obstacle. This has
--   better cache behaviour than breadth-firsts-search, where we would
--   process all tiles equally distant from the viewer in the same round,
--   because then we'd need to keep the many convex hulls and edges, not
--   just a single set, and we'd potentially traverse all of them each
--   round.
module Game.LambdaHack.Server.FovDigital

-- | Calculates the list of tiles visible from (0, 0) within the given
--   sight range.
scan :: Distance -> (PointI -> Bool) -> (Bump -> PointI) -> [PointI]

-- | Rotated and translated coordinates of 2D points, so that the points
--   fit in a single quadrant area (e, g., quadrant I for Permissive FOV,
--   hence both coordinates positive; adjacent diagonal halves of quadrant
--   I and II for Digital FOV, hence y positive). The special coordinates
--   are written using the standard mathematical coordinate setup, where
--   quadrant I, with x and y positive, is on the upper right.
data Bump
B :: Int -> Int -> Bump
[bx] :: Bump -> Int
[by] :: Bump -> Int

-- | Distance from the (0, 0) point where FOV originates.
type Distance = Int

-- | Progress along an arc with a constant distance from (0, 0).
type Progress = Int

-- | Two strict orderings of lines with a common point.
data LineOrdering

-- | Straight line between points.
data Line
Line :: Bump -> Bump -> Line

-- | Convex hull represented as a non-empty list of points.
data ConvexHull
ConvexHull :: Bump -> CHull -> ConvexHull
data CHull
CHNil :: CHull
CHCons :: Bump -> CHull -> CHull

-- | An edge (comprising of a line and a convex hull) of the area to be
--   scanned.
type Edge = (Line, ConvexHull)

-- | The contiguous area left to be scanned, delimited by edges.
type EdgeInterval = (Edge, Edge)

-- | Specialized implementation for speed in the inner loop. Not partial.
steepestInHull :: LineOrdering -> Bump -> ConvexHull -> Bump

-- | Standard foldl' over CHull.
foldlCHull' :: (a -> Bump -> a) -> a -> CHull -> a

-- | Extends a convex hull of bumps with a new bump. The new bump makes
--   some old bumps unnecessary, e.g. those that are joined with the new
--   steep bump with lines that are not shallower than any newer lines in
--   the hull. Removing such unnecessary bumps slightly speeds up
--   computation of steepestInHull.
--   
--   Recursion in addToHullGo seems spurious, but it's called each
--   time with potentially different comparison predicate, so it's
--   necessary.
addToHull :: LineOrdering -> Bump -> ConvexHull -> ConvexHull
addToHullGo :: LineOrdering -> Bump -> CHull -> CHull

-- | Create a line from two points.
--   
--   Debug: check if well-defined.
createLine :: Bump -> Bump -> Line

-- | Strictly compare steepness of lines (b1, bf) and (b2,
--   bf), according to the LineOrdering given. This is
--   related to comparing the slope (gradient, angle) of two lines, but
--   simplified wrt signs to work fast in this particular setup.
--   
--   Debug: Verify that the results of 2 independent checks are equal.
steepness :: LineOrdering -> Bump -> Bump -> Bump -> Bool

-- | A pair (a, b) such that a divided by b is
--   the X coordinate of the intersection of a given line and the
--   horizontal line at distance d above the X axis.
--   
--   Derivation of the formula: The intersection point (xt, yt)
--   satisfies the following equalities:
--   
--   
--   yt = d
--   (yt - y) (xf - x) = (xt - x) (yf - y)
--   
--   
--   hence
--   
--   
--   (yt - y) (xf - x) = (xt - x) (yf - y)
--   (d - y) (xf - x) = (xt - x) (yf - y)
--   (d - y) (xf - x) + x (yf - y) = xt (yf - y)
--   xt = ((d - y) (xf - x) + x (yf - y)) / (yf - y)
--   
--   
--   General remarks: The FOV agrees with physical properties of tiles as
--   diamonds and visibility from any point to any point. A diamond is
--   denoted by the left corner of its encompassing tile. Hero is at (0,
--   0). Order of processing in the first quadrant rotated by 45 degrees is
--   
--   
--   45678
--    123
--     @
--   
--   
--   so the first processed diamond is at (-1, 1). The order is similar as
--   for the restrictive shadow casting algorithm and reversed wrt PFOV.
--   The fast moving line when scanning is called the shallow line, and
--   it's the one that delimits the view from the left, while the steep
--   line is on the right, opposite to PFOV. We start scanning from the
--   left.
--   
--   The PointI (Enum representation of Point)
--   coordinates are cartesian. The Bump coordinates are cartesian,
--   translated so that the hero is at (0, 0) and rotated so that he always
--   looks at the first (rotated 45 degrees) quadrant. The
--   (Progress, Distance) cordinates coincide with the
--   Bump coordinates, unlike in PFOV.
--   
--   Debug: check that the line fits in the upper half-plane.
intersect :: Line -> Distance -> (Int, Int)

-- | Debug functions for DFOV:
--   
--   Debug: calculate steepness for DFOV in another way and compare
--   results.
_debugSteeper :: LineOrdering -> Bump -> Bump -> Bump -> Bool

-- | Debug: check if a view border line for DFOV is legal.
_debugLine :: Line -> (Bool, String)
instance GHC.Internal.Show.Show Game.LambdaHack.Server.FovDigital.Bump
instance GHC.Internal.Show.Show Game.LambdaHack.Server.FovDigital.CHull
instance GHC.Internal.Show.Show Game.LambdaHack.Server.FovDigital.ConvexHull
instance GHC.Internal.Show.Show Game.LambdaHack.Server.FovDigital.Line

-- | Field Of View scanning.
--   
--   See https://github.com/LambdaHack/LambdaHack/wiki/Fov-and-los
--   for discussion.
module Game.LambdaHack.Server.Fov
data FovValid a
FovValid :: a -> FovValid a
FovInvalid :: FovValid a

-- | Main perception validity map, for all factions.
--   
--   The inner type is not a set, due to an unbenchmarked theory that a
--   constant shape map is faster.
type PerValidFid = EnumMap FactionId EnumMap LevelId Bool

-- | Visually reachable positions (light passes through them to the actor).
--   They need to be intersected with lucid positions to obtain visible
--   positions.
newtype PerReachable
PerReachable :: EnumSet Point -> PerReachable
[preachable] :: PerReachable -> EnumSet Point
data CacheBeforeLucid
CacheBeforeLucid :: PerReachable -> PerVisible -> PerSmelled -> CacheBeforeLucid
[creachable] :: CacheBeforeLucid -> PerReachable
[cnocto] :: CacheBeforeLucid -> PerVisible
[csmell] :: CacheBeforeLucid -> PerSmelled
type PerActor = EnumMap ActorId FovValid CacheBeforeLucid
data PerceptionCache
PerceptionCache :: FovValid CacheBeforeLucid -> PerActor -> PerceptionCache
[ptotal] :: PerceptionCache -> FovValid CacheBeforeLucid
[perActor] :: PerceptionCache -> PerActor

-- | Server cache of perceptions of a single faction, indexed by level
--   identifier.
type PerCacheLid = EnumMap LevelId PerceptionCache

-- | Server cache of perceptions, indexed by faction identifier.
type PerCacheFid = EnumMap FactionId PerCacheLid

-- | Map from level positions that currently hold item or actor(s) with
--   shine to the maximum of radiuses of the shining lights.
--   
--   Note that floor and (many projectile) actors light on a single tile
--   should be additive for FovShine to be incrementally updated.
--   
--   FovShine should not even be kept in StateServer,
--   because it's cheap to compute, compared to FovLucid and
--   invalidated almost as often (not invalidated only by
--   UpdAlterTile).
newtype FovShine
FovShine :: EnumMap Point Int -> FovShine
[fovShine] :: FovShine -> EnumMap Point Int

-- | Level positions with either ambient light or shining items or actors.
newtype FovLucid
FovLucid :: EnumSet Point -> FovLucid
[fovLucid] :: FovLucid -> EnumSet Point
type FovLucidLid = EnumMap LevelId FovValid FovLucid

-- | Level positions that pass through light and vision.
newtype FovClear
FovClear :: Array Bool -> FovClear
[fovClear] :: FovClear -> Array Bool
type FovClearLid = EnumMap LevelId FovClear

-- | Level positions with tiles that have ambient light.
newtype FovLit
FovLit :: EnumSet Point -> FovLit
[fovLit] :: FovLit -> EnumSet Point
type FovLitLid = EnumMap LevelId FovLit

-- | Compute positions visible (reachable and seen) by the party. A
--   position is lucid, if it's lit by an ambient light or by a weak,
--   portable light source, e.g,, carried by an actor. A reachable and
--   lucid position is visible. Additionally, positions directly adjacent
--   to an actor are assumed to be visible to him (through sound, touch,
--   noctovision, whatever).
perceptionFromPTotal :: FactionId -> LevelId -> FovLucid -> CacheBeforeLucid -> State -> Perception
perActorFromLevel :: PerActor -> (ActorId -> Actor) -> ActorMaxSkills -> FovClear -> PerActor
boundSightByCalm :: Int -> Int64 -> Int
totalFromPerActor :: PerActor -> CacheBeforeLucid

-- | Update lights on the level. This is needed every (even enemy) actor
--   move to show thrown torches. We need to update lights even if cmd
--   doesn't change any perception, so that for next cmd that does, but
--   doesn't change lights, and operates on the same level, the lights are
--   up to date. We could make lights lazy to ensure no computation is
--   wasted, but it's rare that cmd changed them, but not the perception
--   (e.g., earthquake in an uninhabited corner of the active arena, but
--   the we'd probably want some feedback, at least sound).
lucidFromLevel :: FovClearLid -> FovLitLid -> State -> LevelId -> Level -> FovLucid

-- | Calculate the perception and its caches for the whole dungeon.
perFidInDungeon :: State -> (FovLitLid, FovClearLid, FovLucidLid, PerValidFid, PerCacheFid, PerFid)
perceptionFromPTotalNoStash :: FovLucid -> CacheBeforeLucid -> Perception

-- | Compute positions reachable by the actor. Reachable are all fields on
--   a visually unblocked path from the actor position. Also compute
--   positions seen by noctovision and perceived by smell.
cacheBeforeLucidFromActor :: FovClear -> Actor -> Skills -> CacheBeforeLucid
shineFromLevel :: State -> LevelId -> Level -> FovShine
floorLightSources :: DiscoveryAspect -> Level -> [(Point, Int)]

-- | Compute all dynamically lit positions on a level, whether lit by
--   actors or shining floor items. Note that an actor can be blind, in
--   which case he doesn't see his own light (but others, from his or other
--   factions, possibly do).
lucidFromItems :: FovClear -> [(Point, Int)] -> [FovLucid]
litFromLevel :: COps -> Level -> FovLit
litInDungeon :: State -> FovLitLid
clearFromLevel :: COps -> Level -> FovClear
clearInDungeon :: State -> FovClearLid
lucidInDungeon :: FovClearLid -> FovLitLid -> State -> FovLucidLid

-- | Calculate perception of a faction.
perLidFromFaction :: FovLucidLid -> FovClearLid -> FactionId -> State -> (PerLid, PerCacheLid)
perceptionCacheFromLevel :: FovClearLid -> FactionId -> LevelId -> State -> PerceptionCache
type Matrix = (Int, Int, Int, Int)

-- | Perform a full scan for a given position. Returns the positions that
--   are currently in the field of view. The actor's own position is
--   considred in his field of view.
fullscan :: Int -> Point -> FovClear -> EnumSet Point
instance GHC.Classes.Eq Game.LambdaHack.Server.Fov.CacheBeforeLucid
instance GHC.Classes.Eq Game.LambdaHack.Server.Fov.FovClear
instance GHC.Classes.Eq Game.LambdaHack.Server.Fov.FovLit
instance GHC.Classes.Eq Game.LambdaHack.Server.Fov.FovLucid
instance GHC.Classes.Eq Game.LambdaHack.Server.Fov.FovShine
instance GHC.Classes.Eq a => GHC.Classes.Eq (Game.LambdaHack.Server.Fov.FovValid a)
instance GHC.Classes.Eq Game.LambdaHack.Server.Fov.PerReachable
instance GHC.Classes.Eq Game.LambdaHack.Server.Fov.PerceptionCache
instance GHC.Internal.Show.Show Game.LambdaHack.Server.Fov.CacheBeforeLucid
instance GHC.Internal.Show.Show Game.LambdaHack.Server.Fov.FovClear
instance GHC.Internal.Show.Show Game.LambdaHack.Server.Fov.FovLit
instance GHC.Internal.Show.Show Game.LambdaHack.Server.Fov.FovLucid
instance GHC.Internal.Show.Show Game.LambdaHack.Server.Fov.FovShine
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Game.LambdaHack.Server.Fov.FovValid a)
instance GHC.Internal.Show.Show Game.LambdaHack.Server.Fov.PerReachable
instance GHC.Internal.Show.Show Game.LambdaHack.Server.Fov.PerceptionCache

-- | Creation of items on the server. Types and operations that don't
--   involve server state nor our custom monads.
module Game.LambdaHack.Server.ItemRev

-- | The essential item properties, used for the ItemRev hash
--   table from items to their ids, needed to assign ids to newly generated
--   items. All the other meaningful properties can be derived from them.
--   Note: item seed instead of AspectRecord is not enough,
--   becaused different seeds may result in the same AspectRecord
--   and we don't want such items to be distinct in UI and elsewhere.
data ItemKnown
ItemKnown :: ItemIdentity -> AspectRecord -> Maybe FactionId -> ItemKnown
data NewItem
NewItem :: GroupName ItemKind -> ItemKnown -> ItemFull -> ItemQuant -> NewItem
NoNewItem :: NewItem

-- | Reverse item map, for item creation, to keep items and item
--   identifiers in bijection.
type ItemRev = HashMap ItemKnown ItemId
type UniqueSet = EnumSet ContentId ItemKind

-- | Roll an item kind based on given Freqs and kind rarities
newItemKind :: COps -> UniqueSet -> Freqs ItemKind -> AbsDepth -> AbsDepth -> Int -> Frequency (GroupName ItemKind, ContentId ItemKind, ItemKind)

-- | Given item kind frequency, roll item kind, generate item aspects based
--   on level and put together the full item data set.
newItem :: COps -> Frequency (GroupName ItemKind, ContentId ItemKind, ItemKind) -> FlavourMap -> DiscoveryKindRev -> AbsDepth -> AbsDepth -> Rnd NewItem

-- | The reverse map to DiscoveryKind, needed for item creation.
--   This is total and never changes, hence implemented as vector. Morally,
--   it's indexed by ContentId ItemKind and elements are
--   ItemKindIx.
data DiscoveryKindRev
emptyDiscoveryKindRev :: DiscoveryKindRev
serverDiscos :: COps -> DiscoveryKindRev -> Rnd (DiscoveryKind, DiscoveryKindRev)

-- | Flavours assigned by the server to item kinds, in this particular
--   game. This is total and never changes, hence implemented as vector.
--   Morally, it's indexed by ContentId ItemKind and elements are
--   Flavour.
data FlavourMap
emptyFlavourMap :: FlavourMap

-- | Randomly chooses flavour for all item kinds for this game.
dungeonFlavourMap :: COps -> FlavourMap -> Rnd FlavourMap

-- | Assigns flavours to item kinds. Assures no flavor is repeated for the
--   same symbol, except for items with only one permitted flavour.
rollFlavourMap :: Vector Word16 -> Rnd (EnumMap (ContentId ItemKind) Flavour, EnumMap (ContentSymbol ItemKind) (EnumSet Flavour)) -> ContentId ItemKind -> ItemKind -> Rnd (EnumMap (ContentId ItemKind) Flavour, EnumMap (ContentSymbol ItemKind) (EnumSet Flavour))

-- | Build an item with the given kind and aspects.
buildItem :: COps -> AspectRecord -> FlavourMap -> DiscoveryKindRev -> ContentId ItemKind -> Item

-- | Keep in a vector the information that is retained from playthrough to
--   playthrough. The information being, e.g., ItemKindIx or
--   Flavour. The information is morally indexed by ContentId
--   ItemKind and its Enum instance fits in Word16.
keepMetaGameInformation :: ContentData ItemKind -> Vector Word16 -> Vector Word16
instance Data.Binary.Class.Binary Game.LambdaHack.Server.ItemRev.DiscoveryKindRev
instance Data.Binary.Class.Binary Game.LambdaHack.Server.ItemRev.FlavourMap
instance Data.Binary.Class.Binary Game.LambdaHack.Server.ItemRev.ItemKnown
instance GHC.Classes.Eq Game.LambdaHack.Server.ItemRev.ItemKnown
instance GHC.Internal.Generics.Generic Game.LambdaHack.Server.ItemRev.ItemKnown
instance Data.Hashable.Class.Hashable Game.LambdaHack.Server.ItemRev.ItemKnown
instance GHC.Internal.Show.Show Game.LambdaHack.Server.ItemRev.DiscoveryKindRev
instance GHC.Internal.Show.Show Game.LambdaHack.Server.ItemRev.FlavourMap
instance GHC.Internal.Show.Show Game.LambdaHack.Server.ItemRev.ItemKnown

-- | Server and client game state types and operations.
module Game.LambdaHack.Server.ServerOptions

-- | Options that affect the behaviour of the server (including game
--   rules).
data ServerOptions
ServerOptions :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Maybe (GroupName ModeKind) -> Bool -> Bool -> Maybe SMGen -> Maybe SMGen -> Bool -> Challenge -> Bool -> String -> Bool -> Maybe Int -> Bool -> Bool -> ClientOptions -> ServerOptions
[sknowMap] :: ServerOptions -> Bool
[sknowEvents] :: ServerOptions -> Bool
[sknowItems] :: ServerOptions -> Bool
[sniff] :: ServerOptions -> Bool
[sallClear] :: ServerOptions -> Bool
[sboostRandomItem] :: ServerOptions -> Bool
[sgameMode] :: ServerOptions -> Maybe (GroupName ModeKind)
[sautomateAll] :: ServerOptions -> Bool
[skeepAutomated] :: ServerOptions -> Bool
[sdungeonRng] :: ServerOptions -> Maybe SMGen
[smainRng] :: ServerOptions -> Maybe SMGen
[snewGameSer] :: ServerOptions -> Bool
[scurChalSer] :: ServerOptions -> Challenge
[sdumpInitRngs] :: ServerOptions -> Bool
[ssavePrefixSer] :: ServerOptions -> String
[sdbgMsgSer] :: ServerOptions -> Bool
[sassertExplored] :: ServerOptions -> Maybe Int
[sshowItemSamples] :: ServerOptions -> Bool
[sstopAfterGameOver] :: ServerOptions -> Bool
[sclientOptions] :: ServerOptions -> ClientOptions
data RNGs
RNGs :: Maybe SMGen -> Maybe SMGen -> RNGs
[dungeonRandomGenerator] :: RNGs -> Maybe SMGen
[startingRandomGenerator] :: RNGs -> Maybe SMGen

-- | Default value of server options.
defServerOptions :: ServerOptions
instance Data.Binary.Class.Binary Game.LambdaHack.Server.ServerOptions.RNGs
instance Data.Binary.Class.Binary Game.LambdaHack.Server.ServerOptions.ServerOptions
instance GHC.Internal.Show.Show Game.LambdaHack.Server.ServerOptions.RNGs
instance GHC.Internal.Show.Show Game.LambdaHack.Server.ServerOptions.ServerOptions

-- | The dungeon generation routine. It creates empty dungeons, without
--   actors and without items, either lying on the floor or embedded inside
--   tiles.
module Game.LambdaHack.Server.DungeonGen

-- | Freshly generated and not yet populated dungeon.
data FreshDungeon
FreshDungeon :: Dungeon -> AbsDepth -> FreshDungeon

-- | maps for all levels
[freshDungeon] :: FreshDungeon -> Dungeon

-- | absolute dungeon depth
[freshTotalDepth] :: FreshDungeon -> AbsDepth

-- | Generate the dungeon for a new game.
dungeonGen :: COps -> ServerOptions -> Caves -> Rnd FreshDungeon
convertTileMaps :: COps -> Bool -> Rnd (ContentId TileKind) -> Maybe (Rnd (ContentId TileKind)) -> Area -> TileMapEM -> Rnd TileMap
buildTileMap :: COps -> Cave -> Rnd TileMap
anchorDown :: Y
buildLevel :: COps -> ServerOptions -> LevelId -> ContentId CaveKind -> CaveKind -> Int -> Int -> AbsDepth -> [(Point, Text)] -> Rnd (Level, [(Point, Text)])
snapToStairList :: Int -> [Point] -> Point -> Either Point Point
placeDownStairs :: Text -> Bool -> ServerOptions -> LevelId -> CaveKind -> Area -> [Point] -> [Point] -> Rnd (Maybe Point)
levelFromCave :: COps -> Cave -> AbsDepth -> TileMap -> ([Point], [Point]) -> [Point] -> Level

-- | Server and client game state types and operations.
module Game.LambdaHack.Server.State

-- | State with server-specific data, including a copy of each client's
--   basic game state, but not the server's basic state.
data StateServer
StateServer :: ActorTime -> ActorTime -> ActorPushedBy -> GearOfTeams -> GearOfTeams -> EnumMap TeamContinuity Int -> FactionAnalytics -> ActorAnalytics -> GenerationAnalytics -> EnumSet ActorId -> DiscoveryKindRev -> UniqueSet -> ItemRev -> FlavourMap -> ActorId -> ItemId -> EnumMap LevelId Int -> IntMap Int -> () -> EnumMap FactionId State -> EnumMap TeamContinuity DiscoveryKind -> PerFid -> PerValidFid -> PerCacheFid -> FovLucidLid -> FovClearLid -> FovLitLid -> EnumSet LevelId -> Bool -> SMGen -> RNGs -> Bool -> Bool -> Bool -> ServerOptions -> ServerOptions -> StateServer

-- | absolute times of actors next actions
[sactorTime] :: StateServer -> ActorTime

-- | and same for actors with trajectories
[strajTime] :: StateServer -> ActorTime

-- | culprits for actors with trajectories
[strajPushedBy] :: StateServer -> ActorPushedBy

-- | metagame persistent personal characteristics and favourite gear of
--   each numbered continued team member
[steamGear] :: StateServer -> GearOfTeams

-- | gear preferences to be taken into account in the current game
[steamGearCur] :: StateServer -> GearOfTeams

-- | stores next continued team character identity index number in this
--   game
[stcounter] :: StateServer -> EnumMap TeamContinuity Int

-- | various past events data for factions
[sfactionAn] :: StateServer -> FactionAnalytics

-- | various past events data for actors
[sactorAn] :: StateServer -> ActorAnalytics

-- | item creation statistics, by item lore
[sgenerationAn] :: StateServer -> GenerationAnalytics

-- | actors currently in time stasis, invulnerable to time warps until move
[sactorStasis] :: StateServer -> EnumSet ActorId

-- | reverse map, used for item creation
[sdiscoKindRev] :: StateServer -> DiscoveryKindRev

-- | already generated unique items
[suniqueSet] :: StateServer -> UniqueSet

-- | reverse id map, used for item creation
[sitemRev] :: StateServer -> ItemRev

-- | association of flavour to item kinds
[sflavour] :: StateServer -> FlavourMap

-- | stores next actor index
[sacounter] :: StateServer -> ActorId

-- | stores next item index
[sicounter] :: StateServer -> ItemId

-- | how many spawned so far on the level
[snumSpawned] :: StateServer -> EnumMap LevelId Int

-- | how many times such group spawned
[sbandSpawned] :: StateServer -> IntMap Int
[sundo] :: StateServer -> ()

-- | each faction state, as seen by clients
[sclientStates] :: StateServer -> EnumMap FactionId State

-- | discovery info for absent factions
[smetaBackup] :: StateServer -> EnumMap TeamContinuity DiscoveryKind

-- | perception of all factions
[sperFid] :: StateServer -> PerFid

-- | perception validity for all factions
[sperValidFid] :: StateServer -> PerValidFid

-- | perception cache of all factions
[sperCacheFid] :: StateServer -> PerCacheFid

-- | ambient or shining light positions
[sfovLucidLid] :: StateServer -> FovLucidLid

-- | clear tiles positions
[sfovClearLid] :: StateServer -> FovClearLid

-- | ambient light positions
[sfovLitLid] :: StateServer -> FovLitLid

-- | the set of active arenas
[sarenas] :: StateServer -> EnumSet LevelId

-- | whether active arenas valid
[svalidArenas] :: StateServer -> Bool

-- | current random generator
[srandom] :: StateServer -> SMGen

-- | initial random generators
[srngs] :: StateServer -> RNGs

-- | exit game loop after clip's end; usually no game save follows
[sbreakLoop] :: StateServer -> Bool

-- | exit game loop ASAP; usually with save
[sbreakASAP] :: StateServer -> Bool

-- | write savegame to file after loop exit
[swriteSave] :: StateServer -> Bool

-- | current commandline options
[soptions] :: StateServer -> ServerOptions

-- | options for the next game
[soptionsNxt] :: StateServer -> ServerOptions

-- | Position in time for each actor, grouped by level and by faction.
type ActorTime = EnumMap FactionId EnumMap LevelId EnumMap ActorId Time

-- | Record who last propelled a given actor with trajectory.
type ActorPushedBy = EnumMap ActorId ActorId

-- | Initial, empty game server state.
emptyStateServer :: StateServer
updateActorTime :: FactionId -> LevelId -> ActorId -> Time -> ActorTime -> ActorTime
lookupActorTime :: FactionId -> LevelId -> ActorId -> ActorTime -> Maybe Time
ageActor :: FactionId -> LevelId -> ActorId -> Delta Time -> ActorTime -> ActorTime

-- | Per-team, per-actor metagame persistent favourite organs and gear.
type GearOfTeams = EnumMap TeamContinuity IntMap [(GroupName ItemKind, ContentId ItemKind)]
instance Data.Binary.Class.Binary Game.LambdaHack.Server.State.StateServer
instance GHC.Internal.Show.Show Game.LambdaHack.Server.State.StateServer

-- | Basic server monads and related operations.
module Game.LambdaHack.Server.MonadServer
class MonadStateRead m => MonadServer (m :: Type -> Type)
getsServer :: MonadServer m => (StateServer -> a) -> m a
modifyServer :: MonadServer m => (StateServer -> StateServer) -> m ()
chanSaveServer :: MonadServer m => m (ChanSave (State, StateServer))
liftIO :: MonadServer m => IO a -> m a

-- | The monad for executing atomic game state transformations.
class MonadServer m => MonadServerAtomic (m :: Type -> Type)

-- | Execute an atomic command that changes the state on the server and on
--   all clients that can notice it.
execUpdAtomic :: MonadServerAtomic m => UpdAtomic -> m ()

-- | Execute an atomic command that changes the state on the server only.
execUpdAtomicSer :: MonadServerAtomic m => UpdAtomic -> m Bool

-- | Execute an atomic command that changes the state on the given single
--   client only.
execUpdAtomicFid :: MonadServerAtomic m => FactionId -> UpdAtomic -> m ()

-- | Execute an atomic command that changes the state on the given single
--   client only. Catch AtomicFail and indicate if it was in fact
--   raised.
execUpdAtomicFidCatch :: MonadServerAtomic m => FactionId -> UpdAtomic -> m Bool

-- | Execute an atomic command that only displays special effects.
execSfxAtomic :: MonadServerAtomic m => SfxAtomic -> m ()
execSendPer :: MonadServerAtomic m => FactionId -> LevelId -> Perception -> Perception -> Perception -> m ()
getServer :: MonadServer m => m StateServer
putServer :: MonadServer m => StateServer -> m ()
debugPossiblyPrint :: MonadServer m => Text -> m ()
debugPossiblyPrintAndExit :: MonadServer m => Text -> m ()
serverPrint :: MonadServer m => Text -> m ()
saveServer :: MonadServer m => m ()

-- | Dumps to stdout the RNG states from the start of the game.
dumpRngs :: MonadServer m => RNGs -> m ()

-- | Read the high scores dictionary. Return the empty table if no file.
restoreScore :: MonadServer m => COps -> m ScoreDict

-- | Generate a new score, register it and save.
registerScore :: MonadServer m => Status -> FactionId -> m ()

-- | Invoke pseudo-random computation with the generator kept in the state.
rndToAction :: MonadServer m => Rnd a -> m a

-- | Gets a random generator from the user-submitted options or, if not
--   present, generates one.
getSetGen :: MonadServer m => Maybe SMGen -> m SMGen

-- | Server operations for items.
module Game.LambdaHack.Server.ItemM
registerItem :: MonadServerAtomic m => Bool -> ItemFullKit -> ItemKnown -> Container -> m ItemId
moveStashIfNeeded :: MonadStateRead m => Container -> m [UpdAtomic]
randomResetTimeout :: MonadServerAtomic m => Int -> ItemId -> ItemFull -> [ItemTimer] -> Container -> m ()
embedItemOnPos :: MonadServerAtomic m => LevelId -> Point -> ContentId TileKind -> m ()
prepareItemKind :: MonadServerAtomic m => Int -> AbsDepth -> Freqs ItemKind -> m (Frequency (GroupName ItemKind, ContentId ItemKind, ItemKind))
rollItemAspect :: MonadServerAtomic m => Frequency (GroupName ItemKind, ContentId ItemKind, ItemKind) -> AbsDepth -> m NewItem
rollAndRegisterItem :: MonadServerAtomic m => Bool -> AbsDepth -> Frequency (GroupName ItemKind, ContentId ItemKind, ItemKind) -> Container -> Maybe Int -> m (Maybe (ItemId, ItemFullKit))
placeItemsInDungeon :: MonadServerAtomic m => EnumMap LevelId (EnumMap FactionId Point) -> m ()
embedItemsInDungeon :: MonadServerAtomic m => m ()

-- | Mapping over actor's items from a give store.
mapActorCStore_ :: MonadServer m => CStore -> (ItemId -> ItemQuant -> m ()) -> Actor -> m ()
onlyRegisterItem :: MonadServerAtomic m => ItemKnown -> m ItemId
computeRndTimeout :: Time -> ItemFull -> Rnd (Maybe ItemTimer)
createCaveItem :: MonadServerAtomic m => Point -> LevelId -> m ()
createEmbedItem :: MonadServerAtomic m => LevelId -> Point -> GroupName ItemKind -> m ()

-- | Handle atomic commands on the server, after they are executed to
--   change server State and before they are sent to clients.
module Game.LambdaHack.Server.HandleAtomicM

-- | Effect of atomic actions on server state is calculated with the global
--   state from after the command is executed (except where the supplied
--   oldState is used).
cmdAtomicSemSer :: MonadServer m => State -> UpdAtomic -> m ()
validateFloor :: MonadServer m => ItemId -> LevelId -> m ()
validateFloorBag :: MonadServer m => ItemBag -> LevelId -> m ()
levelOfStash :: MonadStateRead m => ActorId -> m LevelId
invalidateArenas :: MonadServer m => m ()
updateSclear :: MonadServer m => LevelId -> Point -> ContentId TileKind -> ContentId TileKind -> m Bool
updateSlit :: MonadServer m => LevelId -> Point -> ContentId TileKind -> ContentId TileKind -> m Bool
invalidateLucidLid :: MonadServer m => LevelId -> m ()
invalidateLucidAid :: MonadServer m => ActorId -> m ()
actorHasShine :: ActorMaxSkills -> ActorId -> Bool
itemAffectsShineRadius :: DiscoveryAspect -> ItemId -> Bool
itemAffectsPerRadius :: DiscoveryAspect -> ItemId -> Bool
addPerActor :: MonadServer m => ActorId -> Actor -> m ()
addPerActorAny :: MonadServer m => ActorId -> Actor -> m ()
deletePerActor :: MonadServer m => ActorMaxSkills -> ActorId -> Actor -> m ()
deletePerActorAny :: MonadServer m => ActorId -> Actor -> m ()
invalidatePerActor :: MonadServer m => ActorId -> m ()
reconsiderPerActor :: MonadServer m => ActorId -> m ()
invalidatePerLid :: MonadServer m => LevelId -> m ()

-- | Debug output for requests and responses.
module Game.LambdaHack.Server.DebugM
debugResponse :: MonadServer m => FactionId -> Response -> m ()
debugRequestAI :: MonadServer m => ActorId -> m ()
debugRequestUI :: MonadServer m => ActorId -> m ()
debugShow :: Show a => a -> Text
debugPretty :: MonadServer m => FactionId -> Text -> UpdAtomic -> m ()
debugPlain :: MonadServer m => FactionId -> Text -> UpdAtomic -> m ()
data DebugAid
DebugAid :: Text -> ActorId -> FactionId -> LevelId -> Int64 -> Maybe Time -> Maybe Time -> Time -> DebugAid
[label] :: DebugAid -> Text
[aid] :: DebugAid -> ActorId
[faction] :: DebugAid -> FactionId
[lid] :: DebugAid -> LevelId
[bHP] :: DebugAid -> Int64
[btime] :: DebugAid -> Maybe Time
[btrTime] :: DebugAid -> Maybe Time
[time] :: DebugAid -> Time
debugAid :: MonadServer m => ActorId -> Text -> m Text
instance GHC.Internal.Show.Show Game.LambdaHack.Server.DebugM.DebugAid

-- | The server definitions for the server-client communication protocol.
module Game.LambdaHack.Server.ProtocolM
type CliSerQueue = MVar

-- | Connection information for all factions, indexed by faction
--   identifier.
type ConnServerDict = EnumMap FactionId ChanServer

-- | Connection channel between the server and a single client.
data ChanServer
ChanServer :: CliSerQueue Response -> CliSerQueue RequestAI -> Maybe (CliSerQueue RequestUI) -> ChanServer
[responseS] :: ChanServer -> CliSerQueue Response
[requestAIS] :: ChanServer -> CliSerQueue RequestAI
[requestUIS] :: ChanServer -> Maybe (CliSerQueue RequestUI)

-- | The server monad with the ability to communicate with clients.
class MonadServer m => MonadServerComm (m :: Type -> Type)
getsDict :: MonadServerComm m => (ConnServerDict -> a) -> m a
putDict :: MonadServerComm m => ConnServerDict -> m ()
liftIO :: MonadServerComm m => IO a -> m a

-- | If the AtomicFail conditions hold, send a command to client,
--   otherwise do nothing.
sendUpdate :: (MonadServerAtomic m, MonadServerComm m) => FactionId -> UpdAtomic -> m ()

-- | Send a command to client, crashing if the AtomicFail
--   conditions don't hold when executed on the client's state.
sendUpdateCheck :: (MonadServerAtomic m, MonadServerComm m) => FactionId -> UpdAtomic -> m ()
sendUpdNoState :: MonadServerComm m => FactionId -> UpdAtomic -> m ()
sendSfx :: MonadServerComm m => FactionId -> SfxAtomic -> m ()
sendQueryAI :: MonadServerComm m => FactionId -> ActorId -> m RequestAI
sendQueryUI :: (MonadServerAtomic m, MonadServerComm m) => Response -> FactionId -> ActorId -> m RequestUI
killAllClients :: (MonadServerAtomic m, MonadServerComm m) => m ()
childrenServer :: MVar [Async ()]

-- | Update connections to the new definition of factions. Connect to
--   clients in old or newly spawned threads that read and write directly
--   to the channels.
updateConn :: (MonadServerAtomic m, MonadServerComm m) => (FactionId -> ChanServer -> IO ()) -> m ()
tryRestore :: MonadServerComm m => m (Maybe (State, StateServer))
writeQueue :: MonadServerComm m => Response -> CliSerQueue Response -> m ()
readQueueAI :: MonadServerComm m => CliSerQueue RequestAI -> m RequestAI
readQueueUI :: MonadServerComm m => CliSerQueue RequestUI -> m RequestUI
newQueue :: IO (CliSerQueue a)

-- | Server operations common to many modules.
module Game.LambdaHack.Server.CommonM
revealAll :: MonadServerAtomic m => FactionId -> m ()

-- | Generate the atomic updates that jointly perform a given item move.
generalMoveItem :: MonadStateRead m => Bool -> ItemId -> Int -> Container -> Container -> m [UpdAtomic]
deduceQuits :: MonadServerAtomic m => FactionId -> Status -> m ()

-- | Save game on server and all clients.
writeSaveAll :: MonadServerAtomic m => Bool -> Bool -> m ()
verifyCaches :: MonadServer m => m ()
deduceKilled :: MonadServerAtomic m => ActorId -> m ()
electLeader :: MonadServerAtomic m => FactionId -> LevelId -> ActorId -> m ()
setFreshLeader :: MonadServerAtomic m => FactionId -> ActorId -> m ()
updatePer :: MonadServerAtomic m => FactionId -> LevelId -> m ()
projectFail :: MonadServerAtomic m => ActorId -> ActorId -> Point -> Point -> Int -> Bool -> ItemId -> CStore -> Bool -> m (Maybe ReqFailure)
addActorFromGroup :: MonadServerAtomic m => GroupName ItemKind -> FactionId -> Point -> LevelId -> Time -> m (Maybe ActorId)
registerActor :: MonadServerAtomic m => Bool -> ItemKnown -> ItemFullKit -> FactionId -> Point -> LevelId -> Time -> m ActorId
discoverIfMinorEffects :: MonadServerAtomic m => Container -> ItemId -> ContentId ItemKind -> m ()
pickWeaponServer :: MonadServer m => ActorId -> ActorId -> m (Maybe (ItemId, CStore))
currentSkillsServer :: MonadServer m => ActorId -> m Skills
allGroupItems :: MonadServerAtomic m => CStore -> GroupName ItemKind -> ActorId -> m [(ItemId, ItemQuant)]
addCondition :: MonadServerAtomic m => Bool -> GroupName ItemKind -> ActorId -> m ()
removeConditionSingle :: MonadServerAtomic m => GroupName ItemKind -> ActorId -> m Int
addSleep :: MonadServerAtomic m => ActorId -> m ()
removeSleepSingle :: MonadServerAtomic m => ActorId -> m ()
addKillToAnalytics :: MonadServerAtomic m => ActorId -> KillHow -> FactionId -> ItemId -> m ()
revealItems :: MonadServerAtomic m => FactionId -> m ()
revealPerceptionLid :: MonadServerAtomic m => FactionId -> (LevelId, Level) -> m ()
containerMoveItem :: MonadStateRead m => Bool -> ItemId -> Int -> Container -> Container -> m [UpdAtomic]
quitF :: MonadServerAtomic m => Status -> FactionId -> m ()

-- | Tell whether a faction that we know is still in game, keeps arena.
--   Keeping arena means, if the faction is still in game, it always has a
--   leader in the dungeon somewhere. So, leaderless factions and spawner
--   factions do not keep an arena, even though the latter usually has a
--   leader for most of the game.
keepArenaFact :: Faction -> Bool
anyActorsAlive :: MonadServer m => FactionId -> ActorId -> m Bool
updatePerFromNew :: MonadServerAtomic m => FactionId -> LevelId -> Perception -> m ()
recomputeCachePer :: MonadServer m => FactionId -> LevelId -> m Perception
projectBla :: MonadServerAtomic m => ActorId -> ActorId -> Point -> [Point] -> ItemId -> CStore -> Bool -> m ()
addProjectile :: MonadServerAtomic m => ActorId -> Point -> [Point] -> ItemId -> ItemQuant -> LevelId -> FactionId -> Time -> m ()
addNonProjectile :: MonadServerAtomic m => Bool -> ItemId -> ItemFullKit -> FactionId -> Point -> LevelId -> Time -> m ActorId
addActorIid :: MonadServerAtomic m => ItemId -> ItemFull -> Bool -> FactionId -> Point -> LevelId -> (Actor -> Actor) -> m ActorId
getCacheLucid :: MonadServer m => LevelId -> m FovLucid
getCacheTotal :: MonadServer m => FactionId -> LevelId -> m CacheBeforeLucid

-- | Operations for starting and restarting the game.
module Game.LambdaHack.Server.StartM
initPer :: MonadServer m => m ()
reinitGame :: MonadServerAtomic m => FactionDict -> m ()
gameReset :: MonadServer m => ServerOptions -> Maybe (GroupName ModeKind) -> Maybe SMGen -> m State

-- | Apply options that don't need a new game.
applyDebug :: MonadServer m => m ()
sampleTrunks :: MonadServerAtomic m => Dungeon -> m GenerationAnalytics
sampleItems :: MonadServerAtomic m => Dungeon -> m GenerationAnalytics
mapFromFuns :: Ord b => [a] -> [a -> b] -> Map b a
resetFactions :: ContentData FactionKind -> AbsDepth -> ModeKind -> Bool -> Rnd FactionDict
populateDungeon :: MonadServerAtomic m => m ()

-- | Find starting postions for all factions. Try to make them distant from
--   each other. Place as many of the factions, as possible, over stairs.
--   Place the first faction(s) over escape(s) (we assume they are
--   guardians of the escapes). This implies the inital factions (if any)
--   start far from escapes.
findEntryPoss :: COps -> Level -> Int -> Rnd [Point]

-- | Server operations performed periodically in the game loop and related
--   operations.
module Game.LambdaHack.Server.PeriodicM

-- | Spawn, possibly, a monster according to the level's actor groups. We
--   assume heroes are never spawned.
spawnMonster :: MonadServerAtomic m => m ()
addManyActors :: MonadServerAtomic m => Bool -> Int -> Freqs ItemKind -> LevelId -> Time -> Maybe Point -> Int -> m Bool

-- | Advance the move time for the given actor.
advanceTime :: MonadServerAtomic m => ActorId -> Int -> Bool -> m ()

-- | Advance the trajectory following time for the given actor.
advanceTimeTraj :: MonadServerAtomic m => ActorId -> m ()

-- | Add communication overhead time delta to all non-projectile, non-dying
--   faction's actors, except the leader. Effectively, this limits moves of
--   a faction on a level to 10, regardless of the number of actors and
--   their speeds. To avoid animals suddenly acting extremely sluggish
--   whenever monster's leader visits a distant arena that has a crowd of
--   animals, overhead applies only to actors on the same level. Since the
--   number of active levels is limited, this bounds the total moves per
--   turn of each faction as well.
--   
--   Leader is immune from overhead and so he is faster than other faction
--   members and of equal speed to leaders of other factions (of equal base
--   speed) regardless how numerous the faction is. Thanks to this, there
--   is no problem with leader of a numerous faction having very long UI
--   turns, introducing UI lag.
overheadActorTime :: MonadServerAtomic m => FactionId -> LevelId -> m ()

-- | Swap the relative move times of two actors (e.g., when switching a UI
--   leader). Notice that their trajectory move times are not swapped.
swapTime :: MonadServerAtomic m => ActorId -> ActorId -> m ()
updateCalm :: MonadServerAtomic m => ActorId -> Int64 -> m ()
leadLevelSwitch :: MonadServerAtomic m => m ()

-- | Continue or exit or restart the game.
endOrLoop :: (MonadServerAtomic m, MonadServerComm m) => m () -> (Maybe (GroupName ModeKind) -> m ()) -> m ()
addAnyActor :: MonadServerAtomic m => Bool -> Int -> Freqs ItemKind -> LevelId -> Time -> Maybe Point -> m (Maybe (ActorId, Point))
rollSpawnPos :: COps -> EnumSet Point -> Bool -> Bool -> LevelId -> Level -> FactionId -> State -> Rnd (Maybe Point)
gameExit :: (MonadServerAtomic m, MonadServerComm m) => m ()

-- | Handle effects. They are most often caused by requests sent by clients
--   but sometimes also caused by projectiles or periodically activated
--   items.
module Game.LambdaHack.Server.HandleEffectM
data UseResult
UseDud :: UseResult
UseId :: UseResult
UseUp :: UseResult
data EffToUse
EffBare :: EffToUse
EffBareAndOnCombine :: EffToUse
EffOnCombine :: EffToUse
data EffApplyFlags
EffApplyFlags :: EffToUse -> Bool -> Bool -> Bool -> ActivationFlag -> Bool -> EffApplyFlags
[effToUse] :: EffApplyFlags -> EffToUse
[effVoluntary] :: EffApplyFlags -> Bool
[effUseAllCopies] :: EffApplyFlags -> Bool
[effKineticPerformed] :: EffApplyFlags -> Bool
[effActivation] :: EffApplyFlags -> ActivationFlag
[effMayDestroy] :: EffApplyFlags -> Bool
applyItem :: MonadServerAtomic m => ActorId -> ItemId -> CStore -> m ()
cutCalm :: MonadServerAtomic m => ActorId -> m ()
kineticEffectAndDestroy :: MonadServerAtomic m => EffApplyFlags -> ActorId -> ActorId -> ActorId -> ItemId -> Container -> m UseResult
effectAndDestroyAndAddKill :: MonadServerAtomic m => EffApplyFlags -> ActorId -> ActorId -> ActorId -> ItemId -> Container -> ItemFull -> m UseResult
itemEffectEmbedded :: MonadServerAtomic m => EffToUse -> Bool -> ActorId -> LevelId -> Point -> ItemId -> m UseResult
highestImpression :: MonadServerAtomic m => Actor -> m (Maybe (FactionId, Int))
dominateFidSfx :: MonadServerAtomic m => ActorId -> ActorId -> ItemId -> FactionId -> m Bool

-- | Drop all actor's equipped items.
dropAllEquippedItems :: MonadServerAtomic m => ActorId -> Actor -> m ()
pickDroppable :: MonadStateRead m => Bool -> ActorId -> Actor -> m Container
consumeItems :: MonadServerAtomic m => ActorId -> EnumMap CStore ItemBag -> [(CStore, (ItemId, ItemFull))] -> m ()

-- | Drop a single actor's item (though possibly multiple copies). Note
--   that if there are multiple copies, at most one explodes to avoid
--   excessive carnage and UI clutter (let's say, the multiple explosions
--   interfere with each other or perhaps larger quantities of explosives
--   tend to be packaged more safely). Note also that OnSmash
--   effects are activated even if item discharged.
dropCStoreItem :: MonadServerAtomic m => Bool -> Bool -> CStore -> ActorId -> Actor -> Int -> ItemId -> ItemQuant -> m UseResult
applyKineticDamage :: MonadServerAtomic m => ActorId -> ActorId -> ItemId -> m Bool
refillHP :: MonadServerAtomic m => ActorId -> ActorId -> Int64 -> m ()
effectAndDestroy :: MonadServerAtomic m => EffApplyFlags -> ActorId -> ActorId -> ItemId -> Container -> ItemFull -> m UseResult
imperishableKit :: ActivationFlag -> ItemFull -> Bool

-- | The source actor affects the target actor, with a given item. If any
--   of the effects fires up, the item gets identified. Even using raw
--   damage (beating the enemy with the magic wand, for example) identifies
--   the item. This means a costly UpdDiscover is processed for
--   each random timeout weapon hit and for most projectiles, but at least
--   not for most explosion particles nor plain organs. And if not needed,
--   the UpdDiscover are eventually not sent to clients. So, enemy
--   missiles that hit us are no longer mysterious until picked up, which
--   is for the better, because the client knows their charging status and
--   so can generate accurate messages in the case when not recharged. This
--   also means that thrown consumables in flasks sturdy enough to cause
--   damage are always identified at hit, even if no effect activated. So
--   throwing them at foes is a better identification method than applying.
--   
--   Note that if we activate a durable non-passive item, e.g., a spiked
--   shield, from the ground, it will get identified, which is perfectly
--   fine, until we want to add sticky armor that can't be easily taken off
--   (and, e.g., has some maluses).
itemEffectDisco :: MonadServerAtomic m => EffApplyFlags -> ActorId -> ActorId -> ItemId -> ContentId ItemKind -> ItemKind -> Container -> [Effect] -> m UseResult

-- | Source actor affects target actor, with a given effect and it
--   strength. Both actors are on the current level and can be the same
--   actor. The item may or may not still be in the container.
effectSem :: MonadServerAtomic m => EffApplyFlags -> ActorId -> ActorId -> ItemId -> Container -> Effect -> m UseResult
effectBurn :: MonadServerAtomic m => Dice -> ActorId -> ActorId -> ItemId -> m UseResult
effectExplode :: MonadServerAtomic m => m () -> GroupName ItemKind -> ActorId -> ActorId -> Container -> m UseResult
effectRefillHP :: MonadServerAtomic m => Int -> ActorId -> ActorId -> ItemId -> m UseResult
effectRefillCalm :: MonadServerAtomic m => m () -> Int -> ActorId -> ActorId -> m UseResult
effectDominate :: MonadServerAtomic m => ActorId -> ActorId -> ItemId -> m UseResult
dominateFid :: MonadServerAtomic m => FactionId -> ActorId -> ActorId -> m ()
effectImpress :: MonadServerAtomic m => (Effect -> m UseResult) -> m () -> ActorId -> ActorId -> m UseResult
effectPutToSleep :: MonadServerAtomic m => m () -> ActorId -> m UseResult
effectYell :: MonadServerAtomic m => m () -> ActorId -> m UseResult
effectSummon :: MonadServerAtomic m => GroupName ItemKind -> Dice -> ItemId -> ActorId -> ActorId -> ActivationFlag -> m UseResult
effectAscend :: MonadServerAtomic m => (Effect -> m UseResult) -> m () -> Bool -> ActorId -> ActorId -> Container -> m UseResult
findStairExit :: MonadStateRead m => FactionId -> Bool -> LevelId -> Point -> m Point
switchLevels1 :: MonadServerAtomic m => (ActorId, Actor) -> m (Maybe ActorId)
switchLevels2 :: MonadServerAtomic m => LevelId -> Point -> (ActorId, Actor) -> Maybe Time -> Maybe Time -> Maybe ActorId -> m ()

-- | The faction leaves the dungeon.
effectEscape :: MonadServerAtomic m => m () -> ActorId -> ActorId -> m UseResult

-- | Advance target actor time by this many time clips. Not by actor moves,
--   to hurt fast actors more.
effectParalyze :: MonadServerAtomic m => m () -> Dice -> ActorId -> ActorId -> m UseResult
paralyze :: MonadServerAtomic m => m () -> Dice -> ActorId -> ActorId -> m UseResult

-- | Advance target actor time by this many time clips. Not by actor moves,
--   to hurt fast actors more. Due to water, so resistable.
effectParalyzeInWater :: MonadServerAtomic m => m () -> Dice -> ActorId -> ActorId -> m UseResult

-- | Give target actor the given number of tenths of extra move. Don't give
--   an absolute amount of time units, to benefit slow actors more.
effectInsertMove :: MonadServerAtomic m => m () -> Dice -> ActorId -> ActorId -> m UseResult

-- | Teleport the target actor. Note that projectiles can be teleported,
--   too, for extra fun.
effectTeleport :: MonadServerAtomic m => m () -> Dice -> ActorId -> ActorId -> m UseResult
effectCreateItem :: MonadServerAtomic m => Maybe FactionId -> Maybe Int -> ActorId -> ActorId -> Maybe ItemId -> CStore -> GroupName ItemKind -> TimerDice -> m UseResult

-- | Make the target actor destroy items in a store from the given group.
--   The item that caused the effect itself is *not* immune, because often
--   the item needs to destroy itself, e.g., to model wear and tear. In
--   such a case, the item may need to be identified, in a container, when
--   it no longer exists, at least in the container. This is OK. Durable
--   items are not immune, unlike the tools in ConsumeItems.
effectDestroyItem :: MonadServerAtomic m => m () -> Int -> Int -> CStore -> ActorId -> GroupName ItemKind -> m UseResult

-- | Make the target actor drop items in a store from the given group. The
--   item that caused the effect itself is immune (any copies).
effectDropItem :: MonadServerAtomic m => m () -> ItemId -> Int -> Int -> CStore -> GroupName ItemKind -> ActorId -> m UseResult

-- | Make the target actor destroy the given items, if all present, or none
--   at all, if any is missing. To be used in crafting. The item that
--   caused the effect itself is not considered (any copies).
effectConsumeItems :: MonadServerAtomic m => m () -> ItemId -> ActorId -> [(Int, GroupName ItemKind)] -> [(Int, GroupName ItemKind)] -> m UseResult
effectRecharge :: MonadServerAtomic m => Bool -> m () -> ItemId -> Int -> Dice -> ActorId -> m UseResult
effectPolyItem :: MonadServerAtomic m => m () -> ItemId -> ActorId -> m UseResult
effectRerollItem :: MonadServerAtomic m => m () -> ItemId -> ActorId -> m UseResult
effectDupItem :: MonadServerAtomic m => m () -> ItemId -> ActorId -> m UseResult
effectIdentify :: MonadServerAtomic m => m () -> ItemId -> ActorId -> m UseResult
identifyIid :: MonadServerAtomic m => ItemId -> Container -> ContentId ItemKind -> ItemKind -> m ()
effectDetect :: MonadServerAtomic m => m () -> DetectKind -> Int -> ActorId -> Container -> m UseResult
effectDetectX :: MonadServerAtomic m => DetectKind -> (Point -> Bool) -> ([Point] -> m Bool) -> m () -> Int -> ActorId -> m UseResult

-- | Send the target actor flying like a projectile. If the actors are
--   adjacent, the vector is directed outwards, if no, inwards, if it's the
--   same actor, boldpos is used, if it can't, a random outward vector of
--   length 10 is picked.
effectSendFlying :: MonadServerAtomic m => m () -> ThrowMod -> ActorId -> ActorId -> Container -> Maybe Bool -> m UseResult
sendFlyingVector :: MonadServerAtomic m => ActorId -> ActorId -> Container -> Maybe Bool -> m Vector
effectApplyPerfume :: MonadServerAtomic m => m () -> ActorId -> m UseResult
effectAtMostOneOf :: MonadServerAtomic m => (Effect -> m UseResult) -> [Effect] -> m UseResult
effectOneOf :: MonadServerAtomic m => (Effect -> m UseResult) -> [Effect] -> m UseResult
effectAndEffect :: MonadServerAtomic m => (Effect -> m UseResult) -> ActorId -> Effect -> Effect -> m UseResult
effectAndEffectSem :: MonadServerAtomic m => (Effect -> m UseResult) -> Effect -> Effect -> m UseResult
effectOrEffect :: MonadServerAtomic m => (Effect -> m UseResult) -> FactionId -> Effect -> Effect -> m UseResult
effectSeqEffect :: MonadServerAtomic m => (Effect -> m UseResult) -> [Effect] -> m UseResult
effectWhen :: MonadServerAtomic m => (Effect -> m UseResult) -> ActorId -> Condition -> Effect -> ActivationFlag -> m UseResult
effectUnless :: MonadServerAtomic m => (Effect -> m UseResult) -> ActorId -> Condition -> Effect -> ActivationFlag -> m UseResult
effectIfThenElse :: MonadServerAtomic m => (Effect -> m UseResult) -> ActorId -> Condition -> Effect -> Effect -> ActivationFlag -> m UseResult
effectVerbNoLonger :: MonadServerAtomic m => Bool -> m () -> ActorId -> m UseResult
effectVerbMsg :: MonadServerAtomic m => m () -> ActorId -> m UseResult
effectVerbMsgFail :: MonadServerAtomic m => m () -> ActorId -> m UseResult
instance GHC.Classes.Eq Game.LambdaHack.Server.HandleEffectM.EffToUse
instance GHC.Classes.Eq Game.LambdaHack.Server.HandleEffectM.UseResult
instance GHC.Classes.Ord Game.LambdaHack.Server.HandleEffectM.UseResult

-- | Semantics of requests . A couple of them do not take time, the rest
--   does. Note that since the results are atomic commands, which are
--   executed only later (on the server and some of the clients), all
--   condition are checkd by the semantic functions in the context of the
--   state before the server command. Even if one or more atomic actions
--   are already issued by the point an expression is evaluated, they do
--   not influence the outcome of the evaluation.
module Game.LambdaHack.Server.HandleRequestM

-- | The semantics of server commands. AI always takes time and so doesn't
--   loop.
handleRequestAI :: MonadServerAtomic m => ReqAI -> m (Maybe RequestTimed)

-- | The semantics of server commands. Only the first two cases affect
--   time.
handleRequestUI :: MonadServerAtomic m => FactionId -> ActorId -> ReqUI -> m (Maybe RequestTimed)
handleRequestTimed :: MonadServerAtomic m => FactionId -> ActorId -> RequestTimed -> m Bool
switchLeader :: MonadServerAtomic m => FactionId -> ActorId -> m ()
reqMoveGeneric :: MonadServerAtomic m => Bool -> Bool -> ActorId -> Vector -> m ()
reqDisplaceGeneric :: MonadServerAtomic m => Bool -> ActorId -> ActorId -> m ()
reqAlterFail :: MonadServerAtomic m => Bool -> EffToUse -> Bool -> ActorId -> Point -> m (Maybe ReqFailure)
reqGameDropAndExit :: MonadServerAtomic m => ActorId -> m ()
reqGameSaveAndExit :: MonadServerAtomic m => ActorId -> m ()
execFailure :: MonadServerAtomic m => ActorId -> RequestTimed -> ReqFailure -> m ()
checkWaiting :: RequestTimed -> Maybe Bool

-- | This is a shorthand. Instead of setting bwatch in
--   ReqWait and unsetting in all other requests, we call this
--   once after executing a request. In game state, we collect the number
--   of server requests pertaining to the actor (the number of actor's
--   "moves"), through which the actor was waiting.
processWatchfulness :: MonadServerAtomic m => Maybe Bool -> ActorId -> m ()
affectStash :: MonadServerAtomic m => Actor -> m ()

-- | Clear deltas for Calm and HP for proper UI display and AI hints.
managePerRequest :: MonadServerAtomic m => ActorId -> m ()
handleRequestTimedCases :: MonadServerAtomic m => ActorId -> RequestTimed -> m ()

-- | Add a smell trace for the actor to the level. If smell already there
--   and the actor can smell, remove smell. Projectiles are ignored. As
--   long as an actor can smell, he doesn't leave any smell ever. Smell
--   trace is never left in water tiles.
affectSmell :: MonadServerAtomic m => ActorId -> m ()

-- | Actor moves or attacks or alters by bumping. Note that client may not
--   be able to see an invisible monster so it's the server that determines
--   if melee took place, etc. Also, only the server is authorized to check
--   if a move is legal and it needs full context for that, e.g., the
--   initial actor position to check if melee attack does not try to reach
--   to a distant tile.
reqMove :: MonadServerAtomic m => ActorId -> Vector -> m ()

-- | Resolves the result of an actor moving into another. Actors on
--   unwalkable positions can be attacked without any restrictions. For
--   instance, an actor embedded in a wall can be attacked from an adjacent
--   position. This function is analogous to projectGroupItem, but for
--   melee and not using up the weapon. No problem if there are many
--   projectiles at the spot. We just attack the one specified.
reqMelee :: MonadServerAtomic m => ActorId -> ActorId -> ItemId -> CStore -> m ()
reqMeleeChecked :: MonadServerAtomic m => Bool -> ActorId -> ActorId -> ItemId -> CStore -> m ()

-- | Actor tries to swap positions with another.
reqDisplace :: MonadServerAtomic m => ActorId -> ActorId -> m ()

-- | Search and/or alter the tile.
reqAlter :: MonadServerAtomic m => ActorId -> Point -> m ()

-- | Do nothing. Wait skill 1 required. Bracing requires 2, sleep 3,
--   lurking 4.
--   
--   Something is sometimes done in processWatchfulness.
reqWait :: MonadServerAtomic m => ActorId -> m ()

-- | Do nothing.
--   
--   Something is sometimes done in processWatchfulness.
reqWait10 :: MonadServerAtomic m => ActorId -> m ()

-- | Yellyawnstretch/taunt. Wakes up (gradually) from sleep. Causes
--   noise heard by enemies on the level even if out of their hearing
--   range.
--   
--   Governed by the waiting skill (because everyone is supposed to have
--   it). unlike ReqWait, induces overhead.
--   
--   This is similar to the effect Yell, but always voluntary.
reqYell :: MonadServerAtomic m => ActorId -> m ()
reqMoveItems :: MonadServerAtomic m => ActorId -> [(ItemId, Int, CStore, CStore)] -> m ()
reqMoveItem :: MonadServerAtomic m => Bool -> ActorId -> Bool -> (ItemId, Int, CStore, CStore) -> m ()
reqProject :: MonadServerAtomic m => ActorId -> Point -> Int -> ItemId -> CStore -> m ()
reqApply :: MonadServerAtomic m => ActorId -> ItemId -> CStore -> m ()
reqGameRestart :: MonadServerAtomic m => ActorId -> GroupName ModeKind -> Challenge -> m ()
reqGameSave :: MonadServer m => m ()
reqDoctrine :: MonadServerAtomic m => FactionId -> Doctrine -> m ()
reqAutomate :: MonadServerAtomic m => FactionId -> m ()

-- | The main loop of the server, processing human and computer player
--   moves turn by turn.
module Game.LambdaHack.Server.LoopM

-- | Start a game session, including the clients, and then loop,
--   communicating with the clients.
--   
--   The loop is started in server state that is empty, see
--   emptyStateServer.
loopSer :: (MonadServerAtomic m, MonadServerComm m) => ServerOptions -> (Bool -> FactionId -> ChanServer -> IO ()) -> m ()
factionArena :: MonadStateRead m => Faction -> m (Maybe LevelId)
arenasForLoop :: MonadStateRead m => m (EnumSet LevelId)
handleFidUpd :: (MonadServerAtomic m, MonadServerComm m) => (FactionId -> m ()) -> FactionId -> Faction -> m ()

-- | Handle a clip (the smallest fraction of a game turn for which a frame
--   may potentially be generated). Run the leader and other actors moves.
--   Eventually advance the time and repeat.
loopUpd :: (MonadServerAtomic m, MonadServerComm m) => m () -> m ()

-- | Handle the end of every clip. Do whatever has to be done every fixed
--   number of clips, e.g., monster generation. Advance time. Perform
--   periodic saves, if applicable.
--   
--   This is never run if UI requested save or exit or restart and it's
--   correct, because we know nobody moved and no time was or needs to be
--   advanced and arenas are not changed. After game was saved and exited,
--   on game resume the first clip is performed with empty arenas, so arena
--   time is not updated and nobody moves, nor anything happens, but arenas
--   are here correctly updated.
endClip :: MonadServerAtomic m => (FactionId -> m ()) -> m ()

-- | Check if the given actor is dominated and update his calm.
manageCalmAndDomination :: MonadServerAtomic m => ActorId -> Actor -> m ()

-- | Trigger periodic items for all actors on the given level.
applyPeriodicLevel :: MonadServerAtomic m => m ()
handleTrajectories :: MonadServerAtomic m => LevelId -> FactionId -> m ()
hTrajectories :: MonadServerAtomic m => ActorId -> m ()

-- | Manage trajectory of a projectile or a pushed other actor.
--   
--   Colliding with a wall or actor doesn't take time, because the
--   projectile does not move (the move is blocked). Not advancing time
--   forces dead projectiles to be destroyed ASAP. Otherwise, with some
--   timings, it can stay on the game map dead, blocking path of
--   human-controlled actors and alarming the hapless human.
advanceTrajectory :: MonadServerAtomic m => ActorId -> Actor -> m ()
handleActors :: (MonadServerAtomic m, MonadServerComm m) => LevelId -> FactionId -> m Bool
hActors :: (MonadServerAtomic m, MonadServerComm m) => [ActorId] -> m Bool
handleUIunderAI :: (MonadServerAtomic m, MonadServerComm m) => FactionId -> ActorId -> m ()
dieSer :: MonadServerAtomic m => ActorId -> Actor -> m ()
restartGame :: MonadServerAtomic m => m () -> m () -> Maybe (GroupName ModeKind) -> m ()

-- | Sending atomic commands to clients and executing them on the server.
--   
--   See
--   https://github.com/LambdaHack/LambdaHack/wiki/Client-server-architecture.
module Game.LambdaHack.Server.BroadcastAtomic

-- | Send an atomic action to all clients that can see it.
handleAndBroadcast :: (MonadServerAtomic m, MonadServerComm m) => PosAtomic -> [UpdAtomic] -> CmdAtomic -> m ()
sendPer :: (MonadServerAtomic m, MonadServerComm m) => FactionId -> LevelId -> Perception -> Perception -> Perception -> m ()
handleCmdAtomicServer :: MonadServerAtomic m => UpdAtomic -> m (PosAtomic, [UpdAtomic], Bool)
cmdItemsFromIids :: [ItemId] -> State -> State -> [UpdAtomic]

-- | Messages for some unseen atomic commands.
hearUpdAtomic :: MonadStateRead m => UpdAtomic -> m (Bool, Maybe Point)

-- | Messages for some unseen sfx.
hearSfxAtomic :: MonadServer m => SfxAtomic -> m (Maybe (HearMsg, Bool, Point))
filterHear :: MonadStateRead m => Point -> [(ActorId, Actor)] -> m [ActorId]
atomicForget :: FactionId -> LevelId -> Perception -> State -> [UpdAtomic]
atomicRemember :: LevelId -> Perception -> State -> State -> [UpdAtomic]

-- | Parsing of commandline arguments.
module Game.LambdaHack.Server.Commandline

-- | Parser for server options from commandline arguments.
serverOptionsPI :: ParserInfo ServerOptions
serverOptionsP :: Parser ServerOptions

-- | Semantics of requests that are sent by clients to the server, in terms
--   of game state changes and responses to be sent to the clients.
--   
--   See
--   https://github.com/LambdaHack/LambdaHack/wiki/Client-server-architecture.
module Game.LambdaHack.Server

-- | Start a game session, including the clients, and then loop,
--   communicating with the clients.
--   
--   The loop is started in server state that is empty, see
--   emptyStateServer.
loopSer :: (MonadServerAtomic m, MonadServerComm m) => ServerOptions -> (Bool -> FactionId -> ChanServer -> IO ()) -> m ()

-- | Connection channel between the server and a single client.
data ChanServer
ChanServer :: CliSerQueue Response -> CliSerQueue RequestAI -> Maybe (CliSerQueue RequestUI) -> ChanServer
[responseS] :: ChanServer -> CliSerQueue Response
[requestAIS] :: ChanServer -> CliSerQueue RequestAI
[requestUIS] :: ChanServer -> Maybe (CliSerQueue RequestUI)

-- | Parser for server options from commandline arguments.
serverOptionsPI :: ParserInfo ServerOptions

-- | Options that affect the behaviour of the server (including game
--   rules).
data ServerOptions
ServerOptions :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Maybe (GroupName ModeKind) -> Bool -> Bool -> Maybe SMGen -> Maybe SMGen -> Bool -> Challenge -> Bool -> String -> Bool -> Maybe Int -> Bool -> Bool -> ClientOptions -> ServerOptions
[sknowMap] :: ServerOptions -> Bool
[sknowEvents] :: ServerOptions -> Bool
[sknowItems] :: ServerOptions -> Bool
[sniff] :: ServerOptions -> Bool
[sallClear] :: ServerOptions -> Bool
[sboostRandomItem] :: ServerOptions -> Bool
[sgameMode] :: ServerOptions -> Maybe (GroupName ModeKind)
[sautomateAll] :: ServerOptions -> Bool
[skeepAutomated] :: ServerOptions -> Bool
[sdungeonRng] :: ServerOptions -> Maybe SMGen
[smainRng] :: ServerOptions -> Maybe SMGen
[snewGameSer] :: ServerOptions -> Bool
[scurChalSer] :: ServerOptions -> Challenge
[sdumpInitRngs] :: ServerOptions -> Bool
[ssavePrefixSer] :: ServerOptions -> String
[sdbgMsgSer] :: ServerOptions -> Bool
[sassertExplored] :: ServerOptions -> Maybe Int
[sshowItemSamples] :: ServerOptions -> Bool
[sstopAfterGameOver] :: ServerOptions -> Bool
[sclientOptions] :: ServerOptions -> ClientOptions

-- | The implementation of our custom game client monads. Just as any other
--   component of the library, this implementation can be substituted.
module Implementation.MonadClientImplementation

-- | Run the main client loop, with the given arguments and empty initial
--   states, in the IO monad.
executorCli :: CCUI -> UIOptions -> ClientOptions -> Bool -> COps -> FactionId -> ChanServer -> IO ()
data CliState
CliState :: State -> StateClient -> Maybe SessionUI -> ChanServer -> ChanSave (StateClient, Maybe SessionUI) -> CliState

-- | current global state
[cliState] :: CliState -> State

-- | current client state
[cliClient] :: CliState -> StateClient

-- | UI state, empty for AI clients
[cliSession] :: CliState -> Maybe SessionUI

-- | this client connection information
[cliDict] :: CliState -> ChanServer

-- | connection to the save thread
[cliToSave] :: CliState -> ChanSave (StateClient, Maybe SessionUI)

-- | Client state transformation monad.
newtype CliImplementation a
CliImplementation :: StateT CliState IO a -> CliImplementation a
[runCliImplementation] :: CliImplementation a -> StateT CliState IO a
instance GHC.Internal.Base.Applicative Implementation.MonadClientImplementation.CliImplementation
instance GHC.Internal.Base.Functor Implementation.MonadClientImplementation.CliImplementation
instance GHC.Internal.Base.Monad Implementation.MonadClientImplementation.CliImplementation
instance Game.LambdaHack.Client.HandleResponseM.MonadClientAtomic Implementation.MonadClientImplementation.CliImplementation
instance Game.LambdaHack.Client.MonadClient.MonadClient Implementation.MonadClientImplementation.CliImplementation
instance Game.LambdaHack.Client.MonadClient.MonadClientRead Implementation.MonadClientImplementation.CliImplementation
instance Game.LambdaHack.Client.LoopM.MonadClientReadResponse Implementation.MonadClientImplementation.CliImplementation
instance Game.LambdaHack.Client.HandleAtomicM.MonadClientSetup Implementation.MonadClientImplementation.CliImplementation
instance Game.LambdaHack.Client.UI.MonadClientUI.MonadClientUI Implementation.MonadClientImplementation.CliImplementation
instance Game.LambdaHack.Client.HandleResponseM.MonadClientWriteRequest Implementation.MonadClientImplementation.CliImplementation
instance Game.LambdaHack.Common.MonadStateRead.MonadStateRead Implementation.MonadClientImplementation.CliImplementation
instance Game.LambdaHack.Atomic.MonadStateWrite.MonadStateWrite Implementation.MonadClientImplementation.CliImplementation

-- | The implementation of our custom game server monads. Just as any other
--   component of the library, this implementation can be substituted.
module Implementation.MonadServerImplementation

-- | Run the main server loop, with the given arguments and empty initial
--   states, in the IO monad.
executorSer :: COps -> CCUI -> ServerOptions -> UIOptions -> IO ()
data SerState
SerState :: State -> StateServer -> ConnServerDict -> ChanSave (State, StateServer) -> SerState

-- | current global state
[serState] :: SerState -> State

-- | current server state
[serServer] :: SerState -> StateServer

-- | client-server connection information
[serDict] :: SerState -> ConnServerDict

-- | connection to the save thread
[serToSave] :: SerState -> ChanSave (State, StateServer)

-- | Server state transformation monad.
newtype SerImplementation a
SerImplementation :: StateT SerState IO a -> SerImplementation a
[runSerImplementation] :: SerImplementation a -> StateT SerState IO a
instance GHC.Internal.Base.Applicative Implementation.MonadServerImplementation.SerImplementation
instance GHC.Internal.Base.Functor Implementation.MonadServerImplementation.SerImplementation
instance GHC.Internal.Base.Monad Implementation.MonadServerImplementation.SerImplementation
instance Game.LambdaHack.Server.MonadServer.MonadServerAtomic Implementation.MonadServerImplementation.SerImplementation
instance Game.LambdaHack.Server.ProtocolM.MonadServerComm Implementation.MonadServerImplementation.SerImplementation
instance Game.LambdaHack.Server.MonadServer.MonadServer Implementation.MonadServerImplementation.SerImplementation
instance Game.LambdaHack.Common.MonadStateRead.MonadStateRead Implementation.MonadServerImplementation.SerImplementation
instance Game.LambdaHack.Atomic.MonadStateWrite.MonadStateWrite Implementation.MonadServerImplementation.SerImplementation

-- | Game rules and assorted game setup data.
module Content.RuleKind
standardRules :: RuleContent

-- | Actor organ definitions.
module Content.ItemKindOrgan
pattern S_FIST :: GroupName ItemKind
pattern S_FOOT :: GroupName ItemKind
pattern S_HOOKED_CLAW :: GroupName ItemKind
pattern S_SMALL_CLAW :: GroupName ItemKind
pattern S_SNOUT :: GroupName ItemKind
pattern S_SMALL_JAW :: GroupName ItemKind
pattern S_JAW :: GroupName ItemKind
pattern S_LARGE_JAW :: GroupName ItemKind
pattern S_ANTLER :: GroupName ItemKind
pattern S_HORN :: GroupName ItemKind
pattern S_RHINO_HORN :: GroupName ItemKind
pattern S_TENTACLE :: GroupName ItemKind
pattern S_TIP :: GroupName ItemKind
pattern S_LIP :: GroupName ItemKind
pattern S_THORN :: GroupName ItemKind
pattern S_BOILING_FISSURE :: GroupName ItemKind
pattern S_ARSENIC_FISSURE :: GroupName ItemKind
pattern S_SULFUR_FISSURE :: GroupName ItemKind
pattern S_BEE_STING :: GroupName ItemKind
pattern S_STING :: GroupName ItemKind
pattern S_VENOM_TOOTH :: GroupName ItemKind
pattern S_VENOM_FANG :: GroupName ItemKind
pattern S_SCREECHING_BEAK :: GroupName ItemKind
pattern S_LARGE_TAIL :: GroupName ItemKind
pattern S_HUGE_TAIL :: GroupName ItemKind
pattern S_ARMORED_SKIN :: GroupName ItemKind
pattern S_BARK :: GroupName ItemKind
pattern S_NOSTRIL :: GroupName ItemKind
pattern S_RATLLE :: GroupName ItemKind
pattern S_INSECT_MORTALITY :: GroupName ItemKind
pattern S_SAPIENT_BRAIN :: GroupName ItemKind
pattern S_ANIMAL_BRAIN :: GroupName ItemKind
pattern S_SCENT_GLAND :: GroupName ItemKind
pattern S_BOILING_VENT :: GroupName ItemKind
pattern S_ARSENIC_VENT :: GroupName ItemKind
pattern S_SULFUR_VENT :: GroupName ItemKind
pattern S_EYE_3 :: GroupName ItemKind
pattern S_EYE_6 :: GroupName ItemKind
pattern S_EYE_8 :: GroupName ItemKind
pattern S_VISION_6 :: GroupName ItemKind
pattern S_VISION_12 :: GroupName ItemKind
pattern S_VISION_16 :: GroupName ItemKind
pattern S_EAR_3 :: GroupName ItemKind
pattern S_EAR_6 :: GroupName ItemKind
pattern S_EAR_8 :: GroupName ItemKind
pattern S_SPEED_GLAND_5 :: GroupName ItemKind
pattern S_SPEED_GLAND_10 :: GroupName ItemKind
pattern SCAVENGER :: GroupName ItemKind
pattern S_TOOTH :: GroupName ItemKind
pattern S_LASH :: GroupName ItemKind
pattern S_RIGHT_TORSION :: GroupName ItemKind
pattern S_LEFT_TORSION :: GroupName ItemKind
pattern S_PUPIL :: GroupName ItemKind
organsGNSingleton :: [GroupName ItemKind]
organsGN :: [GroupName ItemKind]
organs :: [ItemKind]

-- | Actor (or rather actor body trunk) definitions.
module Content.ItemKindActor
pattern S_WOODEN_TORCH :: GroupName ItemKind
pattern S_SANDSTONE_ROCK :: GroupName ItemKind
pattern HERO :: GroupName ItemKind
pattern SCOUT_HERO :: GroupName ItemKind
pattern RANGER_HERO :: GroupName ItemKind
pattern ESCAPIST_HERO :: GroupName ItemKind
pattern AMBUSHER_HERO :: GroupName ItemKind
pattern BRAWLER_HERO :: GroupName ItemKind
pattern SOLDIER_HERO :: GroupName ItemKind
pattern CIVILIAN :: GroupName ItemKind
pattern MONSTER :: GroupName ItemKind
pattern MOBILE_MONSTER :: GroupName ItemKind
pattern SCOUT_MONSTER :: GroupName ItemKind
pattern ANIMAL :: GroupName ItemKind
pattern MOBILE_ANIMAL :: GroupName ItemKind
pattern IMMOBILE_ANIMAL :: GroupName ItemKind
pattern INSECT :: GroupName ItemKind
pattern GEOPHENOMENON :: GroupName ItemKind
pattern ADD_SIGHT :: GroupName ItemKind
pattern ARMOR_RANGED :: GroupName ItemKind
pattern ADD_NOCTO_1 :: GroupName ItemKind
pattern WEAK_ARROW :: GroupName ItemKind
pattern LIGHT_ATTENUATOR :: GroupName ItemKind
pattern FIREPROOF_CLOTH :: GroupName ItemKind
pattern RING_OF_OPPORTUNITY_SNIPER :: GroupName ItemKind
pattern ANY_ARROW :: GroupName ItemKind
pattern STARTING_ARMOR :: GroupName ItemKind
pattern STARTING_WEAPON :: GroupName ItemKind
pattern GEM :: GroupName ItemKind
actorsGN :: [GroupName ItemKind]
actorsGNSingleton :: [GroupName ItemKind]
actors :: [ItemKind]

-- | Definitions of items embedded in map tiles.
module Content.ItemKindEmbed
pattern SCRATCH_ON_WALL :: GroupName ItemKind
pattern OBSCENE_PICTOGRAM :: GroupName ItemKind
pattern SUBTLE_FRESCO :: GroupName ItemKind
pattern TREASURE_CACHE :: GroupName ItemKind
pattern TREASURE_CACHE_TRAP :: GroupName ItemKind
pattern SIGNAGE :: GroupName ItemKind
pattern SMALL_FIRE :: GroupName ItemKind
pattern BIG_FIRE :: GroupName ItemKind
pattern FROST :: GroupName ItemKind
pattern RUBBLE :: GroupName ItemKind
pattern DOORWAY_TRAP_UNKNOWN :: GroupName ItemKind
pattern DOORWAY_TRAP :: GroupName ItemKind
pattern STAIRS_UP :: GroupName ItemKind
pattern STAIRS_DOWN :: GroupName ItemKind
pattern ESCAPE :: GroupName ItemKind
pattern STAIRS_TRAP_UP :: GroupName ItemKind
pattern STAIRS_TRAP_DOWN :: GroupName ItemKind
pattern LECTERN :: GroupName ItemKind
pattern SHALLOW_WATER :: GroupName ItemKind
pattern STRAIGHT_PATH :: GroupName ItemKind
pattern FROZEN_GROUND :: GroupName ItemKind
embedsGN :: [GroupName ItemKind]
embeds :: [ItemKind]

-- | Definitions of tile kinds. Every terrain tile in the game is an
--   instantiated tile kind.
module Content.TileKind
pattern FILLER_WALL :: GroupName TileKind
pattern FLOOR_CORRIDOR_LIT :: GroupName TileKind
pattern FLOOR_CORRIDOR_DARK :: GroupName TileKind
pattern TRAIL_LIT :: GroupName TileKind
pattern SAFE_TRAIL_LIT :: GroupName TileKind
pattern LAB_TRAIL_LIT :: GroupName TileKind
pattern DAMP_FLOOR_LIT :: GroupName TileKind
pattern DAMP_FLOOR_DARK :: GroupName TileKind
pattern OUTDOOR_OUTER_FENCE :: GroupName TileKind
pattern DIRT_LIT :: GroupName TileKind
pattern DIRT_DARK :: GroupName TileKind
pattern FLOOR_ARENA_LIT :: GroupName TileKind
pattern FLOOR_ARENA_DARK :: GroupName TileKind
pattern EMPTY_SET_LIT :: GroupName TileKind
pattern EMPTY_SET_DARK :: GroupName TileKind
pattern NOISE_SET_LIT :: GroupName TileKind
pattern POWER_SET_LIT :: GroupName TileKind
pattern POWER_SET_DARK :: GroupName TileKind
pattern BATTLE_SET_LIT :: GroupName TileKind
pattern BATTLE_SET_DARK :: GroupName TileKind
pattern BRAWL_SET_LIT :: GroupName TileKind
pattern SHOOTOUT_SET_LIT :: GroupName TileKind
pattern ZOO_SET_LIT :: GroupName TileKind
pattern ZOO_SET_DARK :: GroupName TileKind
pattern FLIGHT_SET_LIT :: GroupName TileKind
pattern FLIGHT_SET_DARK :: GroupName TileKind
pattern AMBUSH_SET_LIT :: GroupName TileKind
pattern AMBUSH_SET_DARK :: GroupName TileKind
pattern ARENA_SET_LIT :: GroupName TileKind
pattern ARENA_SET_DARK :: GroupName TileKind
pattern RECT_WINDOWS_VERTICAL_LIT :: GroupName TileKind
pattern RECT_WINDOWS_VERTICAL_DARK :: GroupName TileKind
pattern RECT_WINDOWS_HORIZONTAL_LIT :: GroupName TileKind
pattern RECT_WINDOWS_HORIZONTAL_DARK :: GroupName TileKind
pattern TREE_SHADE_WALKABLE_LIT :: GroupName TileKind
pattern TREE_SHADE_WALKABLE_DARK :: GroupName TileKind
pattern SMOKE_CLUMP_LIT :: GroupName TileKind
pattern SMOKE_CLUMP_DARK :: GroupName TileKind
pattern GLASSHOUSE_VERTICAL_LIT :: GroupName TileKind
pattern GLASSHOUSE_VERTICAL_DARK :: GroupName TileKind
pattern GLASSHOUSE_HORIZONTAL_LIT :: GroupName TileKind
pattern GLASSHOUSE_HORIZONTAL_DARK :: GroupName TileKind
pattern BUSH_CLUMP_LIT :: GroupName TileKind
pattern BUSH_CLUMP_DARK :: GroupName TileKind
pattern FOG_CLUMP_LIT :: GroupName TileKind
pattern FOG_CLUMP_DARK :: GroupName TileKind
pattern STAIR_TERMINAL_LIT :: GroupName TileKind
pattern STAIR_TERMINAL_DARK :: GroupName TileKind
pattern CACHE :: GroupName TileKind
pattern SIGNBOARD :: GroupName TileKind
pattern STAIRCASE_UP :: GroupName TileKind
pattern ORDINARY_STAIRCASE_UP :: GroupName TileKind
pattern STAIRCASE_OUTDOOR_UP :: GroupName TileKind
pattern GATED_STAIRCASE_UP :: GroupName TileKind
pattern STAIRCASE_DOWN :: GroupName TileKind
pattern ORDINARY_STAIRCASE_DOWN :: GroupName TileKind
pattern STAIRCASE_OUTDOOR_DOWN :: GroupName TileKind
pattern GATED_STAIRCASE_DOWN :: GroupName TileKind
pattern TILE_INDOOR_ESCAPE_UP :: GroupName TileKind
pattern TILE_INDOOR_ESCAPE_DOWN :: GroupName TileKind
pattern TILE_OUTDOOR_ESCAPE_DOWN :: GroupName TileKind
pattern FLOOR_ACTOR_ITEM_LIT :: GroupName TileKind
pattern FLOOR_ACTOR_ITEM_DARK :: GroupName TileKind
pattern S_PILLAR :: GroupName TileKind
pattern S_RUBBLE_PILE :: GroupName TileKind
pattern S_LAMP_POST :: GroupName TileKind
pattern S_TREE_LIT :: GroupName TileKind
pattern S_TREE_DARK :: GroupName TileKind
pattern S_WALL_LIT :: GroupName TileKind
pattern S_WALL_DARK :: GroupName TileKind
pattern S_WALL_HORIZONTAL_LIT :: GroupName TileKind
pattern S_WALL_HORIZONTAL_DARK :: GroupName TileKind
pattern S_PULPIT :: GroupName TileKind
pattern S_BUSH_LIT :: GroupName TileKind
pattern S_FOG_LIT :: GroupName TileKind
pattern S_SMOKE_LIT :: GroupName TileKind
pattern S_FLOOR_ACTOR_LIT :: GroupName TileKind
pattern S_FLOOR_ACTOR_DARK :: GroupName TileKind
pattern S_FLOOR_ASHES_LIT :: GroupName TileKind
pattern S_FLOOR_ASHES_DARK :: GroupName TileKind
pattern S_SHADED_GROUND :: GroupName TileKind
pattern S_SHALLOW_WATER_LIT :: GroupName TileKind
pattern S_SHALLOW_WATER_DARK :: GroupName TileKind
groupNamesSingleton :: [GroupName TileKind]
groupNames :: [GroupName TileKind]
content :: [TileKind]

-- | Definitions of place kinds. Every room in the game is an instantiated
--   place kind.
module Content.PlaceKind
pattern ROGUE :: GroupName PlaceKind
pattern LABORATORY :: GroupName PlaceKind
pattern ZOO :: GroupName PlaceKind
pattern BRAWL :: GroupName PlaceKind
pattern SHOOTOUT :: GroupName PlaceKind
pattern ARENA :: GroupName PlaceKind
pattern FLIGHT :: GroupName PlaceKind
pattern AMBUSH :: GroupName PlaceKind
pattern BATTLE :: GroupName PlaceKind
pattern NOISE :: GroupName PlaceKind
pattern MINE :: GroupName PlaceKind
pattern EMPTY :: GroupName PlaceKind
pattern INDOOR_ESCAPE_DOWN :: GroupName PlaceKind
pattern INDOOR_ESCAPE_UP :: GroupName PlaceKind
pattern OUTDOOR_ESCAPE_DOWN :: GroupName PlaceKind
pattern TINY_STAIRCASE :: GroupName PlaceKind
pattern OPEN_STAIRCASE :: GroupName PlaceKind
pattern CLOSED_STAIRCASE :: GroupName PlaceKind
pattern WALLED_STAIRCASE :: GroupName PlaceKind
pattern GATED_TINY_STAIRCASE :: GroupName PlaceKind
pattern GATED_OPEN_STAIRCASE :: GroupName PlaceKind
pattern GATED_CLOSED_STAIRCASE :: GroupName PlaceKind
pattern OUTDOOR_TINY_STAIRCASE :: GroupName PlaceKind
pattern OUTDOOR_CLOSED_STAIRCASE :: GroupName PlaceKind
pattern OUTDOOR_WALLED_STAIRCASE :: GroupName PlaceKind
groupNamesSingleton :: [GroupName PlaceKind]
groupNames :: [GroupName PlaceKind]
content :: [PlaceKind]

-- | Definitions of kinds of factions present in a game, both human and
--   computer-controlled.
module Content.FactionKind
pattern EXPLORER_REPRESENTATIVE :: GroupName FactionKind
pattern EXPLORER_SHORT :: GroupName FactionKind
pattern EXPLORER_NO_ESCAPE :: GroupName FactionKind
pattern EXPLORER_MEDIUM :: GroupName FactionKind
pattern EXPLORER_TRAPPED :: GroupName FactionKind
pattern EXPLORER_AUTOMATED :: GroupName FactionKind
pattern EXPLORER_AUTOMATED_TRAPPED :: GroupName FactionKind
pattern EXPLORER_CAPTIVE :: GroupName FactionKind
pattern EXPLORER_PACIFIST :: GroupName FactionKind
pattern COMPETITOR_REPRESENTATIVE :: GroupName FactionKind
pattern COMPETITOR_SHORT :: GroupName FactionKind
pattern COMPETITOR_NO_ESCAPE :: GroupName FactionKind
pattern CIVILIAN_REPRESENTATIVE :: GroupName FactionKind
pattern CONVICT_REPRESENTATIVE :: GroupName FactionKind
pattern MONSTER_REPRESENTATIVE :: GroupName FactionKind
pattern MONSTER_ANTI :: GroupName FactionKind
pattern MONSTER_ANTI_CAPTIVE :: GroupName FactionKind
pattern MONSTER_ANTI_PACIFIST :: GroupName FactionKind
pattern MONSTER_TOURIST :: GroupName FactionKind
pattern MONSTER_TOURIST_PASSIVE :: GroupName FactionKind
pattern MONSTER_CAPTIVE :: GroupName FactionKind
pattern MONSTER_CAPTIVE_NARRATING :: GroupName FactionKind
pattern ANIMAL_REPRESENTATIVE :: GroupName FactionKind
pattern ANIMAL_MAGNIFICENT :: GroupName FactionKind
pattern ANIMAL_EXQUISITE :: GroupName FactionKind
pattern ANIMAL_CAPTIVE :: GroupName FactionKind
pattern ANIMAL_NARRATING :: GroupName FactionKind
pattern ANIMAL_MAGNIFICENT_NARRATING :: GroupName FactionKind
pattern ANIMAL_CAPTIVE_NARRATING :: GroupName FactionKind
pattern HORROR_REPRESENTATIVE :: GroupName FactionKind
pattern HORROR_CAPTIVE :: GroupName FactionKind
pattern HORROR_PACIFIST :: GroupName FactionKind
pattern REPRESENTATIVE :: GroupName FactionKind
groupNamesSingleton :: [GroupName FactionKind]
groupNames :: [GroupName FactionKind]
content :: [FactionKind]

-- | Definitions of basic items.
module Content.ItemKind
pattern HARPOON :: GroupName ItemKind
pattern EDIBLE_PLANT :: GroupName ItemKind
pattern RING_OF_OPPORTUNITY_GRENADIER :: GroupName ItemKind
pattern ARMOR_LOOSE :: GroupName ItemKind
pattern CLOTHING_MISC :: GroupName ItemKind
pattern CHIC_GEAR :: GroupName ItemKind
groupNamesSingleton :: [GroupName ItemKind]
groupNames :: [GroupName ItemKind]
content :: [ItemKind]
items :: [ItemKind]
otherItemContent :: [ItemKind]

-- | Definitions of of cave kinds. Every level in the game is an
--   instantiated cave kind.
module Content.CaveKind
pattern CAVE_ROGUE :: GroupName CaveKind
pattern CAVE_ARENA :: GroupName CaveKind
pattern CAVE_SMOKING :: GroupName CaveKind
pattern CAVE_LABORATORY :: GroupName CaveKind
pattern CAVE_NOISE :: GroupName CaveKind
pattern CAVE_MINE :: GroupName CaveKind
pattern CAVE_EMPTY :: GroupName CaveKind
pattern CAVE_SHALLOW_ROGUE :: GroupName CaveKind
pattern CAVE_OUTERMOST :: GroupName CaveKind
pattern CAVE_RAID :: GroupName CaveKind
pattern CAVE_BRAWL :: GroupName CaveKind
pattern CAVE_SHOOTOUT :: GroupName CaveKind
pattern CAVE_HUNT :: GroupName CaveKind
pattern CAVE_FLIGHT :: GroupName CaveKind
pattern CAVE_ZOO :: GroupName CaveKind
pattern CAVE_AMBUSH :: GroupName CaveKind
pattern CAVE_BATTLE :: GroupName CaveKind
pattern CAVE_SAFARI_1 :: GroupName CaveKind
pattern CAVE_SAFARI_2 :: GroupName CaveKind
pattern CAVE_SAFARI_3 :: GroupName CaveKind
groupNamesSingleton :: [GroupName CaveKind]
groupNames :: [GroupName CaveKind]
content :: [CaveKind]

-- | Definitions of game mode kinds.
module Content.ModeKind
groupNamesSingleton :: [GroupName ModeKind]
groupNames :: [GroupName ModeKind]
content :: [ModeKind]
pattern RAID :: GroupName ModeKind
pattern BRAWL :: GroupName ModeKind
pattern LONG :: GroupName ModeKind
pattern CRAWL :: GroupName ModeKind
pattern FOGGY :: GroupName ModeKind
pattern SHOOTOUT :: GroupName ModeKind
pattern PERILOUS :: GroupName ModeKind
pattern HUNT :: GroupName ModeKind
pattern NIGHT :: GroupName ModeKind
pattern FLIGHT :: GroupName ModeKind
pattern BURNING :: GroupName ModeKind
pattern ZOO :: GroupName ModeKind
pattern RANGED :: GroupName ModeKind
pattern AMBUSH :: GroupName ModeKind
pattern SAFARI :: GroupName ModeKind
pattern DIG :: GroupName ModeKind
pattern SEE :: GroupName ModeKind
pattern SHORT :: GroupName ModeKind
pattern CRAWL_EMPTY :: GroupName ModeKind
pattern CRAWL_SURVIVAL :: GroupName ModeKind
pattern SAFARI_SURVIVAL :: GroupName ModeKind
pattern BATTLE :: GroupName ModeKind
pattern BATTLE_DEFENSE :: GroupName ModeKind
pattern BATTLE_SURVIVAL :: GroupName ModeKind
pattern DEFENSE :: GroupName ModeKind
pattern DEFENSE_EMPTY :: GroupName ModeKind

-- | Here the knot of engine code pieces, frontend and the game-specific
--   content definitions is tied, resulting in an executable game.
module TieKnot

-- | Tie the LambdaHack engine client, server and frontend code with the
--   game-specific content definitions, and run the game.
--   
--   The custom monad types to be used are determined by the
--   executorSer call, which in turn calls executorCli.
--   If other functions are used in their place- the types are different
--   and so the whole pattern of computation differs. Which of the
--   frontends is run inside the UI client depends on the flags supplied
--   when compiling the engine library. Similarly for the choice of native
--   vs JS builds.
tieKnotForAsync :: ServerOptions -> IO ()

-- | Runs tieKnotForAsync in an async and applies the main thread
--   workaround.
tieKnot :: ServerOptions -> IO ()
