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

-- | A standard library for Haskell
--   
--   See README and Haddocks at https://www.stackage.org/package/rio
@package rio
@version 0.1.22.0

-- | Lazy ByteString partial functions. Import as:
--   
--   
--   import qualified RIO.ByteString.Lazy.Partial as BL'
--   
module RIO.ByteString.Lazy.Partial

-- | O(1) Extract the first element of a ByteString, which must be
--   non-empty.
--   
--   This is a partial function, consider using uncons instead.
head :: HasCallStack => ByteString -> Word8

-- | O(n/c) Extract the last element of a ByteString, which must be
--   finite and non-empty.
--   
--   This is a partial function, consider using unsnoc instead.
last :: HasCallStack => ByteString -> Word8

-- | O(1) Extract the elements after the head of a ByteString, which
--   must be non-empty.
--   
--   This is a partial function, consider using uncons instead.
tail :: HasCallStack => ByteString -> ByteString

-- | O(n/c) Returns all the elements of a ByteString except
--   the last one.
--   
--   This is a partial function, consider using unsnoc instead.
init :: HasCallStack => ByteString -> ByteString

-- | foldl1 is a variant of foldl that has no starting value
--   argument, and thus must be applied to non-empty ByteStrings.
foldl1 :: HasCallStack => (Word8 -> Word8 -> Word8) -> ByteString -> Word8

-- | foldl1' is like foldl1, but strict in the accumulator.
foldl1' :: HasCallStack => (Word8 -> Word8 -> Word8) -> ByteString -> Word8

-- | foldr1 is a variant of foldr that has no starting value
--   argument, and thus must be applied to non-empty ByteStrings
foldr1 :: HasCallStack => (Word8 -> Word8 -> Word8) -> ByteString -> Word8

-- | O(n) maximum returns the maximum value from a
--   ByteString
maximum :: HasCallStack => ByteString -> Word8

-- | O(n) minimum returns the minimum value from a
--   ByteString
minimum :: HasCallStack => ByteString -> Word8

-- | Strict ByteString partial functions. Import as:
--   
--   
--   import qualified RIO.ByteString.Partial as B'
--   
module RIO.ByteString.Partial

-- | O(1) Extract the first element of a ByteString, which must be
--   non-empty. An exception will be thrown in the case of an empty
--   ByteString.
--   
--   This is a partial function, consider using uncons instead.
head :: HasCallStack => ByteString -> Word8

-- | O(1) Extract the last element of a ByteString, which must be
--   finite and non-empty. An exception will be thrown in the case of an
--   empty ByteString.
--   
--   This is a partial function, consider using unsnoc instead.
last :: HasCallStack => ByteString -> Word8

-- | O(1) Extract the elements after the head of a ByteString, which
--   must be non-empty. An exception will be thrown in the case of an empty
--   ByteString.
--   
--   This is a partial function, consider using uncons instead.
tail :: HasCallStack => ByteString -> ByteString

-- | O(1) Returns all the elements of a ByteString except the
--   last one. An exception will be thrown in the case of an empty
--   ByteString.
--   
--   This is a partial function, consider using unsnoc instead.
init :: HasCallStack => ByteString -> ByteString

-- | foldl1 is a variant of foldl that has no starting value
--   argument, and thus must be applied to non-empty ByteStrings. An
--   exception will be thrown in the case of an empty ByteString.
foldl1 :: HasCallStack => (Word8 -> Word8 -> Word8) -> ByteString -> Word8

-- | foldl1' is like foldl1, but strict in the accumulator.
--   An exception will be thrown in the case of an empty ByteString.
foldl1' :: HasCallStack => (Word8 -> Word8 -> Word8) -> ByteString -> Word8

-- | foldr1 is a variant of foldr that has no starting value
--   argument, and thus must be applied to non-empty ByteStrings An
--   exception will be thrown in the case of an empty ByteString.
foldr1 :: HasCallStack => (Word8 -> Word8 -> Word8) -> ByteString -> Word8

-- | foldr1' is a variant of foldr1, but is strict in the
--   accumulator.
foldr1' :: HasCallStack => (Word8 -> Word8 -> Word8) -> ByteString -> Word8

-- | O(n) maximum returns the maximum value from a
--   ByteString An exception will be thrown in the case of an empty
--   ByteString.
maximum :: HasCallStack => ByteString -> Word8

-- | O(n) minimum returns the minimum value from a
--   ByteString An exception will be thrown in the case of an empty
--   ByteString.
minimum :: HasCallStack => ByteString -> Word8

-- | Unicode Char. Import as:
--   
--   
--   import qualified RIO.Char as C
--   
--   
--   This module does not export any partial functions. For those, see
--   RIO.Char.Partial
module RIO.Char

-- | The character type Char is an enumeration whose values
--   represent Unicode (or equivalently ISO/IEC 10646) code points (i.e.
--   characters, see http://www.unicode.org/ for details). This set
--   extends the ISO 8859-1 (Latin-1) character set (the first 256
--   characters), which is itself an extension of the ASCII character set
--   (the first 128 characters). A character literal in Haskell has type
--   Char.
--   
--   To convert a Char to or from the corresponding Int value
--   defined by Unicode, use toEnum and fromEnum from the
--   Enum class respectively (or equivalently ord and
--   chr).
data () => Char

-- | Selects control characters, which are the non-printing characters of
--   the Latin-1 subset of Unicode.
isControl :: Char -> Bool

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

-- | Selects lower-case alphabetic Unicode characters (letters).
isLower :: Char -> Bool

-- | Selects upper-case or title-case alphabetic Unicode characters
--   (letters). Title case is used by a small number of letter ligatures
--   like the single-character form of Lj.
isUpper :: Char -> Bool

-- | Selects alphabetic Unicode characters (lower-case, upper-case and
--   title-case letters, plus letters of caseless scripts and modifiers
--   letters). This function is equivalent to isLetter.
isAlpha :: Char -> Bool

-- | Selects alphabetic or numeric Unicode characters.
--   
--   Note that numeric digits outside the ASCII range, as well as numeric
--   characters which aren't digits, are selected by this function but not
--   by isDigit. Such characters may be part of identifiers but are
--   not used by the printer and reader to represent numbers.
isAlphaNum :: Char -> Bool

-- | Selects printable Unicode characters (letters, numbers, marks,
--   punctuation, symbols and spaces).
isPrint :: Char -> Bool

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

-- | Selects ASCII octal digits, i.e. '0'..'7'.
isOctDigit :: Char -> Bool

-- | Selects ASCII hexadecimal digits, i.e. '0'..'9',
--   'a'..'f', 'A'..'F'.
isHexDigit :: Char -> Bool

-- | Selects alphabetic Unicode characters (lower-case, upper-case and
--   title-case letters, plus letters of caseless scripts and modifiers
--   letters). This function is equivalent to isAlpha.
--   
--   This function returns True if its argument has one of the
--   following GeneralCategorys, or False otherwise:
--   
--   
--   
- UppercaseLetter
--   
- LowercaseLetter
--   
- TitlecaseLetter
--   
- ModifierLetter
--   
- OtherLetter
--   
--   
--   These classes are defined in the Unicode Character Database,
--   part of the Unicode standard. The same document defines what is and is
--   not a "Letter".
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> isLetter 'a'
--   True
--   
--   >>> isLetter 'A'
--   True
--   
--   >>> isLetter 'λ'
--   True
--   
--   >>> isLetter '0'
--   False
--   
--   >>> isLetter '%'
--   False
--   
--   >>> isLetter '♥'
--   False
--   
--   >>> isLetter '\31'
--   False
--   
--   
--   Ensure that isLetter and isAlpha are equivalent.
--   
--   
--   >>> let chars = [(chr 0)..]
--   
--   >>> let letters = map isLetter chars
--   
--   >>> let alphas = map isAlpha chars
--   
--   >>> letters == alphas
--   True
--   
isLetter :: Char -> Bool

-- | Selects Unicode mark characters, for example accents and the like,
--   which combine with preceding characters.
--   
--   This function returns True if its argument has one of the
--   following GeneralCategorys, or False otherwise:
--   
--   
--   
- NonSpacingMark
--   
- SpacingCombiningMark
--   
- EnclosingMark
--   
--   
--   These classes are defined in the Unicode Character Database,
--   part of the Unicode standard. The same document defines what is and is
--   not a "Mark".
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> isMark 'a'
--   False
--   
--   >>> isMark '0'
--   False
--   
--   
--   Combining marks such as accent characters usually need to follow
--   another character before they become printable:
--   
--   
--   >>> map isMark "ò"
--   [False,True]
--   
--   
--   Puns are not necessarily supported:
--   
--   
--   >>> isMark '✓'
--   False
--   
isMark :: Char -> Bool

-- | Selects Unicode numeric characters, including digits from various
--   scripts, Roman numerals, et cetera.
--   
--   This function returns True if its argument has one of the
--   following GeneralCategorys, or False otherwise:
--   
--   
--   
- DecimalNumber
--   
- LetterNumber
--   
- OtherNumber
--   
--   
--   These classes are defined in the Unicode Character Database,
--   part of the Unicode standard. The same document defines what is and is
--   not a "Number".
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> isNumber 'a'
--   False
--   
--   >>> isNumber '%'
--   False
--   
--   >>> isNumber '3'
--   True
--   
--   
--   ASCII '0' through '9' are all numbers:
--   
--   
--   >>> and $ map isNumber ['0'..'9']
--   True
--   
--   
--   Unicode Roman numerals are "numbers" as well:
--   
--   
--   >>> isNumber 'Ⅸ'
--   True
--   
isNumber :: Char -> Bool

-- | Selects Unicode punctuation characters, including various kinds of
--   connectors, brackets and quotes.
--   
--   This function returns True if its argument has one of the
--   following GeneralCategorys, or False otherwise:
--   
--   
--   
- ConnectorPunctuation
--   
- DashPunctuation
--   
- OpenPunctuation
--   
- ClosePunctuation
--   
- InitialQuote
--   
- FinalQuote
--   
- OtherPunctuation
--   
--   
--   These classes are defined in the Unicode Character Database,
--   part of the Unicode standard. The same document defines what is and is
--   not a "Punctuation".
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> isPunctuation 'a'
--   False
--   
--   >>> isPunctuation '7'
--   False
--   
--   >>> isPunctuation '♥'
--   False
--   
--   >>> isPunctuation '"'
--   True
--   
--   >>> isPunctuation '?'
--   True
--   
--   >>> isPunctuation '—'
--   True
--   
isPunctuation :: Char -> Bool

-- | Selects Unicode symbol characters, including mathematical and currency
--   symbols.
--   
--   This function returns True if its argument has one of the
--   following GeneralCategorys, or False otherwise:
--   
--   
--   
- MathSymbol
--   
- CurrencySymbol
--   
- ModifierSymbol
--   
- OtherSymbol
--   
--   
--   These classes are defined in the Unicode Character Database,
--   part of the Unicode standard. The same document defines what is and is
--   not a "Symbol".
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> isSymbol 'a'
--   False
--   
--   >>> isSymbol '6'
--   False
--   
--   >>> isSymbol '='
--   True
--   
--   
--   The definition of "math symbol" may be a little counter-intuitive
--   depending on one's background:
--   
--   
--   >>> isSymbol '+'
--   True
--   
--   >>> isSymbol '-'
--   False
--   
isSymbol :: Char -> Bool

-- | Selects Unicode space and separator characters.
--   
--   This function returns True if its argument has one of the
--   following GeneralCategorys, or False otherwise:
--   
--   
--   
- Space
--   
- LineSeparator
--   
- ParagraphSeparator
--   
--   
--   These classes are defined in the Unicode Character Database,
--   part of the Unicode standard. The same document defines what is and is
--   not a "Separator".
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> isSeparator 'a'
--   False
--   
--   >>> isSeparator '6'
--   False
--   
--   >>> isSeparator ' '
--   True
--   
--   
--   Warning: newlines and tab characters are not considered separators.
--   
--   
--   >>> isSeparator '\n'
--   False
--   
--   >>> isSeparator '\t'
--   False
--   
--   
--   But some more exotic characters are (like HTML's &nbsp;):
--   
--   
--   >>> isSeparator '\160'
--   True
--   
isSeparator :: Char -> Bool

-- | Selects the first 128 characters of the Unicode character set,
--   corresponding to the ASCII character set.
isAscii :: Char -> Bool

-- | Selects the first 256 characters of the Unicode character set,
--   corresponding to the ISO 8859-1 (Latin-1) character set.
isLatin1 :: Char -> Bool

-- | Selects ASCII upper-case letters, i.e. characters satisfying both
--   isAscii and isUpper.
isAsciiUpper :: Char -> Bool

-- | Selects ASCII lower-case letters, i.e. characters satisfying both
--   isAscii and isLower.
isAsciiLower :: Char -> Bool

-- | Unicode General Categories (column 2 of the UnicodeData table) in the
--   order they are listed in the Unicode standard (the Unicode Character
--   Database, in particular).
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> :t OtherLetter
--   OtherLetter :: GeneralCategory
--   
--   
--   Eq instance:
--   
--   
--   >>> UppercaseLetter == UppercaseLetter
--   True
--   
--   >>> UppercaseLetter == LowercaseLetter
--   False
--   
--   
--   Ord instance:
--   
--   
--   >>> NonSpacingMark <= MathSymbol
--   True
--   
--   
--   Enum instance:
--   
--   
--   >>> enumFromTo ModifierLetter SpacingCombiningMark
--   [ModifierLetter,OtherLetter,NonSpacingMark,SpacingCombiningMark]
--   
--   
--   Read instance:
--   
--   
--   >>> read "DashPunctuation" :: GeneralCategory
--   DashPunctuation
--   
--   >>> read "17" :: GeneralCategory
--   *** Exception: Prelude.read: no parse
--   
--   
--   Show instance:
--   
--   
--   >>> show EnclosingMark
--   "EnclosingMark"
--   
--   
--   Bounded instance:
--   
--   
--   >>> minBound :: GeneralCategory
--   UppercaseLetter
--   
--   >>> maxBound :: GeneralCategory
--   NotAssigned
--   
--   
--   Ix instance:
--   
--   
--   >>> import Data.Ix ( index )
--   
--   >>> index (OtherLetter,Control) FinalQuote
--   12
--   
--   >>> index (OtherLetter,Control) Format
--   *** Exception: Error in array index
--   
data () => GeneralCategory

-- | Lu: Letter, Uppercase
UppercaseLetter :: GeneralCategory

-- | Ll: Letter, Lowercase
LowercaseLetter :: GeneralCategory

-- | Lt: Letter, Titlecase
TitlecaseLetter :: GeneralCategory

-- | Lm: Letter, Modifier
ModifierLetter :: GeneralCategory

-- | Lo: Letter, Other
OtherLetter :: GeneralCategory

-- | Mn: Mark, Non-Spacing
NonSpacingMark :: GeneralCategory

-- | Mc: Mark, Spacing Combining
SpacingCombiningMark :: GeneralCategory

-- | Me: Mark, Enclosing
EnclosingMark :: GeneralCategory

-- | Nd: Number, Decimal
DecimalNumber :: GeneralCategory

-- | Nl: Number, Letter
LetterNumber :: GeneralCategory

-- | No: Number, Other
OtherNumber :: GeneralCategory

-- | Pc: Punctuation, Connector
ConnectorPunctuation :: GeneralCategory

-- | Pd: Punctuation, Dash
DashPunctuation :: GeneralCategory

-- | Ps: Punctuation, Open
OpenPunctuation :: GeneralCategory

-- | Pe: Punctuation, Close
ClosePunctuation :: GeneralCategory

-- | Pi: Punctuation, Initial quote
InitialQuote :: GeneralCategory

-- | Pf: Punctuation, Final quote
FinalQuote :: GeneralCategory

-- | Po: Punctuation, Other
OtherPunctuation :: GeneralCategory

-- | Sm: Symbol, Math
MathSymbol :: GeneralCategory

-- | Sc: Symbol, Currency
CurrencySymbol :: GeneralCategory

-- | Sk: Symbol, Modifier
ModifierSymbol :: GeneralCategory

-- | So: Symbol, Other
OtherSymbol :: GeneralCategory

-- | Zs: Separator, Space
Space :: GeneralCategory

-- | Zl: Separator, Line
LineSeparator :: GeneralCategory

-- | Zp: Separator, Paragraph
ParagraphSeparator :: GeneralCategory

-- | Cc: Other, Control
Control :: GeneralCategory

-- | Cf: Other, Format
Format :: GeneralCategory

-- | Cs: Other, Surrogate
Surrogate :: GeneralCategory

-- | Co: Other, Private Use
PrivateUse :: GeneralCategory

-- | Cn: Other, Not Assigned
NotAssigned :: GeneralCategory

-- | The Unicode general category of the character. This relies on the
--   Enum instance of GeneralCategory, which must remain in
--   the same order as the categories are presented in the Unicode
--   standard.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> generalCategory 'a'
--   LowercaseLetter
--   
--   >>> generalCategory 'A'
--   UppercaseLetter
--   
--   >>> generalCategory '0'
--   DecimalNumber
--   
--   >>> generalCategory '%'
--   OtherPunctuation
--   
--   >>> generalCategory '♥'
--   OtherSymbol
--   
--   >>> generalCategory '\31'
--   Control
--   
--   >>> generalCategory ' '
--   Space
--   
generalCategory :: Char -> GeneralCategory

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

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

-- | Convert a letter to the corresponding title-case or upper-case letter,
--   if any. (Title case differs from upper case only for a small number of
--   ligature letters.) Any other character is returned unchanged.
toTitle :: Char -> Char

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

-- | Convert a character to a string using only printable characters, using
--   Haskell source-language escape conventions. For example:
--   
--   
--   showLitChar '\n' s  =  "\\n" ++ s
--   
showLitChar :: Char -> ShowS

-- | Read a string representation of a character, using Haskell
--   source-language escape conventions. For example:
--   
--   
--   lexLitChar  "\\nHello"  =  [("\\n", "Hello")]
--   
lexLitChar :: ReadS String

-- | Read a string representation of a character, using Haskell
--   source-language escape conventions, and convert it to the character
--   that it encodes. For example:
--   
--   
--   readLitChar "\\nHello"  =  [('\n', "Hello")]
--   
readLitChar :: ReadS Char

-- | Unicode Char partial functions. Import as:
--   
--   
--   import qualified RIO.Char.Partial as C'
--   
module RIO.Char.Partial

-- | Convert a single digit Char to the corresponding Int.
--   This function fails unless its argument satisfies isHexDigit,
--   but recognises both upper- and lower-case hexadecimal digits (that is,
--   '0'..'9', 'a'..'f',
--   'A'..'F').
--   
--   
Examples
--   
--   Characters '0' through '9' are converted properly to
--   0..9:
--   
--   
--   >>> map digitToInt ['0'..'9']
--   [0,1,2,3,4,5,6,7,8,9]
--   
--   
--   Both upper- and lower-case 'A' through 'F' are
--   converted as well, to 10..15.
--   
--   
--   >>> map digitToInt ['a'..'f']
--   [10,11,12,13,14,15]
--   
--   >>> map digitToInt ['A'..'F']
--   [10,11,12,13,14,15]
--   
--   
--   Anything else throws an exception:
--   
--   
--   >>> digitToInt 'G'
--   *** Exception: Char.digitToInt: not a digit 'G'
--   
--   >>> digitToInt '♥'
--   *** Exception: Char.digitToInt: not a digit '\9829'
--   
digitToInt :: Char -> Int

-- | Convert an Int in the range 0..15 to the
--   corresponding single digit Char. This function fails on other
--   inputs, and generates lower-case hexadecimal digits.
intToDigit :: Int -> Char

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

module RIO.Directory

-- | 
Rationale
--   
--   This module offers functions to handle files that offer better
--   durability and/or atomicity.
--   
--   See UnliftIO.IO.File for the rationale behind this module,
--   since all of the functions were moved upstream and are now simply
--   re-exported from here.
module RIO.File

-- | Unlifted version of withBinaryFile.
withBinaryFile :: MonadUnliftIO m => FilePath -> IOMode -> (Handle -> m a) -> m a

-- | Lifted version of writeFile
writeBinaryFile :: MonadIO m => FilePath -> ByteString -> m ()

-- | Perform an action on a new or existing file at the destination file
--   path. If previously the file existed at the supplied file path then:
--   
--   
--   
- in case of WriteMode it will be overwritten
--   
- upon ReadWriteMode or AppendMode files contents will
--   be copied over into a temporary file, thus making sure no corruption
--   can happen to an existing file upon any failures, even catastrophic
--   one, yet its contents are availble for modification.
--   
- There is nothing atomic about ReadMode, so no special
--   treatment there.
--   
--   
--   It is similar to withBinaryFileDurableAtomic, but without the
--   durability part. It means that all modification can still disappear
--   after it has been succesfully written due to some extreme event like
--   an abrupt power loss, but the contents will not be corrupted in case
--   when the file write did not end successfully.
--   
--   The same performance caveats apply as for
--   withBinaryFileDurableAtomic due to making a copy of the content
--   of existing files during non-truncating writes.
--   
--   Important - Do not close the handle, otherwise it will result
--   in invalid argument (Bad file descriptor) exception
--   
--   Note - on Linux operating system and only with supported file
--   systems an anonymous temporary file will be used while working on the
--   file (see O_TMPFILE in man openat). In case when
--   such feature is not available or not supported a temporary file
--   ".target-file-nameXXX.ext.tmp", where XXX is some random number, will
--   be created alongside the target file in the same directory
withBinaryFileAtomic :: MonadUnliftIO m => FilePath -> IOMode -> (Handle -> m r) -> m r

-- | Same as writeBinaryFileDurableAtomic, except it does not
--   guarantee durability.
--   
--   
Cross-Platform support
--   
--   This function behaves the same as writeBinaryFile on Windows
--   platforms.
writeBinaryFileAtomic :: MonadIO m => FilePath -> ByteString -> m ()

-- | Opens a file with the following guarantees:
--   
--   
--   
- It successfully closes the file in case of an asynchronous
--   exception
--   
- It reliably saves the file in the correct directory; including
--   edge case situations like a different device being mounted to the
--   current directory, or the current directory being renamed to some
--   other name while the file is being used.
--   
- It ensures durability by executing an fsync() call before
--   closing the file handle
--   
--   
--   
Cross-Platform support
--   
--   This function behaves the same as withBinaryFile on Windows
--   platforms.
withBinaryFileDurable :: MonadUnliftIO m => FilePath -> IOMode -> (Handle -> m r) -> m r

-- | Similar to writeBinaryFile, but it also ensures that changes
--   executed to the file are guaranteed to be durable. It internally uses
--   fsync() and makes sure it synchronizes the file on disk.
--   
--   
Cross-Platform support
--   
--   This function behaves the same as writeBinaryFile on Windows
--   platforms.
writeBinaryFileDurable :: MonadIO m => FilePath -> ByteString -> m ()

-- | After a file is closed, this function opens it again and executes
--   fsync() internally on both the file and the directory that
--   contains it. Note that this function is intended to work around the
--   non-durability of existing file APIs, as opposed to being necessary
--   for the API functions provided in this module.
--   
--   The effectiveness of calling this function is debatable, as it
--   relies on internal implementation details at the Kernel level that
--   might change. We argue that, despite this fact, calling this function
--   may bring benefits in terms of durability.
--   
--   This function does not provide the same guarantee as if you would open
--   and modify a file using withBinaryFileDurable or
--   writeBinaryFileDurable, since they ensure that the
--   fsync() is called before the file is closed, so if possible
--   use those instead.
--   
--   
Cross-Platform support
--   
--   This function is a noop on Windows platforms.
ensureFileDurable :: MonadIO m => FilePath -> m ()

-- | Opens a file with the following guarantees:
--   
--   
--   
- It successfully closes the file in case of an asynchronous
--   exception
--   
- It reliably saves the file in the correct directory; including
--   edge case situations like a different device being mounted to the
--   current directory, or the current directory being renamed to some
--   other name while the file is being used.
--   
- It ensures durability by executing an fsync() call before
--   closing the file handle
--   
- It keeps all changes in a temporary file, and after it is closed
--   it atomically moves the temporary file to the original filepath, in
--   case of catastrophic failure, the original file stays unaffected.
--   
--   
--   If you do not need durability but only atomicity, use
--   withBinaryFileAtomic instead, which is faster as it does not
--   perform fsync().
--   
--   Important - Make sure not to close the Handle, it will
--   be closed for you, otherwise it will result in invalid argument
--   (Bad file descriptor) exception.
--   
--   
Performance Considerations
--   
--   When using a writable but non-truncating IOMode (i.e.
--   ReadWriteMode and AppendMode), this function performs a
--   copy operation of the specified input file to guarantee the original
--   file is intact in case of a catastrophic failure (no partial writes).
--   This approach may be prohibitive in scenarios where the input file is
--   expected to be large in size.
--   
--   
Cross-Platform support
--   
--   This function behaves the same as withBinaryFile on Windows
--   platforms.
withBinaryFileDurableAtomic :: MonadUnliftIO m => FilePath -> IOMode -> (Handle -> m r) -> m r

-- | Similar to writeBinaryFile, but it also guarantes that changes
--   executed to the file are durable, also, in case of failure, the
--   modified file is never going to get corrupted. It internally uses
--   fsync() and makes sure it synchronizes the file on disk.
--   
--   
Cross-Platform support
--   
--   This function behaves the same as writeBinaryFile on Windows
--   platforms.
writeBinaryFileDurableAtomic :: MonadIO m => FilePath -> ByteString -> m ()

module RIO.FilePath

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

-- | The character that is used to separate the entries in the $PATH
--   environment variable.
--   
--   
--   Windows: searchPathSeparator == ';'
--   Posix:   searchPathSeparator == ':'
--   
searchPathSeparator :: Char

-- | Normalise a file
--   
--   
--   
- // outside of the drive can be made blank
--   
- / -> pathSeparator
--   
- ./ -> ""
--   
--   
--   Does not remove "..", because of symlinks.
--   
--   
--   Posix:   normalise "/file/\\test////" == "/file/\\test/"
--   Posix:   normalise "/file/./test" == "/file/test"
--   Posix:   normalise "/test/file/../bob/fred/" == "/test/file/../bob/fred/"
--   Posix:   normalise "../bob/fred/" == "../bob/fred/"
--   Posix:   normalise "/a/../c" == "/a/../c"
--   Posix:   normalise "./bob/fred/" == "bob/fred/"
--   Windows: normalise "c:\\file/bob\\" == "C:\\file\\bob\\"
--   Windows: normalise "c:\\" == "C:\\"
--   Windows: normalise "C:.\\" == "C:"
--   Windows: normalise "\\\\server\\test" == "\\\\server\\test"
--   Windows: normalise "//server/test" == "\\\\server\\test"
--   Windows: normalise "c:/file" == "C:\\file"
--   Windows: normalise "/file" == "\\file"
--   Windows: normalise "\\" == "\\"
--   Windows: normalise "/./" == "\\"
--            normalise "." == "."
--   Posix:   normalise "./" == "./"
--   Posix:   normalise "./." == "./"
--   Posix:   normalise "/./" == "/"
--   Posix:   normalise "/" == "/"
--   Posix:   normalise "bob/fred/." == "bob/fred/"
--   Posix:   normalise "//home" == "/home"
--   
normalise :: FilePath -> FilePath

-- | Remove any trailing path separators
--   
--   
--   dropTrailingPathSeparator "file/test/" == "file/test"
--             dropTrailingPathSeparator "/" == "/"
--   Windows:  dropTrailingPathSeparator "\\" == "\\"
--   Posix:    not (hasTrailingPathSeparator (dropTrailingPathSeparator x)) || isDrive x
--   
dropTrailingPathSeparator :: FilePath -> FilePath

-- | Contract a filename, based on a relative path. Note that the resulting
--   path will never introduce .. paths, as the presence of
--   symlinks means ../b may not reach a/b if it starts
--   from a/c. For a worked example see this blog post.
--   
--   The corresponding makeAbsolute function can be found in
--   System.Directory.
--   
--   
--            makeRelative "/directory" "/directory/file.ext" == "file.ext"
--            Valid x => makeRelative (takeDirectory x) x `equalFilePath` takeFileName x
--            makeRelative x x == "."
--            Valid x y => equalFilePath x y || (isRelative x && makeRelative y x == x) || equalFilePath (y </> makeRelative y x) x
--   Windows: makeRelative "C:\\Home" "c:\\home\\bob" == "bob"
--   Windows: makeRelative "C:\\Home" "c:/home/bob" == "bob"
--   Windows: makeRelative "C:\\Home" "D:\\Home\\Bob" == "D:\\Home\\Bob"
--   Windows: makeRelative "C:\\Home" "C:Home\\Bob" == "C:Home\\Bob"
--   Windows: makeRelative "/Home" "/home/bob" == "bob"
--   Windows: makeRelative "/" "//" == "//"
--   Posix:   makeRelative "/Home" "/home/bob" == "/home/bob"
--   Posix:   makeRelative "/home/" "/home/bob/foo/bar" == "bob/foo/bar"
--   Posix:   makeRelative "/fred" "bob" == "bob"
--   Posix:   makeRelative "/file/test" "/file/test/fred" == "fred"
--   Posix:   makeRelative "/file/test" "/file/test/fred/" == "fred/"
--   Posix:   makeRelative "some/path" "some/path/a/b/c" == "a/b/c"
--   
makeRelative :: FilePath -> FilePath -> FilePath

-- | Combine two paths with a path separator. If the second path starts
--   with a path separator or a drive letter, then it returns the second.
--   The intention is that readFile (dir </> file)
--   will access the same file as setCurrentDirectory dir; readFile
--   file.
--   
--   
--   Posix:   "/directory" </> "file.ext" == "/directory/file.ext"
--   Windows: "/directory" </> "file.ext" == "/directory\\file.ext"
--            "directory" </> "/file.ext" == "/file.ext"
--   Valid x => (takeDirectory x </> takeFileName x) `equalFilePath` x
--   
--   
--   Combined:
--   
--   
--   Posix:   "/" </> "test" == "/test"
--   Posix:   "home" </> "bob" == "home/bob"
--   Posix:   "x:" </> "foo" == "x:/foo"
--   Windows: "C:\\foo" </> "bar" == "C:\\foo\\bar"
--   Windows: "home" </> "bob" == "home\\bob"
--   
--   
--   Not combined:
--   
--   
--   Posix:   "home" </> "/bob" == "/bob"
--   Windows: "home" </> "C:\\bob" == "C:\\bob"
--   
--   
--   Not combined (tricky):
--   
--   On Windows, if a filepath starts with a single slash, it is relative
--   to the root of the current drive. In [1], this is (confusingly)
--   referred to as an absolute path. The current behavior of
--   </> is to never combine these forms.
--   
--   
--   Windows: "home" </> "/bob" == "/bob"
--   Windows: "home" </> "\\bob" == "\\bob"
--   Windows: "C:\\home" </> "\\bob" == "\\bob"
--   
--   
--   On Windows, from [1]: "If a file name begins with only a disk
--   designator but not the backslash after the colon, it is interpreted as
--   a relative path to the current directory on the drive with the
--   specified letter." The current behavior of </> is to
--   never combine these forms.
--   
--   
--   Windows: "D:\\foo" </> "C:bar" == "C:bar"
--   Windows: "C:\\foo" </> "C:bar" == "C:bar"
--   
(</>) :: FilePath -> FilePath -> FilePath
infixr 5 </>

-- | The character that separates directories. In the case where more than
--   one character is possible, pathSeparator is the 'ideal' one.
--   
--   
--   Windows: pathSeparator == '\\'
--   Posix:   pathSeparator ==  '/'
--   isPathSeparator pathSeparator
--   
pathSeparator :: Char

-- | The list of all possible separators.
--   
--   
--   Windows: pathSeparators == ['\\', '/']
--   Posix:   pathSeparators == ['/']
--   pathSeparator `elem` pathSeparators
--   
pathSeparators :: [Char]

-- | Rather than using (== pathSeparator), use this. Test
--   if something is a path separator.
--   
--   
--   isPathSeparator a == (a `elem` pathSeparators)
--   
isPathSeparator :: Char -> Bool

-- | Is the character a file separator?
--   
--   
--   isSearchPathSeparator a == (a == searchPathSeparator)
--   
isSearchPathSeparator :: Char -> Bool

-- | File extension character
--   
--   
--   extSeparator == '.'
--   
extSeparator :: Char

-- | Is the character an extension character?
--   
--   
--   isExtSeparator a == (a == extSeparator)
--   
isExtSeparator :: Char -> Bool

-- | Take a string, split it on the searchPathSeparator character.
--   Blank items are ignored on Windows, and converted to . on
--   Posix. On Windows path elements are stripped of quotes.
--   
--   Follows the recommendations in
--   http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html
--   
--   
--   Posix:   splitSearchPath "File1:File2:File3"  == ["File1","File2","File3"]
--   Posix:   splitSearchPath "File1::File2:File3" == ["File1",".","File2","File3"]
--   Windows: splitSearchPath "File1;File2;File3"  == ["File1","File2","File3"]
--   Windows: splitSearchPath "File1;;File2;File3" == ["File1","File2","File3"]
--   Windows: splitSearchPath "File1;\"File2\";File3" == ["File1","File2","File3"]
--   
splitSearchPath :: String -> [FilePath]

-- | Split on the extension. addExtension is the inverse.
--   
--   
--   splitExtension "/directory/path.ext" == ("/directory/path",".ext")
--   uncurry (++) (splitExtension x) == x
--   Valid x => uncurry addExtension (splitExtension x) == x
--   splitExtension "file.txt" == ("file",".txt")
--   splitExtension "file" == ("file","")
--   splitExtension "file/file.txt" == ("file/file",".txt")
--   splitExtension "file.txt/boris" == ("file.txt/boris","")
--   splitExtension "file.txt/boris.ext" == ("file.txt/boris",".ext")
--   splitExtension "file/path.txt.bob.fred" == ("file/path.txt.bob",".fred")
--   splitExtension "file/path.txt/" == ("file/path.txt/","")
--   
splitExtension :: FilePath -> (String, String)

-- | Get the extension of a file, returns "" for no extension,
--   .ext otherwise.
--   
--   
--   takeExtension "/directory/path.ext" == ".ext"
--   takeExtension x == snd (splitExtension x)
--   Valid x => takeExtension (addExtension x "ext") == ".ext"
--   Valid x => takeExtension (replaceExtension x "ext") == ".ext"
--   
takeExtension :: FilePath -> String

-- | Remove the current extension and add another, equivalent to
--   replaceExtension.
--   
--   
--   "/directory/path.txt" -<.> "ext" == "/directory/path.ext"
--   "/directory/path.txt" -<.> ".ext" == "/directory/path.ext"
--   "foo.o" -<.> "c" == "foo.c"
--   
(-<.>) :: FilePath -> String -> FilePath
infixr 7 -<.>

-- | Set the extension of a file, overwriting one if already present,
--   equivalent to -<.>.
--   
--   
--   replaceExtension "/directory/path.txt" "ext" == "/directory/path.ext"
--   replaceExtension "/directory/path.txt" ".ext" == "/directory/path.ext"
--   replaceExtension "file.txt" ".bob" == "file.bob"
--   replaceExtension "file.txt" "bob" == "file.bob"
--   replaceExtension "file" ".bob" == "file.bob"
--   replaceExtension "file.txt" "" == "file"
--   replaceExtension "file.fred.bob" "txt" == "file.fred.txt"
--   replaceExtension x y == addExtension (dropExtension x) y
--   
replaceExtension :: FilePath -> String -> FilePath

-- | Add an extension, even if there is already one there, equivalent to
--   addExtension.
--   
--   
--   "/directory/path" <.> "ext" == "/directory/path.ext"
--   "/directory/path" <.> ".ext" == "/directory/path.ext"
--   
(<.>) :: FilePath -> String -> FilePath
infixr 7 <.>

-- | Remove last extension, and the "." preceding it.
--   
--   
--   dropExtension "/directory/path.ext" == "/directory/path"
--   dropExtension x == fst (splitExtension x)
--   
dropExtension :: FilePath -> FilePath

-- | Add an extension, even if there is already one there, equivalent to
--   <.>.
--   
--   
--   addExtension "/directory/path" "ext" == "/directory/path.ext"
--   addExtension "file.txt" "bib" == "file.txt.bib"
--   addExtension "file." ".bib" == "file..bib"
--   addExtension "file" ".bib" == "file.bib"
--   addExtension "/" "x" == "/.x"
--   addExtension x "" == x
--   Valid x => takeFileName (addExtension (addTrailingPathSeparator x) "ext") == ".ext"
--   Windows: addExtension "\\\\share" ".txt" == "\\\\share\\.txt"
--   
addExtension :: FilePath -> String -> FilePath

-- | Does the given filename have an extension?
--   
--   
--   hasExtension "/directory/path.ext" == True
--   hasExtension "/directory/path" == False
--   null (takeExtension x) == not (hasExtension x)
--   
hasExtension :: FilePath -> Bool

-- | Does the given filename have the specified extension?
--   
--   
--   "png" `isExtensionOf` "/directory/file.png" == True
--   ".png" `isExtensionOf` "/directory/file.png" == True
--   ".tar.gz" `isExtensionOf` "bar/foo.tar.gz" == True
--   "ar.gz" `isExtensionOf` "bar/foo.tar.gz" == False
--   "png" `isExtensionOf` "/directory/file.png.jpg" == False
--   "csv/table.csv" `isExtensionOf` "/data/csv/table.csv" == False
--   
isExtensionOf :: String -> FilePath -> Bool

-- | Drop the given extension from a FilePath, and the "."
--   preceding it. Returns Nothing if the FilePath does not have the
--   given extension, or Just and the part before the extension if
--   it does.
--   
--   This function can be more predictable than dropExtensions,
--   especially if the filename might itself contain . characters.
--   
--   
--   stripExtension "hs.o" "foo.x.hs.o" == Just "foo.x"
--   stripExtension "hi.o" "foo.x.hs.o" == Nothing
--   dropExtension x == fromJust (stripExtension (takeExtension x) x)
--   dropExtensions x == fromJust (stripExtension (takeExtensions x) x)
--   stripExtension ".c.d" "a.b.c.d"  == Just "a.b"
--   stripExtension ".c.d" "a.b..c.d" == Just "a.b."
--   stripExtension "baz"  "foo.bar"  == Nothing
--   stripExtension "bar"  "foobar"   == Nothing
--   stripExtension ""     x          == Just x
--   
stripExtension :: String -> FilePath -> Maybe FilePath

-- | Split on all extensions.
--   
--   
--   splitExtensions "/directory/path.ext" == ("/directory/path",".ext")
--   splitExtensions "file.tar.gz" == ("file",".tar.gz")
--   uncurry (++) (splitExtensions x) == x
--   Valid x => uncurry addExtension (splitExtensions x) == x
--   splitExtensions "file.tar.gz" == ("file",".tar.gz")
--   
splitExtensions :: FilePath -> (FilePath, String)

-- | Drop all extensions.
--   
--   
--   dropExtensions "/directory/path.ext" == "/directory/path"
--   dropExtensions "file.tar.gz" == "file"
--   not $ hasExtension $ dropExtensions x
--   not $ any isExtSeparator $ takeFileName $ dropExtensions x
--   
dropExtensions :: FilePath -> FilePath

-- | Get all extensions.
--   
--   
--   takeExtensions "/directory/path.ext" == ".ext"
--   takeExtensions "file.tar.gz" == ".tar.gz"
--   
takeExtensions :: FilePath -> String

-- | Replace all extensions of a file with a new extension. Note that
--   replaceExtension and addExtension both work for adding
--   multiple extensions, so only required when you need to drop all
--   extensions first.
--   
--   
--   replaceExtensions "file.fred.bob" "txt" == "file.txt"
--   replaceExtensions "file.fred.bob" "tar.gz" == "file.tar.gz"
--   
replaceExtensions :: FilePath -> String -> FilePath

-- | Split a path into a drive and a path. On Posix, / is a Drive.
--   
--   
--   uncurry (++) (splitDrive x) == x
--   Windows: splitDrive "file" == ("","file")
--   Windows: splitDrive "c:/file" == ("c:/","file")
--   Windows: splitDrive "c:\\file" == ("c:\\","file")
--   Windows: splitDrive "\\\\shared\\test" == ("\\\\shared\\","test")
--   Windows: splitDrive "\\\\shared" == ("\\\\shared","")
--   Windows: splitDrive "\\\\?\\UNC\\shared\\file" == ("\\\\?\\UNC\\shared\\","file")
--   Windows: splitDrive "\\\\?\\UNCshared\\file" == ("\\\\?\\","UNCshared\\file")
--   Windows: splitDrive "\\\\?\\d:\\file" == ("\\\\?\\d:\\","file")
--   Windows: splitDrive "/d" == ("","/d")
--   Posix:   splitDrive "/test" == ("/","test")
--   Posix:   splitDrive "//test" == ("//","test")
--   Posix:   splitDrive "test/file" == ("","test/file")
--   Posix:   splitDrive "file" == ("","file")
--   
splitDrive :: FilePath -> (FilePath, FilePath)

-- | Join a drive and the rest of the path.
--   
--   
--   Valid x => uncurry joinDrive (splitDrive x) == x
--   Windows: joinDrive "C:" "foo" == "C:foo"
--   Windows: joinDrive "C:\\" "bar" == "C:\\bar"
--   Windows: joinDrive "\\\\share" "foo" == "\\\\share\\foo"
--   Windows: joinDrive "/:" "foo" == "/:\\foo"
--   
joinDrive :: FilePath -> FilePath -> FilePath

-- | Get the drive from a filepath.
--   
--   
--   takeDrive x == fst (splitDrive x)
--   
takeDrive :: FilePath -> FilePath

-- | Delete the drive, if it exists.
--   
--   
--   dropDrive x == snd (splitDrive x)
--   
dropDrive :: FilePath -> FilePath

-- | Does a path have a drive.
--   
--   
--   not (hasDrive x) == null (takeDrive x)
--   Posix:   hasDrive "/foo" == True
--   Windows: hasDrive "C:\\foo" == True
--   Windows: hasDrive "C:foo" == True
--            hasDrive "foo" == False
--            hasDrive "" == False
--   
hasDrive :: FilePath -> Bool

-- | Is an element a drive
--   
--   
--   Posix:   isDrive "/" == True
--   Posix:   isDrive "/foo" == False
--   Windows: isDrive "C:\\" == True
--   Windows: isDrive "C:\\foo" == False
--            isDrive "" == False
--   
isDrive :: FilePath -> Bool

-- | Split a filename into directory and file. </> is the
--   inverse. The first component will often end with a trailing slash.
--   
--   
--   splitFileName "/directory/file.ext" == ("/directory/","file.ext")
--   Valid x => uncurry (</>) (splitFileName x) == x || fst (splitFileName x) == "./"
--   Valid x => isValid (fst (splitFileName x))
--   splitFileName "file/bob.txt" == ("file/", "bob.txt")
--   splitFileName "file/" == ("file/", "")
--   splitFileName "bob" == ("./", "bob")
--   Posix:   splitFileName "/" == ("/","")
--   Windows: splitFileName "c:" == ("c:","")
--   
splitFileName :: FilePath -> (String, String)

-- | Set the filename.
--   
--   
--   replaceFileName "/directory/other.txt" "file.ext" == "/directory/file.ext"
--   Valid x => replaceFileName x (takeFileName x) == x
--   
replaceFileName :: FilePath -> String -> FilePath

-- | Drop the filename. Unlike takeDirectory, this function will
--   leave a trailing path separator on the directory.
--   
--   
--   dropFileName "/directory/file.ext" == "/directory/"
--   dropFileName x == fst (splitFileName x)
--   
dropFileName :: FilePath -> FilePath

-- | Get the file name.
--   
--   
--   takeFileName "/directory/file.ext" == "file.ext"
--   takeFileName "test/" == ""
--   takeFileName x `isSuffixOf` x
--   takeFileName x == snd (splitFileName x)
--   Valid x => takeFileName (replaceFileName x "fred") == "fred"
--   Valid x => takeFileName (x </> "fred") == "fred"
--   Valid x => isRelative (takeFileName x)
--   
takeFileName :: FilePath -> FilePath

-- | Get the base name, without an extension or path.
--   
--   
--   takeBaseName "/directory/file.ext" == "file"
--   takeBaseName "file/test.txt" == "test"
--   takeBaseName "dave.ext" == "dave"
--   takeBaseName "" == ""
--   takeBaseName "test" == "test"
--   takeBaseName (addTrailingPathSeparator x) == ""
--   takeBaseName "file/file.tar.gz" == "file.tar"
--   
takeBaseName :: FilePath -> String

-- | Set the base name.
--   
--   
--   replaceBaseName "/directory/other.ext" "file" == "/directory/file.ext"
--   replaceBaseName "file/test.txt" "bob" == "file/bob.txt"
--   replaceBaseName "fred" "bill" == "bill"
--   replaceBaseName "/dave/fred/bob.gz.tar" "new" == "/dave/fred/new.tar"
--   Valid x => replaceBaseName x (takeBaseName x) == x
--   
replaceBaseName :: FilePath -> String -> FilePath

-- | Is an item either a directory or the last character a path separator?
--   
--   
--   hasTrailingPathSeparator "test" == False
--   hasTrailingPathSeparator "test/" == True
--   
hasTrailingPathSeparator :: FilePath -> Bool

-- | Add a trailing file path separator if one is not already present.
--   
--   
--   hasTrailingPathSeparator (addTrailingPathSeparator x)
--   hasTrailingPathSeparator x ==> addTrailingPathSeparator x == x
--   Posix:    addTrailingPathSeparator "test/rest" == "test/rest/"
--   
addTrailingPathSeparator :: FilePath -> FilePath

-- | Get the directory name, move up one level.
--   
--   
--             takeDirectory "/directory/other.ext" == "/directory"
--             takeDirectory x `isPrefixOf` x || takeDirectory x == "."
--             takeDirectory "foo" == "."
--             takeDirectory "/" == "/"
--             takeDirectory "/foo" == "/"
--             takeDirectory "/foo/bar/baz" == "/foo/bar"
--             takeDirectory "/foo/bar/baz/" == "/foo/bar/baz"
--             takeDirectory "foo/bar/baz" == "foo/bar"
--   Windows:  takeDirectory "foo\\bar" == "foo"
--   Windows:  takeDirectory "foo\\bar\\\\" == "foo\\bar"
--   Windows:  takeDirectory "C:\\" == "C:\\"
--   
takeDirectory :: FilePath -> FilePath

-- | Set the directory, keeping the filename the same.
--   
--   
--   replaceDirectory "root/file.ext" "/directory/" == "/directory/file.ext"
--   Valid x => replaceDirectory x (takeDirectory x) `equalFilePath` x
--   
replaceDirectory :: FilePath -> String -> FilePath

-- | An alias for </>.
combine :: FilePath -> FilePath -> FilePath

-- | Split a path by the directory separator.
--   
--   
--   splitPath "/directory/file.ext" == ["/","directory/","file.ext"]
--   concat (splitPath x) == x
--   splitPath "test//item/" == ["test//","item/"]
--   splitPath "test/item/file" == ["test/","item/","file"]
--   splitPath "" == []
--   Windows: splitPath "c:\\test\\path" == ["c:\\","test\\","path"]
--   Posix:   splitPath "/file/test" == ["/","file/","test"]
--   
splitPath :: FilePath -> [FilePath]

-- | Just as splitPath, but don't add the trailing slashes to each
--   element.
--   
--   
--            splitDirectories "/directory/file.ext" == ["/","directory","file.ext"]
--            splitDirectories "test/file" == ["test","file"]
--            splitDirectories "/test/file" == ["/","test","file"]
--   Windows: splitDirectories "C:\\test\\file" == ["C:\\", "test", "file"]
--            Valid x => joinPath (splitDirectories x) `equalFilePath` x
--            splitDirectories "" == []
--   Windows: splitDirectories "C:\\test\\\\\\file" == ["C:\\", "test", "file"]
--            splitDirectories "/test///file" == ["/","test","file"]
--   
splitDirectories :: FilePath -> [FilePath]

-- | Join path elements back together.
--   
--   
--   joinPath a == foldr (</>) "" a
--   joinPath ["/","directory/","file.ext"] == "/directory/file.ext"
--   Valid x => joinPath (splitPath x) == x
--   joinPath [] == ""
--   Posix: joinPath ["test","file","path"] == "test/file/path"
--   
joinPath :: [FilePath] -> FilePath

-- | Equality of two FilePaths. If you call
--   System.Directory.canonicalizePath first this has a much
--   better chance of working. Note that this doesn't follow symlinks or
--   DOSNAM~1s.
--   
--   Similar to normalise, this does not expand "..",
--   because of symlinks.
--   
--   
--            x == y ==> equalFilePath x y
--            normalise x == normalise y ==> equalFilePath x y
--            equalFilePath "foo" "foo/"
--            not (equalFilePath "/a/../c" "/c")
--            not (equalFilePath "foo" "/foo")
--   Posix:   not (equalFilePath "foo" "FOO")
--   Windows: equalFilePath "foo" "FOO"
--   Windows: not (equalFilePath "C:" "C:/")
--   
equalFilePath :: FilePath -> FilePath -> Bool

-- | Is a FilePath valid, i.e. could you create a file like it? This
--   function checks for invalid names, and invalid characters, but does
--   not check if length limits are exceeded, as these are typically
--   filesystem dependent.
--   
--   
--            isValid "" == False
--            isValid "\0" == False
--   Posix:   isValid "/random_ path:*" == True
--   Posix:   isValid x == not (null x)
--   Windows: isValid "c:\\test" == True
--   Windows: isValid "c:\\test:of_test" == False
--   Windows: isValid "test*" == False
--   Windows: isValid "c:\\test\\nul" == False
--   Windows: isValid "c:\\test\\prn.txt" == False
--   Windows: isValid "c:\\nul\\file" == False
--   Windows: isValid "\\\\" == False
--   Windows: isValid "\\\\\\foo" == False
--   Windows: isValid "\\\\?\\D:file" == False
--   Windows: isValid "foo\tbar" == False
--   Windows: isValid "nul .txt" == False
--   Windows: isValid " nul.txt" == True
--   
isValid :: FilePath -> Bool

-- | Take a FilePath and make it valid; does not change already valid
--   FilePaths.
--   
--   
--   isValid (makeValid x)
--   isValid x ==> makeValid x == x
--   makeValid "" == "_"
--   makeValid "file\0name" == "file_name"
--   Windows: makeValid "c:\\already\\/valid" == "c:\\already\\/valid"
--   Windows: makeValid "c:\\test:of_test" == "c:\\test_of_test"
--   Windows: makeValid "test*" == "test_"
--   Windows: makeValid "c:\\test\\nul" == "c:\\test\\nul_"
--   Windows: makeValid "c:\\test\\prn.txt" == "c:\\test\\prn_.txt"
--   Windows: makeValid "c:\\test/prn.txt" == "c:\\test/prn_.txt"
--   Windows: makeValid "c:\\nul\\file" == "c:\\nul_\\file"
--   Windows: makeValid "\\\\\\foo" == "\\\\drive"
--   Windows: makeValid "\\\\?\\D:file" == "\\\\?\\D:\\file"
--   Windows: makeValid "nul .txt" == "nul _.txt"
--   
makeValid :: FilePath -> FilePath

-- | Is a path relative, or is it fixed to the root?
--   
--   
--   Windows: isRelative "path\\test" == True
--   Windows: isRelative "c:\\test" == False
--   Windows: isRelative "c:test" == True
--   Windows: isRelative "c:\\" == False
--   Windows: isRelative "c:/" == False
--   Windows: isRelative "c:" == True
--   Windows: isRelative "\\\\foo" == False
--   Windows: isRelative "\\\\?\\foo" == False
--   Windows: isRelative "\\\\?\\UNC\\foo" == False
--   Windows: isRelative "/foo" == True
--   Windows: isRelative "\\foo" == True
--   Posix:   isRelative "test/path" == True
--   Posix:   isRelative "/test" == False
--   Posix:   isRelative "/" == False
--   
--   
--   According to [1]:
--   
--   
--   
- "A UNC name of any format [is never relative]."
--   
- "You cannot use the "\?" prefix with a relative path."
--   
isRelative :: FilePath -> Bool

-- | 
--   not . isRelative
--   
--   
--   
--   isAbsolute x == not (isRelative x)
--   
isAbsolute :: FilePath -> Bool

-- | Lifted version of getSearchPath
getSearchPath :: MonadIO m => m [FilePath]

-- | Strict Map with hashed keys. Import as:
--   
--   
--   import qualified RIO.HashMap as HM
--   
--   
--   This module does not export any partial functions. For those, see
--   RIO.HashMap.Partial
module RIO.HashMap

-- | A map from keys to values. A map cannot contain duplicate keys; each
--   key can map to at most one value.
data () => HashMap k v

-- | <math> Construct an empty map.
empty :: HashMap k v

-- | <math> Construct a map with a single element.
singleton :: Hashable k => k -> v -> HashMap k v

-- | <math> Return True if this map is empty, False
--   otherwise.
null :: HashMap k v -> Bool

-- | <math> Return the number of key-value mappings in this map.
size :: HashMap k v -> Int

-- | <math> Return True if the specified key is present in the
--   map, False otherwise.
member :: (Eq k, Hashable k) => k -> HashMap k a -> Bool

-- | <math> Return the value to which the specified key is mapped, or
--   Nothing if this map contains no mapping for the key.
lookup :: (Eq k, Hashable k) => k -> HashMap k v -> Maybe v

-- | <math> Return the value to which the specified key is mapped, or
--   the default value if this map contains no mapping for the key.
--   
--   DEPRECATED: lookupDefault is deprecated as of version 0.2.11, replaced
--   by findWithDefault.
lookupDefault :: (Eq k, Hashable k) => v -> k -> HashMap k v -> v

-- | <math> Associate the specified value with the specified key in
--   this map. If this map previously contained a mapping for the key, the
--   old value is replaced.
insert :: (Eq k, Hashable k) => k -> v -> HashMap k v -> HashMap k v

-- | <math> Associate the value with the key in this map. If this map
--   previously contained a mapping for the key, the old value is replaced
--   by the result of applying the given function to the new and old value.
--   Example:
--   
--   
--   insertWith f k v map
--     where f new old = new + old
--   
insertWith :: (Eq k, Hashable k) => (v -> v -> v) -> k -> v -> HashMap k v -> HashMap k v

-- | <math> Remove the mapping for the specified key from this map if
--   present.
delete :: (Eq k, Hashable k) => k -> HashMap k v -> HashMap k v

-- | <math> Adjust the value tied to a given key in this map only if
--   it is present. Otherwise, leave the map alone.
adjust :: (Eq k, Hashable k) => (v -> v) -> k -> HashMap k v -> HashMap k v

-- | <math> The expression (update f k map) updates
--   the value x at k (if it is in the map). If (f
--   x) is Nothing, the element is deleted. If it is
--   (Just y), the key k is bound to the new value
--   y.
update :: (Eq k, Hashable k) => (a -> Maybe a) -> k -> HashMap k a -> HashMap k a

-- | <math> The expression (alter f k map) alters the
--   value x at k, or absence thereof.
--   
--   alter can be used to insert, delete, or update a value in a
--   map. In short:
--   
--   
--   lookup k (alter f k m) = f (lookup k m)
--   
alter :: (Eq k, Hashable k) => (Maybe v -> Maybe v) -> k -> HashMap k v -> HashMap k v

-- | <math> The union of two maps. If a key occurs in both maps, the
--   mapping from the first will be the mapping in the result.
--   
--   
Examples
--   
--   
--   >>> union (fromList [(1,'a'),(2,'b')]) (fromList [(2,'c'),(3,'d')])
--   fromList [(1,'a'),(2,'b'),(3,'d')]
--   
union :: (Eq k, Hashable k) => HashMap k v -> HashMap k v -> HashMap k v

-- | <math> The union of two maps. If a key occurs in both maps, the
--   provided function (first argument) will be used to compute the result.
unionWith :: (Eq k, Hashable k) => (v -> v -> v) -> HashMap k v -> HashMap k v -> HashMap k v

-- | <math> The union of two maps. If a key occurs in both maps, the
--   provided function (first argument) will be used to compute the result.
unionWithKey :: (Eq k, Hashable k) => (k -> v -> v -> v) -> HashMap k v -> HashMap k v -> HashMap k v

-- | Construct a set containing all elements from a list of sets.
unions :: (Eq k, Hashable k) => [HashMap k v] -> HashMap k v

-- | <math> Transform this map by applying a function to every value.
map :: (v1 -> v2) -> HashMap k v1 -> HashMap k v2

-- | <math> Transform this map by applying a function to every value.
mapWithKey :: (k -> v1 -> v2) -> HashMap k v1 -> HashMap k v2

-- | <math> Perform an Applicative action for each key-value
--   pair in a HashMap and produce a HashMap of all the
--   results. Each HashMap will be strict in all its values.
--   
--   
--   traverseWithKey f = fmap (map id) . Data.HashMap.Lazy.traverseWithKey f
--   
--   
--   Note: the order in which the actions occur is unspecified. In
--   particular, when the map contains hash collisions, the order in which
--   the actions associated with the keys involved will depend in an
--   unspecified way on their insertion order.
traverseWithKey :: Applicative f => (k -> v1 -> f v2) -> HashMap k v1 -> f (HashMap k v2)

-- | <math> Difference of two maps. Return elements of the first map
--   not existing in the second.
difference :: (Eq k, Hashable k) => HashMap k v -> HashMap k w -> HashMap k v

-- | <math> Difference with a combining function. When two equal keys
--   are encountered, the combining function is applied to the values of
--   these keys. If it returns Nothing, the element is discarded
--   (proper set difference). If it returns (Just y), the
--   element is updated with a new value y.
differenceWith :: (Eq k, Hashable k) => (v -> w -> Maybe v) -> HashMap k v -> HashMap k w -> HashMap k v

-- | <math> Intersection of two maps. Return elements of the first
--   map for keys existing in the second.
intersection :: (Eq k, Hashable k) => HashMap k v -> HashMap k w -> HashMap k v

-- | <math> Intersection of two maps. If a key occurs in both maps
--   the provided function is used to combine the values from the two maps.
intersectionWith :: (Eq k, Hashable k) => (v1 -> v2 -> v3) -> HashMap k v1 -> HashMap k v2 -> HashMap k v3

-- | <math> Intersection of two maps. If a key occurs in both maps
--   the provided function is used to combine the values from the two maps.
intersectionWithKey :: (Eq k, Hashable k) => (k -> v1 -> v2 -> v3) -> HashMap k v1 -> HashMap k v2 -> HashMap k v3

-- | <math> Reduce this map by applying a binary operator to all
--   elements, using the given starting value (typically the left-identity
--   of the operator). Each application of the operator is evaluated before
--   using the result in the next application. This function is strict in
--   the starting value.
foldl' :: (a -> v -> a) -> a -> HashMap k v -> a

-- | <math> Reduce this map by applying a binary operator to all
--   elements, using the given starting value (typically the left-identity
--   of the operator). Each application of the operator is evaluated before
--   using the result in the next application. This function is strict in
--   the starting value.
foldlWithKey' :: (a -> k -> v -> a) -> a -> HashMap k v -> a

-- | <math> Reduce this map by applying a binary operator to all
--   elements, using the given starting value (typically the right-identity
--   of the operator).
foldr :: (v -> a -> a) -> a -> HashMap k v -> a

-- | <math> Reduce this map by applying a binary operator to all
--   elements, using the given starting value (typically the right-identity
--   of the operator).
foldrWithKey :: (k -> v -> a -> a) -> a -> HashMap k v -> a

-- | <math> Filter this map by retaining only elements which values
--   satisfy a predicate.
filter :: (v -> Bool) -> HashMap k v -> HashMap k v

-- | <math> Filter this map by retaining only elements satisfying a
--   predicate.
filterWithKey :: (k -> v -> Bool) -> HashMap k v -> HashMap k v

-- | <math> Transform this map by applying a function to every value
--   and retaining only some of them.
mapMaybe :: (v1 -> Maybe v2) -> HashMap k v1 -> HashMap k v2

-- | <math> Transform this map by applying a function to every value
--   and retaining only some of them.
mapMaybeWithKey :: (k -> v1 -> Maybe v2) -> HashMap k v1 -> HashMap k v2

-- | <math> Return a list of this map's keys. The list is produced
--   lazily.
keys :: HashMap k v -> [k]

-- | <math> Return a list of this map's values. The list is produced
--   lazily.
elems :: HashMap k v -> [v]

-- | <math> Return a list of this map's elements. The list is
--   produced lazily. The order of its elements is unspecified.
toList :: HashMap k v -> [(k, v)]

-- | <math> Construct a map with the supplied mappings. If the list
--   contains duplicate mappings, the later mappings take precedence.
fromList :: (Eq k, Hashable k) => [(k, v)] -> HashMap k v

-- | <math> Construct a map from a list of elements. Uses the
--   provided function f to merge duplicate entries with (f
--   newVal oldVal).
--   
--   
Examples
--   
--   Given a list xs, create a map with the number of occurrences
--   of each element in xs:
--   
--   
--   let xs = ['a', 'b', 'a']
--   in fromListWith (+) [ (x, 1) | x <- xs ]
--   
--   = fromList [('a', 2), ('b', 1)]
--   
--   
--   Given a list of key-value pairs xs :: [(k, v)], group all
--   values by their keys and return a HashMap k [v].
--   
--   
--   let xs = ('a', 1), ('b', 2), ('a', 3)]
--   in fromListWith (++) [ (k, [v]) | (k, v) <- xs ]
--   
--   = fromList [('a', [3, 1]), ('b', [2])]
--   
--   
--   Note that the lists in the resulting map contain elements in reverse
--   order from their occurences in the original list.
--   
--   More generally, duplicate entries are accumulated as follows; this
--   matters when f is not commutative or not associative.
--   
--   
--   fromListWith f [(k, a), (k, b), (k, c), (k, d)]
--   = fromList [(k, f d (f c (f b a)))]
--   
fromListWith :: (Eq k, Hashable k) => (v -> v -> v) -> [(k, v)] -> HashMap k v

-- | Strict HashMap partial functions. Import as:
--   
--   
--   import qualified RIO.HashMap.Partial as HM'
--   
module RIO.HashMap.Partial

-- | <math> Return the value to which the specified key is mapped.
--   Calls error if this map contains no mapping for the key.
(!) :: (Eq k, Hashable k, HasCallStack) => HashMap k v -> k -> v
infixl 9 !

-- | Set with hashed members. Import as:
--   
--   
--   import qualified RIO.HashSet as HS
--   
module RIO.HashSet

-- | A set of values. A set cannot contain duplicate values.
data () => HashSet a

-- | <math> Construct an empty set.
--   
--   
--   >>> HashSet.empty
--   fromList []
--   
empty :: HashSet a

-- | <math> Construct a set with a single element.
--   
--   
--   >>> HashSet.singleton 1
--   fromList [1]
--   
singleton :: Hashable a => a -> HashSet a

-- | <math> Construct a set containing all elements from both sets.
--   
--   To obtain good performance, the smaller set must be presented as the
--   first argument.
--   
--   
--   >>> union (fromList [1,2]) (fromList [2,3])
--   fromList [1,2,3]
--   
union :: (Eq a, Hashable a) => HashSet a -> HashSet a -> HashSet a

-- | Construct a set containing all elements from a list of sets.
unions :: (Eq a, Hashable a) => [HashSet a] -> HashSet a

-- | <math> Return True if this set is empty, False
--   otherwise.
--   
--   
--   >>> HashSet.null HashSet.empty
--   True
--   
--   >>> HashSet.null (HashSet.singleton 1)
--   False
--   
null :: HashSet a -> Bool

-- | <math> Return the number of elements in this set.
--   
--   
--   >>> HashSet.size HashSet.empty
--   0
--   
--   >>> HashSet.size (HashSet.fromList [1,2,3])
--   3
--   
size :: HashSet a -> Int

-- | <math> Return True if the given value is present in this
--   set, False otherwise.
--   
--   
--   >>> HashSet.member 1 (Hashset.fromList [1,2,3])
--   True
--   
--   >>> HashSet.member 1 (Hashset.fromList [4,5,6])
--   False
--   
member :: (Eq a, Hashable a) => a -> HashSet a -> Bool

-- | <math> Add the specified value to this set.
--   
--   
--   >>> HashSet.insert 1 HashSet.empty
--   fromList [1]
--   
insert :: (Eq a, Hashable a) => a -> HashSet a -> HashSet a

-- | <math> Remove the specified value from this set if present.
--   
--   
--   >>> HashSet.delete 1 (HashSet.fromList [1,2,3])
--   fromList [2,3]
--   
--   >>> HashSet.delete 1 (HashSet.fromList [4,5,6])
--   fromList [4,5,6]
--   
delete :: (Eq a, Hashable a) => a -> HashSet a -> HashSet a

-- | <math> Transform this set by applying a function to every value.
--   The resulting set may be smaller than the source.
--   
--   
--   >>> HashSet.map show (HashSet.fromList [1,2,3])
--   HashSet.fromList ["1","2","3"]
--   
map :: (Hashable b, Eq b) => (a -> b) -> HashSet a -> HashSet b

-- | <math> Difference of two sets. Return elements of the first set
--   not existing in the second.
--   
--   
--   >>> HashSet.difference (HashSet.fromList [1,2,3]) (HashSet.fromList [2,3,4])
--   fromList [1]
--   
difference :: (Eq a, Hashable a) => HashSet a -> HashSet a -> HashSet a

-- | <math> Intersection of two sets. Return elements present in both
--   the first set and the second.
--   
--   
--   >>> HashSet.intersection (HashSet.fromList [1,2,3]) (HashSet.fromList [2,3,4])
--   fromList [2,3]
--   
intersection :: (Eq a, Hashable a) => HashSet a -> HashSet a -> HashSet a

-- | <math> Reduce this set by applying a binary operator to all
--   elements, using the given starting value (typically the left-identity
--   of the operator). Each application of the operator is evaluated before
--   before using the result in the next application. This function is
--   strict in the starting value.
foldl' :: (a -> b -> a) -> a -> HashSet b -> a

-- | <math> Reduce this set by applying a binary operator to all
--   elements, using the given starting value (typically the right-identity
--   of the operator).
foldr :: (b -> a -> a) -> a -> HashSet b -> a

-- | <math> Filter this set by retaining only elements satisfying a
--   predicate.
filter :: (a -> Bool) -> HashSet a -> HashSet a

-- | <math> Return a list of this set's elements. The list is
--   produced lazily.
toList :: HashSet a -> [a]

-- | <math> Construct a set from a list of elements.
fromList :: (Eq a, Hashable a) => [a] -> HashSet a

-- | <math> Convert to set to the equivalent HashMap with
--   () values.
--   
--   
--   >>> HashSet.toMap (HashSet.singleton 1)
--   fromList [(1,())]
--   
toMap :: HashSet a -> HashMap a ()

-- | <math> Convert from the equivalent HashMap with
--   () values.
--   
--   
--   >>> HashSet.fromMap (HashMap.singleton 1 ())
--   fromList [1]
--   
fromMap :: HashMap a () -> HashSet a

-- | Extra utilities from microlens.
--   
--   @since: 0.1.16.0
module RIO.Lens

-- | A SimpleFold s a extracts several as from
--   s; so, it's pretty much the same thing as (s ->
--   [a]), but you can use it with lens operators.
--   
--   The actual Fold from lens is more general:
--   
--   
--   type Fold s a =
--     forall f. (Contravariant f, Applicative f) => (a -> f a) -> s -> f s
--   
--   
--   There are several functions in lens that accept lens's Fold
--   but won't accept SimpleFold; I'm aware of
--   takingWhile, droppingWhile,
--   backwards, foldByOf,
--   foldMapByOf. For this reason, try not to export
--   SimpleFolds if at all possible. microlens-contra
--   provides a fully lens-compatible Fold.
--   
--   Lens users: you can convert a SimpleFold to Fold by
--   applying folded . toListOf to it.
type SimpleFold s a = forall r. Monoid r => Getting r s a

-- | toListOf is a synonym for (^..).
toListOf :: Getting (Endo [a]) s a -> s -> [a]

-- | has checks whether a getter (any getter, including lenses,
--   traversals, and folds) returns at least 1 value.
--   
--   Checking whether a list is non-empty:
--   
--   
--   >>> has each []
--   False
--   
--   
--   You can also use it with e.g. _Left (and other 0-or-1
--   traversals) as a replacement for isNothing, isJust and
--   other isConstructorName functions:
--   
--   
--   >>> has _Left (Left 1)
--   True
--   
has :: Getting Any s a -> s -> Bool

-- | Gives access to the 1st field of a tuple (up to 5-tuples).
--   
--   Getting the 1st component:
--   
--   
--   >>> (1,2,3,4,5) ^. _1
--   1
--   
--   
--   Setting the 1st component:
--   
--   
--   >>> (1,2,3) & _1 .~ 10
--   (10,2,3)
--   
--   
--   Note that this lens is lazy, and can set fields even of
--   undefined:
--   
--   
--   >>> set _1 10 undefined :: (Int, Int)
--   (10,*** Exception: Prelude.undefined
--   
--   
--   This is done to avoid violating a lens law stating that you can get
--   back what you put:
--   
--   
--   >>> view _1 . set _1 10 $ (undefined :: (Int, Int))
--   10
--   
--   
--   The implementation (for 2-tuples) is:
--   
--   
--   _1 f t = (,) <$> f    (fst t)
--                <*> pure (snd t)
--   
--   
--   or, alternatively,
--   
--   
--   _1 f ~(a,b) = (\a' -> (a',b)) <$> f a
--   
--   
--   (where ~ means a lazy pattern).
--   
--   _2, _3, _4, and _5 are also available (see
--   below).
_1 :: Field1 s t a b => Lens s t a b
_2 :: Field2 s t a b => Lens s t a b
_3 :: Field3 s t a b => Lens s t a b
_4 :: Field4 s t a b => Lens s t a b
_5 :: Field5 s t a b => Lens s t a b

-- | This lens lets you read, write, or delete elements in
--   Map-like structures. It returns Nothing when the value
--   isn't found, just like lookup:
--   
--   
--   Data.Map.lookup k m = m ^. at k
--   
--   
--   However, it also lets you insert and delete values by setting the
--   value to Just value or Nothing:
--   
--   
--   Data.Map.insert k a m = m & at k .~ Just a
--   
--   Data.Map.delete k m = m & at k .~ Nothing
--   
--   
--   Or you could use (?~) instead of (.~):
--   
--   
--   Data.Map.insert k a m = m & at k ?~ a
--   
--   
--   Note that at doesn't work for arrays or lists. You can't delete
--   an arbitrary element from an array (what would be left in its place?),
--   and you can't set an arbitrary element in a list because if the index
--   is out of list's bounds, you'd have to somehow fill the stretch
--   between the last element and the element you just inserted (i.e.
--   [1,2,3] & at 10 .~ 5 is undefined). If you want to modify
--   an already existing value in an array or list, you should use
--   ix instead.
--   
--   at is often used with non. See the documentation of
--   non for examples.
--   
--   Note that at isn't strict for Map, even if you're
--   using Data.Map.Strict:
--   
--   
--   >>> Data.Map.Strict.size (Data.Map.Strict.empty & at 1 .~ Just undefined)
--   1
--   
--   
--   The reason for such behavior is that there's actually no “strict
--   Map” type; Data.Map.Strict just provides some strict
--   functions for ordinary Maps.
--   
--   This package doesn't actually provide any instances for at, but
--   there are instances for Map and IntMap in
--   microlens-ghc and an instance for HashMap in
--   microlens-platform.
at :: At m => Index m -> Lens' m (Maybe (IxValue m))

-- | lens creates a Lens from a getter and a setter. The
--   resulting lens isn't the most effective one (because of having to
--   traverse the structure twice when modifying), but it shouldn't matter
--   much.
--   
--   A (partial) lens for list indexing:
--   
--   
--   ix :: Int -> Lens' [a] a
--   ix i = lens (!! i)                                   -- getter
--               (\s b -> take i s ++ b : drop (i+1) s)   -- setter
--   
--   
--   Usage:
--   
--   
--   >>> [1..9] ^. ix 3
--   4
--   
--   >>> [1..9] & ix 3 %~ negate
--   [1,2,3,-4,5,6,7,8,9]
--   
--   
--   When getting, the setter is completely unused; when setting, the
--   getter is unused. Both are used only when the value is being modified.
--   For instance, here we define a lens for the 1st element of a list, but
--   instead of a legitimate getter we use undefined. Then we use
--   the resulting lens for setting and it works, which proves that
--   the getter wasn't used:
--   
--   
--   >>> [1,2,3] & lens undefined (\s b -> b : tail s) .~ 10
--   [10,2,3]
--   
lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b

-- | non lets you “relabel” a Maybe by equating
--   Nothing to an arbitrary value (which you can choose):
--   
--   
--   >>> Just 1 ^. non 0
--   1
--   
--   
--   
--   >>> Nothing ^. non 0
--   0
--   
--   
--   The most useful thing about non is that relabeling also works
--   in other direction. If you try to set the “forbidden” value,
--   it'll be turned to Nothing:
--   
--   
--   >>> Just 1 & non 0 .~ 0
--   Nothing
--   
--   
--   Setting anything else works just fine:
--   
--   
--   >>> Just 1 & non 0 .~ 5
--   Just 5
--   
--   
--   Same happens if you try to modify a value:
--   
--   
--   >>> Just 1 & non 0 %~ subtract 1
--   Nothing
--   
--   
--   
--   >>> Just 1 & non 0 %~ (+ 1)
--   Just 2
--   
--   
--   non is often useful when combined with at. For instance,
--   if you have a map of songs and their playcounts, it makes sense not to
--   store songs with 0 plays in the map; non can act as a filter
--   that wouldn't pass such entries.
--   
--   Decrease playcount of a song to 0, and it'll be gone:
--   
--   
--   >>> fromList [("Soon",1),("Yesterday",3)] & at "Soon" . non 0 %~ subtract 1
--   fromList [("Yesterday",3)]
--   
--   
--   Try to add a song with 0 plays, and it won't be added:
--   
--   
--   >>> fromList [("Yesterday",3)] & at "Soon" . non 0 .~ 0
--   fromList [("Yesterday",3)]
--   
--   
--   But it will be added if you set any other number:
--   
--   
--   >>> fromList [("Yesterday",3)] & at "Soon" . non 0 .~ 1
--   fromList [("Soon",1),("Yesterday",3)]
--   
--   
--   non is also useful when working with nested maps. Here a nested
--   map is created when it's missing:
--   
--   
--   >>> Map.empty & at "Dez Mona" . non Map.empty . at "Soon" .~ Just 1
--   fromList [("Dez Mona",fromList [("Soon",1)])]
--   
--   
--   and here it is deleted when its last entry is deleted (notice that
--   non is used twice here):
--   
--   
--   >>> fromList [("Dez Mona",fromList [("Soon",1)])] & at "Dez Mona" . non Map.empty . at "Soon" . non 0 %~ subtract 1
--   fromList []
--   
--   
--   To understand the last example better, observe the flow of values in
--   it:
--   
--   
--   
- the map goes into at "Dez Mona"
--   
- the nested map (wrapped into Just) goes into non
--   Map.empty
--   
- Just is unwrapped and the nested map goes into at
--   "Soon"
--   
- Just 1 is unwrapped by non 0
--   
--   
--   Then the final value – i.e. 1 – is modified by subtract 1 and
--   the result (which is 0) starts flowing backwards:
--   
--   
--   
- non 0 sees the 0 and produces a Nothing
--   
- at "Soon" sees Nothing and deletes the
--   corresponding value from the map
--   
- the resulting empty map is passed to non Map.empty, which
--   sees that it's empty and thus produces Nothing
--   
- at "Dez Mona" sees Nothing and removes the key
--   from the map
--   
non :: Eq a => a -> Lens' (Maybe a) a

-- | singular turns a traversal into a lens that behaves like a
--   single-element traversal:
--   
--   
--   >>> [1,2,3] ^. singular each
--   1
--   
--   
--   
--   >>> [1,2,3] & singular each %~ negate
--   [-1,2,3]
--   
--   
--   If there is nothing to return, it'll throw an error:
--   
--   
--   >>> [] ^. singular each
--   *** Exception: Lens.Micro.singular: empty traversal
--   
--   
--   However, it won't fail if you are merely setting the value:
--   
--   
--   >>> [] & singular each %~ negate
--   
singular :: HasCallStack => Traversal s t a a -> Lens s t a a

-- | failing lets you chain traversals together; if the 1st
--   traversal fails, the 2nd traversal will be used.
--   
--   
--   >>> ([1,2],[3]) & failing (_1.each) (_2.each) .~ 0
--   ([0,0],[3])
--   
--   
--   
--   >>> ([],[3]) & failing (_1.each) (_2.each) .~ 0
--   ([],[0])
--   
--   
--   Note that the resulting traversal won't be valid unless either both
--   traversals don't touch each others' elements, or both traversals
--   return exactly the same results. To see an example of how
--   failing can generate invalid traversals, see this
--   Stackoverflow question.
failing :: Traversal s t a b -> Traversal s t a b -> Traversal s t a b
infixl 5 `failing`

-- | filtered is a traversal that filters elements “passing” through
--   it:
--   
--   
--   >>> (1,2,3,4) ^.. each
--   [1,2,3,4]
--   
--   
--   
--   >>> (1,2,3,4) ^.. each . filtered even
--   [2,4]
--   
--   
--   It also can be used to modify elements selectively:
--   
--   
--   >>> (1,2,3,4) & each . filtered even %~ (*100)
--   (1,200,3,400)
--   
--   
--   The implementation of filtered is very simple. Consider this
--   traversal, which always “traverses” just the value it's given:
--   
--   
--   id :: Traversal' a a
--   id f s = f s
--   
--   
--   And this traversal, which traverses nothing (in other words,
--   doesn't traverse the value it's given):
--   
--   
--   ignored :: Traversal' a a
--   ignored f s = pure s
--   
--   
--   And now combine them into a traversal that conditionally traverses the
--   value it's given, and you get filtered:
--   
--   
--   filtered :: (a -> Bool) -> Traversal' a a
--   filtered p f s = if p s then f s else pure s
--   
--   
--   By the way, note that filtered can generate illegal traversals
--   – sometimes this can bite you. In particular, an optimisation that
--   should be safe becomes unsafe. (To the best of my knowledge, this
--   optimisation never happens automatically. If you just use
--   filtered to modify/view something, you're safe. If you don't
--   define any traversals that use filtered, you're safe too.)
--   
--   Let's use evens as an example:
--   
--   
--   evens = filtered even
--   
--   
--   If evens was a legal traversal, you'd be able to fuse several
--   applications of evens like this:
--   
--   
--   over evens f . over evens g = over evens (f . g)
--   
--   
--   Unfortunately, in case of evens this isn't a correct
--   optimisation:
--   
--   
--   
- the left-side variant applies g to all even numbers, and
--   then applies f to all even numbers that are left after
--   f (because f might've turned some even numbers into
--   odd ones)
--   
- the right-side variant applies f and g to all
--   even numbers
--   
--   
--   Of course, when you are careful and know what you're doing, you won't
--   try to make such an optimisation. However, if you export an illegal
--   traversal created with filtered and someone tries to use it,
--   they might mistakenly assume that it's legal, do the optimisation, and
--   silently get an incorrect result.
--   
--   If you are using filtered with some another traversal that
--   doesn't overlap with -whatever the predicate checks-, the resulting
--   traversal will be legal. For instance, here the predicate looks at the
--   1st element of a tuple, but the resulting traversal only gives you
--   access to the 2nd:
--   
--   
--   pairedWithEvens :: Traversal [(Int, a)] [(Int, b)] a b
--   pairedWithEvens = each . filtered (even . fst) . _2
--   
--   
--   Since you can't do anything with the 1st components through this
--   traversal, the following holds for any f and g:
--   
--   
--   over pairedWithEvens f . over pairedWithEvens g = over pairedWithEvens (f . g)
--   
filtered :: (a -> Bool) -> Traversal' a a

-- | both traverses both fields of a tuple. Unlike
--   both from lens, it only works for pairs – not for
--   triples or Either.
--   
--   
--   >>> ("str","ing") ^. both
--   "string"
--   
--   
--   
--   >>> ("str","ing") & both %~ reverse
--   ("rts","gni")
--   
both :: forall a b f. Applicative f => (a -> f b) -> (a, a) -> f (b, b)

-- | traversed traverses any Traversable container (list,
--   vector, Map, Maybe, you name it):
--   
--   
--   >>> Just 1 ^.. traversed
--   [1]
--   
--   
--   traversed is the same as traverse, but can be faster
--   thanks to magic rewrite rules.
traversed :: forall (f :: Type -> Type) a b. Traversable f => Traversal (f a) (f b) a b

-- | each tries to be a universal Traversal – it behaves like
--   traversed in most situations, but also adds support for e.g.
--   tuples with same-typed values:
--   
--   
--   >>> (1,2) & each %~ succ
--   (2,3)
--   
--   
--   
--   >>> ["x", "y", "z"] ^. each
--   "xyz"
--   
--   
--   However, note that each doesn't work on every instance
--   of Traversable. If you have a Traversable which isn't
--   supported by each, you can use traversed instead.
--   Personally, I like using each instead of traversed
--   whenever possible – it's shorter and more descriptive.
--   
--   You can use each with these things:
--   
--   
--   each :: Traversal [a] [b] a b
--   
--   each :: Traversal (Maybe a) (Maybe b) a b
--   each :: Traversal (Either a a) (Either b b) a b  -- since 0.4.11
--   
--   each :: Traversal (a,a) (b,b) a b
--   each :: Traversal (a,a,a) (b,b,b) a b
--   each :: Traversal (a,a,a,a) (b,b,b,b) a b
--   each :: Traversal (a,a,a,a,a) (b,b,b,b,b) a b
--   
--   each :: (RealFloat a, RealFloat b) => Traversal (Complex a) (Complex b) a b
--   
--   
--   You can also use each with types from array,
--   bytestring, and containers by using
--   microlens-ghc, or additionally with types from vector,
--   text, and unordered-containers by using
--   microlens-platform.
each :: Each s t a b => Traversal s t a b

-- | This traversal lets you access (and update) an arbitrary element in a
--   list, array, Map, etc. (If you want to insert or delete
--   elements as well, look at at.)
--   
--   An example for lists:
--   
--   
--   >>> [0..5] & ix 3 .~ 10
--   [0,1,2,10,4,5]
--   
--   
--   You can use it for getting, too:
--   
--   
--   >>> [0..5] ^? ix 3
--   Just 3
--   
--   
--   Of course, the element may not be present (which means that you can
--   use ix as a safe variant of (!!)):
--   
--   
--   >>> [0..5] ^? ix 10
--   Nothing
--   
--   
--   Another useful instance is the one for functions – it lets you modify
--   their outputs for specific inputs. For instance, here's maximum
--   that returns 0 when the list is empty (instead of throwing an
--   exception):
--   
--   
--   maximum0 = maximum & ix [] .~ 0
--   
--   
--   The following instances are provided in this package:
--   
--   
--   ix :: Int -> Traversal' [a] a
--   
--   ix :: Int -> Traversal' (NonEmpty a) a
--   
--   ix :: (Eq e) => e -> Traversal' (e -> a) a
--   
--   
--   You can also use ix with types from array,
--   bytestring, and containers by using
--   microlens-ghc, or additionally with types from vector,
--   text, and unordered-containers by using
--   microlens-platform.
ix :: Ixed m => Index m -> Traversal' m (IxValue m)

-- | _head traverses the 1st element of something (usually a list,
--   but can also be a Seq, etc):
--   
--   
--   >>> [1..5] ^? _head
--   Just 1
--   
--   
--   It can be used to modify too, as in this example where the 1st letter
--   of a sentence is capitalised:
--   
--   
--   >>> "mary had a little lamb." & _head %~ toTitle
--   "Mary had a little lamb."
--   
--   
--   The reason it's a traversal and not a lens is that there's nothing to
--   traverse when the list is empty:
--   
--   
--   >>> [] ^? _head
--   Nothing
--   
--   
--   This package only lets you use _head on lists, but if you use
--   microlens-ghc you get instances for ByteString and
--   Seq, and if you use microlens-platform you
--   additionally get instances for Text and Vector.
_head :: Cons s s a a => Traversal' s a

-- | _tail gives you access to the tail of a list (or Seq,
--   etc):
--   
--   
--   >>> [1..5] ^? _tail
--   Just [2,3,4,5]
--   
--   
--   You can modify the tail as well:
--   
--   
--   >>> [4,1,2,3] & _tail %~ reverse
--   [4,3,2,1]
--   
--   
--   Since lists are monoids, you can use _tail with plain
--   (^.) (and then it'll return an empty list if you give it an
--   empty list):
--   
--   
--   >>> [1..5] ^. _tail
--   [2,3,4,5]
--   
--   
--   
--   >>> [] ^. _tail
--   []
--   
--   
--   If you want to traverse each element of the tail, use
--   _tail with each:
--   
--   
--   >>> "I HATE CAPS." & _tail.each %~ toLower
--   "I hate caps."
--   
--   
--   This package only lets you use _tail on lists, but if you use
--   microlens-ghc you get instances for ByteString and
--   Seq, and if you use microlens-platform you
--   additionally get instances for Text and Vector.
_tail :: Cons s s a a => Traversal' s s

-- | _init gives you access to all-but-the-last elements of the
--   list:
--   
--   
--   >>> "Hello." ^. _init
--   "Hello"
--   
--   
--   See documentation for _tail, as _init and _tail
--   are pretty similar.
_init :: Snoc s s a a => Traversal' s s

-- | _last gives you access to the last element of the list:
--   
--   
--   >>> "Hello." ^? _last
--   '.'
--   
--   
--   See documentation for _head, as _last and _head
--   are pretty similar.
_last :: Snoc s s a a => Traversal' s a

-- | _Left targets the value contained in an Either, provided
--   it's a Left.
--   
--   Gathering all Lefts in a structure (like the lefts
--   function, but not necessarily just for lists):
--   
--   
--   >>> [Left 1, Right 'c', Left 3] ^.. each._Left
--   [1,3]
--   
--   
--   Checking whether an Either is a Left (like
--   isLeft):
--   
--   
--   >>> has _Left (Left 1)
--   True
--   
--   
--   
--   >>> has _Left (Right 1)
--   False
--   
--   
--   Extracting a value (if you're sure it's a Left):
--   
--   
--   >>> Left 1 ^?! _Left
--   1
--   
--   
--   Mapping over all Lefts:
--   
--   
--   >>> (each._Left %~ map toUpper) [Left "foo", Right "bar"]
--   [Left "FOO",Right "bar"]
--   
--   
--   Implementation:
--   
--   
--   _Left f (Left a)  = Left <$> f a
--   _Left _ (Right b) = pure (Right b)
--   
_Left :: forall a b a' f. Applicative f => (a -> f a') -> Either a b -> f (Either a' b)

-- | _Right targets the value contained in an Either,
--   provided it's a Right.
--   
--   See documentation for _Left.
_Right :: forall a b b' f. Applicative f => (b -> f b') -> Either a b -> f (Either a b')

-- | _Just targets the value contained in a Maybe, provided
--   it's a Just.
--   
--   See documentation for _Left (as these 2 are pretty similar). In
--   particular, it can be used to write these:
--   
--   
--   
- Unsafely extracting a value from a Just:
--   
--   
--   
--   fromJust = (^?! _Just)
--   
--   
--   
--   
--   
- Checking whether a value is a Just:
--   
--   
--   
--   isJust = has _Just
--   
--   
--   
--   
--   
- Converting a Maybe to a list (empty or consisting of a
--   single element):
--   
--   
--   
--   maybeToList = (^.. _Just)
--   
--   
--   
--   
--   
- Gathering all Justs in a list:
--   
--   
--   
--   catMaybes = (^.. each . _Just)
--   
--   
_Just :: forall a a' f. Applicative f => (a -> f a') -> Maybe a -> f (Maybe a')

-- | _Nothing targets a () if the Maybe is a
--   Nothing, and doesn't target anything otherwise:
--   
--   
--   >>> Just 1 ^.. _Nothing
--   []
--   
--   
--   
--   >>> Nothing ^.. _Nothing
--   [()]
--   
--   
--   It's not particularly useful (unless you want to use has
--   _Nothing as a replacement for isNothing), and
--   provided mainly for consistency.
--   
--   Implementation:
--   
--   
--   _Nothing f Nothing = const Nothing <$> f ()
--   _Nothing _ j       = pure j
--   
_Nothing :: forall a f. Applicative f => (() -> f ()) -> Maybe a -> f (Maybe a)

-- | List. Import as:
--   
--   
--   import qualified RIO.List as L
--   
--   
--   This module does not export any partial functions. For those, see
--   RIO.List.Partial
module RIO.List

-- | Append 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.
--   
--   WARNING: This function takes linear time in the number of elements of
--   the first list.
(++) :: [a] -> [a] -> [a]
infixr 5 ++

-- | <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.
--   
--   
--   
--   >>> uncons []
--   Nothing
--   
--   >>> uncons [1]
--   Just (1,[])
--   
--   >>> uncons [1, 2, 3]
--   Just (1,[2,3])
--   
uncons :: [a] -> Maybe (a, [a])

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

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

headMaybe :: [a] -> Maybe a

lastMaybe :: [a] -> Maybe a

tailMaybe :: [a] -> Maybe [a]

initMaybe :: [a] -> Maybe [a]

-- | <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, ...]
--   
--   
--   
--   >>> map (+1) [1, 2, 3]
--   [2,3,4]
--   
map :: (a -> b) -> [a] -> [b]

-- | reverse xs returns the elements of xs in
--   reverse order. xs must be finite.
--   
--   
--   >>> reverse []
--   []
--   
--   >>> reverse [42]
--   [42]
--   
--   >>> reverse [2,5,7]
--   [7,5,2]
--   
--   >>> reverse [1..]
--   * Hangs forever *
--   
reverse :: [a] -> [a]

-- | <math>. The intersperse function takes an element and a
--   list and `intersperses' that element between the elements of the list.
--   For example,
--   
--   
--   >>> intersperse ',' "abcde"
--   "a,b,c,d,e"
--   
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.
--   
--   
--   >>> intercalate ", " ["Lorem", "ipsum", "dolor"]
--   "Lorem, ipsum, dolor"
--   
intercalate :: [a] -> [[a]] -> [a]

-- | The transpose function transposes the rows and columns of its
--   argument. For example,
--   
--   
--   >>> 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]]
--   
transpose :: [[a]] -> [[a]]

-- | The subsequences function returns the list of all subsequences
--   of the argument.
--   
--   
--   >>> subsequences "abc"
--   ["","a","b","ab","c","ac","bc","abc"]
--   
subsequences :: [a] -> [[a]]

-- | The permutations function returns the list of all permutations
--   of the argument.
--   
--   
--   >>> permutations "abc"
--   ["abc","bac","cba","bca","cab","acb"]
--   
permutations :: [a] -> [[a]]

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

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

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

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

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

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

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

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

maximumMaybe :: (Ord a, Foldable t) => t a -> Maybe a

minimumMaybe :: (Ord a, Foldable t) => t a -> Maybe a

maximumByMaybe :: Foldable t => (a -> a -> Ordering) -> t a -> Maybe a

minimumByMaybe :: Foldable t => (a -> a -> Ordering) -> t a -> Maybe 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
--   
--   
--   
--   >>> 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"]
--   
--   >>> scanl (+) 0 [1..]
--   * Hangs forever *
--   
scanl :: (b -> a -> b) -> b -> [a] -> [b]

-- | <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.
--   
--   
--   
--   >>> 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>. scanl1 is a variant of scanl that has no
--   starting value argument:
--   
--   
--   scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
--   
--   
--   
--   >>> 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]
--   
--   >>> scanl1 (+) [1..]
--   * Hangs forever *
--   
scanl1 :: (a -> a -> a) -> [a] -> [a]

-- | <math>. scanr1 is a variant of scanr that has no
--   starting value argument.
--   
--   
--   >>> 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]

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

-- | iterate f x returns an infinite list of repeated
--   applications of f to x:
--   
--   
--   iterate f x == [x, f x, f (f x), ...]
--   
--   
--   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 10 $ iterate not True
--   [True,False,True,False...
--   
--   >>> take 10 $ iterate (+3) 42
--   [42,45,48,51,54,57,60,63...
--   
iterate :: (a -> a) -> a -> [a]

-- | repeat x is an infinite list, with x the
--   value of every element.
--   
--   
--   >>> take 20 $ repeat 17
--   [17,17,17,17,17,17,17,17,17...
--   
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.
--   
--   
--   >>> replicate 0 True
--   []
--   
--   >>> replicate (-1) True
--   []
--   
--   >>> replicate 4 True
--   [True,True,True,True]
--   
replicate :: Int -> 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.
--   
--   
--   >>> cycle []
--   *** Exception: Prelude.cycle: empty list
--   
--   >>> take 20 $ cycle [42]
--   [42,42,42,42,42,42,42,42,42,42...
--   
--   >>> take 20 $ cycle [2, 5, 7]
--   [2,5,7,2,5,7,2,5,7,2,5,7...
--   
cycle :: HasCallStack => [a] -> [a]

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

-- | take n, applied to a list xs, returns the
--   prefix of xs of length n, or xs itself if
--   n >= length xs.
--   
--   
--   >>> 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]
--   []
--   
--   
--   It is an instance of the more general genericTake, in which
--   n may be of any integral type.
take :: Int -> [a] -> [a]

-- | drop n xs returns the suffix of xs after the
--   first n elements, or [] if n >= length
--   xs.
--   
--   
--   >>> 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]
--   
--   
--   It is an instance of the more general genericDrop, in which
--   n may be of any integral type.
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 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])
--   
--   
--   It is equivalent to (take n xs, drop n xs) when
--   n is not _|_ (splitAt _|_ xs = _|_).
--   splitAt is an instance of the more general
--   genericSplitAt, in which n may be of any integral
--   type.
splitAt :: Int -> [a] -> ([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.
--   
--   
--   >>> 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.
--   
--   
--   >>> 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]

-- | The dropWhileEnd function drops the largest suffix of a list in
--   which the given predicate holds for all elements. For example:
--   
--   
--   >>> dropWhileEnd isSpace "foo\n"
--   "foo"
--   
--   
--   
--   >>> dropWhileEnd isSpace "foo bar"
--   "foo bar"
--   
--   
--   
--   dropWhileEnd isSpace ("foo\n" ++ undefined) == "foo" ++ undefined
--   
dropWhileEnd :: (a -> Bool) -> [a] -> [a]

-- | span, 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 satisfy p and second element
--   is the remainder of the list:
--   
--   
--   >>> 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 p xs is equivalent to (takeWhile p xs,
--   dropWhile p xs)
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 (> 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 p is equivalent to span (not .
--   p).
break :: (a -> Bool) -> [a] -> ([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.
--   
--   
--   >>> stripPrefix "foo" "foobar"
--   Just "bar"
--   
--   
--   
--   >>> stripPrefix "foo" "foo"
--   Just ""
--   
--   
--   
--   >>> stripPrefix "foo" "barfoo"
--   Nothing
--   
--   
--   
--   >>> stripPrefix "foo" "barfoobaz"
--   Nothing
--   
stripPrefix :: Eq a => [a] -> [a] -> Maybe [a]

-- | Remove the suffix from the given list, if present
stripSuffix :: Eq a => [a] -> [a] -> Maybe [a]

-- | Drop prefix if present, otherwise return original list.
dropPrefix :: Eq a => [a] -> [a] -> [a]

-- | Drop prefix if present, otherwise return original list.
dropSuffix :: Eq a => [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 contains only equal elements. For
--   example,
--   
--   
--   >>> group "Mississippi"
--   ["M","i","ss","i","ss","i","pp","i"]
--   
--   
--   It is a special case of groupBy, which allows the programmer to
--   supply their own equality test.
group :: Eq a => [a] -> [[a]]

-- | The inits function returns all initial segments of the
--   argument, shortest first. For example,
--   
--   
--   >>> inits "abc"
--   ["","a","ab","abc"]
--   
--   
--   Note that inits has the following strictness property:
--   inits (xs ++ _|_) = inits xs ++ _|_
--   
--   In particular, inits _|_ = [] : _|_
inits :: [a] -> [[a]]

-- | <math>. The tails function returns all final segments of
--   the argument, longest first. For example,
--   
--   
--   >>> tails "abc"
--   ["abc","bc","c",""]
--   
--   
--   Note that tails has the following strictness property:
--   tails _|_ = _|_ : _|_
tails :: [a] -> [[a]]

-- | <math>. The isPrefixOf function takes two lists and
--   returns True iff the first list is a prefix of the second.
--   
--   
--   >>> "Hello" `isPrefixOf` "Hello World!"
--   True
--   
--   
--   
--   >>> "Hello" `isPrefixOf` "Wello Horld!"
--   False
--   
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. The second list must be
--   finite.
--   
--   
--   >>> "ld!" `isSuffixOf` "Hello World!"
--   True
--   
--   
--   
--   >>> "World" `isSuffixOf` "Hello World!"
--   False
--   
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.
--   
--   
--   >>> isInfixOf "Haskell" "I really like Haskell."
--   True
--   
--   
--   
--   >>> isInfixOf "Ial" "I really like Haskell."
--   False
--   
isInfixOf :: Eq a => [a] -> [a] -> Bool

-- | 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 elem x
--   (subsequences y).
--   
--   
Examples
--   
--   
--   >>> isSubsequenceOf "GHC" "The Glorious Haskell Compiler"
--   True
--   
--   >>> isSubsequenceOf ['a','d'..'z'] ['a'..'z']
--   True
--   
--   >>> isSubsequenceOf [1..10] [10,9..0]
--   False
--   
isSubsequenceOf :: Eq a => [a] -> [a] -> Bool

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

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

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

-- | <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]
--   
--   
--   
--   >>> filter odd [1, 2, 3]
--   [1,3]
--   
filter :: (a -> Bool) -> [a] -> [a]

-- | The partition function takes a predicate and a list, and
--   returns the pair of lists of elements which do and do not satisfy the
--   predicate, respectively; i.e.,
--   
--   
--   partition p xs == (filter p xs, filter (not . p) xs)
--   
--   
--   
--   >>> partition (`elem` "aeiou") "Hello World!"
--   ("eoo","Hll Wrld!")
--   
partition :: (a -> Bool) -> [a] -> ([a], [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.
--   
--   
--   >>> elemIndex 4 [0..]
--   Just 4
--   
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.
--   
--   
--   >>> elemIndices 'o' "Hello World"
--   [4,7]
--   
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.
--   
--   
--   >>> findIndex isSpace "Hello World!"
--   Just 5
--   
findIndex :: (a -> Bool) -> [a] -> Maybe Int

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

-- | <math>. zip takes two lists and returns a list of
--   corresponding pairs.
--   
--   
--   >>> zip [1, 2] ['a', 'b']
--   [(1,'a'),(2,'b')]
--   
--   
--   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 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.
zip :: [a] -> [b] -> [(a, b)]

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

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

-- | <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..]
--   
--   
--   For example, zipWith (+) is applied to two lists to
--   produce the list of corresponding sums:
--   
--   
--   >>> zipWith (+) [1, 2, 3] [4, 5, 6]
--   [5,7,9]
--   
--   
--   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.
zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]

-- | 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..]
--   
zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]

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

-- | unzip transforms a list of pairs into a list of first
--   components and a list of second components.
--   
--   
--   >>> 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, analogous to unzip.
--   
--   
--   >>> unzip3 []
--   ([],[],[])
--   
--   >>> unzip3 [(1, 'a', True), (2, 'b', False)]
--   ([1,2],"ab",[True,False])
--   
unzip3 :: [(a, b, c)] -> ([a], [b], [c])

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

-- | 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.
--   
--   For example:
--   
--   
--   >>> 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"]
--   
--   
--   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)
--   
lines :: String -> [String]

-- | linesCR breaks a String up into a list of Strings
--   at newline Chars. It is very similar to lines, but it
--   also removes any trailing 'r' Chars. The resulting
--   String values do not contain newlines or trailing 'r'
--   characters.
linesCR :: String -> [String]

-- | words breaks a string up into a list of words, which were
--   delimited by white space.
--   
--   
--   >>> words "Lorem ipsum\ndolor"
--   ["Lorem","ipsum","dolor"]
--   
words :: String -> [String]

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

-- | unwords is an inverse operation to words. It joins words
--   with separating spaces.
--   
--   
--   >>> unwords ["Lorem", "ipsum", "dolor"]
--   "Lorem ipsum dolor"
--   
unwords :: [String] -> String

-- | <math>. The nub function removes duplicate elements from
--   a list. In particular, it keeps only the first occurrence of each
--   element. (The name nub means `essence'.) It is a special case
--   of nubBy, which allows the programmer to supply their own
--   equality test.
--   
--   
--   >>> nub [1,2,3,4,3,2,1,2,4,3,5]
--   [1,2,3,4,5]
--   
nub :: Eq a => [a] -> [a]

-- | <math>. delete x removes the first occurrence of
--   x from its list argument. For example,
--   
--   
--   >>> delete 'a' "banana"
--   "bnana"
--   
--   
--   It is a special case of deleteBy, which allows the programmer
--   to supply their own equality test.
delete :: Eq a => 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.
--   
--   
--   
--   >>> "Hello World!" \\ "ell W"
--   "Hoorld!"
--   
--   
--   It is a special case of deleteFirstsBy, which allows the
--   programmer to supply their own equality test.
(\\) :: Eq a => [a] -> [a] -> [a]
infix 5 \\

-- | The union function returns the list union of the two lists. For
--   example,
--   
--   
--   >>> "dog" `union` "cow"
--   "dogcw"
--   
--   
--   Duplicates, and elements of the first list, are removed from the the
--   second list, but if the first list contains duplicates, so will the
--   result. It is a special case of unionBy, which allows the
--   programmer to supply their own equality test.
union :: Eq a => [a] -> [a] -> [a]

-- | The intersect function takes the list intersection of two
--   lists. For example,
--   
--   
--   >>> [1,2,3,4] `intersect` [2,4,6,8]
--   [2,4]
--   
--   
--   If the first list contains duplicates, so will the result.
--   
--   
--   >>> [1,2,2,3,4] `intersect` [6,4,4,2]
--   [2,2,4]
--   
--   
--   It is a special case of intersectBy, which allows the
--   programmer to supply their own equality test. If the element is found
--   in both the first and the second list, the element from the first list
--   will be used.
intersect :: Eq a => [a] -> [a] -> [a]

-- | The sort function implements a stable sorting algorithm. It is
--   a special case of sortBy, which allows the programmer to supply
--   their own comparison function.
--   
--   Elements are arranged from lowest to highest, keeping duplicates in
--   the order they appeared in the input.
--   
--   
--   >>> sort [1,6,4,3,2,5]
--   [1,2,3,4,5,6]
--   
sort :: Ord a => [a] -> [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.
--   
--   
--   >>> sortOn fst [(2, "world"), (4, "!"), (1, "Hello")]
--   [(1,"Hello"),(2,"world"),(4,"!")]
--   
sortOn :: Ord b => (a -> b) -> [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.
--   
--   
--   >>> insert 4 [1,2,3,5,6,7]
--   [1,2,3,4,5,6,7]
--   
insert :: Ord a => a -> [a] -> [a]

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

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

-- | 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.
deleteFirstsBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]

-- | The unionBy function is the non-overloaded version of
--   union.
unionBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]

-- | The intersectBy function is the non-overloaded version of
--   intersect.
intersectBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]

-- | The groupBy function is the non-overloaded version of
--   group.
groupBy :: (a -> a -> Bool) -> [a] -> [[a]]

-- | The sortBy function is the non-overloaded version of
--   sort.
--   
--   
--   >>> sortBy (\(a,_) (b,_) -> compare a b) [(2, "world"), (4, "!"), (1, "Hello")]
--   [(1,"Hello"),(2,"world"),(4,"!")]
--   
sortBy :: (a -> a -> Ordering) -> [a] -> [a]

-- | <math>. The non-overloaded version of insert.
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.
--   
--   
--   >>> 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]

-- | List partial functions. Import as:
--   
--   
--   import qualified RIO.List.Partial as L'
--   
module RIO.List.Partial

-- | <math>. Extract the first element of a list, which must be
--   non-empty.
--   
--   
--   >>> head [1, 2, 3]
--   1
--   
--   >>> head [1..]
--   1
--   
--   >>> head []
--   *** Exception: Prelude.head: empty list
--   
--   
--   WARNING: This function is partial. You can use case-matching,
--   uncons or listToMaybe instead.
head :: HasCallStack => [a] -> a

-- | <math>. Extract the last element of a list, which must be finite
--   and non-empty.
--   
--   
--   >>> last [1, 2, 3]
--   3
--   
--   >>> last [1..]
--   * Hangs forever *
--   
--   >>> last []
--   *** Exception: Prelude.last: empty list
--   
--   
--   WARNING: This function is partial. You can use reverse with
--   case-matching, uncons or listToMaybe instead.
last :: HasCallStack => [a] -> a

-- | <math>. Extract the elements after the head of a list, which
--   must be non-empty.
--   
--   
--   >>> tail [1, 2, 3]
--   [2,3]
--   
--   >>> tail [1]
--   []
--   
--   >>> tail []
--   *** Exception: Prelude.tail: empty list
--   
--   
--   WARNING: This function is partial. You can use case-matching or
--   uncons instead.
tail :: HasCallStack => [a] -> [a]

-- | <math>. Return all the elements of a list except the last one.
--   The list must be non-empty.
--   
--   
--   >>> init [1, 2, 3]
--   [1,2]
--   
--   >>> init [1]
--   []
--   
--   >>> init []
--   *** Exception: Prelude.init: empty list
--   
--   
--   WARNING: This function is partial. You can use reverse with
--   case-matching or uncons instead.
init :: HasCallStack => [a] -> [a]

-- | A variant of foldl 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.
--   
--   
--   foldl1 f = foldl1 f . toList
--   
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> foldl1 (+) [1..4]
--   10
--   
--   
--   
--   >>> foldl1 (+) []
--   *** Exception: Prelude.foldl1: empty list
--   
--   
--   
--   >>> foldl1 (+) Nothing
--   *** Exception: foldl1: empty structure
--   
--   
--   
--   >>> foldl1 (-) [1..4]
--   -8
--   
--   
--   
--   >>> foldl1 (&&) [True, False, True, True]
--   False
--   
--   
--   
--   >>> foldl1 (||) [False, False, True, True]
--   True
--   
--   
--   
--   >>> foldl1 (+) [1..]
--   * Hangs forever *
--   
foldl1 :: Foldable t => (a -> a -> a) -> t a -> a

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

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

-- | <math>. scanl1 is a variant of scanl that has no
--   starting value argument:
--   
--   
--   scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
--   
--   
--   
--   >>> 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]
--   
--   >>> scanl1 (+) [1..]
--   * Hangs forever *
--   
scanl1 :: (a -> a -> a) -> [a] -> [a]

-- | <math>. scanr1 is a variant of scanr that has no
--   starting value argument.
--   
--   
--   >>> 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]

-- | List index (subscript) operator, starting from 0. It is an instance of
--   the more general genericIndex, which takes an index of any
--   integral type.
--   
--   
--   >>> ['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
--   
--   
--   WARNING: This function is partial. You can use <atMay
--   https://hackage.haskell.org/package/safe-0.3.19/docs/Safe.html#v:atMay>
--   instead.
(!!) :: HasCallStack => [a] -> Int -> a
infixl 9 !!

-- | Strict Map. Import as:
--   
--   
--   import qualified RIO.Map as Map
--   
--   
--   This module does not export any partial or unchecked functions. For
--   those, see RIO.Map.Partial and RIO.Map.Unchecked
module RIO.Map

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

-- | <math>. Find the value at a key. Returns Nothing when the
--   element can not be found.
--   
--   
--   fromList [(5, 'a'), (3, 'b')] !? 1 == Nothing
--   
--   
--   
--   fromList [(5, 'a'), (3, 'b')] !? 5 == Just 'a'
--   
(!?) :: Ord k => Map k a -> k -> Maybe a
infixl 9 !?

-- | Same as difference.
(\\) :: Ord k => Map k a -> Map k b -> Map k a
infixl 9 \\

-- | <math>. Is the map empty?
--   
--   
--   Data.Map.null (empty)           == True
--   Data.Map.null (singleton 1 'a') == False
--   
null :: Map k a -> Bool

-- | <math>. The number of elements in the map.
--   
--   
--   size empty                                   == 0
--   size (singleton 1 'a')                       == 1
--   size (fromList([(1,'a'), (2,'c'), (3,'b')])) == 3
--   
size :: Map k a -> Int

-- | <math>. Is the key a member of the map? See also
--   notMember.
--   
--   
--   member 5 (fromList [(5,'a'), (3,'b')]) == True
--   member 1 (fromList [(5,'a'), (3,'b')]) == False
--   
member :: Ord k => k -> Map k a -> Bool

-- | <math>. Is the key not a member of the map? See also
--   member.
--   
--   
--   notMember 5 (fromList [(5,'a'), (3,'b')]) == False
--   notMember 1 (fromList [(5,'a'), (3,'b')]) == True
--   
notMember :: Ord k => k -> Map k a -> Bool

-- | <math>. Lookup the value at a key in the map.
--   
--   The function will return the corresponding value as (Just
--   value), or Nothing if the key isn't in the map.
--   
--   An example of using lookup:
--   
--   
--   import Prelude hiding (lookup)
--   import Data.Map
--   
--   employeeDept = fromList([("John","Sales"), ("Bob","IT")])
--   deptCountry = fromList([("IT","USA"), ("Sales","France")])
--   countryCurrency = fromList([("USA", "Dollar"), ("France", "Euro")])
--   
--   employeeCurrency :: String -> Maybe String
--   employeeCurrency name = do
--       dept <- lookup name employeeDept
--       country <- lookup dept deptCountry
--       lookup country countryCurrency
--   
--   main = do
--       putStrLn $ "John's currency: " ++ (show (employeeCurrency "John"))
--       putStrLn $ "Pete's currency: " ++ (show (employeeCurrency "Pete"))
--   
--   
--   The output of this program:
--   
--   
--   John's currency: Just "Euro"
--   Pete's currency: Nothing
--   
lookup :: Ord k => k -> Map k a -> Maybe a

-- | <math>. The expression (findWithDefault def k
--   map) returns the value at key k or returns default value
--   def when the key is not in the map.
--   
--   
--   findWithDefault 'x' 1 (fromList [(5,'a'), (3,'b')]) == 'x'
--   findWithDefault 'x' 5 (fromList [(5,'a'), (3,'b')]) == 'a'
--   
findWithDefault :: Ord k => a -> k -> Map k a -> a

-- | <math>. Find largest key smaller than the given one and return
--   the corresponding (key, value) pair.
--   
--   
--   lookupLT 3 (fromList [(3,'a'), (5,'b')]) == Nothing
--   lookupLT 4 (fromList [(3,'a'), (5,'b')]) == Just (3, 'a')
--   
lookupLT :: Ord k => k -> Map k v -> Maybe (k, v)

-- | <math>. Find smallest key greater than the given one and return
--   the corresponding (key, value) pair.
--   
--   
--   lookupGT 4 (fromList [(3,'a'), (5,'b')]) == Just (5, 'b')
--   lookupGT 5 (fromList [(3,'a'), (5,'b')]) == Nothing
--   
lookupGT :: Ord k => k -> Map k v -> Maybe (k, v)

-- | <math>. Find largest key smaller or equal to the given one and
--   return the corresponding (key, value) pair.
--   
--   
--   lookupLE 2 (fromList [(3,'a'), (5,'b')]) == Nothing
--   lookupLE 4 (fromList [(3,'a'), (5,'b')]) == Just (3, 'a')
--   lookupLE 5 (fromList [(3,'a'), (5,'b')]) == Just (5, 'b')
--   
lookupLE :: Ord k => k -> Map k v -> Maybe (k, v)

-- | <math>. Find smallest key greater or equal to the given one and
--   return the corresponding (key, value) pair.
--   
--   
--   lookupGE 3 (fromList [(3,'a'), (5,'b')]) == Just (3, 'a')
--   lookupGE 4 (fromList [(3,'a'), (5,'b')]) == Just (5, 'b')
--   lookupGE 6 (fromList [(3,'a'), (5,'b')]) == Nothing
--   
lookupGE :: Ord k => k -> Map k v -> Maybe (k, v)

-- | <math>. The empty map.
--   
--   
--   empty      == fromList []
--   size empty == 0
--   
empty :: Map k a

-- | <math>. A map with a single element.
--   
--   
--   singleton 1 'a'        == fromList [(1, 'a')]
--   size (singleton 1 'a') == 1
--   
singleton :: k -> a -> Map k a

-- | <math>. Insert a new key and value in the map. If the key is
--   already present in the map, the associated value is replaced with the
--   supplied value. insert is equivalent to insertWith
--   const.
--   
--   
--   insert 5 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'x')]
--   insert 7 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'a'), (7, 'x')]
--   insert 5 'x' empty                         == singleton 5 'x'
--   
insert :: Ord k => k -> a -> Map k a -> Map k a

-- | <math>. Insert with a function, combining new value and old
--   value. insertWith f key value mp will insert the pair
--   (key, value) into mp if key does not exist in the map. If the
--   key does exist, the function will insert the pair (key, f
--   new_value old_value).
--   
--   
--   insertWith (++) 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "xxxa")]
--   insertWith (++) 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")]
--   insertWith (++) 5 "xxx" empty                         == singleton 5 "xxx"
--   
insertWith :: Ord k => (a -> a -> a) -> k -> a -> Map k a -> Map k a

-- | <math>. Insert with a function, combining key, new value and old
--   value. insertWithKey f key value mp will insert the
--   pair (key, value) into mp if key does not exist in the map.
--   If the key does exist, the function will insert the pair (key,f
--   key new_value old_value). Note that the key passed to f is the
--   same key passed to insertWithKey.
--   
--   
--   let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value
--   insertWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:xxx|a")]
--   insertWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")]
--   insertWithKey f 5 "xxx" empty                         == singleton 5 "xxx"
--   
insertWithKey :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k a -> Map k a

-- | <math>. Combines insert operation with old value retrieval. The
--   expression (insertLookupWithKey f k x map) is a pair
--   where the first element is equal to (lookup k map) and
--   the second element equal to (insertWithKey f k x map).
--   
--   
--   let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value
--   insertLookupWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "5:xxx|a")])
--   insertLookupWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == (Nothing,  fromList [(3, "b"), (5, "a"), (7, "xxx")])
--   insertLookupWithKey f 5 "xxx" empty                         == (Nothing,  singleton 5 "xxx")
--   
--   
--   This is how to define insertLookup using
--   insertLookupWithKey:
--   
--   
--   let insertLookup kx x t = insertLookupWithKey (\_ a _ -> a) kx x t
--   insertLookup 5 "x" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "x")])
--   insertLookup 7 "x" (fromList [(5,"a"), (3,"b")]) == (Nothing,  fromList [(3, "b"), (5, "a"), (7, "x")])
--   
insertLookupWithKey :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k a -> (Maybe a, Map k a)

-- | <math>. Delete a key and its value from the map. When the key is
--   not a member of the map, the original map is returned.
--   
--   
--   delete 5 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
--   delete 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]
--   delete 5 empty                         == empty
--   
delete :: Ord k => k -> Map k a -> Map k a

-- | <math>. Update a value at a specific key with the result of the
--   provided function. When the key is not a member of the map, the
--   original map is returned.
--   
--   
--   adjust ("new " ++) 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")]
--   adjust ("new " ++) 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]
--   adjust ("new " ++) 7 empty                         == empty
--   
adjust :: Ord k => (a -> a) -> k -> Map k a -> Map k a

-- | <math>. Adjust a value at a specific key. When the key is not a
--   member of the map, the original map is returned.
--   
--   
--   let f key x = (show key) ++ ":new " ++ x
--   adjustWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")]
--   adjustWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]
--   adjustWithKey f 7 empty                         == empty
--   
adjustWithKey :: Ord k => (k -> a -> a) -> k -> Map k a -> Map k a

-- | <math>. The expression (update f k map) updates
--   the value x at k (if it is in the map). If (f
--   x) is Nothing, the element is deleted. If it is
--   (Just y), the key k is bound to the new value
--   y.
--   
--   
--   let f x = if x == "a" then Just "new a" else Nothing
--   update f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")]
--   update f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]
--   update f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
--   
update :: Ord k => (a -> Maybe a) -> k -> Map k a -> Map k a

-- | <math>. The expression (updateWithKey f k map)
--   updates the value x at k (if it is in the map). If
--   (f k x) is Nothing, the element is deleted. If it is
--   (Just y), the key k is bound to the new value
--   y.
--   
--   
--   let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing
--   updateWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")]
--   updateWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]
--   updateWithKey f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
--   
updateWithKey :: Ord k => (k -> a -> Maybe a) -> k -> Map k a -> Map k a

-- | <math>. Lookup and update. See also updateWithKey. The
--   function returns changed value, if it is updated. Returns the original
--   key value if the map entry is deleted.
--   
--   
--   let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing
--   updateLookupWithKey f 5 (fromList [(5,"a"), (3,"b")]) == (Just "5:new a", fromList [(3, "b"), (5, "5:new a")])
--   updateLookupWithKey f 7 (fromList [(5,"a"), (3,"b")]) == (Nothing,  fromList [(3, "b"), (5, "a")])
--   updateLookupWithKey f 3 (fromList [(5,"a"), (3,"b")]) == (Just "b", singleton 5 "a")
--   
updateLookupWithKey :: Ord k => (k -> a -> Maybe a) -> k -> Map k a -> (Maybe a, Map k a)

-- | <math>. The expression (alter f k map) alters
--   the value x at k, or absence thereof. alter
--   can be used to insert, delete, or update a value in a Map. In
--   short : lookup k (alter f k m) = f (lookup k
--   m).
--   
--   
--   let f _ = Nothing
--   alter f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]
--   alter f 5 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
--   
--   let f _ = Just "c"
--   alter f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "c")]
--   alter f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "c")]
--   
--   
--   Note that adjust = alter . fmap.
alter :: Ord k => (Maybe a -> Maybe a) -> k -> Map k a -> Map k a

-- | <math>. The expression (alterF f k map) alters
--   the value x at k, or absence thereof. alterF
--   can be used to inspect, insert, delete, or update a value in a
--   Map. In short: lookup k <$> alterF f k
--   m = f (lookup k m).
--   
--   Example:
--   
--   
--   interactiveAlter :: Int -> Map Int String -> IO (Map Int String)
--   interactiveAlter k m = alterF f k m where
--     f Nothing = do
--        putStrLn $ show k ++
--            " was not found in the map. Would you like to add it?"
--        getUserResponse1 :: IO (Maybe String)
--     f (Just old) = do
--        putStrLn $ "The key is currently bound to " ++ show old ++
--            ". Would you like to change or delete it?"
--        getUserResponse2 :: IO (Maybe String)
--   
--   
--   alterF is the most general operation for working with an
--   individual key that may or may not be in a given map. When used with
--   trivial functors like Identity and Const, it is often
--   slightly slower than more specialized combinators like lookup
--   and insert. However, when the functor is non-trivial and key
--   comparison is not particularly cheap, it is the fastest way.
--   
--   Note on rewrite rules:
--   
--   This module includes GHC rewrite rules to optimize alterF for
--   the Const and Identity functors. In general, these rules
--   improve performance. The sole exception is that when using
--   Identity, deleting a key that is already absent takes longer
--   than it would without the rules. If you expect this to occur a very
--   large fraction of the time, you might consider using a private copy of
--   the Identity type.
--   
--   Note: alterF is a flipped version of the at combinator
--   from Control.Lens.At.
alterF :: (Functor f, Ord k) => (Maybe a -> f (Maybe a)) -> k -> Map k a -> f (Map k a)

-- | <math>. The expression (union t1 t2) takes the
--   left-biased union of t1 and t2. It prefers
--   t1 when duplicate keys are encountered, i.e.
--   (union == unionWith const).
--   
--   
--   union (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "a"), (7, "C")]
--   
union :: Ord k => Map k a -> Map k a -> Map k a

-- | <math>. Union with a combining function.
--   
--   
--   unionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "aA"), (7, "C")]
--   
unionWith :: Ord k => (a -> a -> a) -> Map k a -> Map k a -> Map k a

-- | <math>. Union with a combining function.
--   
--   
--   let f key left_value right_value = (show key) ++ ":" ++ left_value ++ "|" ++ right_value
--   unionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "5:a|A"), (7, "C")]
--   
unionWithKey :: Ord k => (k -> a -> a -> a) -> Map k a -> Map k a -> Map k a

-- | The union of a list of maps: (unions == foldl
--   union empty).
--   
--   
--   unions [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])]
--       == fromList [(3, "b"), (5, "a"), (7, "C")]
--   unions [(fromList [(5, "A3"), (3, "B3")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "a"), (3, "b")])]
--       == fromList [(3, "B3"), (5, "A3"), (7, "C")]
--   
unions :: (Foldable f, Ord k) => f (Map k a) -> Map k a

-- | The union of a list of maps, with a combining operation:
--   (unionsWith f == foldl (unionWith f)
--   empty).
--   
--   
--   unionsWith (++) [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])]
--       == fromList [(3, "bB3"), (5, "aAA3"), (7, "C")]
--   
unionsWith :: (Foldable f, Ord k) => (a -> a -> a) -> f (Map k a) -> Map k a

-- | <math>. Difference of two maps. Return elements of the first map
--   not existing in the second map.
--   
--   
--   difference (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 3 "b"
--   
difference :: Ord k => Map k a -> Map k b -> Map k a

-- | <math>. Difference with a combining function. When two equal
--   keys are encountered, the combining function is applied to the values
--   of these keys. If it returns Nothing, the element is discarded
--   (proper set difference). If it returns (Just y), the
--   element is updated with a new value y.
--   
--   
--   let f al ar = if al == "b" then Just (al ++ ":" ++ ar) else Nothing
--   differenceWith f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (3, "B"), (7, "C")])
--       == singleton 3 "b:B"
--   
differenceWith :: Ord k => (a -> b -> Maybe a) -> Map k a -> Map k b -> Map k a

-- | <math>. Difference with a combining function. When two equal
--   keys are encountered, the combining function is applied to the key and
--   both values. If it returns Nothing, the element is discarded
--   (proper set difference). If it returns (Just y), the
--   element is updated with a new value y.
--   
--   
--   let f k al ar = if al == "b" then Just ((show k) ++ ":" ++ al ++ "|" ++ ar) else Nothing
--   differenceWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (3, "B"), (10, "C")])
--       == singleton 3 "3:b|B"
--   
differenceWithKey :: Ord k => (k -> a -> b -> Maybe a) -> Map k a -> Map k b -> Map k a

-- | <math>. Intersection of two maps. Return data in the first map
--   for the keys existing in both maps. (intersection m1 m2 ==
--   intersectionWith const m1 m2).
--   
--   
--   intersection (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "a"
--   
intersection :: Ord k => Map k a -> Map k b -> Map k a

-- | <math>. Intersection with a combining function.
--   
--   
--   intersectionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "aA"
--   
intersectionWith :: Ord k => (a -> b -> c) -> Map k a -> Map k b -> Map k c

-- | <math>. Intersection with a combining function.
--   
--   
--   let f k al ar = (show k) ++ ":" ++ al ++ "|" ++ ar
--   intersectionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "5:a|A"
--   
intersectionWithKey :: Ord k => (k -> a -> b -> c) -> Map k a -> Map k b -> Map k c

-- | <math>. An unsafe universal combining function.
--   
--   WARNING: This function can produce corrupt maps and its results may
--   depend on the internal structures of its inputs. Users should prefer
--   merge or mergeA.
--   
--   When mergeWithKey is given three arguments, it is inlined to
--   the call site. You should therefore use mergeWithKey only to
--   define custom combining functions. For example, you could define
--   unionWithKey, differenceWithKey and
--   intersectionWithKey as
--   
--   
--   myUnionWithKey f m1 m2 = mergeWithKey (\k x1 x2 -> Just (f k x1 x2)) id id m1 m2
--   myDifferenceWithKey f m1 m2 = mergeWithKey f id (const empty) m1 m2
--   myIntersectionWithKey f m1 m2 = mergeWithKey (\k x1 x2 -> Just (f k x1 x2)) (const empty) (const empty) m1 m2
--   
--   
--   When calling mergeWithKey combine only1 only2, a
--   function combining two Maps is created, such that
--   
--   
--   
- if a key is present in both maps, it is passed with both
--   corresponding values to the combine function. Depending on
--   the result, the key is either present in the result with specified
--   value, or is left out;
--   
- a nonempty subtree present only in the first map is passed to
--   only1 and the output is added to the result;
--   
- a nonempty subtree present only in the second map is passed to
--   only2 and the output is added to the result.
--   
--   
--   The only1 and only2 methods must return a map
--   with a subset (possibly empty) of the keys of the given map. The
--   values can be modified arbitrarily. Most common variants of
--   only1 and only2 are id and const
--   empty, but for example map f or
--   filterWithKey f could be used for any f.
mergeWithKey :: Ord k => (k -> a -> b -> Maybe c) -> (Map k a -> Map k c) -> (Map k b -> Map k c) -> Map k a -> Map k b -> Map k c

-- | <math>. Map a function over all values in the map.
--   
--   
--   map (++ "x") (fromList [(5,"a"), (3,"b")]) == fromList [(3, "bx"), (5, "ax")]
--   
map :: (a -> b) -> Map k a -> Map k b

-- | <math>. Map a function over all values in the map.
--   
--   
--   let f key x = (show key) ++ ":" ++ x
--   mapWithKey f (fromList [(5,"a"), (3,"b")]) == fromList [(3, "3:b"), (5, "5:a")]
--   
mapWithKey :: (k -> a -> b) -> Map k a -> Map k b

-- | <math>. traverseWithKey f m == fromList
--   <$> traverse (\(k, v) -> (v' -> v' `seq` (k,v'))
--   <$> f k v) (toList m) That is, it behaves much like
--   a regular traverse except that the traversing function also has
--   access to the key associated with a value and the values are forced
--   before they are installed in the result map.
--   
--   
--   traverseWithKey (\k v -> if odd k then Just (succ v) else Nothing) (fromList [(1, 'a'), (5, 'e')]) == Just (fromList [(1, 'b'), (5, 'f')])
--   traverseWithKey (\k v -> if odd k then Just (succ v) else Nothing) (fromList [(2, 'c')])           == Nothing
--   
traverseWithKey :: Applicative t => (k -> a -> t b) -> Map k a -> t (Map k b)

-- | <math>. Traverse keys/values and collect the Just
--   results.
traverseMaybeWithKey :: Applicative f => (k -> a -> f (Maybe b)) -> Map k a -> f (Map k b)

-- | <math>. The function mapAccum threads an accumulating
--   argument through the map in ascending order of keys.
--   
--   
--   let f a b = (a ++ b, b ++ "X")
--   mapAccum f "Everything: " (fromList [(5,"a"), (3,"b")]) == ("Everything: ba", fromList [(3, "bX"), (5, "aX")])
--   
mapAccum :: (a -> b -> (a, c)) -> a -> Map k b -> (a, Map k c)

-- | <math>. The function mapAccumWithKey threads an
--   accumulating argument through the map in ascending order of keys.
--   
--   
--   let f a k b = (a ++ " " ++ (show k) ++ "-" ++ b, b ++ "X")
--   mapAccumWithKey f "Everything:" (fromList [(5,"a"), (3,"b")]) == ("Everything: 3-b 5-a", fromList [(3, "bX"), (5, "aX")])
--   
mapAccumWithKey :: (a -> k -> b -> (a, c)) -> a -> Map k b -> (a, Map k c)

-- | <math>. The function mapAccumRWithKey threads an
--   accumulating argument through the map in descending order of keys.
mapAccumRWithKey :: (a -> k -> b -> (a, c)) -> a -> Map k b -> (a, Map k c)

-- | <math>. mapKeys f s is the map obtained by
--   applying f to each key of s.
--   
--   The size of the result may be smaller if f maps two or more
--   distinct keys to the same new key. In this case the value at the
--   greatest of the original keys is retained.
--   
--   
--   mapKeys (+ 1) (fromList [(5,"a"), (3,"b")])                        == fromList [(4, "b"), (6, "a")]
--   mapKeys (\ _ -> 1) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 1 "c"
--   mapKeys (\ _ -> 3) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 3 "c"
--   
mapKeys :: Ord k2 => (k1 -> k2) -> Map k1 a -> Map k2 a

-- | <math>. mapKeysWith c f s is the map obtained by
--   applying f to each key of s.
--   
--   The size of the result may be smaller if f maps two or more
--   distinct keys to the same new key. In this case the associated values
--   will be combined using c. The value at the greater of the two
--   original keys is used as the first argument to c.
--   
--   
--   mapKeysWith (++) (\ _ -> 1) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 1 "cdab"
--   mapKeysWith (++) (\ _ -> 3) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 3 "cdab"
--   
mapKeysWith :: Ord k2 => (a -> a -> a) -> (k1 -> k2) -> Map k1 a -> Map k2 a

-- | <math>. Fold the values in the map using the given
--   right-associative binary operator, such that foldr f z ==
--   foldr f z . elems.
--   
--   For example,
--   
--   
--   elems map = foldr (:) [] map
--   
--   
--   
--   let f a len = len + (length a)
--   foldr f 0 (fromList [(5,"a"), (3,"bbb")]) == 4
--   
foldr :: (a -> b -> b) -> b -> Map k a -> b

-- | <math>. Fold the values in the map using the given
--   left-associative binary operator, such that foldl f z ==
--   foldl f z . elems.
--   
--   For example,
--   
--   
--   elems = reverse . foldl (flip (:)) []
--   
--   
--   
--   let f len a = len + (length a)
--   foldl f 0 (fromList [(5,"a"), (3,"bbb")]) == 4
--   
foldl :: (a -> b -> a) -> a -> Map k b -> a

-- | <math>. Fold the keys and values in the map using the given
--   right-associative binary operator, such that foldrWithKey f
--   z == foldr (uncurry f) z . toAscList.
--   
--   For example,
--   
--   
--   keys map = foldrWithKey (\k x ks -> k:ks) [] map
--   
--   
--   
--   let f k a result = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")"
--   foldrWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (5:a)(3:b)"
--   
foldrWithKey :: (k -> a -> b -> b) -> b -> Map k a -> b

-- | <math>. Fold the keys and values in the map using the given
--   left-associative binary operator, such that foldlWithKey f
--   z == foldl (\z' (kx, x) -> f z' kx x) z .
--   toAscList.
--   
--   For example,
--   
--   
--   keys = reverse . foldlWithKey (\ks k x -> k:ks) []
--   
--   
--   
--   let f result k a = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")"
--   foldlWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (3:b)(5:a)"
--   
foldlWithKey :: (a -> k -> b -> a) -> a -> Map k b -> a

-- | <math>. Fold the keys and values in the map using the given
--   monoid, such that
--   
--   
--   foldMapWithKey f = fold . mapWithKey f
--   
--   
--   This can be an asymptotically faster than foldrWithKey or
--   foldlWithKey for some monoids.
foldMapWithKey :: Monoid m => (k -> a -> m) -> Map k a -> m

-- | <math>. A strict version of foldr. Each application of
--   the operator is evaluated before using the result in the next
--   application. This function is strict in the starting value.
foldr' :: (a -> b -> b) -> b -> Map k a -> b

-- | <math>. A strict version of foldl. Each application of
--   the operator is evaluated before using the result in the next
--   application. This function is strict in the starting value.
foldl' :: (a -> b -> a) -> a -> Map k b -> a

-- | <math>. A strict version of foldrWithKey. Each
--   application of the operator is evaluated before using the result in
--   the next application. This function is strict in the starting value.
foldrWithKey' :: (k -> a -> b -> b) -> b -> Map k a -> b

-- | <math>. A strict version of foldlWithKey. Each
--   application of the operator is evaluated before using the result in
--   the next application. This function is strict in the starting value.
foldlWithKey' :: (a -> k -> b -> a) -> a -> Map k b -> a

-- | <math>. Return all elements of the map in the ascending order of
--   their keys. Subject to list fusion.
--   
--   
--   elems (fromList [(5,"a"), (3,"b")]) == ["b","a"]
--   elems empty == []
--   
elems :: Map k a -> [a]

-- | <math>. Return all keys of the map in ascending order. Subject
--   to list fusion.
--   
--   
--   keys (fromList [(5,"a"), (3,"b")]) == [3,5]
--   keys empty == []
--   
keys :: Map k a -> [k]

-- | <math>. An alias for toAscList. Return all key/value
--   pairs in the map in ascending key order. Subject to list fusion.
--   
--   
--   assocs (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]
--   assocs empty == []
--   
assocs :: Map k a -> [(k, a)]

-- | <math>. The set of all keys of the map.
--   
--   
--   keysSet (fromList [(5,"a"), (3,"b")]) == Data.Set.fromList [3,5]
--   keysSet empty == Data.Set.empty
--   
keysSet :: Map k a -> Set k

-- | <math>. Build a map from a set of keys and a function which for
--   each key computes its value.
--   
--   
--   fromSet (\k -> replicate k 'a') (Data.Set.fromList [3, 5]) == fromList [(5,"aaaaa"), (3,"aaa")]
--   fromSet undefined Data.Set.empty == empty
--   
fromSet :: (k -> a) -> Set k -> Map k a

-- | <math>. Convert the map to a list of key/value pairs. Subject to
--   list fusion.
--   
--   
--   toList (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]
--   toList empty == []
--   
toList :: Map k a -> [(k, a)]

-- | <math>. Build a map from a list of key/value pairs. See also
--   fromAscList. If the list contains more than one value for the
--   same key, the last value for the key is retained.
--   
--   If the keys of the list are ordered, linear-time implementation is
--   used, with the performance equal to fromDistinctAscList.
--   
--   
--   fromList [] == empty
--   fromList [(5,"a"), (3,"b"), (5, "c")] == fromList [(5,"c"), (3,"b")]
--   fromList [(5,"c"), (3,"b"), (5, "a")] == fromList [(5,"a"), (3,"b")]
--   
fromList :: Ord k => [(k, a)] -> Map k a

-- | <math>. Build a map from a list of key/value pairs with a
--   combining function. See also fromAscListWith.
--   
--   
--   fromListWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "ab"), (5, "aba")]
--   fromListWith (++) [] == empty
--   
fromListWith :: Ord k => (a -> a -> a) -> [(k, a)] -> Map k a

-- | <math>. Build a map from a list of key/value pairs with a
--   combining function. See also fromAscListWithKey.
--   
--   
--   let f key new_value old_value = show key ++ ":" ++ new_value ++ "|" ++ old_value
--   fromListWithKey f [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"c")] == fromList [(3, "3:a|b"), (5, "5:c|5:b|a")]
--   fromListWithKey f [] == empty
--   
fromListWithKey :: Ord k => (k -> a -> a -> a) -> [(k, a)] -> Map k a

-- | <math>. Convert the map to a list of key/value pairs where the
--   keys are in ascending order. Subject to list fusion.
--   
--   
--   toAscList (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]
--   
toAscList :: Map k a -> [(k, a)]

-- | <math>. Convert the map to a list of key/value pairs where the
--   keys are in descending order. Subject to list fusion.
--   
--   
--   toDescList (fromList [(5,"a"), (3,"b")]) == [(5,"a"), (3,"b")]
--   
toDescList :: Map k a -> [(k, a)]

-- | <math>. Filter all values that satisfy the predicate.
--   
--   
--   filter (> "a") (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
--   filter (> "x") (fromList [(5,"a"), (3,"b")]) == empty
--   filter (< "a") (fromList [(5,"a"), (3,"b")]) == empty
--   
filter :: (a -> Bool) -> Map k a -> Map k a

-- | <math>. Filter all keys/values that satisfy the predicate.
--   
--   
--   filterWithKey (\k _ -> k > 4) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
--   
filterWithKey :: (k -> a -> Bool) -> Map k a -> Map k a

-- | <math>. Restrict a Map to only those keys found in a
--   Set.
--   
--   
--   m `restrictKeys` s = filterWithKey (\k _ -> k `member` s) m
--   m `restrictKeys` s = m `intersection` fromSet (const ()) s
--   
restrictKeys :: Ord k => Map k a -> Set k -> Map k a

-- | <math>. Remove all keys in a Set from a Map.
--   
--   
--   m `withoutKeys` s = filterWithKey (\k _ -> k `notMember` s) m
--   m `withoutKeys` s = m `difference` fromSet (const ()) s
--   
withoutKeys :: Ord k => Map k a -> Set k -> Map k a

-- | <math>. Partition the map according to a predicate. The first
--   map contains all elements that satisfy the predicate, the second all
--   elements that fail the predicate. See also split.
--   
--   
--   partition (> "a") (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", singleton 5 "a")
--   partition (< "x") (fromList [(5,"a"), (3,"b")]) == (fromList [(3, "b"), (5, "a")], empty)
--   partition (> "x") (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3, "b"), (5, "a")])
--   
partition :: (a -> Bool) -> Map k a -> (Map k a, Map k a)

-- | <math>. Partition the map according to a predicate. The first
--   map contains all elements that satisfy the predicate, the second all
--   elements that fail the predicate. See also split.
--   
--   
--   partitionWithKey (\ k _ -> k > 3) (fromList [(5,"a"), (3,"b")]) == (singleton 5 "a", singleton 3 "b")
--   partitionWithKey (\ k _ -> k < 7) (fromList [(5,"a"), (3,"b")]) == (fromList [(3, "b"), (5, "a")], empty)
--   partitionWithKey (\ k _ -> k > 7) (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3, "b"), (5, "a")])
--   
partitionWithKey :: (k -> a -> Bool) -> Map k a -> (Map k a, Map k a)

-- | <math>. Take while a predicate on the keys holds. The user is
--   responsible for ensuring that for all keys j and k
--   in the map, j < k ==> p j >= p k. See note at
--   spanAntitone.
--   
--   
--   takeWhileAntitone p = fromDistinctAscList . takeWhile (p . fst) . toList
--   takeWhileAntitone p = filterWithKey (k _ -> p k)
--   
takeWhileAntitone :: (k -> Bool) -> Map k a -> Map k a

-- | <math>. Drop while a predicate on the keys holds. The user is
--   responsible for ensuring that for all keys j and k
--   in the map, j < k ==> p j >= p k. See note at
--   spanAntitone.
--   
--   
--   dropWhileAntitone p = fromDistinctAscList . dropWhile (p . fst) . toList
--   dropWhileAntitone p = filterWithKey (\k _ -> not (p k))
--   
dropWhileAntitone :: (k -> Bool) -> Map k a -> Map k a

-- | <math>. Divide a map at the point where a predicate on the keys
--   stops holding. The user is responsible for ensuring that for all keys
--   j and k in the map, j < k ==> p j >= p
--   k.
--   
--   
--   spanAntitone p xs = (takeWhileAntitone p xs, dropWhileAntitone p xs)
--   spanAntitone p xs = partitionWithKey (\k _ -> p k) xs
--   
--   
--   Note: if p is not actually antitone, then
--   spanAntitone will split the map at some unspecified
--   point where the predicate switches from holding to not holding (where
--   the predicate is seen to hold before the first key and to fail after
--   the last key).
spanAntitone :: (k -> Bool) -> Map k a -> (Map k a, Map k a)

-- | <math>. Map values and collect the Just results.
--   
--   
--   let f x = if x == "a" then Just "new a" else Nothing
--   mapMaybe f (fromList [(5,"a"), (3,"b")]) == singleton 5 "new a"
--   
mapMaybe :: (a -> Maybe b) -> Map k a -> Map k b

-- | <math>. Map keys/values and collect the Just results.
--   
--   
--   let f k _ = if k < 5 then Just ("key : " ++ (show k)) else Nothing
--   mapMaybeWithKey f (fromList [(5,"a"), (3,"b")]) == singleton 3 "key : 3"
--   
mapMaybeWithKey :: (k -> a -> Maybe b) -> Map k a -> Map k b

-- | <math>. Map values and separate the Left and Right
--   results.
--   
--   
--   let f a = if a < "c" then Left a else Right a
--   mapEither f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])
--       == (fromList [(3,"b"), (5,"a")], fromList [(1,"x"), (7,"z")])
--   
--   mapEither (\ a -> Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])
--       == (empty, fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])
--   
mapEither :: (a -> Either b c) -> Map k a -> (Map k b, Map k c)

-- | <math>. Map keys/values and separate the Left and
--   Right results.
--   
--   
--   let f k a = if k < 5 then Left (k * 2) else Right (a ++ a)
--   mapEitherWithKey f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])
--       == (fromList [(1,2), (3,6)], fromList [(5,"aa"), (7,"zz")])
--   
--   mapEitherWithKey (\_ a -> Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])
--       == (empty, fromList [(1,"x"), (3,"b"), (5,"a"), (7,"z")])
--   
mapEitherWithKey :: (k -> a -> Either b c) -> Map k a -> (Map k b, Map k c)

-- | <math>. The expression (split k map) is a pair
--   (map1,map2) where the keys in map1 are smaller than
--   k and the keys in map2 larger than k. Any
--   key equal to k is found in neither map1 nor
--   map2.
--   
--   
--   split 2 (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3,"b"), (5,"a")])
--   split 3 (fromList [(5,"a"), (3,"b")]) == (empty, singleton 5 "a")
--   split 4 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", singleton 5 "a")
--   split 5 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", empty)
--   split 6 (fromList [(5,"a"), (3,"b")]) == (fromList [(3,"b"), (5,"a")], empty)
--   
split :: Ord k => k -> Map k a -> (Map k a, Map k a)

-- | <math>. The expression (splitLookup k map)
--   splits a map just like split but also returns lookup
--   k map.
--   
--   
--   splitLookup 2 (fromList [(5,"a"), (3,"b")]) == (empty, Nothing, fromList [(3,"b"), (5,"a")])
--   splitLookup 3 (fromList [(5,"a"), (3,"b")]) == (empty, Just "b", singleton 5 "a")
--   splitLookup 4 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", Nothing, singleton 5 "a")
--   splitLookup 5 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", Just "a", empty)
--   splitLookup 6 (fromList [(5,"a"), (3,"b")]) == (fromList [(3,"b"), (5,"a")], Nothing, empty)
--   
splitLookup :: Ord k => k -> Map k a -> (Map k a, Maybe a, Map k a)

-- | <math>. Decompose a map into pieces based on the structure of
--   the underlying tree. This function is useful for consuming a map in
--   parallel.
--   
--   No guarantee is made as to the sizes of the pieces; an internal, but
--   deterministic process determines this. However, it is guaranteed that
--   the pieces returned will be in ascending order (all elements in the
--   first submap less than all elements in the second, and so on).
--   
--   Examples:
--   
--   
--   splitRoot (fromList (zip [1..6] ['a'..])) ==
--     [fromList [(1,'a'),(2,'b'),(3,'c')],fromList [(4,'d')],fromList [(5,'e'),(6,'f')]]
--   
--   
--   
--   splitRoot empty == []
--   
--   
--   Note that the current implementation does not return more than three
--   submaps, but you should not depend on this behaviour because it can
--   change in the future without notice.
splitRoot :: Map k b -> [Map k b]

-- | <math>. This function is defined as (isSubmapOf =
--   isSubmapOfBy (==)).
isSubmapOf :: (Ord k, Eq a) => Map k a -> Map k a -> Bool

-- | <math>. The expression (isSubmapOfBy f t1 t2)
--   returns True if all keys in t1 are in tree
--   t2, and when f returns True when applied to
--   their respective values. For example, the following expressions are
--   all True:
--   
--   
--   isSubmapOfBy (==) (fromList [('a',1)]) (fromList [('a',1),('b',2)])
--   isSubmapOfBy (<=) (fromList [('a',1)]) (fromList [('a',1),('b',2)])
--   isSubmapOfBy (==) (fromList [('a',1),('b',2)]) (fromList [('a',1),('b',2)])
--   
--   
--   But the following are all False:
--   
--   
--   isSubmapOfBy (==) (fromList [('a',2)]) (fromList [('a',1),('b',2)])
--   isSubmapOfBy (<)  (fromList [('a',1)]) (fromList [('a',1),('b',2)])
--   isSubmapOfBy (==) (fromList [('a',1),('b',2)]) (fromList [('a',1)])
--   
--   
--   Note that isSubmapOfBy (_ _ -> True) m1 m2 tests whether
--   all the keys in m1 are also keys in m2.
isSubmapOfBy :: Ord k => (a -> b -> Bool) -> Map k a -> Map k b -> Bool

-- | <math>. Is this a proper submap? (ie. a submap but not equal).
--   Defined as (isProperSubmapOf = isProperSubmapOfBy
--   (==)).
isProperSubmapOf :: (Ord k, Eq a) => Map k a -> Map k a -> Bool

-- | <math>. Is this a proper submap? (ie. a submap but not equal).
--   The expression (isProperSubmapOfBy f m1 m2) returns
--   True when keys m1 and keys m2 are not equal,
--   all keys in m1 are in m2, and when f
--   returns True when applied to their respective values. For
--   example, the following expressions are all True:
--   
--   
--   isProperSubmapOfBy (==) (fromList [(1,1)]) (fromList [(1,1),(2,2)])
--   isProperSubmapOfBy (<=) (fromList [(1,1)]) (fromList [(1,1),(2,2)])
--   
--   
--   But the following are all False:
--   
--   
--   isProperSubmapOfBy (==) (fromList [(1,1),(2,2)]) (fromList [(1,1),(2,2)])
--   isProperSubmapOfBy (==) (fromList [(1,1),(2,2)]) (fromList [(1,1)])
--   isProperSubmapOfBy (<)  (fromList [(1,1)])       (fromList [(1,1),(2,2)])
--   
isProperSubmapOfBy :: Ord k => (a -> b -> Bool) -> Map k a -> Map k b -> Bool

-- | <math>. Lookup the index of a key, which is its
--   zero-based index in the sequence sorted by keys. The index is a number
--   from 0 up to, but not including, the size of the map.
--   
--   
--   isJust (lookupIndex 2 (fromList [(5,"a"), (3,"b")]))   == False
--   fromJust (lookupIndex 3 (fromList [(5,"a"), (3,"b")])) == 0
--   fromJust (lookupIndex 5 (fromList [(5,"a"), (3,"b")])) == 1
--   isJust (lookupIndex 6 (fromList [(5,"a"), (3,"b")]))   == False
--   
lookupIndex :: Ord k => k -> Map k a -> Maybe Int

-- | <math>. Retrieve an element by its index, i.e. by its
--   zero-based index in the sequence sorted by keys. If the index
--   is out of range (less than zero, greater or equal to size of
--   the map), error is called.
--   
--   
--   elemAt 0 (fromList [(5,"a"), (3,"b")]) == (3,"b")
--   elemAt 1 (fromList [(5,"a"), (3,"b")]) == (5, "a")
--   elemAt 2 (fromList [(5,"a"), (3,"b")])    Error: index out of range
--   
elemAt :: Int -> Map k a -> (k, a)

-- | <math>. Delete the element at index, i.e. by its
--   zero-based index in the sequence sorted by keys. If the index
--   is out of range (less than zero, greater or equal to size of
--   the map), error is called.
--   
--   
--   deleteAt 0  (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
--   deleteAt 1  (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
--   deleteAt 2 (fromList [(5,"a"), (3,"b")])     Error: index out of range
--   deleteAt (-1) (fromList [(5,"a"), (3,"b")])  Error: index out of range
--   
deleteAt :: Int -> Map k a -> Map k a

-- | <math>. Take a given number of entries in key order, beginning
--   with the smallest keys.
--   
--   
--   take n = fromDistinctAscList . take n . toAscList
--   
take :: Int -> Map k a -> Map k a

-- | <math>. Drop a given number of entries in key order, beginning
--   with the smallest keys.
--   
--   
--   drop n = fromDistinctAscList . drop n . toAscList
--   
drop :: Int -> Map k a -> Map k a

-- | <math>. Split a map at a particular index.
--   
--   
--   splitAt !n !xs = (take n xs, drop n xs)
--   
splitAt :: Int -> Map k a -> (Map k a, Map k a)

-- | <math>. The minimal key of the map. Returns Nothing if
--   the map is empty.
--   
--   
--   lookupMin (fromList [(5,"a"), (3,"b")]) == Just (3,"b")
--   lookupMin empty = Nothing
--   
lookupMin :: Map k a -> Maybe (k, a)

-- | <math>. The maximal key of the map. Returns Nothing if
--   the map is empty.
--   
--   
--   lookupMax (fromList [(5,"a"), (3,"b")]) == Just (5,"a")
--   lookupMax empty = Nothing
--   
lookupMax :: Map k a -> Maybe (k, a)

-- | <math>. Delete the minimal key. Returns an empty map if the map
--   is empty.
--   
--   
--   deleteMin (fromList [(5,"a"), (3,"b"), (7,"c")]) == fromList [(5,"a"), (7,"c")]
--   deleteMin empty == empty
--   
deleteMin :: Map k a -> Map k a

-- | <math>. Delete the maximal key. Returns an empty map if the map
--   is empty.
--   
--   
--   deleteMax (fromList [(5,"a"), (3,"b"), (7,"c")]) == fromList [(3,"b"), (5,"a")]
--   deleteMax empty == empty
--   
deleteMax :: Map k a -> Map k a

-- | <math>. Update the value at the minimal key.
--   
--   
--   updateMin (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "Xb"), (5, "a")]
--   updateMin (\ _ -> Nothing)         (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
--   
updateMin :: (a -> Maybe a) -> Map k a -> Map k a

-- | <math>. Update the value at the maximal key.
--   
--   
--   updateMax (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "Xa")]
--   updateMax (\ _ -> Nothing)         (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
--   
updateMax :: (a -> Maybe a) -> Map k a -> Map k a

-- | <math>. Update the value at the minimal key.
--   
--   
--   updateMinWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"3:b"), (5,"a")]
--   updateMinWithKey (\ _ _ -> Nothing)                     (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
--   
updateMinWithKey :: (k -> a -> Maybe a) -> Map k a -> Map k a

-- | <math>. Update the value at the maximal key.
--   
--   
--   updateMaxWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"b"), (5,"5:a")]
--   updateMaxWithKey (\ _ _ -> Nothing)                     (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
--   
updateMaxWithKey :: (k -> a -> Maybe a) -> Map k a -> Map k a

-- | <math>. Retrieves the value associated with minimal key of the
--   map, and the map stripped of that element, or Nothing if passed
--   an empty map.
--   
--   
--   minView (fromList [(5,"a"), (3,"b")]) == Just ("b", singleton 5 "a")
--   minView empty == Nothing
--   
minView :: Map k a -> Maybe (a, Map k a)

-- | <math>. Retrieves the value associated with maximal key of the
--   map, and the map stripped of that element, or Nothing if passed
--   an empty map.
--   
--   
--   maxView (fromList [(5,"a"), (3,"b")]) == Just ("a", singleton 3 "b")
--   maxView empty == Nothing
--   
maxView :: Map k a -> Maybe (a, Map k a)

-- | <math>. Retrieves the minimal (key,value) pair of the map, and
--   the map stripped of that element, or Nothing if passed an empty
--   map.
--   
--   
--   minViewWithKey (fromList [(5,"a"), (3,"b")]) == Just ((3,"b"), singleton 5 "a")
--   minViewWithKey empty == Nothing
--   
minViewWithKey :: Map k a -> Maybe ((k, a), Map k a)

-- | <math>. Retrieves the maximal (key,value) pair of the map, and
--   the map stripped of that element, or Nothing if passed an empty
--   map.
--   
--   
--   maxViewWithKey (fromList [(5,"a"), (3,"b")]) == Just ((5,"a"), singleton 3 "b")
--   maxViewWithKey empty == Nothing
--   
maxViewWithKey :: Map k a -> Maybe ((k, a), Map k a)

-- | This function has moved to showTree.
showTree :: Whoops "showTree has moved to Data.Map.Internal.Debug.showTree." => Map k a -> String

-- | This function has moved to showTreeWith.
showTreeWith :: Whoops "showTreeWith has moved to Data.Map.Internal.Debug.showTreeWith." => (k -> a -> String) -> Bool -> Bool -> Map k a -> String

-- | <math>. Test if the internal map structure is valid.
--   
--   
--   valid (fromAscList [(3,"b"), (5,"a")]) == True
--   valid (fromAscList [(5,"a"), (3,"b")]) == False
--   
valid :: Ord k => Map k a -> Bool

-- | Strict Map partial functions. Import as:
--   
--   
--   import qualified RIO.Map.Partial as Map'
--   
module RIO.Map.Partial

-- | <math>. Find the value at a key. Calls error when the
--   element can not be found.
--   
--   
--   fromList [(5,'a'), (3,'b')] ! 1    Error: element not in the map
--   fromList [(5,'a'), (3,'b')] ! 5 == 'a'
--   
(!) :: Ord k => Map k a -> k -> a
infixl 9 !

-- | <math>. Retrieve an element by its index, i.e. by its
--   zero-based index in the sequence sorted by keys. If the index
--   is out of range (less than zero, greater or equal to size of
--   the map), error is called.
--   
--   
--   elemAt 0 (fromList [(5,"a"), (3,"b")]) == (3,"b")
--   elemAt 1 (fromList [(5,"a"), (3,"b")]) == (5, "a")
--   elemAt 2 (fromList [(5,"a"), (3,"b")])    Error: index out of range
--   
elemAt :: Int -> Map k a -> (k, a)

-- | <math>. Delete the element at index, i.e. by its
--   zero-based index in the sequence sorted by keys. If the index
--   is out of range (less than zero, greater or equal to size of
--   the map), error is called.
--   
--   
--   deleteAt 0  (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
--   deleteAt 1  (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
--   deleteAt 2 (fromList [(5,"a"), (3,"b")])     Error: index out of range
--   deleteAt (-1) (fromList [(5,"a"), (3,"b")])  Error: index out of range
--   
deleteAt :: Int -> Map k a -> Map k a

-- | <math>. Return the index of a key, which is its
--   zero-based index in the sequence sorted by keys. The index is a number
--   from 0 up to, but not including, the size of the map.
--   Calls error when the key is not a member of the map.
--   
--   
--   findIndex 2 (fromList [(5,"a"), (3,"b")])    Error: element is not in the map
--   findIndex 3 (fromList [(5,"a"), (3,"b")]) == 0
--   findIndex 5 (fromList [(5,"a"), (3,"b")]) == 1
--   findIndex 6 (fromList [(5,"a"), (3,"b")])    Error: element is not in the map
--   
findIndex :: Ord k => k -> Map k a -> Int

-- | <math>. Update the element at index. Calls error
--   when an invalid index is used.
--   
--   
--   updateAt (\ _ _ -> Just "x") 0    (fromList [(5,"a"), (3,"b")]) == fromList [(3, "x"), (5, "a")]
--   updateAt (\ _ _ -> Just "x") 1    (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "x")]
--   updateAt (\ _ _ -> Just "x") 2    (fromList [(5,"a"), (3,"b")])    Error: index out of range
--   updateAt (\ _ _ -> Just "x") (-1) (fromList [(5,"a"), (3,"b")])    Error: index out of range
--   updateAt (\_ _  -> Nothing)  0    (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
--   updateAt (\_ _  -> Nothing)  1    (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
--   updateAt (\_ _  -> Nothing)  2    (fromList [(5,"a"), (3,"b")])    Error: index out of range
--   updateAt (\_ _  -> Nothing)  (-1) (fromList [(5,"a"), (3,"b")])    Error: index out of range
--   
updateAt :: (k -> a -> Maybe a) -> Int -> Map k a -> Map k a

-- | <math>. The minimal key of the map. Calls error if the
--   map is empty.
--   
--   
--   findMin (fromList [(5,"a"), (3,"b")]) == (3,"b")
--   findMin empty                            Error: empty map has no minimal element
--   
findMin :: Map k a -> (k, a)

-- | <math>. The maximal key of the map. Calls error if the
--   map is empty.
--   
--   
--   findMax (fromList [(5,"a"), (3,"b")]) == (5,"a")
--   findMax empty                            Error: empty map has no maximal element
--   
findMax :: Map k a -> (k, a)

-- | <math>. Delete and find the minimal element.
--   
--   
--   deleteFindMin (fromList [(5,"a"), (3,"b"), (10,"c")]) == ((3,"b"), fromList[(5,"a"), (10,"c")])
--   deleteFindMin empty                                      Error: can not return the minimal element of an empty map
--   
deleteFindMin :: Map k a -> ((k, a), Map k a)

-- | <math>. Delete and find the maximal element.
--   
--   
--   deleteFindMax (fromList [(5,"a"), (3,"b"), (10,"c")]) == ((10,"c"), fromList [(3,"b"), (5,"a")])
--   deleteFindMax empty                                      Error: can not return the maximal element of an empty map
--   
deleteFindMax :: Map k a -> ((k, a), Map k a)

-- | This module contains functions from Data.Map.Strict that have
--   unchecked preconditions on their input. If these preconditions are not
--   satisfied, the data structure may end up in an invalid state and other
--   operations may misbehave. Import as:
--   
--   
--   import qualified RIO.Map.Unchecked as Map'
--   
module RIO.Map.Unchecked

-- | <math>. mapKeysMonotonic f s == mapKeys f
--   s, but works only when f is strictly monotonic. That is,
--   for any values x and y, if x <
--   y then f x < f y. The precondition is
--   not checked. Semi-formally, we have:
--   
--   
--   and [x < y ==> f x < f y | x <- ls, y <- ls]
--                       ==> mapKeysMonotonic f s == mapKeys f s
--       where ls = keys s
--   
--   
--   This means that f maps distinct original keys to distinct
--   resulting keys. This function has better performance than
--   mapKeys.
--   
--   
--   mapKeysMonotonic (\ k -> k * 2) (fromList [(5,"a"), (3,"b")]) == fromList [(6, "b"), (10, "a")]
--   valid (mapKeysMonotonic (\ k -> k * 2) (fromList [(5,"a"), (3,"b")])) == True
--   valid (mapKeysMonotonic (\ _ -> 1)     (fromList [(5,"a"), (3,"b")])) == False
--   
mapKeysMonotonic :: (k1 -> k2) -> Map k1 a -> Map k2 a

-- | <math>. Convert the map to a list of key/value pairs where the
--   keys are in ascending order. Subject to list fusion.
--   
--   
--   toAscList (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]
--   
toAscList :: Map k a -> [(k, a)]

-- | <math>. Build a map from an ascending list in linear time.
--   The precondition (input list is ascending) is not checked.
--   
--   
--   fromAscList [(3,"b"), (5,"a")]          == fromList [(3, "b"), (5, "a")]
--   fromAscList [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "b")]
--   valid (fromAscList [(3,"b"), (5,"a"), (5,"b")]) == True
--   valid (fromAscList [(5,"a"), (3,"b"), (5,"b")]) == False
--   
fromAscList :: Eq k => [(k, a)] -> Map k a

-- | <math>. Build a map from an ascending list in linear time with a
--   combining function for equal keys. The precondition (input list is
--   ascending) is not checked.
--   
--   
--   fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "ba")]
--   valid (fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")]) == True
--   valid (fromAscListWith (++) [(5,"a"), (3,"b"), (5,"b")]) == False
--   
fromAscListWith :: Eq k => (a -> a -> a) -> [(k, a)] -> Map k a

-- | <math>. Build a map from an ascending list in linear time with a
--   combining function for equal keys. The precondition (input list is
--   ascending) is not checked.
--   
--   
--   let f k a1 a2 = (show k) ++ ":" ++ a1 ++ a2
--   fromAscListWithKey f [(3,"b"), (5,"a"), (5,"b"), (5,"b")] == fromList [(3, "b"), (5, "5:b5:ba")]
--   valid (fromAscListWithKey f [(3,"b"), (5,"a"), (5,"b"), (5,"b")]) == True
--   valid (fromAscListWithKey f [(5,"a"), (3,"b"), (5,"b"), (5,"b")]) == False
--   
fromAscListWithKey :: Eq k => (k -> a -> a -> a) -> [(k, a)] -> Map k a

-- | <math>. Build a map from an ascending list of distinct elements
--   in linear time. The precondition is not checked.
--   
--   
--   fromDistinctAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")]
--   valid (fromDistinctAscList [(3,"b"), (5,"a")])          == True
--   valid (fromDistinctAscList [(3,"b"), (5,"a"), (5,"b")]) == False
--   
fromDistinctAscList :: [(k, a)] -> Map k a

-- | <math>. Convert the map to a list of key/value pairs where the
--   keys are in descending order. Subject to list fusion.
--   
--   
--   toDescList (fromList [(5,"a"), (3,"b")]) == [(5,"a"), (3,"b")]
--   
toDescList :: Map k a -> [(k, a)]

-- | <math>. Build a map from a descending list in linear time.
--   The precondition (input list is descending) is not checked.
--   
--   
--   fromDescList [(5,"a"), (3,"b")]          == fromList [(3, "b"), (5, "a")]
--   fromDescList [(5,"a"), (5,"b"), (3,"a")] == fromList [(3, "b"), (5, "b")]
--   valid (fromDescList [(5,"a"), (5,"b"), (3,"b")]) == True
--   valid (fromDescList [(5,"a"), (3,"b"), (5,"b")]) == False
--   
fromDescList :: Eq k => [(k, a)] -> Map k a

-- | <math>. Build a map from a descending list in linear time with a
--   combining function for equal keys. The precondition (input list is
--   descending) is not checked.
--   
--   
--   fromDescListWith (++) [(5,"a"), (5,"b"), (3,"b")] == fromList [(3, "b"), (5, "ba")]
--   valid (fromDescListWith (++) [(5,"a"), (5,"b"), (3,"b")]) == True
--   valid (fromDescListWith (++) [(5,"a"), (3,"b"), (5,"b")]) == False
--   
fromDescListWith :: Eq k => (a -> a -> a) -> [(k, a)] -> Map k a

-- | <math>. Build a map from a descending list in linear time with a
--   combining function for equal keys. The precondition (input list is
--   descending) is not checked.
--   
--   
--   let f k a1 a2 = (show k) ++ ":" ++ a1 ++ a2
--   fromDescListWithKey f [(5,"a"), (5,"b"), (5,"b"), (3,"b")] == fromList [(3, "b"), (5, "5:b5:ba")]
--   valid (fromDescListWithKey f [(5,"a"), (5,"b"), (5,"b"), (3,"b")]) == True
--   valid (fromDescListWithKey f [(5,"a"), (3,"b"), (5,"b"), (5,"b")]) == False
--   
fromDescListWithKey :: Eq k => (k -> a -> a -> a) -> [(k, a)] -> Map k a

-- | <math>. Build a map from a descending list of distinct elements
--   in linear time. The precondition is not checked.
--   
--   
--   fromDistinctDescList [(5,"a"), (3,"b")] == fromList [(3, "b"), (5, "a")]
--   valid (fromDistinctDescList [(5,"a"), (3,"b")])          == True
--   valid (fromDistinctDescList [(5,"a"), (3,"b"), (3,"a")]) == False
--   
fromDistinctDescList :: [(k, a)] -> Map k a

-- | NonEmpty list. Import as:
--   
--   
--   import qualified RIO.NonEmpty as NE
--   
--   
--   This module does not export any partial functions. For those, see
--   RIO.NonEmpty.Partial
module RIO.NonEmpty

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

-- | Map a function over a NonEmpty stream.
map :: (a -> b) -> NonEmpty a -> NonEmpty b

-- | 'intersperse x xs' alternates elements of the list with copies of
--   x.
--   
--   
--   intersperse 0 (1 :| [2,3]) == 1 :| [0,2,0,3]
--   
intersperse :: a -> NonEmpty a -> NonEmpty a

-- | scanl is similar to foldl, but returns a stream 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.
--   
scanl :: Foldable f => (b -> a -> b) -> b -> f a -> NonEmpty b

-- | scanr is the right-to-left dual of scanl. Note that
--   
--   
--   head (scanr f z xs) == foldr f z xs.
--   
scanr :: Foldable f => (a -> b -> b) -> b -> f a -> NonEmpty b

-- | scanl1 is a variant of scanl that has no starting value
--   argument:
--   
--   
--   scanl1 f [x1, x2, ...] == x1 :| [x1 `f` x2, x1 `f` (x2 `f` x3), ...]
--   
scanl1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a

-- | scanr1 is a variant of scanr that has no starting value
--   argument.
scanr1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a

-- | transpose for NonEmpty, behaves the same as
--   transpose The rows/columns need not be the same length, in
--   which case > transpose . transpose /= id
transpose :: NonEmpty (NonEmpty a) -> NonEmpty (NonEmpty a)

-- | sortBy for NonEmpty, behaves the same as sortBy
sortBy :: (a -> a -> Ordering) -> NonEmpty a -> NonEmpty a

-- | sortWith for NonEmpty, behaves the same as:
--   
--   
--   sortBy . comparing
--   
sortWith :: Ord o => (a -> o) -> NonEmpty a -> NonEmpty a

-- | Number of elements in NonEmpty list.
length :: NonEmpty a -> Int

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

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

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

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

-- | Prepend an element to the stream.
(<|) :: a -> NonEmpty a -> NonEmpty a
infixr 5 <|

-- | Synonym for <|.
cons :: a -> NonEmpty a -> NonEmpty a

-- | uncons produces the first element of the stream, and a stream
--   of the remaining elements, if any.
uncons :: NonEmpty a -> (a, Maybe (NonEmpty a))

-- | The unfoldr function is analogous to Data.List's
--   unfoldr operation.
unfoldr :: (a -> (b, Maybe a)) -> a -> NonEmpty b

-- | Sort a stream.
sort :: Ord a => NonEmpty a -> NonEmpty a

-- | reverse a finite NonEmpty stream.
reverse :: NonEmpty a -> NonEmpty a

-- | The inits function takes a stream xs and returns all
--   the finite prefixes of xs.
inits :: Foldable f => f a -> NonEmpty [a]

-- | The tails function takes a stream xs and returns all
--   the suffixes of xs.
tails :: Foldable f => f a -> NonEmpty [a]

-- | iterate f x produces the infinite sequence of repeated
--   applications of f to x.
--   
--   
--   iterate f x = x :| [f x, f (f x), ..]
--   
iterate :: (a -> a) -> a -> NonEmpty a

-- | repeat x returns a constant stream, where all elements
--   are equal to x.
repeat :: a -> NonEmpty a

-- | cycle xs returns the infinite repetition of
--   xs:
--   
--   
--   cycle (1 :| [2,3]) = 1 :| [2,3,1,2,3,...]
--   
cycle :: NonEmpty a -> NonEmpty a

-- | insert x xs inserts x into the last position
--   in xs where it is still less than or equal to the next
--   element. In particular, if the list is sorted beforehand, the result
--   will also be sorted.
insert :: (Foldable f, Ord a) => a -> f a -> NonEmpty a

-- | some1 x sequences x one or more times.
some1 :: Alternative f => f a -> f (NonEmpty a)

-- | take n xs returns the first n elements of
--   xs.
take :: Int -> NonEmpty a -> [a]

-- | drop n xs drops the first n elements off the
--   front of the sequence xs.
drop :: Int -> NonEmpty a -> [a]

-- | splitAt n xs returns a pair consisting of the prefix
--   of xs of length n and the remaining stream
--   immediately following this prefix.
--   
--   
--   'splitAt' n xs == ('take' n xs, 'drop' n xs)
--   xs == ys ++ zs where (ys, zs) = 'splitAt' n xs
--   
splitAt :: Int -> NonEmpty a -> ([a], [a])

-- | takeWhile p xs returns the longest prefix of the
--   stream xs for which the predicate p holds.
takeWhile :: (a -> Bool) -> NonEmpty a -> [a]

-- | dropWhile p xs returns the suffix remaining after
--   takeWhile p xs.
dropWhile :: (a -> Bool) -> NonEmpty a -> [a]

-- | span p xs returns the longest prefix of xs
--   that satisfies p, together with the remainder of the stream.
--   
--   
--   'span' p xs == ('takeWhile' p xs, 'dropWhile' p xs)
--   xs == ys ++ zs where (ys, zs) = 'span' p xs
--   
span :: (a -> Bool) -> NonEmpty a -> ([a], [a])

-- | The break p function is equivalent to span
--   (not . p).
break :: (a -> Bool) -> NonEmpty a -> ([a], [a])

-- | filter p xs removes any elements from xs that
--   do not satisfy p.
filter :: (a -> Bool) -> NonEmpty a -> [a]

-- | The partition function takes a predicate p and a
--   stream xs, and returns a pair of lists. The first list
--   corresponds to the elements of xs for which p holds;
--   the second corresponds to the elements of xs for which
--   p does not hold.
--   
--   
--   'partition' p xs = ('filter' p xs, 'filter' (not . p) xs)
--   
partition :: (a -> Bool) -> NonEmpty a -> ([a], [a])

-- | The group function takes a stream and returns a list of streams
--   such that flattening the resulting list is equal to the argument.
--   Moreover, each stream in the resulting list contains only equal
--   elements. For example, in list notation:
--   
--   
--   'group' $ 'cycle' "Mississippi"
--     = "M" : "i" : "ss" : "i" : "ss" : "i" : "pp" : "i" : "M" : "i" : ...
--   
group :: (Foldable f, Eq a) => f a -> [NonEmpty a]

-- | groupBy operates like group, but uses the provided
--   equality predicate instead of ==.
groupBy :: Foldable f => (a -> a -> Bool) -> f a -> [NonEmpty a]

-- | groupWith operates like group, but uses the provided
--   projection when comparing for equality
groupWith :: (Foldable f, Eq b) => (a -> b) -> f a -> [NonEmpty a]

-- | groupAllWith operates like groupWith, but sorts the list
--   first so that each equivalence class has, at most, one list in the
--   output
groupAllWith :: Ord b => (a -> b) -> [a] -> [NonEmpty a]

-- | group1 operates like group, but uses the knowledge that
--   its input is non-empty to produce guaranteed non-empty output.
group1 :: Eq a => NonEmpty a -> NonEmpty (NonEmpty a)

-- | groupBy1 is to group1 as groupBy is to
--   group.
groupBy1 :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty (NonEmpty a)

-- | groupWith1 is to group1 as groupWith is to
--   group
groupWith1 :: Eq b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a)

-- | groupAllWith1 is to groupWith1 as groupAllWith is
--   to groupWith
groupAllWith1 :: Ord b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a)

-- | The isPrefixOf function returns True if the first
--   argument is a prefix of the second.
isPrefixOf :: Eq a => [a] -> NonEmpty a -> Bool

-- | 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
--   inequality test.
nub :: Eq a => NonEmpty a -> NonEmpty a

-- | The nubBy function behaves just like nub, except it uses
--   a user-supplied equality predicate instead of the overloaded ==
--   function.
nubBy :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty a

-- | The zip function takes two streams and returns a stream of
--   corresponding pairs.
zip :: NonEmpty a -> NonEmpty b -> NonEmpty (a, b)

-- | The zipWith function generalizes zip. Rather than
--   tupling the elements, the elements are combined using the function
--   passed as the first argument.
zipWith :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c

-- | The unzip function is the inverse of the zip function.
unzip :: Functor f => f (a, b) -> (f a, f b)

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

-- | Convert a stream to a normal list efficiently.
toList :: NonEmpty a -> [a]

-- | Compute n-ary logic exclusive OR operation on NonEmpty list.
xor :: NonEmpty Bool -> Bool

-- | NonEmpty list partial functions. Import as:
--   
--   
--   import qualified RIO.NonEmpty.Partial as NE'
--   
module RIO.NonEmpty.Partial

-- | xs !! n returns the element of the stream xs at
--   index n. Note that the head of the stream has index 0.
--   
--   Beware: a negative or out-of-bounds index will cause an error.
(!!) :: HasCallStack => NonEmpty a -> Int -> a
infixl 9 !!

-- | Converts a normal list to a NonEmpty stream.
--   
--   Raises an error if given an empty list.
fromList :: HasCallStack => [a] -> NonEmpty a

-- | Partial functions. Import as:
--   
--   
--   import qualified RIO.Partial as RIO'
--   
module RIO.Partial

-- | The fromJust function extracts the element out of a Just
--   and throws an error if its argument is Nothing.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> fromJust (Just 1)
--   1
--   
--   
--   
--   >>> 2 * (fromJust (Just 10))
--   20
--   
--   
--   
--   >>> 2 * (fromJust Nothing)
--   *** Exception: Maybe.fromJust: Nothing
--   ...
--   
--   
--   WARNING: This function is partial. You can use case-matching instead.
fromJust :: HasCallStack => Maybe a -> 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

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

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

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

module RIO.Prelude.Types
data () => Bool
False :: Bool
True :: Bool

-- | The character type Char is an enumeration whose values
--   represent Unicode (or equivalently ISO/IEC 10646) code points (i.e.
--   characters, see http://www.unicode.org/ for details). This set
--   extends the ISO 8859-1 (Latin-1) character set (the first 256
--   characters), which is itself an extension of the ASCII character set
--   (the first 128 characters). A character literal in Haskell has type
--   Char.
--   
--   To convert a Char to or from the corresponding Int value
--   defined by Unicode, use toEnum and fromEnum from the
--   Enum class respectively (or equivalently ord and
--   chr).
data () => Char

-- | A String is a list of characters. String constants in Haskell
--   are values of type String.
--   
--   See Data.List for operations on lists.
type String = [Char]

-- | 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
data () => Ordering
LT :: Ordering
EQ :: Ordering
GT :: Ordering

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

-- | 8-bit signed integer type
data () => Int8

-- | 16-bit signed integer type
data () => Int16

-- | 32-bit signed integer type
data () => Int32

-- | 64-bit signed integer type
data () => Int64

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

-- | 8-bit unsigned integer type
data () => Word8

-- | 16-bit unsigned integer type
data () => Word16

-- | 32-bit unsigned integer type
data () => Word32

-- | 64-bit unsigned integer type
data () => Word64

-- | 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 (fit into an Int), IS constructor
--   is used. Otherwise Integer and IN constructors are used
--   to store a BigNat representing respectively the positive or the
--   negative value magnitude.
--   
--   Invariant: Integer and IN are used iff value doesn't fit
--   in IS
data () => Integer

-- | Natural number
--   
--   Invariant: numbers <= 0xffffffffffffffff use the NS
--   constructor
data () => Natural

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

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

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

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

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

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

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

-- | Uninhabited data type
data () => Void

-- | The Const functor.
newtype () => Const a (b :: k)
Const :: a -> Const a (b :: k)
[getConst] :: Const a (b :: k) -> a

-- | Identity functor and monad. (a non-strict monad)
newtype () => Identity a
Identity :: a -> Identity a
[runIdentity] :: Identity a -> a

-- | 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 strict ST monad. The ST monad allows for destructive
--   updates, but is escapable (unlike IO). A computation of type
--   ST s a returns a value of type a, and execute
--   in "thread" s. The s parameter is either
--   
--   
--   
- an uninstantiated type variable (inside invocations of
--   runST), or
--   
- RealWorld (inside invocations of stToIO).
--   
--   
--   It serves to keep the internal states of different invocations of
--   runST separate from each other and from invocations of
--   stToIO.
--   
--   The >>= and >> operations are strict in the
--   state (though not in values stored in the state). For example,
--   
--   
--   runST (writeSTRef _|_ v >>= f) = _|_
--   
data () => ST s 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)
--   
--   
--   Minimal complete definition: either == or /=.
class () => Eq a

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

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

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

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

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

-- | Class for string-like datastructures; used by the overloaded string
--   extension (-XOverloadedStrings in GHC).
class () => IsString a

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

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

-- | 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
class (Num a, Ord a) => Real a

-- | 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.
class (Real a, Enum a) => Integral a

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

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

-- | 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
--   https://www.schoolofhaskell.com/user/edwardk/snippets/fmap or
--   https://github.com/quchen/articles/blob/master/second_functor_law.md
--   for an explanation.
class () => Functor (f :: Type -> Type)

-- | A bifunctor is a type constructor that takes two type arguments and is
--   a functor in both arguments. That is, unlike with
--   Functor, a type constructor such as Either does not need
--   to be partially applied for a Bifunctor instance, and the
--   methods in this class permit mapping functions over the Left
--   value or the Right value, or both at the same time.
--   
--   Formally, the class Bifunctor represents a bifunctor from
--   Hask -> Hask.
--   
--   Intuitively it is a bifunctor where both the first and second
--   arguments are covariant.
--   
--   You can define a Bifunctor by either defining bimap or
--   by defining both first and second.
--   
--   If you supply bimap, you should ensure that:
--   
--   
--   bimap id id ≡ id
--   
--   
--   If you supply first and second, ensure:
--   
--   
--   first id ≡ id
--   second id ≡ id
--   
--   
--   If you supply both, you should also ensure:
--   
--   
--   bimap f g ≡ first f . second g
--   
--   
--   These ensure by parametricity:
--   
--   
--   bimap  (f . g) (h . i) ≡ bimap f h . bimap g i
--   first  (f . g) ≡ first  f . first  g
--   second (f . g) ≡ second f . second g
--   
class () => Bifunctor (p :: Type -> Type -> Type)

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

-- | Bifoldable identifies foldable structures with two different
--   varieties of elements (as opposed to Foldable, which has one
--   variety of element). Common examples are Either and
--   (,):
--   
--   
--   instance Bifoldable Either where
--     bifoldMap f _ (Left  a) = f a
--     bifoldMap _ g (Right b) = g b
--   
--   instance Bifoldable (,) where
--     bifoldr f g z (a, b) = f a (g b z)
--   
--   
--   Some examples below also use the following BiList to showcase empty
--   Bifoldable behaviors when relevant (Either and (,)
--   containing always exactly resp. 1 and 2 elements):
--   
--   
--   data BiList a b = BiList [a] [b]
--   
--   instance Bifoldable BiList where
--     bifoldr f g z (BiList as bs) = foldr f (foldr g z bs) as
--   
--   
--   A minimal Bifoldable definition consists of either
--   bifoldMap or bifoldr. When defining more than this
--   minimal set, one should ensure that the following identities hold:
--   
--   
--   bifold ≡ bifoldMap id id
--   bifoldMap f g ≡ bifoldr (mappend . f) (mappend . g) mempty
--   bifoldr f g z t ≡ appEndo (bifoldMap (Endo . f) (Endo . g) t) z
--   
--   
--   If the type is also a Bifunctor instance, it should satisfy:
--   
--   
--   bifoldMap f g ≡ bifold . bimap f g
--   
--   
--   which implies that
--   
--   
--   bifoldMap f g . bimap h i ≡ bifoldMap (f . h) (g . i)
--   
class () => Bifoldable (p :: Type -> Type -> Type)

-- | The class of semigroups (types with an associative binary operation).
--   
--   Instances should satisfy the following:
--   
--   
--   
- Associativity x <> (y <> z) =
--   (x <> y) <> z
--   
class () => Semigroup a

-- | The class of monoids (types with an associative binary operation that
--   has an identity). Instances should satisfy the following:
--   
--   
--   
- Right identity x <> mempty =
--   x
--   
- Left identity mempty <> x =
--   x
--   
- Associativity x <> (y <> z) =
--   (x <> y) <> z (Semigroup
--   law)
--   
- Concatenation mconcat = foldr
--   (<>) mempty
--   
--   
--   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

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

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

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

--   
class Applicative f => Alternative (f :: Type -> Type)

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

-- | Bitraversable identifies bifunctorial data structures whose
--   elements can be traversed in order, performing Applicative or
--   Monad actions at each element, and collecting a result
--   structure with the same shape.
--   
--   As opposed to Traversable data structures, which have one
--   variety of element on which an action can be performed,
--   Bitraversable data structures have two such varieties of
--   elements.
--   
--   A definition of bitraverse must satisfy the following laws:
--   
--   
--   
- Naturality bitraverse (t . f) (t . g) ≡ t .
--   bitraverse f g for every applicative transformation
--   t
--   
- Identity bitraverse Identity
--   Identity ≡ Identity
--   
- Composition Compose . fmap
--   (bitraverse g1 g2) . bitraverse f1 f2 ≡
--   bitraverse (Compose . fmap g1 . f1)
--   (Compose . fmap g2 . f2)
--   
--   
--   where an applicative transformation is a function
--   
--   
--   t :: (Applicative f, Applicative g) => f a -> g a
--   
--   
--   preserving the Applicative operations:
--   
--   
--   t (pure x) = pure x
--   t (f <*> x) = t f <*> t x
--   
--   
--   and the identity functor Identity and composition functors
--   Compose are from Data.Functor.Identity and
--   Data.Functor.Compose.
--   
--   Some simple examples are Either and (,):
--   
--   
--   instance Bitraversable Either where
--     bitraverse f _ (Left x) = Left <$> f x
--     bitraverse _ g (Right y) = Right <$> g y
--   
--   instance Bitraversable (,) where
--     bitraverse f g (x, y) = (,) <$> f x <*> g y
--   
--   
--   Bitraversable relates to its superclasses in the following
--   ways:
--   
--   
--   bimap f g ≡ runIdentity . bitraverse (Identity . f) (Identity . g)
--   bifoldMap f g = getConst . bitraverse (Const . f) (Const . g)
--   
--   
--   These are available as bimapDefault and bifoldMapDefault
--   respectively.
class (Bifunctor t, Bifoldable t) => Bitraversable (t :: Type -> Type -> Type)

-- | 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 lists, Maybe and IO
--   defined in the Prelude satisfy these laws.
class Applicative m => Monad (m :: Type -> Type)

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

-- | A class for categories. Instances should satisfy the laws
--   
--   
--   
- Right identity f . id = f
--   
- Left identity id . f = f
--   
- Associativity f . (g . h) = (f .
--   g) . h
--   
class () => Category (cat :: k -> k -> Type)

-- | The basic arrow class.
--   
--   Instances should satisfy the following laws:
--   
--   
--   
- 
arr id = id

--   
- 
arr (f >>> g) = arr f >>>
--   arr g

--   
- 
first (arr f) = arr (first
--   f)

--   
- 
first (f >>> g) = first f >>>
--   first g

--   
- 
first f >>> arr fst =
--   arr fst >>> f

--   
- 
first f >>> arr (id *** g) =
--   arr (id *** g) >>> first f

--   
- 
first (first f) >>> arr assoc =
--   arr assoc >>> first f

--   
--   
--   where
--   
--   
--   assoc ((a,b),c) = (a,(b,c))
--   
--   
--   The other combinators have sensible default definitions, which may be
--   overridden for efficiency.
class Category a => Arrow (a :: Type -> Type -> Type)

-- | 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
--   
class Monad m => MonadFail (m :: Type -> Type)

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

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

-- | Left-associative fold operation for constructor applications.
--   
--   The type of gfoldl is a headache, but operationally it is a
--   simple generalisation of a list fold.
--   
--   The default definition for gfoldl is const
--   id, which is suitable for abstract datatypes with no
--   substructures.
gfoldl :: Data a => (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. () => g -> c g) -> a -> c a

-- | Unfolding constructor applications
gunfold :: Data a => (forall b r. Data b => c (b -> r) -> c r) -> (forall r. () => r -> c r) -> Constr -> c a

-- | Obtaining the constructor from a given datum. For proper terms, this
--   is meant to be the top-level constructor. Primitive datatypes are here
--   viewed as potentially infinite sets of values (i.e., constructors).
toConstr :: Data a => a -> Constr

-- | The outer type constructor of the type
dataTypeOf :: Data a => a -> DataType

-- | Mediate types and unary type constructors.
--   
--   In Data instances of the form
--   
--   
--   instance (Data a, ...) => Data (T a)
--   
--   
--   dataCast1 should be defined as gcast1.
--   
--   The default definition is const Nothing, which
--   is appropriate for instances of other forms.
dataCast1 :: (Data a, Typeable t) => (forall d. Data d => c (t d)) -> Maybe (c a)

-- | Mediate types and binary type constructors.
--   
--   In Data instances of the form
--   
--   
--   instance (Data a, Data b, ...) => Data (T a b)
--   
--   
--   dataCast2 should be defined as gcast2.
--   
--   The default definition is const Nothing, which
--   is appropriate for instances of other forms.
dataCast2 :: (Data a, Typeable t) => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a)

-- | A generic transformation that maps over the immediate subterms
--   
--   The default definition instantiates the type constructor c in
--   the type of gfoldl to an identity datatype constructor, using
--   the isomorphism pair as injection and projection.
gmapT :: Data a => (forall b. Data b => b -> b) -> a -> a

-- | A generic query with a left-associative binary operator
gmapQl :: Data a => (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r

-- | A generic query with a right-associative binary operator
gmapQr :: forall r r'. Data a => (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r

-- | A generic query that processes the immediate subterms and returns a
--   list of results. The list is given in the same order as originally
--   specified in the declaration of the data constructors.
gmapQ :: Data a => (forall d. Data d => d -> u) -> a -> [u]

-- | A generic query that processes one child by index (zero-based)
gmapQi :: Data a => Int -> (forall d. Data d => d -> u) -> a -> u

-- | A generic monadic transformation that maps over the immediate subterms
--   
--   The default definition instantiates the type constructor c in
--   the type of gfoldl to the monad datatype constructor, defining
--   injection and projection using return and >>=.
gmapM :: (Data a, Monad m) => (forall d. Data d => d -> m d) -> a -> m a

-- | Transformation of at least one immediate subterm does not fail
gmapMp :: (Data a, MonadPlus m) => (forall d. Data d => d -> m d) -> a -> m a

-- | Transformation of one immediate subterm with success
gmapMo :: (Data a, MonadPlus m) => (forall d. Data d => d -> m d) -> a -> m a

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

-- | The member functions of this class facilitate writing values of
--   primitive types to raw memory (which may have been allocated with the
--   above mentioned routines) and reading values from blocks of raw
--   memory. The class, furthermore, includes support for computing the
--   storage requirements and alignment restrictions of storable types.
--   
--   Memory addresses are represented as values of type Ptr
--   a, for some a which is an instance of class
--   Storable. The type argument to Ptr helps provide some
--   valuable type safety in FFI code (you can't mix pointers of different
--   types without an explicit cast), while helping the Haskell type system
--   figure out which marshalling method is needed for a given pointer.
--   
--   All marshalling between Haskell and a foreign language ultimately
--   boils down to translating Haskell data structures into the binary
--   representation of a corresponding data structure of the foreign
--   language and vice versa. To code this marshalling in Haskell, it is
--   necessary to manipulate primitive data types stored in unstructured
--   memory blocks. The class Storable facilitates this manipulation
--   on all types for which it is instantiated, which are the standard
--   basic types of Haskell, the fixed size Int types
--   (Int8, Int16, Int32, Int64), the fixed
--   size Word types (Word8, Word16, Word32,
--   Word64), StablePtr, all types from
--   Foreign.C.Types, as well as Ptr.
class () => Storable a

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

-- | Request a CallStack.
--   
--   NOTE: The implicit parameter ?callStack :: CallStack is an
--   implementation detail and should not be considered part of the
--   CallStack API, we may decide to change the implementation in
--   the future.
type HasCallStack = ?callStack :: CallStack

-- | A class of types that can be fully evaluated.
class () => NFData a

-- | The class of monad transformers. Instances should satisfy the
--   following laws, which state that lift is a monad
--   transformation:
--   
--   
--   
- 
lift . return = return

--   
- 
lift (m >>= f) = lift m >>=
--   (lift . f)

--   
class () => MonadTrans (t :: Type -> Type -> Type -> Type)

-- | See examples in Control.Monad.Reader. Note, the partially
--   applied function type (->) r is a simple reader monad. See
--   the instance declaration below.
class Monad m => MonadReader r (m :: Type -> Type) | m -> r

-- | The parameterizable reader monad.
--   
--   Computations are functions of a shared environment.
--   
--   The return function ignores the environment, while
--   >>= passes the inherited environment to both
--   subcomputations.
type Reader r = ReaderT r Identity

-- | The reader monad transformer, which adds a read-only environment to
--   the given monad.
--   
--   The return function ignores the environment, while
--   >>= passes the inherited environment to both
--   subcomputations.
newtype () => ReaderT r (m :: Type -> Type) a
ReaderT :: (r -> m a) -> ReaderT r (m :: Type -> Type) a

-- | A class for monads in which exceptions may be thrown.
--   
--   Instances should obey the following law:
--   
--   
--   throwM e >> x = throwM e
--   
--   
--   In other words, throwing an exception short-circuits the rest of the
--   monadic computation.
class Monad m => MonadThrow (m :: Type -> Type)

-- | A space-efficient representation of a Word8 vector, supporting
--   many efficient operations.
--   
--   A ByteString contains 8-bit bytes, or by using the operations
--   from Data.ByteString.Char8 it can be interpreted as containing
--   8-bit characters.
data () => ByteString
type LByteString = ByteString

-- | Builders denote sequences of bytes. They are Monoids
--   where mempty is the zero-length sequence and mappend is
--   concatenation, which runs in O(1).
data () => Builder

-- | A compact representation of a Word8 vector.
--   
--   It has a lower memory overhead than a ByteString and does not
--   contribute to heap fragmentation. It can be converted to or from a
--   ByteString (at the cost of copying the string data). It
--   supports very few other operations.
data () => ShortByteString

-- | A space efficient, packed, unboxed Unicode text type.
data () => Text
type LText = Text

-- | An exception type for representing Unicode encoding errors.
data () => UnicodeException

-- | Could not decode a byte sequence because it was invalid under the
--   given encoding, or ran out of input in mid-decode.
DecodeError :: String -> Maybe Word8 -> UnicodeException

-- | Tried to encode a character that could not be represented under the
--   given encoding, or ran out of input in mid-encode.
EncodeError :: String -> Maybe Char -> UnicodeException

-- | Boxed vectors, supporting efficient slicing.
data () => Vector a
type UVector = Vector
class (Vector Vector a, MVector MVector a) => Unbox a
type SVector = Vector
type GVector = Vector

-- | A map of integers to values a.
data () => IntMap a

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

-- | A set of integers.
data () => IntSet

-- | A set of values a.
data () => Set a

-- | General-purpose finite sequences.
data () => Seq a

-- | The class of types that can be converted to a hash value.
--   
--   Minimal implementation: hashWithSalt.
--   
--   Note: the hash is not guaranteed to be stable across library
--   versions, operating systems or architectures. For stable hashing use
--   named hashes: SHA256, CRC32 etc.
--   
--   If you are looking for Hashable instance in time
--   package, check time-compat
class Eq a => Hashable a

-- | A map from keys to values. A map cannot contain duplicate keys; each
--   key can map to at most one value.
data () => HashMap k v

-- | A set of values. A set cannot contain duplicate values.
data () => HashSet a

-- | Class of monads which can perform primitive state-transformer actions.
class Monad m => PrimMonad (m :: Type -> Type) where {
    
    -- | State token type.
    type family PrimState (m :: Type -> Type);
}

module RIO.Prelude

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

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

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

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

-- | Case analysis for the Bool type. bool x y p
--   evaluates to x when p is False, and evaluates
--   to y when p is True.
--   
--   This is equivalent to if p then y else x; that is, one can
--   think of it as an if-then-else construct with its arguments reordered.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> bool "foo" "bar" True
--   "bar"
--   
--   >>> bool "foo" "bar" False
--   "foo"
--   
--   
--   Confirm that bool x y p and if p then y else
--   x are equivalent:
--   
--   
--   >>> let p = True; x = "bar"; y = "foo"
--   
--   >>> bool x y p == if p then y else x
--   True
--   
--   >>> let p = False
--   
--   >>> bool x y p == if p then y else x
--   True
--   
bool :: a -> a -> Bool -> 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 Text.Read ( readMaybe )
--   
--   >>> maybe 0 (*2) (readMaybe "5")
--   10
--   
--   >>> maybe 0 (*2) (readMaybe "")
--   0
--   
--   
--   Apply show to a Maybe Int. If we have Just n,
--   we want to show the underlying Int n. But if we have
--   Nothing, we return the empty string instead of (for example)
--   "Nothing":
--   
--   
--   >>> maybe "" show (Just 5)
--   "5"
--   
--   >>> maybe "" show Nothing
--   ""
--   
maybe :: b -> (a -> b) -> Maybe a -> b

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

-- | Get a First value with a default fallback
fromFirst :: a -> First a -> a

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

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

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

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

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

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

-- | Applicative mapMaybe.
mapMaybeA :: Applicative f => (a -> f (Maybe b)) -> [a] -> f [b]

-- | Monadic mapMaybe.
mapMaybeM :: Monad m => (a -> m (Maybe b)) -> [a] -> m [b]

-- | 
--   forMaybeA == flip mapMaybeA
--   
forMaybeA :: Applicative f => [a] -> (a -> f (Maybe b)) -> f [b]

-- | 
--   forMaybeM == flip mapMaybeM
--   
forMaybeM :: Monad m => [a] -> (a -> m (Maybe b)) -> m [b]

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

-- | Return the contents of a Left-value or a default value
--   otherwise.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> fromLeft 1 (Left 3)
--   3
--   
--   >>> fromLeft 1 (Right "foo")
--   1
--   
fromLeft :: a -> Either a b -> a

-- | Return the contents of a Right-value or a default value
--   otherwise.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> fromRight 1 (Right 3)
--   3
--   
--   >>> fromRight 1 (Left "foo")
--   1
--   
fromRight :: b -> Either a b -> b

-- | Return True if the given value is a Left-value,
--   False otherwise.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> isLeft (Left "foo")
--   True
--   
--   >>> isLeft (Right 3)
--   False
--   
--   
--   Assuming a Left value signifies some sort of error, we can use
--   isLeft to write a very simple error-reporting function that
--   does absolutely nothing in the case of success, and outputs "ERROR" if
--   any error occurred.
--   
--   This example shows how isLeft might be used to avoid pattern
--   matching when one does not care about the value contained in the
--   constructor:
--   
--   
--   >>> import Control.Monad ( when )
--   
--   >>> let report e = when (isLeft e) $ putStrLn "ERROR"
--   
--   >>> report (Right 1)
--   
--   >>> report (Left "parse error")
--   ERROR
--   
isLeft :: Either a b -> Bool

-- | Return True if the given value is a Right-value,
--   False otherwise.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> isRight (Left "foo")
--   False
--   
--   >>> isRight (Right 3)
--   True
--   
--   
--   Assuming a Left value signifies some sort of error, we can use
--   isRight to write a very simple reporting function that only
--   outputs "SUCCESS" when a computation has succeeded.
--   
--   This example shows how isRight might be used to avoid pattern
--   matching when one does not care about the value contained in the
--   constructor:
--   
--   
--   >>> import Control.Monad ( when )
--   
--   >>> let report e = when (isRight e) $ putStrLn "SUCCESS"
--   
--   >>> report (Left "parse error")
--   
--   >>> report (Right 1)
--   SUCCESS
--   
isRight :: Either a b -> Bool

-- | Apply a function to a Left constructor
mapLeft :: (a1 -> a2) -> Either a1 b -> Either a2 b

-- | Extracts from a list of Either all the Left elements.
--   All the Left elements are extracted in order.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]
--   
--   >>> lefts list
--   ["foo","bar","baz"]
--   
lefts :: [Either a b] -> [a]

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

-- | Extracts from a list of Either all the Right elements.
--   All the Right elements are extracted in order.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]
--   
--   >>> rights list
--   [3,7]
--   
rights :: [Either a b] -> [b]

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

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

-- | curry converts 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
(==) :: Eq a => a -> a -> Bool
infix 4 ==
(/=) :: Eq a => a -> a -> Bool
infix 4 /=
(<) :: Ord a => a -> a -> Bool
infix 4 <
(<=) :: Ord a => a -> a -> Bool
infix 4 <=
(>) :: Ord a => a -> a -> Bool
infix 4 >
(>=) :: Ord a => a -> a -> Bool
infix 4 >=
max :: Ord a => a -> a -> a
min :: Ord a => a -> a -> a
compare :: Ord a => a -> a -> Ordering

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

-- | The Down type allows you to reverse sort order conveniently. A
--   value of type Down a contains a value of type
--   a (represented as Down a).
--   
--   If a has an Ord instance associated with it
--   then comparing two values thus wrapped will give you the opposite of
--   their normal sort order. This is particularly useful when sorting in
--   generalised list comprehensions, as in: then sortWith by
--   Down x.
--   
--   
--   >>> compare True False
--   GT
--   
--   
--   
--   >>> compare (Down True) (Down False)
--   LT
--   
--   
--   If a has a Bounded instance then the wrapped
--   instance also respects the reversed ordering by exchanging the values
--   of minBound and maxBound.
--   
--   
--   >>> minBound :: Int
--   -9223372036854775808
--   
--   
--   
--   >>> minBound :: Down Int
--   Down 9223372036854775807
--   
--   
--   All other instances of Down a behave as they do for
--   a.
newtype () => Down a
Down :: a -> Down a

[getDown] :: Down a -> 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
minBound :: Bounded a => a
maxBound :: Bounded a => a
(+) :: Num a => a -> a -> a
infixl 6 +
(-) :: Num a => a -> a -> a
infixl 6 -
(*) :: Num a => a -> a -> a
infixl 7 *

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

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

-- | 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 rational equivalent of its real argument with full precision
toRational :: Real a => a -> Rational

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

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

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

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

-- | 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
even :: Integral a => a -> Bool
odd :: Integral a => a -> Bool

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

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

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

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

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

-- | 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
pi :: Floating a => a
exp :: Floating a => a -> a
log :: Floating a => a -> a
sqrt :: Floating a => a -> a
(**) :: Floating a => a -> a -> a
infixr 8 **
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

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

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

-- | Reverse order of bytes in Word16.
byteSwap16 :: Word16 -> Word16

-- | Reverse order of bytes in Word32.
byteSwap32 :: Word32 -> Word32

-- | Reverse order of bytes in Word64.
byteSwap64 :: Word64 -> Word64

-- | An associative operation.
--   
--   
--   >>> [1,2,3] <> [4,5,6]
--   [1,2,3,4,5,6]
--   
(<>) :: Semigroup a => a -> a -> a
infixr 6 <>
sappend :: Semigroup s => s -> s -> s

-- | Identity of mappend
--   
--   
--   >>> "Hello world" <> mempty
--   "Hello world"
--   
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

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

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

-- | 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.
(<$) :: Functor f => a -> f b -> f a
infixl 4 <$

-- | Flipped version of <$.
--   
--   
Examples
--   
--   Replace the contents of a Maybe Int with a
--   constant String:
--   
--   
--   >>> Nothing $> "foo"
--   Nothing
--   
--   >>> Just 90210 $> "foo"
--   Just "foo"
--   
--   
--   Replace the contents of an Either Int
--   Int with a constant String, resulting in an
--   Either Int String:
--   
--   
--   >>> Left 8675309 $> "foo"
--   Left 8675309
--   
--   >>> Right 8675309 $> "foo"
--   Right "foo"
--   
--   
--   Replace each element of a list with a constant String:
--   
--   
--   >>> [1,2,3] $> "foo"
--   ["foo","foo","foo"]
--   
--   
--   Replace the second element of a pair with a constant String:
--   
--   
--   >>> (1,2) $> "foo"
--   (1,"foo")
--   
($>) :: Functor f => f a -> b -> f b
infixl 4 $>

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

-- | Flipped version of <$>.
--   
--   
--   (<&>) = flip fmap
--   
--   
--   
Examples
--   
--   Apply (+1) to a list, a Just and a Right:
--   
--   
--   >>> Just 2 <&> (+1)
--   Just 3
--   
--   
--   
--   >>> [1,2,3] <&> (+1)
--   [2,3,4]
--   
--   
--   
--   >>> Right 3 <&> (+1)
--   Right 4
--   
(<&>) :: Functor f => f a -> (a -> b) -> f b
infixl 1 <&>

-- | Lift a value.
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
infixl 4 <*>

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

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

-- | Lift a function to actions. Equivalent to Functor's fmap but
--   implemented using only Applicative's methods: `liftA f a = pure
--   f * a`
--   
--   As such this function may be used to implement a Functor
--   instance from an Applicative one.
liftA :: Applicative 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 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c

-- | Lift a ternary function to actions.
liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d

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

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

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

-- | Evaluate each action in the structure from left to right, and ignore
--   the results. For a version that doesn't ignore the results see
--   sequenceA.
--   
--   sequenceA_ is just like sequence_, but generalised to
--   Applicative actions.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> sequenceA_ [print "Hello", print "world", print "!"]
--   "Hello"
--   "world"
--   "!"
--   
sequenceA_ :: (Foldable t, Applicative f) => t (f a) -> f ()

-- | This generalizes the list-based filter function.
filterM :: Applicative m => (a -> m Bool) -> [a] -> m [a]

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

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

-- | Inject a value into the monadic type.
return :: Monad m => a -> m a

-- | The join function is the conventional monad join operator. It
--   is used to remove one level of monadic structure, projecting its bound
--   argument into the outer level.
--   
--   'join bss' can be understood as the do
--   expression
--   
--   
--   do bs <- bss
--      bs
--   
--   
--   
Examples
--   
--   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
fail :: MonadFail m => String -> m a

-- | 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
--   
(>>=) :: Monad m => m a -> (a -> m b) -> m b
infixl 1 >>=

-- | 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
--   
(>>) :: Monad m => m a -> m b -> m b
infixl 1 >>

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

-- | Left-to-right composition of Kleisli arrows.
--   
--   '(bs >=> cs) a' can be understood as the
--   do expression
--   
--   
--   do b <- bs a
--      cs b
--   
(>=>) :: 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 <=<

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

-- | Promote a function to a monad.
liftM :: Monad m => (a1 -> r) -> m a1 -> m r

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

-- | Run the second value if the first value returns True
whenM :: Monad m => m Bool -> m () -> m ()

-- | Run the second value if the first value returns False
unlessM :: Monad m => m Bool -> m () -> m ()

-- | Map each element of a structure to a monadic action, evaluate these
--   actions from left to right, and ignore the results. For a version that
--   doesn't ignore the results see mapM.
--   
--   mapM_ is just like traverse_, but specialised to monadic
--   actions.
mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m ()

-- | forM_ is mapM_ with its arguments flipped. For a version
--   that doesn't ignore the results see forM.
--   
--   forM_ is just like for_, but specialised to monadic
--   actions.
forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m ()

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

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

-- | Given a structure with elements whose type is a Monoid, combine
--   them via the monoid's (<>) operator. This fold
--   is right-associative and lazy in the accumulator. When you need a
--   strict left-associative fold, use foldMap' instead, with
--   id as the map.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> fold [[1, 2, 3], [4, 5], [6], []]
--   [1,2,3,4,5,6]
--   
--   
--   
--   >>> fold $ Node (Leaf (Sum 1)) (Sum 3) (Leaf (Sum 5))
--   Sum {getSum = 9}
--   
--   
--   Folds of unbounded structures do not terminate when the monoid's
--   (<>) operator is strict:
--   
--   
--   >>> fold (repeat Nothing)
--   * Hangs forever *
--   
--   
--   Lazy corecursive folds of unbounded structures are fine:
--   
--   
--   >>> take 12 $ fold $ map (\i -> [i..i+2]) [0..]
--   [0,1,2,1,2,3,2,3,4,3,4,5]
--   
--   >>> sum $ take 4000000 $ fold $ map (\i -> [i..i+2]) [0..]
--   2666668666666
--   
fold :: (Foldable t, Monoid m) => t m -> m

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

-- | Extend foldMap to allow side effects.
--   
--   Internally, this is implemented using a strict left fold. This is used
--   for performance reasons. It also necessitates that this function has a
--   Monad constraint and not just an Applicative
--   constraint. For more information, see
--   https://github.com/commercialhaskell/rio/pull/99#issuecomment-394179757.
foldMapM :: (Monad m, Monoid w, Foldable t) => (a -> m w) -> t a -> m w

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

-- | One or more.
some :: Alternative f => f a -> f [a]

-- | Zero or more.
many :: Alternative f => f a -> f [a]

-- | One or none.
--   
--   It is useful for modelling any computation that is allowed to fail.
--   
--   
Examples
--   
--   Using the Alternative instance of Control.Monad.Except,
--   the following functions:
--   
--   
--   >>> import Control.Monad.Except
--   
--   
--   
--   >>> canFail = throwError "it failed" :: Except String Int
--   
--   >>> final = return 42                :: Except String Int
--   
--   
--   Can be combined by allowing the first function to fail:
--   
--   
--   >>> runExcept $ canFail *> final
--   Left "it failed"
--   
--   >>> runExcept $ optional canFail *> final
--   Right 42
--   
optional :: Alternative f => f a -> f (Maybe a)

-- | The sum of a collection of actions, generalizing concat.
--   
--   asum is just like msum, but generalised to
--   Alternative.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> asum [Just "Hello", Nothing, Just "World"]
--   Just "Hello"
--   
asum :: (Foldable t, Alternative f) => t (f a) -> f a

-- | Conditional failure of Alternative computations. Defined by
--   
--   
--   guard True  = pure ()
--   guard False = empty
--   
--   
--   
Examples
--   
--   Common uses of guard include conditionally signaling an error
--   in an error monad and conditionally rejecting the current choice in an
--   Alternative-based parser.
--   
--   As an example of signaling 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 ()

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

-- | The reverse of when.
unless :: Applicative f => Bool -> f () -> f ()

-- | Map over both arguments at the same time.
--   
--   
--   bimap f g ≡ first f . second g
--   
--   
--   
Examples
--   
--   
--   >>> bimap toUpper (+1) ('j', 3)
--   ('J',4)
--   
--   
--   
--   >>> bimap toUpper (+1) (Left 'j')
--   Left 'J'
--   
--   
--   
--   >>> bimap toUpper (+1) (Right 3)
--   Right 4
--   
bimap :: Bifunctor p => (a -> b) -> (c -> d) -> p a c -> p b d

-- | Map covariantly over the first argument.
--   
--   
--   first f ≡ bimap f id
--   
--   
--   
Examples
--   
--   
--   >>> first toUpper ('j', 3)
--   ('J',3)
--   
--   
--   
--   >>> first toUpper (Left 'j')
--   Left 'J'
--   
first :: Bifunctor p => (a -> b) -> p a c -> p b c

-- | Map covariantly over the second argument.
--   
--   
--   second ≡ bimap id
--   
--   
--   
Examples
--   
--   
--   >>> second (+1) ('j', 3)
--   ('j',4)
--   
--   
--   
--   >>> second (+1) (Right 3)
--   Right 4
--   
second :: Bifunctor p => (b -> c) -> p a b -> p a c

-- | Combines the elements of a structure using a monoid.
--   
--   
--   bifold ≡ bifoldMap id id
--   
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> bifold (Right [1, 2, 3])
--   [1,2,3]
--   
--   
--   
--   >>> bifold (Left [5, 6])
--   [5,6]
--   
--   
--   
--   >>> bifold ([1, 2, 3], [4, 5])
--   [1,2,3,4,5]
--   
--   
--   
--   >>> bifold (Product 6, Product 7)
--   Product {getProduct = 42}
--   
--   
--   
--   >>> bifold (Sum 6, Sum 7)
--   Sum {getSum = 13}
--   
bifold :: (Bifoldable p, Monoid m) => p m m -> m

-- | Combines the elements of a structure, given ways of mapping them to a
--   common monoid.
--   
--   
--   bifoldMap f g ≡ bifoldr (mappend . f) (mappend . g) mempty
--   
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> bifoldMap (take 3) (fmap digitToInt) ([1..], "89")
--   [1,2,3,8,9]
--   
--   
--   
--   >>> bifoldMap (take 3) (fmap digitToInt) (Left [1..])
--   [1,2,3]
--   
--   
--   
--   >>> bifoldMap (take 3) (fmap digitToInt) (Right "89")
--   [8,9]
--   
bifoldMap :: (Bifoldable p, Monoid m) => (a -> m) -> (b -> m) -> p a b -> m

-- | Combines the elements of a structure in a right associative manner.
--   Given a hypothetical function toEitherList :: p a b -> [Either
--   a b] yielding a list of all elements of a structure in order, the
--   following would hold:
--   
--   
--   bifoldr f g z ≡ foldr (either f g) z . toEitherList
--   
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   > bifoldr (+) (*) 3 (5, 7)
--   26 -- 5 + (7 * 3)
--   
--   > bifoldr (+) (*) 3 (7, 5)
--   22 -- 7 + (5 * 3)
--   
--   > bifoldr (+) (*) 3 (Right 5)
--   15 -- 5 * 3
--   
--   > bifoldr (+) (*) 3 (Left 5)
--   8 -- 5 + 3
--   
bifoldr :: Bifoldable p => (a -> c -> c) -> (b -> c -> c) -> c -> p a b -> c

-- | Combines the elements of a structure in a left associative manner.
--   Given a hypothetical function toEitherList :: p a b -> [Either
--   a b] yielding a list of all elements of a structure in order, the
--   following would hold:
--   
--   
--   bifoldl f g z
--        ≡ foldl (acc -> either (f acc) (g acc)) z . toEitherList
--   
--   
--   Note that if you want an efficient left-fold, you probably want to use
--   bifoldl' instead of bifoldl. The reason is that the
--   latter does not force the "inner" results, resulting in a thunk chain
--   which then must be evaluated from the outside-in.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   > bifoldl (+) (*) 3 (5, 7)
--   56 -- (5 + 3) * 7
--   
--   > bifoldl (+) (*) 3 (7, 5)
--   50 -- (7 + 3) * 5
--   
--   > bifoldl (+) (*) 3 (Right 5)
--   15 -- 5 * 3
--   
--   > bifoldl (+) (*) 3 (Left 5)
--   8 -- 5 + 3
--   
bifoldl :: Bifoldable p => (c -> a -> c) -> (c -> b -> c) -> c -> p a b -> c

-- | As bifoldr, but strict in the result of the reduction functions
--   at each step.
bifoldr' :: Bifoldable t => (a -> c -> c) -> (b -> c -> c) -> c -> t a b -> c

-- | A variant of bifoldr that has no base case, and thus may only
--   be applied to non-empty structures.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> bifoldr1 (+) (5, 7)
--   12
--   
--   
--   
--   >>> bifoldr1 (+) (Right 7)
--   7
--   
--   
--   
--   >>> bifoldr1 (+) (Left 5)
--   5
--   
--   
--   
--   > bifoldr1 (+) (BiList [1, 2] [3, 4])
--   10 -- 1 + (2 + (3 + 4))
--   
--   
--   
--   >>> bifoldr1 (+) (BiList [1, 2] [])
--   3
--   
--   
--   On empty structures, this function throws an exception:
--   
--   
--   >>> bifoldr1 (+) (BiList [] [])
--   *** Exception: bifoldr1: empty structure
--   ...
--   
bifoldr1 :: Bifoldable t => (a -> a -> a) -> t a a -> a

-- | Right associative monadic bifold over a structure.
bifoldrM :: (Bifoldable t, Monad m) => (a -> c -> m c) -> (b -> c -> m c) -> c -> t a b -> m c

-- | As bifoldl, but strict in the result of the reduction functions
--   at each step.
--   
--   This ensures that each step of the bifold 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, monolithic result (e.g.,
--   bilength).
bifoldl' :: Bifoldable t => (a -> b -> a) -> (a -> c -> a) -> a -> t b c -> a

-- | A variant of bifoldl that has no base case, and thus may only
--   be applied to non-empty structures.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> bifoldl1 (+) (5, 7)
--   12
--   
--   
--   
--   >>> bifoldl1 (+) (Right 7)
--   7
--   
--   
--   
--   >>> bifoldl1 (+) (Left 5)
--   5
--   
--   
--   
--   > bifoldl1 (+) (BiList [1, 2] [3, 4])
--   10 -- ((1 + 2) + 3) + 4
--   
--   
--   
--   >>> bifoldl1 (+) (BiList [1, 2] [])
--   3
--   
--   
--   On empty structures, this function throws an exception:
--   
--   
--   >>> bifoldl1 (+) (BiList [] [])
--   *** Exception: bifoldl1: empty structure
--   ...
--   
bifoldl1 :: Bifoldable t => (a -> a -> a) -> t a a -> a

-- | Left associative monadic bifold over a structure.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> bifoldlM (\a b -> print b >> pure a) (\a c -> print (show c) >> pure a) 42 ("Hello", True)
--   "Hello"
--   "True"
--   42
--   
--   
--   
--   >>> bifoldlM (\a b -> print b >> pure a) (\a c -> print (show c) >> pure a) 42 (Right True)
--   "True"
--   42
--   
--   
--   
--   >>> bifoldlM (\a b -> print b >> pure a) (\a c -> print (show c) >> pure a) 42 (Left "Hello")
--   "Hello"
--   42
--   
bifoldlM :: (Bifoldable t, Monad m) => (a -> b -> m a) -> (a -> c -> m a) -> a -> t b c -> m a

-- | Map each element of a structure using one of two actions, evaluate
--   these actions from left to right, and ignore the results. For a
--   version that doesn't ignore the results, see bitraverse.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> bitraverse_ print (print . show) ("Hello", True)
--   "Hello"
--   "True"
--   
--   
--   
--   >>> bitraverse_ print (print . show) (Right True)
--   "True"
--   
--   
--   
--   >>> bitraverse_ print (print . show) (Left "Hello")
--   "Hello"
--   
bitraverse_ :: (Bifoldable t, Applicative f) => (a -> f c) -> (b -> f d) -> t a b -> f ()

-- | As bitraverse_, but with the structure as the primary argument.
--   For a version that doesn't ignore the results, see bifor.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> bifor_ ("Hello", True) print (print . show)
--   "Hello"
--   "True"
--   
--   
--   
--   >>> bifor_ (Right True) print (print . show)
--   "True"
--   
--   
--   
--   >>> bifor_ (Left "Hello") print (print . show)
--   "Hello"
--   
bifor_ :: (Bifoldable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f ()

-- | Evaluate each action in the structure from left to right, and ignore
--   the results. For a version that doesn't ignore the results, see
--   bisequence.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> bisequence_ (print "Hello", print "World")
--   "Hello"
--   "World"
--   
--   
--   
--   >>> bisequence_ (Left (print "Hello"))
--   "Hello"
--   
--   
--   
--   >>> bisequence_ (Right (print "World"))
--   "World"
--   
bisequence_ :: (Bifoldable t, Applicative f) => t (f a) (f b) -> f ()

-- | The sum of a collection of actions, generalizing biconcat.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> biasum (Nothing, Nothing)
--   Nothing
--   
--   
--   
--   >>> biasum (Nothing, Just 42)
--   Just 42
--   
--   
--   
--   >>> biasum (Just 18, Nothing)
--   Just 18
--   
--   
--   
--   >>> biasum (Just 18, Just 42)
--   Just 18
--   
biasum :: (Bifoldable t, Alternative f) => t (f a) (f a) -> f a

-- | Collects the list of elements of a structure, from left to right.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> biList (18, 42)
--   [18,42]
--   
--   
--   
--   >>> biList (Left 18)
--   [18]
--   
biList :: Bifoldable t => t a a -> [a]

-- | Test whether the structure is empty.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> binull (18, 42)
--   False
--   
--   
--   
--   >>> binull (Right 42)
--   False
--   
--   
--   
--   >>> binull (BiList [] [])
--   True
--   
binull :: Bifoldable t => t a b -> Bool

-- | Returns the size/length of a finite structure as an Int.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> bilength (True, 42)
--   2
--   
--   
--   
--   >>> bilength (Right 42)
--   1
--   
--   
--   
--   >>> bilength (BiList [1,2,3] [4,5])
--   5
--   
--   
--   
--   >>> bilength (BiList [] [])
--   0
--   
--   
--   On infinite structures, this function hangs:
--   
--   
--   > bilength (BiList [1..] [])
--   * Hangs forever *
--   
bilength :: Bifoldable t => t a b -> Int

-- | Does the element occur in the structure?
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> bielem 42 (17, 42)
--   True
--   
--   
--   
--   >>> bielem 42 (17, 43)
--   False
--   
--   
--   
--   >>> bielem 42 (Left 42)
--   True
--   
--   
--   
--   >>> bielem 42 (Right 13)
--   False
--   
--   
--   
--   >>> bielem 42 (BiList [1..5] [1..100])
--   True
--   
--   
--   
--   >>> bielem 42 (BiList [1..5] [1..41])
--   False
--   
bielem :: (Bifoldable t, Eq a) => a -> t a a -> Bool

-- | The largest element of a non-empty structure.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> bimaximum (42, 17)
--   42
--   
--   
--   
--   >>> bimaximum (Right 42)
--   42
--   
--   
--   
--   >>> bimaximum (BiList [13, 29, 4] [18, 1, 7])
--   29
--   
--   
--   
--   >>> bimaximum (BiList [13, 29, 4] [])
--   29
--   
--   
--   On empty structures, this function throws an exception:
--   
--   
--   >>> bimaximum (BiList [] [])
--   *** Exception: bimaximum: empty structure
--   ...
--   
bimaximum :: (Bifoldable t, Ord a) => t a a -> a

-- | The least element of a non-empty structure.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> biminimum (42, 17)
--   17
--   
--   
--   
--   >>> biminimum (Right 42)
--   42
--   
--   
--   
--   >>> biminimum (BiList [13, 29, 4] [18, 1, 7])
--   1
--   
--   
--   
--   >>> biminimum (BiList [13, 29, 4] [])
--   4
--   
--   
--   On empty structures, this function throws an exception:
--   
--   
--   >>> biminimum (BiList [] [])
--   *** Exception: biminimum: empty structure
--   ...
--   
biminimum :: (Bifoldable t, Ord a) => t a a -> a

-- | The bisum function computes the sum of the numbers of a
--   structure.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> bisum (42, 17)
--   59
--   
--   
--   
--   >>> bisum (Right 42)
--   42
--   
--   
--   
--   >>> bisum (BiList [13, 29, 4] [18, 1, 7])
--   72
--   
--   
--   
--   >>> bisum (BiList [13, 29, 4] [])
--   46
--   
--   
--   
--   >>> bisum (BiList [] [])
--   0
--   
bisum :: (Bifoldable t, Num a) => t a a -> a

-- | The biproduct function computes the product of the numbers of a
--   structure.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> biproduct (42, 17)
--   714
--   
--   
--   
--   >>> biproduct (Right 42)
--   42
--   
--   
--   
--   >>> biproduct (BiList [13, 29, 4] [18, 1, 7])
--   190008
--   
--   
--   
--   >>> biproduct (BiList [13, 29, 4] [])
--   1508
--   
--   
--   
--   >>> biproduct (BiList [] [])
--   1
--   
biproduct :: (Bifoldable t, Num a) => t a a -> a

-- | Reduces a structure of lists to the concatenation of those lists.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> biconcat ([1, 2, 3], [4, 5])
--   [1,2,3,4,5]
--   
--   
--   
--   >>> biconcat (Left [1, 2, 3])
--   [1,2,3]
--   
--   
--   
--   >>> biconcat (BiList [[1, 2, 3, 4, 5], [6, 7, 8]] [[9]])
--   [1,2,3,4,5,6,7,8,9]
--   
biconcat :: Bifoldable t => t [a] [a] -> [a]

-- | Given a means of mapping the elements of a structure to lists,
--   computes the concatenation of all such lists in order.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> biconcatMap (take 3) (fmap digitToInt) ([1..], "89")
--   [1,2,3,8,9]
--   
--   
--   
--   >>> biconcatMap (take 3) (fmap digitToInt) (Left [1..])
--   [1,2,3]
--   
--   
--   
--   >>> biconcatMap (take 3) (fmap digitToInt) (Right "89")
--   [8,9]
--   
biconcatMap :: Bifoldable t => (a -> [c]) -> (b -> [c]) -> t a b -> [c]

-- | biand 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:
--   
--   
--   >>> biand (True, False)
--   False
--   
--   
--   
--   >>> biand (True, True)
--   True
--   
--   
--   
--   >>> biand (Left True)
--   True
--   
--   
--   Empty structures yield True:
--   
--   
--   >>> biand (BiList [] [])
--   True
--   
--   
--   A False value finitely far from the left end yields
--   False (short circuit):
--   
--   
--   >>> biand (BiList [True, True, False, True] (repeat True))
--   False
--   
--   
--   A False value infinitely far from the left end hangs:
--   
--   
--   > biand (BiList (repeat True) [False])
--   * Hangs forever *
--   
--   
--   An infinitely True value hangs:
--   
--   
--   > biand (BiList (repeat True) [])
--   * Hangs forever *
--   
biand :: Bifoldable t => t Bool Bool -> Bool

-- | bior 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:
--   
--   
--   >>> bior (True, False)
--   True
--   
--   
--   
--   >>> bior (False, False)
--   False
--   
--   
--   
--   >>> bior (Left True)
--   True
--   
--   
--   Empty structures yield False:
--   
--   
--   >>> bior (BiList [] [])
--   False
--   
--   
--   A True value finitely far from the left end yields True
--   (short circuit):
--   
--   
--   >>> bior (BiList [False, False, True, False] (repeat False))
--   True
--   
--   
--   A True value infinitely far from the left end hangs:
--   
--   
--   > bior (BiList (repeat False) [True])
--   * Hangs forever *
--   
--   
--   An infinitely False value hangs:
--   
--   
--   > bior (BiList (repeat False) [])
--   * Hangs forever *
--   
bior :: Bifoldable t => t Bool Bool -> Bool

-- | Determines whether any element of the structure satisfies its
--   appropriate predicate argument. Empty structures yield False.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> biany even isDigit (27, 't')
--   False
--   
--   
--   
--   >>> biany even isDigit (27, '8')
--   True
--   
--   
--   
--   >>> biany even isDigit (26, 't')
--   True
--   
--   
--   
--   >>> biany even isDigit (Left 27)
--   False
--   
--   
--   
--   >>> biany even isDigit (Left 26)
--   True
--   
--   
--   
--   >>> biany even isDigit (BiList [27, 53] ['t', '8'])
--   True
--   
--   
--   Empty structures yield False:
--   
--   
--   >>> biany even isDigit (BiList [] [])
--   False
--   
biany :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool

-- | Determines whether all elements of the structure satisfy their
--   appropriate predicate argument. Empty structures yield True.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> biall even isDigit (27, 't')
--   False
--   
--   
--   
--   >>> biall even isDigit (26, '8')
--   True
--   
--   
--   
--   >>> biall even isDigit (Left 27)
--   False
--   
--   
--   
--   >>> biall even isDigit (Left 26)
--   True
--   
--   
--   
--   >>> biall even isDigit (BiList [26, 52] ['3', '8'])
--   True
--   
--   
--   Empty structures yield True:
--   
--   
--   >>> biall even isDigit (BiList [] [])
--   True
--   
biall :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool

-- | The largest element of a non-empty structure with respect to the given
--   comparison function.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> bimaximumBy compare (42, 17)
--   42
--   
--   
--   
--   >>> bimaximumBy compare (Left 17)
--   17
--   
--   
--   
--   >>> bimaximumBy compare (BiList [42, 17, 23] [-5, 18])
--   42
--   
--   
--   On empty structures, this function throws an exception:
--   
--   
--   >>> bimaximumBy compare (BiList [] [])
--   *** Exception: bifoldr1: empty structure
--   ...
--   
bimaximumBy :: Bifoldable t => (a -> a -> Ordering) -> t a a -> a

-- | The least element of a non-empty structure with respect to the given
--   comparison function.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> biminimumBy compare (42, 17)
--   17
--   
--   
--   
--   >>> biminimumBy compare (Left 17)
--   17
--   
--   
--   
--   >>> biminimumBy compare (BiList [42, 17, 23] [-5, 18])
--   -5
--   
--   
--   On empty structures, this function throws an exception:
--   
--   
--   >>> biminimumBy compare (BiList [] [])
--   *** Exception: bifoldr1: empty structure
--   ...
--   
biminimumBy :: Bifoldable t => (a -> a -> Ordering) -> t a a -> a

-- | binotElem is the negation of bielem.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> binotElem 42 (17, 42)
--   False
--   
--   
--   
--   >>> binotElem 42 (17, 43)
--   True
--   
--   
--   
--   >>> binotElem 42 (Left 42)
--   False
--   
--   
--   
--   >>> binotElem 42 (Right 13)
--   True
--   
--   
--   
--   >>> binotElem 42 (BiList [1..5] [1..100])
--   False
--   
--   
--   
--   >>> binotElem 42 (BiList [1..5] [1..41])
--   True
--   
binotElem :: (Bifoldable t, Eq a) => a -> t a a -> Bool

-- | The bifind 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:
--   
--   
--   >>> bifind even (27, 53)
--   Nothing
--   
--   
--   
--   >>> bifind even (27, 52)
--   Just 52
--   
--   
--   
--   >>> bifind even (26, 52)
--   Just 26
--   
--   
--   Empty structures always yield Nothing:
--   
--   
--   >>> bifind even (BiList [] [])
--   Nothing
--   
bifind :: Bifoldable t => (a -> Bool) -> t a a -> Maybe a

-- | Evaluates the relevant functions at each element in the structure,
--   running the action, and builds a new structure with the same shape,
--   using the results produced from sequencing the actions.
--   
--   
--   bitraverse f g ≡ bisequenceA . bimap f g
--   
--   
--   For a version that ignores the results, see bitraverse_.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> bitraverse listToMaybe (find odd) (Left [])
--   Nothing
--   
--   
--   
--   >>> bitraverse listToMaybe (find odd) (Left [1, 2, 3])
--   Just (Left 1)
--   
--   
--   
--   >>> bitraverse listToMaybe (find odd) (Right [4, 5])
--   Just (Right 5)
--   
--   
--   
--   >>> bitraverse listToMaybe (find odd) ([1, 2, 3], [4, 5])
--   Just (1,5)
--   
--   
--   
--   >>> bitraverse listToMaybe (find odd) ([], [4, 5])
--   Nothing
--   
bitraverse :: (Bitraversable t, Applicative f) => (a -> f c) -> (b -> f d) -> t a b -> f (t c d)

-- | Sequences all the actions in a structure, building a new structure
--   with the same shape using the results of the actions. For a version
--   that ignores the results, see bisequence_.
--   
--   
--   bisequence ≡ bitraverse id id
--   
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> bisequence (Just 4, Nothing)
--   Nothing
--   
--   
--   
--   >>> bisequence (Just 4, Just 5)
--   Just (4,5)
--   
--   
--   
--   >>> bisequence ([1, 2, 3], [4, 5])
--   [(1,4),(1,5),(2,4),(2,5),(3,4),(3,5)]
--   
bisequence :: (Bitraversable t, Applicative f) => t (f a) (f b) -> f (t a b)

-- | bifor is bitraverse with the structure as the first
--   argument. For a version that ignores the results, see bifor_.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> bifor (Left []) listToMaybe (find even)
--   Nothing
--   
--   
--   
--   >>> bifor (Left [1, 2, 3]) listToMaybe (find even)
--   Just (Left 1)
--   
--   
--   
--   >>> bifor (Right [4, 5]) listToMaybe (find even)
--   Just (Right 4)
--   
--   
--   
--   >>> bifor ([1, 2, 3], [4, 5]) listToMaybe (find even)
--   Just (1,4)
--   
--   
--   
--   >>> bifor ([], [4, 5]) listToMaybe (find even)
--   Nothing
--   
bifor :: (Bitraversable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f (t c d)

-- | The bimapAccumL function behaves like a combination of
--   bimap and bifoldl; it traverses a structure from left to
--   right, threading a state of type a and using the given
--   actions to compute new elements for the structure.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> bimapAccumL (\acc bool -> (acc + 1, show bool)) (\acc string -> (acc * 2, reverse string)) 3 (True, "foo")
--   (8,("True","oof"))
--   
bimapAccumL :: Bitraversable t => (a -> b -> (a, c)) -> (a -> d -> (a, e)) -> a -> t b d -> (a, t c e)

-- | The bimapAccumR function behaves like a combination of
--   bimap and bifoldr; it traverses a structure from right
--   to left, threading a state of type a and using the given
--   actions to compute new elements for the structure.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> bimapAccumR (\acc bool -> (acc + 1, show bool)) (\acc string -> (acc * 2, reverse string)) 3 (True, "foo")
--   (7,("True","oof"))
--   
bimapAccumR :: Bitraversable t => (a -> b -> (a, c)) -> (a -> d -> (a, e)) -> a -> t b d -> (a, t c e)

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

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

-- | The sum of a collection of actions, generalizing concat.
--   
--   msum is just like asum, but specialised to
--   MonadPlus.
msum :: (Foldable t, MonadPlus m) => t (m a) -> m a

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

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

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

-- | Left-to-right composition
(>>>) :: forall {k} cat (a :: k) (b :: k) (c :: k). Category cat => cat a b -> cat b c -> cat a c
infixr 1 >>>

-- | Identity function.
--   
--   
--   id x = x
--   
id :: a -> a

-- | const x y always evaluates to x, ignoring its second
--   argument.
--   
--   
--   >>> const 42 "hello"
--   42
--   
--   
--   
--   >>> map (const 42) [0..3]
--   [42,42,42,42]
--   
const :: a -> b -> a

-- | Function composition.
(.) :: (b -> c) -> (a -> b) -> a -> c
infixr 9 .

-- | Application operator. This operator is redundant, since ordinary
--   application (f x) means the same as (f $ x).
--   However, $ has low, right-associative binding precedence, so it
--   sometimes allows parentheses to be omitted; for example:
--   
--   
--   f $ g $ h x  =  f (g (h x))
--   
--   
--   It is also useful in higher-order situations, such as map
--   ($ 0) xs, or zipWith ($) fs xs.
--   
--   Note that ($) is representation-polymorphic in its
--   result type, so that foo $ True where foo :: Bool
--   -> Int# is well-typed.
($) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b
infixr 0 $

-- | & is a reverse application operator. This provides
--   notational convenience. Its precedence is one higher than that of the
--   forward application operator $, which allows & to be
--   nested in $.
--   
--   
--   >>> 5 & (+1) & show
--   "6"
--   
(&) :: a -> (a -> b) -> b
infixl 1 &

-- | flip f takes its (first) two arguments in the reverse
--   order of f.
--   
--   
--   >>> flip (++) "hello" "world"
--   "worldhello"
--   
flip :: (a -> b -> c) -> b -> a -> c

-- | fix f is the least fixed point of the function
--   f, i.e. the least defined x such that f x =
--   x.
--   
--   For example, we can write the factorial function using direct
--   recursion as
--   
--   
--   >>> let fac n = if n <= 1 then 1 else n * fac (n-1) in fac 5
--   120
--   
--   
--   This uses the fact that Haskell’s let introduces recursive
--   bindings. We can rewrite this definition using fix,
--   
--   
--   >>> fix (\rec n -> if n <= 1 then 1 else n * rec (n-1)) 5
--   120
--   
--   
--   Instead of making a recursive call, we introduce a dummy parameter
--   rec; when used within fix, this parameter then refers
--   to fix’s argument, hence the recursion is reintroduced.
fix :: (a -> a) -> a

-- | on b u x y runs the binary function b
--   on the results of applying unary function u to two
--   arguments x and y. From the opposite perspective, it
--   transforms two inputs and combines the outputs.
--   
--   
--   ((+) `<a>on</a>` f) x y = f x + f y
--   
--   
--   Typical usage: sortBy (compare `on`
--   fst).
--   
--   Algebraic properties:
--   
--   
--   
- 
(*) `on` id = (*) -- (if (*) ∉ {⊥, const
--   ⊥})

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

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

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

-- | 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.
($!) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b
infixr 0 $!

-- | 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 :: forall {r :: RuntimeRep} a (b :: TYPE r). a -> b -> b
infixr 0 `seq`

-- | error stops execution and displays an error message.
error :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => [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 :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => 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

-- | Helper function to force an action to run in IO. Especially
--   useful for overly general contexts, like hspec tests.
asIO :: IO a -> IO a

-- | Append 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.
--   
--   WARNING: This function takes linear time in the number of elements of
--   the first list.
(++) :: [a] -> [a] -> [a]
infixr 5 ++

-- | 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 (> 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 p is equivalent to span (not .
--   p).
break :: (a -> Bool) -> [a] -> ([a], [a])

-- | drop n xs returns the suffix of xs after the
--   first n elements, or [] if n >= length
--   xs.
--   
--   
--   >>> 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]
--   
--   
--   It is an instance of the more general genericDrop, in which
--   n may be of any integral type.
drop :: Int -> [a] -> [a]

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

-- | <math>. filter, applied to a predicate and a list,
--   returns the list of those elements that satisfy the predicate; i.e.,
--   
--   
--   filter p xs = [ x | x <- xs, p x]
--   
--   
--   
--   >>> filter odd [1, 2, 3]
--   [1,3]
--   
filter :: (a -> Bool) -> [a] -> [a]

-- | <math>. lookup key assocs looks up a key in an
--   association list.
--   
--   
--   >>> 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

-- | <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, ...]
--   
--   
--   
--   >>> map (+1) [1, 2, 3]
--   [2,3,4]
--   
map :: (a -> b) -> [a] -> [b]

-- | 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.
--   
--   
--   >>> replicate 0 True
--   []
--   
--   >>> replicate (-1) True
--   []
--   
--   >>> replicate 4 True
--   [True,True,True,True]
--   
replicate :: Int -> a -> [a]

-- | reverse xs returns the elements of xs in
--   reverse order. xs must be finite.
--   
--   
--   >>> reverse []
--   []
--   
--   >>> reverse [42]
--   [42]
--   
--   >>> reverse [2,5,7]
--   [7,5,2]
--   
--   >>> reverse [1..]
--   * Hangs forever *
--   
reverse :: [a] -> [a]

-- | span, 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 satisfy p and second element
--   is the remainder of the list:
--   
--   
--   >>> 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 p xs is equivalent to (takeWhile p xs,
--   dropWhile p xs)
span :: (a -> Bool) -> [a] -> ([a], [a])

-- | take n, applied to a list xs, returns the
--   prefix of xs of length n, or xs itself if
--   n >= length xs.
--   
--   
--   >>> 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]
--   []
--   
--   
--   It is an instance of the more general genericTake, in which
--   n may be of any integral type.
take :: Int -> [a] -> [a]

-- | takeWhile, applied to a predicate p and a list
--   xs, returns the longest prefix (possibly empty) of
--   xs of elements that satisfy p.
--   
--   
--   >>> 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]

-- | <math>. zip takes two lists and returns a list of
--   corresponding pairs.
--   
--   
--   >>> zip [1, 2] ['a', 'b']
--   [(1,'a'),(2,'b')]
--   
--   
--   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 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.
zip :: [a] -> [b] -> [(a, b)]

-- | <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..]
--   
--   
--   For example, zipWith (+) is applied to two lists to
--   produce the list of corresponding sums:
--   
--   
--   >>> zipWith (+) [1, 2, 3] [4, 5, 6]
--   [5,7,9]
--   
--   
--   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.
zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]

-- | Strip out duplicates
nubOrd :: Ord a => [a] -> [a]
fromString :: IsString a => String -> 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.
--   
--   For example:
--   
--   
--   >>> 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"]
--   
--   
--   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)
--   
lines :: String -> [String]

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

-- | unwords is an inverse operation to words. It joins words
--   with separating spaces.
--   
--   
--   >>> unwords ["Lorem", "ipsum", "dolor"]
--   "Lorem ipsum dolor"
--   
unwords :: [String] -> String

-- | words breaks a string up into a list of words, which were
--   delimited by white space.
--   
--   
--   >>> words "Lorem ipsum\ndolor"
--   ["Lorem","ipsum","dolor"]
--   
words :: String -> [String]

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

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

-- | the deep analogue of $!. In the expression f $!! x,
--   x is fully evaluated before the function f is
--   applied to it.
($!!) :: NFData a => (a -> b) -> a -> b
infixr 0 $!!

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

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

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

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

-- | Lift a computation from the argument monad to the constructed monad.
lift :: (MonadTrans t, Monad m) => m a -> t m a

-- | Retrieves the monad environment.
ask :: MonadReader r m => m r

-- | Retrieves a function of the current environment.
asks :: MonadReader r m => (r -> a) -> m a

-- | Executes a computation in a modified environment.
local :: MonadReader r m => (r -> r) -> m a -> m a

-- | Runs a Reader and extracts the final value from it. (The
--   inverse of reader.)
runReader :: Reader r a -> r -> a
runReaderT :: ReaderT r m a -> r -> m a
toStrictBytes :: LByteString -> ByteString
fromStrictBytes :: ByteString -> LByteString

-- | O(n). Convert a ByteString into a
--   ShortByteString.
--   
--   This makes a copy, so does not retain the input string.
toShort :: ByteString -> ShortByteString

-- | O(n). Convert a ShortByteString into a
--   ByteString.
fromShort :: ShortByteString -> ByteString
tshow :: Show a => a -> Text
decodeUtf8Lenient :: ByteString -> Text

-- | Decode a ByteString containing UTF-8 encoded text.
--   
--   If the input contains any invalid UTF-8 data, the relevant exception
--   will be returned, otherwise the decoded text.
decodeUtf8' :: ByteString -> Either UnicodeException Text

-- | Decode a ByteString containing UTF-8 encoded text.
--   
--   Surrogate code points in replacement character returned by
--   OnDecodeError will be automatically remapped to the replacement
--   char U+FFFD.
decodeUtf8With :: OnDecodeError -> ByteString -> Text

-- | Encode text using UTF-8 encoding.
encodeUtf8 :: Text -> ByteString

-- | Encode text to a ByteString Builder using UTF-8 encoding.
encodeUtf8Builder :: Text -> Builder

-- | Replace an invalid input byte with the Unicode replacement character
--   U+FFFD.
lenientDecode :: OnDecodeError

-- | Execute a primitive operation.
primitive :: PrimMonad m => (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a

-- | Return the value computed by a state thread. The forall
--   ensures that the internal state used by the ST computation is
--   inaccessible to the rest of the program.
runST :: (forall s. () => ST s a) -> a

module RIO.Deque

-- | A double-ended queue supporting any underlying vector type and any
--   monad.
--   
--   This implements a circular double-ended queue with exponential growth.
data Deque v s a

-- | A Deque specialized to unboxed vectors.
type UDeque = Deque MVector

-- | A Deque specialized to storable vectors.
type SDeque = Deque MVector

-- | A Deque specialized to boxed vectors.
type BDeque = Deque MVector

-- | Create a new, empty Deque
newDeque :: (MVector v a, PrimMonad m) => m (Deque v (PrimState m) a)

-- | O(1) - Get the number of elements that is currently in the
--   Deque
getDequeSize :: PrimMonad m => Deque v (PrimState m) a -> m Int

-- | Pop the first value from the beginning of the Deque
popFrontDeque :: (MVector v a, PrimMonad m) => Deque v (PrimState m) a -> m (Maybe a)

-- | Pop the first value from the end of the Deque
popBackDeque :: (MVector v a, PrimMonad m) => Deque v (PrimState m) a -> m (Maybe a)

-- | Push a new value to the beginning of the Deque
pushFrontDeque :: (MVector v a, PrimMonad m) => Deque v (PrimState m) a -> a -> m ()

-- | Push a new value to the end of the Deque
pushBackDeque :: (MVector v a, PrimMonad m) => Deque v (PrimState m) a -> a -> m ()

-- | Fold over a Deque, starting at the beginning. Does not modify
--   the Deque.
foldlDeque :: (MVector v a, PrimMonad m) => (acc -> a -> m acc) -> acc -> Deque v (PrimState m) a -> m acc

-- | Fold over a Deque, starting at the end. Does not modify the
--   Deque.
foldrDeque :: (MVector v a, PrimMonad m) => (a -> acc -> m acc) -> acc -> Deque v (PrimState m) a -> m acc

-- | Convert a Deque into a list. Does not modify the Deque.
dequeToList :: (MVector v a, PrimMonad m) => Deque v (PrimState m) a -> m [a]

-- | Convert to an immutable vector of any type. If resulting pure vector
--   corresponds to the mutable one used by the Deque, it will be
--   more efficient to use freezeDeque instead.
--   
--   
Example
--   
--   
--   >>> :set -XTypeApplications
--   
--   >>> import qualified RIO.Vector.Unboxed as U
--   
--   >>> import qualified RIO.Vector.Storable as S
--   
--   >>> d <- newDeque @U.MVector @Int
--   
--   >>> mapM_ (pushFrontDeque d) [0..10]
--   
--   >>> dequeToVector @S.Vector d
--   [10,9,8,7,6,5,4,3,2,1,0]
--   
dequeToVector :: (Vector v' a, MVector v a, PrimMonad m) => Deque v (PrimState m) a -> m (v' a)

-- | Yield an immutable copy of the underlying mutable vector. The
--   difference from dequeToVector is that the the copy will be
--   performed with a more efficient memcpy, rather than element
--   by element. The downside is that the resulting vector type must be the
--   one that corresponds to the mutable one that is used in the
--   Deque.
--   
--   
Example
--   
--   
--   >>> :set -XTypeApplications
--   
--   >>> import qualified RIO.Vector.Unboxed as U
--   
--   >>> d <- newDeque @U.MVector @Int
--   
--   >>> mapM_ (pushFrontDeque d) [0..10]
--   
--   >>> freezeDeque @U.Vector d
--   [10,9,8,7,6,5,4,3,2,1,0]
--   
freezeDeque :: (Vector v a, PrimMonad m) => Deque (Mutable v) (PrimState m) a -> m (v a)

-- | Helper function to assist with type inference, forcing usage of an
--   unboxed vector.
asUDeque :: UDeque s a -> UDeque s a

-- | Helper function to assist with type inference, forcing usage of a
--   storable vector.
asSDeque :: SDeque s a -> SDeque s a

-- | Helper function to assist with type inference, forcing usage of a
--   boxed vector.
asBDeque :: BDeque s a -> BDeque s a

-- | Interacting with external processes.
--   
--   This module provides a layer on top of System.Process.Typed,
--   with the following additions:
--   
--   
--   
- For efficiency, it will cache PATH lookups.
--   
- For convenience, you can set the working directory and env vars
--   overrides in a RIO environment instead of on the individual
--   calls to the process.
--   
- Built-in support for logging at the debug level.
--   
--   
--   In order to switch over to this API, the main idea is:
--   
--   
--   
- Like most of the rio library, you need to create an environment
--   value (this time ProcessContext), and include it in your
--   RIO environment. See mkProcessContext.
--   
- Instead of using the proc function from
--   System.Process.Typed for creating a ProcessConfig, use
--   the locally defined proc function, which will handle overriding
--   environment variables, looking up paths, performing logging, etc.
--   
--   
--   Once you have your ProcessConfig, use the standard functions
--   from Typed (reexported here for convenient) for running the
--   ProcessConfig.
module RIO.Process

-- | Context in which to run processes.
data ProcessContext

-- | Get the ProcessContext from the environment.
class HasProcessContext env
processContextL :: HasProcessContext env => Lens' env ProcessContext

-- | The environment variable map
type EnvVars = Map Text Text

-- | Create a new ProcessContext from the given environment variable
--   map.
mkProcessContext :: MonadIO m => EnvVars -> m ProcessContext

-- | Same as mkProcessContext but uses the system environment (from
--   getEnvironment).
mkDefaultProcessContext :: MonadIO m => m ProcessContext

-- | Modify the environment variables of a ProcessContext. This will
--   not change the working directory.
--   
--   Note that this requires MonadIO, as it will create a new
--   IORef for the cache.
modifyEnvVars :: MonadIO m => ProcessContext -> (EnvVars -> EnvVars) -> m ProcessContext

-- | Use modifyEnvVars to create a new ProcessContext, and
--   then use it in the provided action.
withModifyEnvVars :: (HasProcessContext env, MonadReader env m, MonadIO m) => (EnvVars -> EnvVars) -> m a -> m a

-- | Look into the ProcessContext and return the specified
--   environmet variable if one is available.
lookupEnvFromContext :: (MonadReader env m, HasProcessContext env) => Text -> m (Maybe Text)

-- | Set the working directory to be used by child processes.
withWorkingDir :: (HasProcessContext env, MonadReader env m, MonadIO m) => FilePath -> m a -> m a

-- | Override the working directory processes run in. Nothing
--   means the current process's working directory.
workingDirL :: HasProcessContext env => Lens' env (Maybe FilePath)

-- | Get the environment variables. We cannot provide a Lens here,
--   since updating the environment variables requires an IO
--   action to allocate a new IORef for holding the executable
--   path cache.
envVarsL :: HasProcessContext env => SimpleGetter env EnvVars

-- | Get the EnvVars as an associated list of Strings.
--   
--   Useful for interacting with other libraries.
envVarsStringsL :: HasProcessContext env => SimpleGetter env [(String, String)]

-- | Get the list of directories searched for executables (the
--   PATH).
--   
--   Similar to envVarMapL, this cannot be a full Lens.
exeSearchPathL :: HasProcessContext env => SimpleGetter env [FilePath]

-- | Reset the executable cache.
resetExeCache :: (MonadIO m, MonadReader env m, HasProcessContext env) => m ()

-- | Provide a ProcessConfig based on the ProcessContext in
--   scope. Deals with resolving the full path, setting the child process's
--   environment variables, setting the working directory, and wrapping the
--   call with withProcessTimeLog for debugging output.
--   
--   This is intended to be analogous to the proc function
--   provided by the System.Process.Typed module, but has a
--   different type signature to (1) allow it to perform IO
--   actions for looking up paths, and (2) allow logging and timing of the
--   running action.
proc :: (HasProcessContext env, HasLogFunc env, MonadReader env m, MonadIO m, HasCallStack) => FilePath -> [String] -> (ProcessConfig () () () -> m a) -> m a

-- | Same as withProcess, but generalized to MonadUnliftIO.

-- | Deprecated: Please consider using withProcessWait, or instead use
--   withProcessTerm
withProcess :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a

-- | Same as withProcess_, but generalized to MonadUnliftIO.

-- | Deprecated: Please consider using withProcessWait, or instead use
--   withProcessTerm
withProcess_ :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a

-- | Same as withProcessWait, but generalized to
--   MonadUnliftIO.
withProcessWait :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a

-- | Same as withProcessWait_, but generalized to
--   MonadUnliftIO.
withProcessWait_ :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a

-- | Same as withProcessTerm, but generalized to
--   MonadUnliftIO.
withProcessTerm :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a

-- | Same as withProcessTerm_, but generalized to
--   MonadUnliftIO.
withProcessTerm_ :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a

-- | Execute a process within the configured environment.
--   
--   Execution will not return, because either:
--   
--   1) On non-windows, execution is taken over by execv of the
--   sub-process. This allows signals to be propagated (#527)
--   
--   2) On windows, an ExitCode exception will be thrown.
exec :: (HasProcessContext env, HasLogFunc env) => String -> [String] -> RIO env b

-- | Like exec, but does not use execv on non-windows. This
--   way, there is a sub-process, which is helpful in some cases
--   (https://github.com/commercialhaskell/stack/issues/1306).
--   
--   This function only exits by throwing ExitCode.
execSpawn :: (HasProcessContext env, HasLogFunc env) => String -> [String] -> RIO env a

-- | A convenience environment combining a LogFunc and a
--   ProcessContext
data LoggedProcessContext
LoggedProcessContext :: ProcessContext -> LogFunc -> LoggedProcessContext

-- | Run an action using a LoggedProcessContext with default
--   settings and no logging.
withProcessContextNoLogging :: MonadIO m => RIO LoggedProcessContext a -> m a

-- | Exception type which may be generated in this module.
--   
--   NOTE Other exceptions may be thrown by underlying libraries!
data ProcessException
NoPathFound :: ProcessException
ExecutableNotFound :: String -> [FilePath] -> ProcessException
ExecutableNotFoundAt :: FilePath -> ProcessException
PathsInvalidInPath :: [FilePath] -> ProcessException

-- | Check if the given executable exists on the given PATH.
doesExecutableExist :: (MonadIO m, MonadReader env m, HasProcessContext env) => String -> m Bool

-- | Find the complete path for the given executable name.
--   
--   On POSIX systems, filenames that match but are not exectuables are
--   excluded.
--   
--   On Windows systems, the executable names tried, in turn, are the
--   supplied name (only if it has an extension) and that name extended by
--   each of the exeExtensions. Also, this function may behave
--   differently from findExecutable. The latter excludes as
--   executables filenames without a .bat, .cmd,
--   .com or .exe extension (case-insensitive).
findExecutable :: (MonadIO m, MonadReader env m, HasProcessContext env) => String -> m (Either ProcessException FilePath)

-- | Get the filename extensions for executable files, including the dot
--   (if any).
--   
--   On POSIX systems, this is [""].
--   
--   On Windows systems, the list is determined by the value of the
--   PATHEXT environment variable, if it present in the
--   environment. If the variable is absent, this is its default value on a
--   Windows system. This function may, therefore, behave differently from
--   exeExtension, which returns only ".exe".
exeExtensions :: (MonadIO m, MonadReader env m, HasProcessContext env) => m [String]

-- | Augment the given value (assumed to be that of an environment variable
--   that lists paths, such as PATH; this is not checked) with the given
--   extra paths. Those paths are prepended (as in: they take precedence).
augmentPath :: [FilePath] -> Maybe Text -> Either ProcessException Text

-- | Apply augmentPath on the value of the PATH environment variable
--   in the given EnvVars.
augmentPathMap :: [FilePath] -> EnvVars -> Either ProcessException EnvVars

-- | Apply augmentPath on the value of the given environment
--   variable in the given EnvVars.
augmentPathMap' :: Text -> [FilePath] -> EnvVars -> Either ProcessException EnvVars

-- | Show a process arg including speechmarks when necessary. Just for
--   debugging purposes, not functionally important.
showProcessArgDebug :: String -> Text

-- | An abstract configuration for a process, which can then be launched
--   into an actual running Process. Takes three type parameters,
--   providing the types of standard input, standard output, and standard
--   error, respectively.
--   
--   There are three ways to construct a value of this type:
--   
--   
--   
- With the proc smart constructor, which takes a command name
--   and a list of arguments.
--   
- With the shell smart constructor, which takes a shell
--   string
--   
- With the IsString instance via OverloadedStrings. If you
--   provide it a string with no spaces (e.g., "date"), it will
--   treat it as a raw command with no arguments (e.g., proc "date"
--   []). If it has spaces, it will use shell.
--   
--   
--   In all cases, the default for all three streams is to inherit the
--   streams from the parent process. For other settings, see the
--   setters below for default values.
--   
--   Once you have a ProcessConfig you can launch a process from
--   it using the functions in the section Launch a process.
data () => ProcessConfig stdin stdout stderr

-- | A specification for how to create one of the three standard child
--   streams, stdin, stdout and stderr. A
--   StreamSpec can be thought of as containing
--   
--   
--   
- A type safe version of StdStream from
--   System.Process. This determines whether the stream should be
--   inherited from the parent process, piped to or from a Handle,
--   etc.
--   
- A means of accessing the stream as a value of type a
--   
- A cleanup action which will be run on the stream once the process
--   terminates
--   
--   
--   To create a StreamSpec see the section Stream specs.
data () => StreamSpec (streamType :: StreamType) a

-- | Whether a stream is an input stream or output stream. Note that this
--   is from the perspective of the child process, so that a child's
--   standard input stream is an STInput, even though the parent
--   process will be writing to it.
data () => StreamType
STInput :: StreamType
STOutput :: StreamType

-- | A running process. The three type parameters provide the type of the
--   standard input, standard output, and standard error streams.
--   
--   To interact with a Process use the functions from the section
--   Interact with a process.
data () => Process stdin stdout stderr

-- | Set the child's standard input stream to the given StreamSpec.
--   
--   Default: inherit
setStdin :: StreamSpec 'STInput stdin -> ProcessConfig stdin0 stdout stderr -> ProcessConfig stdin stdout stderr

-- | Set the child's standard output stream to the given StreamSpec.
--   
--   Default: inherit
setStdout :: StreamSpec 'STOutput stdout -> ProcessConfig stdin stdout0 stderr -> ProcessConfig stdin stdout stderr

-- | Set the child's standard error stream to the given StreamSpec.
--   
--   Default: inherit
setStderr :: StreamSpec 'STOutput stderr -> ProcessConfig stdin stdout stderr0 -> ProcessConfig stdin stdout stderr

-- | Should we close all file descriptors besides stdin, stdout, and
--   stderr? See close_fds for more information.
--   
--   Default: False
setCloseFds :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Should we create a new process group?
--   
--   Default: False
setCreateGroup :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Delegate handling of Ctrl-C to the child. For more information, see
--   delegate_ctlc.
--   
--   Default: False
setDelegateCtlc :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Detach console on Windows, see detach_console.
--   
--   Default: False
setDetachConsole :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Create new console on Windows, see create_new_console.
--   
--   Default: False
setCreateNewConsole :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Set a new session with the POSIX setsid syscall, does nothing
--   on non-POSIX. See new_session.
--   
--   Default: False
setNewSession :: Bool -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Set the child process's group ID with the POSIX setgid
--   syscall, does nothing on non-POSIX. See child_group.
--   
--   Default: False
setChildGroup :: GroupID -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Set the child process's user ID with the POSIX setuid
--   syscall, does nothing on non-POSIX. See child_user.
--   
--   Default: False
setChildUser :: UserID -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr

-- | Create a new StreamSpec from the given StdStream and a
--   helper function. This function:
--   
--   
--   
- Takes as input the raw Maybe Handle returned by the
--   createProcess function. The handle will be Just
--   Handle if the StdStream argument is CreatePipe
--   and Nothing otherwise. See createProcess for more
--   details.
--   
- Returns the actual stream value a, as well as a cleanup
--   function to be run when calling stopProcess.
--   
--   
--   If making a StreamSpec with CreatePipe, prefer
--   mkPipeStreamSpec, which encodes the invariant that a
--   Handle is created.
mkStreamSpec :: forall a (streamType :: StreamType). StdStream -> (ProcessConfig () () () -> Maybe Handle -> IO (a, IO ())) -> StreamSpec streamType a

-- | A stream spec which simply inherits the stream of the parent process.
inherit :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType ()

-- | A stream spec which will close the stream for the child process. You
--   usually do not want to use this, as it will leave the corresponding
--   file descriptor unassigned and hence available for re-use in the child
--   process. Prefer nullStream unless you're certain you want this
--   behavior.
closed :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType ()

-- | An input stream spec which sets the input to the given
--   ByteString. A separate thread will be forked to write the
--   contents to the child process.
byteStringInput :: ByteString -> StreamSpec 'STInput ()

-- | Capture the output of a process in a ByteString.
--   
--   This function will fork a separate thread to consume all input from
--   the process, and will only make the results available when the
--   underlying Handle is closed. As this is provided as an
--   STM action, you can either check if the result is available, or
--   block until it's ready.
--   
--   In the event of any exception occurring when reading from the
--   Handle, the STM action will throw a
--   ByteStringOutputException.
byteStringOutput :: StreamSpec 'STOutput (STM ByteString)

-- | Create a new pipe between this process and the child, and return a
--   Handle to communicate with the child.
createPipe :: forall (anyStreamType :: StreamType). StreamSpec anyStreamType Handle

-- | Use the provided Handle for the child process, and when the
--   process exits, do not close it. This is useful if, for example,
--   you want to have multiple processes write to the same log file
--   sequentially.
useHandleOpen :: forall (anyStreamType :: StreamType). Handle -> StreamSpec anyStreamType ()

-- | Use the provided Handle for the child process, and when the
--   process exits, close it. If you have no reason to keep the
--   Handle open, you should use this over useHandleOpen.
useHandleClose :: forall (anyStreamType :: StreamType). Handle -> StreamSpec anyStreamType ()

-- | Launch a process based on the given ProcessConfig. You should
--   ensure that you call stopProcess on the result. It's usually
--   better to use one of the functions in this module which ensures
--   stopProcess is called, such as withProcessWait.
startProcess :: MonadIO m => ProcessConfig stdin stdout stderr -> m (Process stdin stdout stderr)

-- | Close a process and release any resources acquired. This will ensure
--   terminateProcess is called, wait for the process to actually
--   exit, and then close out resources allocated for the streams. In the
--   event of any cleanup exceptions being thrown this will throw an
--   exception.
stopProcess :: MonadIO m => Process stdin stdout stderr -> m ()

-- | Run a process, capture its standard output and error as a
--   ByteString, wait for it to complete, and then return its exit
--   code, output, and error.
--   
--   Note that any previously used setStdout or setStderr
--   will be overridden.
readProcess :: MonadIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> m (ExitCode, ByteString, ByteString)

-- | Same as readProcess, but instead of returning the
--   ExitCode, checks it with checkExitCode.
--   
--   Exceptions thrown by this function will include stdout and stderr.
readProcess_ :: MonadIO m => ProcessConfig stdin stdoutIgnored stderrIgnored -> m (ByteString, ByteString)

-- | Run the given process, wait for it to exit, and returns its
--   ExitCode.
runProcess :: MonadIO m => ProcessConfig stdin stdout stderr -> m ExitCode

-- | Same as runProcess, but instead of returning the
--   ExitCode, checks it with checkExitCode.
runProcess_ :: MonadIO m => ProcessConfig stdin stdout stderr -> m ()

-- | Same as readProcess, but only read the stdout of the process.
--   Original settings for stderr remain.
readProcessStdout :: MonadIO m => ProcessConfig stdin stdoutIgnored stderr -> m (ExitCode, ByteString)

-- | Same as readProcessStdout, but instead of returning the
--   ExitCode, checks it with checkExitCode.
--   
--   Exceptions thrown by this function will include stdout.
readProcessStdout_ :: MonadIO m => ProcessConfig stdin stdoutIgnored stderr -> m ByteString

-- | Same as readProcess, but only read the stderr of the process.
--   Original settings for stdout remain.
readProcessStderr :: MonadIO m => ProcessConfig stdin stdout stderrIgnored -> m (ExitCode, ByteString)

-- | Same as readProcessStderr, but instead of returning the
--   ExitCode, checks it with checkExitCode.
--   
--   Exceptions thrown by this function will include stderr.
readProcessStderr_ :: MonadIO m => ProcessConfig stdin stdout stderrIgnored -> m ByteString

-- | Wait for the process to exit and then return its ExitCode.
waitExitCode :: MonadIO m => Process stdin stdout stderr -> m ExitCode

-- | Same as waitExitCode, but in STM.
waitExitCodeSTM :: Process stdin stdout stderr -> STM ExitCode

-- | Check if a process has exited and, if so, return its ExitCode.
getExitCode :: MonadIO m => Process stdin stdout stderr -> m (Maybe ExitCode)

-- | Same as getExitCode, but in STM.
getExitCodeSTM :: Process stdin stdout stderr -> STM (Maybe ExitCode)

-- | Wait for a process to exit, and ensure that it exited successfully. If
--   not, throws an ExitCodeException.
--   
--   Exceptions thrown by this function will not include stdout or stderr
--   (This prevents unbounded memory usage from reading them into memory).
--   However, some callers such as readProcess_ catch the exception,
--   add the stdout and stderr, and rethrow.
checkExitCode :: MonadIO m => Process stdin stdout stderr -> m ()

-- | Same as checkExitCode, but in STM.
checkExitCodeSTM :: Process stdin stdout stderr -> STM ()

-- | Get the child's standard input stream value.
getStdin :: Process stdin stdout stderr -> stdin

-- | Get the child's standard output stream value.
getStdout :: Process stdin stdout stderr -> stdout

-- | Get the child's standard error stream value.
getStderr :: Process stdin stdout stderr -> stderr

-- | Exception thrown by checkExitCode in the event of a
--   non-success exit code. Note that checkExitCode is called by
--   other functions as well, like runProcess_ or
--   readProcess_.
--   
--   Note that several functions that throw an ExitCodeException
--   intentionally do not populate eceStdout or eceStderr.
--   This prevents unbounded memory usage for large stdout and stderrs.
data () => ExitCodeException
ExitCodeException :: ExitCode -> ProcessConfig () () () -> ByteString -> ByteString -> ExitCodeException
[eceExitCode] :: ExitCodeException -> ExitCode
[eceProcessConfig] :: ExitCodeException -> ProcessConfig () () ()
[eceStdout] :: ExitCodeException -> ByteString
[eceStderr] :: ExitCodeException -> ByteString

-- | Wrapper for when an exception is thrown when reading from a child
--   process, used by byteStringOutput.
data () => ByteStringOutputException
ByteStringOutputException :: SomeException -> ProcessConfig () () () -> ByteStringOutputException

-- | Take ProcessHandle out of the Process. This method is
--   needed in cases one need to use low level functions from the
--   process package. Use cases for this method are:
--   
--   
--   
- Send a special signal to the process.
--   
- Terminate the process group instead of terminating single
--   process.
--   
- Use platform specific API on the underlying process.
--   
--   
--   This method is considered unsafe because the actions it performs on
--   the underlying process may overlap with the functionality that
--   typed-process provides. For example the user should not call
--   waitForProcess on the process handle as either
--   waitForProcess or stopProcess will lock. Additionally,
--   even if process was terminated by the terminateProcess or by
--   sending signal, stopProcess should be called either way in
--   order to cleanup resources allocated by the typed-process.
unsafeProcessHandle :: Process stdin stdout stderr -> ProcessHandle
instance GHC.Classes.Eq RIO.Process.ProcessException
instance RIO.Prelude.Logger.HasLogFunc RIO.Process.LoggedProcessContext
instance RIO.Process.HasProcessContext RIO.Process.LoggedProcessContext
instance RIO.Process.HasProcessContext RIO.Process.ProcessContext
instance GHC.Show.Show RIO.Process.ProcessException
instance GHC.Exception.Type.Exception RIO.Process.ProcessException

-- | Provide a SimpleApp datatype, for providing a basic
--   App-like environment with common functionality built in. This
--   is intended to make it easier to, e.g., use rio's logging and process
--   code from within short scripts.
module RIO.Prelude.Simple

-- | A simple, non-customizable environment type for RIO, which
--   provides common functionality. If it's insufficient for your needs,
--   define your own, custom App data type.
data SimpleApp

-- | Constructor for SimpleApp. In case when ProcessContext
--   is not supplied mkDefaultProcessContext will be used to create
--   it.
mkSimpleApp :: MonadIO m => LogFunc -> Maybe ProcessContext -> m SimpleApp

-- | Run with a default configured SimpleApp, consisting of:
--   
--   
--   
- Logging to stderr
--   
- If the RIO_VERBOSE environment variable is set, turns on
--   verbose logging
--   
- Default process context
--   
runSimpleApp :: MonadIO m => RIO SimpleApp a -> m a
instance RIO.Prelude.Logger.HasLogFunc RIO.Prelude.Simple.SimpleApp
instance RIO.Process.HasProcessContext RIO.Prelude.Simple.SimpleApp

-- | Seq. Import as:
--   
--   
--   import qualified RIO.Seq as Seq
--   
module RIO.Seq

-- | General-purpose finite sequences.
data () => Seq a

-- | A bidirectional pattern synonym matching an empty sequence.
pattern Empty :: Seq a

-- | A bidirectional pattern synonym viewing the rear of a non-empty
--   sequence.
pattern (:|>) :: Seq a -> a -> Seq a

-- | A bidirectional pattern synonym viewing the front of a non-empty
--   sequence.
pattern (:<|) :: a -> Seq a -> Seq a
infixl 5 :|>
infixr 5 :<|

-- | <math>. The empty sequence.
empty :: Seq a

-- | <math>. A singleton sequence.
singleton :: a -> Seq a

-- | <math>. Add an element to the left end of a sequence. Mnemonic:
--   a triangle with the single element at the pointy end.
(<|) :: a -> Seq a -> Seq a
infixr 5 <|

-- | <math>. Add an element to the right end of a sequence. Mnemonic:
--   a triangle with the single element at the pointy end.
(|>) :: Seq a -> a -> Seq a
infixl 5 |>

-- | <math>. Concatenate two sequences.
(><) :: Seq a -> Seq a -> Seq a
infixr 5 ><

-- | <math>. Create a sequence from a finite list of elements. There
--   is a function toList in the opposite direction for all
--   instances of the Foldable class, including Seq.
fromList :: [a] -> Seq a

-- | <math>. Convert a given sequence length and a function
--   representing that sequence into a sequence.
fromFunction :: Int -> (Int -> a) -> Seq a

-- | <math>. Create a sequence consisting of the elements of an
--   Array. Note that the resulting sequence elements may be
--   evaluated lazily (as on GHC), so you must force the entire structure
--   to be sure that the original array can be garbage-collected.
fromArray :: Ix i => Array i a -> Seq a

-- | <math>. replicate n x is a sequence consisting of
--   n copies of x.
replicate :: Int -> a -> Seq a

-- | replicateA is an Applicative version of
--   replicate, and makes <math> calls to liftA2 and
--   pure.
--   
--   
--   replicateA n x = sequenceA (replicate n x)
--   
replicateA :: Applicative f => Int -> f a -> f (Seq a)

-- | replicateM is a sequence counterpart of replicateM.
--   
--   
--   replicateM n x = sequence (replicate n x)
--   
--   
--   For base >= 4.8.0 and containers >= 0.5.11,
--   replicateM is a synonym for replicateA.
replicateM :: Applicative m => Int -> m a -> m (Seq a)

-- | <math>. cycleTaking k xs forms a sequence of
--   length k by repeatedly concatenating xs with itself.
--   xs may only be empty if k is 0.
--   
--   
--   cycleTaking k = fromList . take k . cycle . toList
--   
cycleTaking :: Int -> Seq a -> Seq a

-- | <math>. Constructs a sequence by repeated application of a
--   function to a seed value.
--   
--   
--   iterateN n f x = fromList (Prelude.take n (Prelude.iterate f x))
--   
iterateN :: Int -> (a -> a) -> a -> Seq a

-- | Builds a sequence from a seed value. Takes time linear in the number
--   of generated elements. WARNING: If the number of generated
--   elements is infinite, this method will not terminate.
unfoldr :: (b -> Maybe (a, b)) -> b -> Seq a

-- | unfoldl f x is equivalent to reverse
--   (unfoldr (fmap swap . f) x).
unfoldl :: (b -> Maybe (b, a)) -> b -> Seq a

-- | <math>. Is this the empty sequence?
null :: Seq a -> Bool

-- | <math>. The number of elements in the sequence.
length :: Seq a -> Int

-- | View of the left end of a sequence.
data () => ViewL a

-- | empty sequence
EmptyL :: ViewL a

-- | leftmost element and the rest of the sequence
(:<) :: a -> Seq a -> ViewL a
infixr 5 :<

-- | <math>. Analyse the left end of a sequence.
viewl :: Seq a -> ViewL a

-- | View of the right end of a sequence.
data () => ViewR a

-- | empty sequence
EmptyR :: ViewR a

-- | the sequence minus the rightmost element, and the rightmost element
(:>) :: Seq a -> a -> ViewR a
infixl 5 :>

-- | <math>. Analyse the right end of a sequence.
viewr :: Seq a -> ViewR a

-- | scanl is similar to foldl, but returns a sequence of
--   reduced values from the left:
--   
--   
--   scanl f z (fromList [x1, x2, ...]) = fromList [z, z `f` x1, (z `f` x1) `f` x2, ...]
--   
scanl :: (a -> b -> a) -> a -> Seq b -> Seq a

-- | scanl1 is a variant of scanl that has no starting value
--   argument:
--   
--   
--   scanl1 f (fromList [x1, x2, ...]) = fromList [x1, x1 `f` x2, ...]
--   
scanl1 :: (a -> a -> a) -> Seq a -> Seq a

-- | scanr is the right-to-left dual of scanl.
scanr :: (a -> b -> b) -> b -> Seq a -> Seq b

-- | scanr1 is a variant of scanr that has no starting value
--   argument.
scanr1 :: (a -> a -> a) -> Seq a -> Seq a

-- | <math>. Returns a sequence of all suffixes of this sequence,
--   longest first. For example,
--   
--   
--   tails (fromList "abc") = fromList [fromList "abc", fromList "bc", fromList "c", fromList ""]
--   
--   
--   Evaluating the <math>th suffix takes <math>, but
--   evaluating every suffix in the sequence takes <math> due to
--   sharing.
tails :: Seq a -> Seq (Seq a)

-- | <math>. Returns a sequence of all prefixes of this sequence,
--   shortest first. For example,
--   
--   
--   inits (fromList "abc") = fromList [fromList "", fromList "a", fromList "ab", fromList "abc"]
--   
--   
--   Evaluating the <math>th prefix takes <math>, but
--   evaluating every prefix in the sequence takes <math> due to
--   sharing.
inits :: Seq a -> Seq (Seq a)

-- | <math>. chunksOf c xs splits xs into chunks of
--   size c>0. If c does not divide the length of
--   xs evenly, then the last element of the result will be short.
--   
--   Side note: the given performance bound is missing some messy terms
--   that only really affect edge cases. Performance degrades smoothly from
--   <math> (for <math>) to <math> (for <math>).
--   The true bound is more like <math>
chunksOf :: Int -> Seq a -> Seq (Seq a)

-- | <math> where <math> is the prefix length.
--   takeWhileL, applied to a predicate p and a sequence
--   xs, returns the longest prefix (possibly empty) of
--   xs of elements that satisfy p.
takeWhileL :: (a -> Bool) -> Seq a -> Seq a

-- | <math> where <math> is the suffix length.
--   takeWhileR, applied to a predicate p and a sequence
--   xs, returns the longest suffix (possibly empty) of
--   xs of elements that satisfy p.
--   
--   takeWhileR p xs is equivalent to reverse
--   (takeWhileL p (reverse xs)).
takeWhileR :: (a -> Bool) -> Seq a -> Seq a

-- | <math> where <math> is the prefix length.
--   dropWhileL p xs returns the suffix remaining after
--   takeWhileL p xs.
dropWhileL :: (a -> Bool) -> Seq a -> Seq a

-- | <math> where <math> is the suffix length.
--   dropWhileR p xs returns the prefix remaining after
--   takeWhileR p xs.
--   
--   dropWhileR p xs is equivalent to reverse
--   (dropWhileL p (reverse xs)).
dropWhileR :: (a -> Bool) -> Seq a -> Seq a

-- | <math> where <math> is the prefix length. spanl,
--   applied to a predicate p and a sequence xs, returns
--   a pair whose first element is the longest prefix (possibly empty) of
--   xs of elements that satisfy p and the second element
--   is the remainder of the sequence.
spanl :: (a -> Bool) -> Seq a -> (Seq a, Seq a)

-- | <math> where <math> is the suffix length. spanr,
--   applied to a predicate p and a sequence xs, returns
--   a pair whose first element is the longest suffix
--   (possibly empty) of xs of elements that satisfy p
--   and the second element is the remainder of the sequence.
spanr :: (a -> Bool) -> Seq a -> (Seq a, Seq a)

-- | <math> where <math> is the breakpoint index.
--   breakl, applied to a predicate p and a sequence
--   xs, returns a pair whose first element is the longest prefix
--   (possibly empty) of xs of elements that do not satisfy
--   p and the second element is the remainder of the sequence.
--   
--   breakl p is equivalent to spanl (not .
--   p).
breakl :: (a -> Bool) -> Seq a -> (Seq a, Seq a)

-- | breakr p is equivalent to spanr (not .
--   p).
breakr :: (a -> Bool) -> Seq a -> (Seq a, Seq a)

-- | <math>. The partition function takes a predicate
--   p and a sequence xs and returns sequences of those
--   elements which do and do not satisfy the predicate.
partition :: (a -> Bool) -> Seq a -> (Seq a, Seq a)

-- | <math>. The filter function takes a predicate p
--   and a sequence xs and returns a sequence of those elements
--   which satisfy the predicate.
filter :: (a -> Bool) -> Seq a -> Seq a

-- | <math>. sort sorts the specified Seq by the
--   natural ordering of its elements. The sort is stable. If stability is
--   not required, unstableSort can be slightly faster.
sort :: Ord a => Seq a -> Seq a

-- | <math>. sortBy sorts the specified Seq according
--   to the specified comparator. The sort is stable. If stability is not
--   required, unstableSortBy can be slightly faster.
sortBy :: (a -> a -> Ordering) -> Seq a -> Seq a

-- | <math>. unstableSort sorts the specified Seq by
--   the natural ordering of its elements, but the sort is not stable. This
--   algorithm is frequently faster and uses less memory than sort.
unstableSort :: Ord a => Seq a -> Seq a

-- | <math>. A generalization of unstableSort,
--   unstableSortBy takes an arbitrary comparator and sorts the
--   specified sequence. The sort is not stable. This algorithm is
--   frequently faster and uses less memory than sortBy.
unstableSortBy :: (a -> a -> Ordering) -> Seq a -> Seq a

-- | <math>. The element at the specified position, counting from 0.
--   If the specified position is negative or at least the length of the
--   sequence, lookup returns Nothing.
--   
--   
--   0 <= i < length xs ==> lookup i xs == Just (toList xs !! i)
--   
--   
--   
--   i < 0 || i >= length xs ==> lookup i xs = Nothing
--   
--   
--   Unlike index, this can be used to retrieve an element without
--   forcing it. For example, to insert the fifth element of a sequence
--   xs into a Map m at key k, you could
--   use
--   
--   
--   case lookup 5 xs of
--     Nothing -> m
--     Just x -> insert k x m
--   
lookup :: Int -> Seq a -> Maybe a

-- | <math>. A flipped, infix version of lookup.
(!?) :: Seq a -> Int -> Maybe a

-- | <math>. The element at the specified position, counting from 0.
--   The argument should thus be a non-negative integer less than the size
--   of the sequence. If the position is out of range, index fails
--   with an error.
--   
--   
--   xs `index` i = toList xs !! i
--   
--   
--   Caution: index necessarily delays retrieving the requested
--   element until the result is forced. It can therefore lead to a space
--   leak if the result is stored, unforced, in another structure. To
--   retrieve an element immediately without forcing it, use lookup
--   or (!?).
index :: Seq a -> Int -> a

-- | <math>. Update the element at the specified position. If the
--   position is out of range, the original sequence is returned.
--   adjust can lead to poor performance and even memory leaks,
--   because it does not force the new value before installing it in the
--   sequence. adjust' should usually be preferred.
adjust :: (a -> a) -> Int -> Seq a -> Seq a

-- | <math>. Update the element at the specified position. If the
--   position is out of range, the original sequence is returned. The new
--   value is forced before it is installed in the sequence.
--   
--   
--   adjust' f i xs =
--    case xs !? i of
--      Nothing -> xs
--      Just x -> let !x' = f x
--                in update i x' xs
--   
adjust' :: (a -> a) -> Int -> Seq a -> Seq a

-- | <math>. Replace the element at the specified position. If the
--   position is out of range, the original sequence is returned.
update :: Int -> a -> Seq a -> Seq a

-- | <math>. The first i elements of a sequence. If
--   i is negative, take i s yields the empty
--   sequence. If the sequence contains fewer than i elements, the
--   whole sequence is returned.
take :: Int -> Seq a -> Seq a

-- | <math>. Elements of a sequence after the first i. If
--   i is negative, drop i s yields the whole
--   sequence. If the sequence contains fewer than i elements, the
--   empty sequence is returned.
drop :: Int -> Seq a -> Seq a

-- | <math>. insertAt i x xs inserts x into
--   xs at the index i, shifting the rest of the sequence
--   over.
--   
--   
--   insertAt 2 x (fromList [a,b,c,d]) = fromList [a,b,x,c,d]
--   insertAt 4 x (fromList [a,b,c,d]) = insertAt 10 x (fromList [a,b,c,d])
--                                     = fromList [a,b,c,d,x]
--   
--   
--   
--   insertAt i x xs = take i xs >< singleton x >< drop i xs
--   
insertAt :: Int -> a -> Seq a -> Seq a

-- | <math>. Delete the element of a sequence at a given index.
--   Return the original sequence if the index is out of range.
--   
--   
--   deleteAt 2 [a,b,c,d] = [a,b,d]
--   deleteAt 4 [a,b,c,d] = deleteAt (-1) [a,b,c,d] = [a,b,c,d]
--   
deleteAt :: Int -> Seq a -> Seq a

-- | <math>. Split a sequence at a given position. splitAt
--   i s = (take i s, drop i s).
splitAt :: Int -> Seq a -> (Seq a, Seq a)

-- | elemIndexL finds the leftmost index of the specified element,
--   if it is present, and otherwise Nothing.
elemIndexL :: Eq a => a -> Seq a -> Maybe Int

-- | elemIndicesL finds the indices of the specified element, from
--   left to right (i.e. in ascending order).
elemIndicesL :: Eq a => a -> Seq a -> [Int]

-- | elemIndexR finds the rightmost index of the specified element,
--   if it is present, and otherwise Nothing.
elemIndexR :: Eq a => a -> Seq a -> Maybe Int

-- | elemIndicesR finds the indices of the specified element, from
--   right to left (i.e. in descending order).
elemIndicesR :: Eq a => a -> Seq a -> [Int]

-- | findIndexL p xs finds the index of the leftmost
--   element that satisfies p, if any exist.
findIndexL :: (a -> Bool) -> Seq a -> Maybe Int

-- | findIndicesL p finds all indices of elements that
--   satisfy p, in ascending order.
findIndicesL :: (a -> Bool) -> Seq a -> [Int]

-- | findIndexR p xs finds the index of the rightmost
--   element that satisfies p, if any exist.
findIndexR :: (a -> Bool) -> Seq a -> Maybe Int

-- | findIndicesR p finds all indices of elements that
--   satisfy p, in descending order.
findIndicesR :: (a -> Bool) -> Seq a -> [Int]
foldMapWithIndex :: Monoid m => (Int -> a -> m) -> Seq a -> m

-- | foldlWithIndex is a version of foldl that also provides
--   access to the index of each element.
foldlWithIndex :: (b -> Int -> a -> b) -> b -> Seq a -> b

-- | foldrWithIndex is a version of foldr that also provides
--   access to the index of each element.
foldrWithIndex :: (Int -> a -> b -> b) -> b -> Seq a -> b

-- | A generalization of fmap, mapWithIndex takes a mapping
--   function that also depends on the element's index, and applies it to
--   every element in the sequence.
mapWithIndex :: (Int -> a -> b) -> Seq a -> Seq b

-- | traverseWithIndex is a version of traverse that also
--   offers access to the index of each element.
traverseWithIndex :: Applicative f => (Int -> a -> f b) -> Seq a -> f (Seq b)

-- | <math>. The reverse of a sequence.
reverse :: Seq a -> Seq a

-- | <math>. Intersperse an element between the elements of a
--   sequence.
--   
--   
--   intersperse a empty = empty
--   intersperse a (singleton x) = singleton x
--   intersperse a (fromList [x,y]) = fromList [x,a,y]
--   intersperse a (fromList [x,y,z]) = fromList [x,a,y,a,z]
--   
intersperse :: a -> Seq a -> Seq a

-- | <math>. zip takes two sequences and returns a sequence of
--   corresponding pairs. If one input is short, excess elements are
--   discarded from the right end of the longer sequence.
zip :: Seq a -> Seq b -> Seq (a, b)

-- | <math>. zipWith generalizes zip by zipping with
--   the function given as the first argument, instead of a tupling
--   function. For example, zipWith (+) is applied to two
--   sequences to take the sequence of corresponding sums.
zipWith :: (a -> b -> c) -> Seq a -> Seq b -> Seq c

-- | <math>. zip3 takes three sequences and returns a sequence
--   of triples, analogous to zip.
zip3 :: Seq a -> Seq b -> Seq c -> Seq (a, b, c)

-- | <math>. zipWith3 takes a function which combines three
--   elements, as well as three sequences and returns a sequence of their
--   point-wise combinations, analogous to zipWith.
zipWith3 :: (a -> b -> c -> d) -> Seq a -> Seq b -> Seq c -> Seq d

-- | <math>. zip4 takes four sequences and returns a sequence
--   of quadruples, analogous to zip.
zip4 :: Seq a -> Seq b -> Seq c -> Seq d -> Seq (a, b, c, d)

-- | <math>. zipWith4 takes a function which combines four
--   elements, as well as four sequences and returns a sequence of their
--   point-wise combinations, analogous to zipWith.
zipWith4 :: (a -> b -> c -> d -> e) -> Seq a -> Seq b -> Seq c -> Seq d -> Seq e

-- | Set. Import as:
--   
--   
--   import qualified RIO.Set as Set
--   
--   
--   This module does not export any partial or unchecked functions. For
--   those, see RIO.Set.Partial and RIO.Set.Unchecked
module RIO.Set

-- | A set of values a.
data () => Set a

-- | <math>. See difference.
(\\) :: Ord a => Set a -> Set a -> Set a
infixl 9 \\

-- | <math>. Is this the empty set?
null :: Set a -> Bool

-- | <math>. The number of elements in the set.
size :: Set a -> Int

-- | <math>. Is the element in the set?
member :: Ord a => a -> Set a -> Bool

-- | <math>. Is the element not in the set?
notMember :: Ord a => a -> Set a -> Bool

-- | <math>. Find largest element smaller than the given one.
--   
--   
--   lookupLT 3 (fromList [3, 5]) == Nothing
--   lookupLT 5 (fromList [3, 5]) == Just 3
--   
lookupLT :: Ord a => a -> Set a -> Maybe a

-- | <math>. Find smallest element greater than the given one.
--   
--   
--   lookupGT 4 (fromList [3, 5]) == Just 5
--   lookupGT 5 (fromList [3, 5]) == Nothing
--   
lookupGT :: Ord a => a -> Set a -> Maybe a

-- | <math>. Find largest element smaller or equal to the given one.
--   
--   
--   lookupLE 2 (fromList [3, 5]) == Nothing
--   lookupLE 4 (fromList [3, 5]) == Just 3
--   lookupLE 5 (fromList [3, 5]) == Just 5
--   
lookupLE :: Ord a => a -> Set a -> Maybe a

-- | <math>. Find smallest element greater or equal to the given one.
--   
--   
--   lookupGE 3 (fromList [3, 5]) == Just 3
--   lookupGE 4 (fromList [3, 5]) == Just 5
--   lookupGE 6 (fromList [3, 5]) == Nothing
--   
lookupGE :: Ord a => a -> Set a -> Maybe a

-- | <math>. (s1 `isSubsetOf` s2) indicates whether
--   s1 is a subset of s2.
--   
--   
--   s1 `isSubsetOf` s2 = all (`member` s2) s1
--   s1 `isSubsetOf` s2 = null (s1 `difference` s2)
--   s1 `isSubsetOf` s2 = s1 `union` s2 == s2
--   s1 `isSubsetOf` s2 = s1 `intersection` s2 == s1
--   
isSubsetOf :: Ord a => Set a -> Set a -> Bool

-- | <math>. (s1 `isProperSubsetOf` s2) indicates whether
--   s1 is a proper subset of s2.
--   
--   
--   s1 `isProperSubsetOf` s2 = s1 `isSubsetOf` s2 && s1 /= s2
--   
isProperSubsetOf :: Ord a => Set a -> Set a -> Bool

-- | <math>. The empty set.
empty :: Set a

-- | <math>. Create a singleton set.
singleton :: a -> Set a

-- | <math>. Insert an element in a set. If the set already contains
--   an element equal to the given value, it is replaced with the new
--   value.
insert :: Ord a => a -> Set a -> Set a

-- | <math>. Delete an element from a set.
delete :: Ord a => a -> Set a -> Set a

-- | <math>. The union of two sets, preferring the first set when
--   equal elements are encountered.
union :: Ord a => Set a -> Set a -> Set a

-- | The union of the sets in a Foldable structure : (unions ==
--   foldl union empty).
unions :: (Foldable f, Ord a) => f (Set a) -> Set a

-- | <math>. Difference of two sets.
--   
--   Return elements of the first set not existing in the second set.
--   
--   
--   difference (fromList [5, 3]) (fromList [5, 7]) == singleton 3
--   
difference :: Ord a => Set a -> Set a -> Set a

-- | <math>. The intersection of two sets. Elements of the result
--   come from the first set, so for example
--   
--   
--   import qualified Data.Set as S
--   data AB = A | B deriving Show
--   instance Ord AB where compare _ _ = EQ
--   instance Eq AB where _ == _ = True
--   main = print (S.singleton A `S.intersection` S.singleton B,
--                 S.singleton B `S.intersection` S.singleton A)
--   
--   
--   prints (fromList [A],fromList [B]).
intersection :: Ord a => Set a -> Set a -> Set a

-- | <math>. Filter all elements that satisfy the predicate.
filter :: (a -> Bool) -> Set a -> Set a

-- | <math>. Take while a predicate on the elements holds. The user
--   is responsible for ensuring that for all elements j and
--   k in the set, j < k ==> p j >= p k. See
--   note at spanAntitone.
--   
--   
--   takeWhileAntitone p = fromDistinctAscList . takeWhile p . toList
--   takeWhileAntitone p = filter p
--   
takeWhileAntitone :: (a -> Bool) -> Set a -> Set a

-- | <math>. Drop while a predicate on the elements holds. The user
--   is responsible for ensuring that for all elements j and
--   k in the set, j < k ==> p j >= p k. See
--   note at spanAntitone.
--   
--   
--   dropWhileAntitone p = fromDistinctAscList . dropWhile p . toList
--   dropWhileAntitone p = filter (not . p)
--   
dropWhileAntitone :: (a -> Bool) -> Set a -> Set a

-- | <math>. Divide a set at the point where a predicate on the
--   elements stops holding. The user is responsible for ensuring that for
--   all elements j and k in the set, j < k ==>
--   p j >= p k.
--   
--   
--   spanAntitone p xs = (takeWhileAntitone p xs, dropWhileAntitone p xs)
--   spanAntitone p xs = partition p xs
--   
--   
--   Note: if p is not actually antitone, then
--   spanAntitone will split the set at some unspecified
--   point where the predicate switches from holding to not holding (where
--   the predicate is seen to hold before the first element and to fail
--   after the last element).
spanAntitone :: (a -> Bool) -> Set a -> (Set a, Set a)

-- | <math>. Partition the set into two sets, one with all elements
--   that satisfy the predicate and one with all elements that don't
--   satisfy the predicate. See also split.
partition :: (a -> Bool) -> Set a -> (Set a, Set a)

-- | <math>. The expression (split x set) is a pair
--   (set1,set2) where set1 comprises the elements of
--   set less than x and set2 comprises the
--   elements of set greater than x.
split :: Ord a => a -> Set a -> (Set a, Set a)

-- | <math>. Performs a split but also returns whether the
--   pivot element was found in the original set.
splitMember :: Ord a => a -> Set a -> (Set a, Bool, Set a)

-- | <math>. Decompose a set into pieces based on the structure of
--   the underlying tree. This function is useful for consuming a set in
--   parallel.
--   
--   No guarantee is made as to the sizes of the pieces; an internal, but
--   deterministic process determines this. However, it is guaranteed that
--   the pieces returned will be in ascending order (all elements in the
--   first subset less than all elements in the second, and so on).
--   
--   Examples:
--   
--   
--   splitRoot (fromList [1..6]) ==
--     [fromList [1,2,3],fromList [4],fromList [5,6]]
--   
--   
--   
--   splitRoot empty == []
--   
--   
--   Note that the current implementation does not return more than three
--   subsets, but you should not depend on this behaviour because it can
--   change in the future without notice.
splitRoot :: Set a -> [Set a]

-- | <math>. Lookup the index of an element, which is its
--   zero-based index in the sorted sequence of elements. The index is a
--   number from 0 up to, but not including, the size of the
--   set.
--   
--   
--   isJust   (lookupIndex 2 (fromList [5,3])) == False
--   fromJust (lookupIndex 3 (fromList [5,3])) == 0
--   fromJust (lookupIndex 5 (fromList [5,3])) == 1
--   isJust   (lookupIndex 6 (fromList [5,3])) == False
--   
lookupIndex :: Ord a => a -> Set a -> Maybe Int

-- | <math>. Take a given number of elements in order, beginning with
--   the smallest ones.
--   
--   
--   take n = fromDistinctAscList . take n . toAscList
--   
take :: Int -> Set a -> Set a

-- | <math>. Drop a given number of elements in order, beginning with
--   the smallest ones.
--   
--   
--   drop n = fromDistinctAscList . drop n . toAscList
--   
drop :: Int -> Set a -> Set a

-- | <math>. Split a set at a particular index.
--   
--   
--   splitAt !n !xs = (take n xs, drop n xs)
--   
splitAt :: Int -> Set a -> (Set a, Set a)

-- | <math>. map f s is the set obtained by applying
--   f to each element of s.
--   
--   It's worth noting that the size of the result may be smaller if, for
--   some (x,y), x /= y && f x == f y
map :: Ord b => (a -> b) -> Set a -> Set b

-- | <math>. Fold the elements in the set using the given
--   right-associative binary operator, such that foldr f z ==
--   foldr f z . toAscList.
--   
--   For example,
--   
--   
--   toAscList set = foldr (:) [] set
--   
foldr :: (a -> b -> b) -> b -> Set a -> b

-- | <math>. Fold the elements in the set using the given
--   left-associative binary operator, such that foldl f z ==
--   foldl f z . toAscList.
--   
--   For example,
--   
--   
--   toDescList set = foldl (flip (:)) [] set
--   
foldl :: (a -> b -> a) -> a -> Set b -> a

-- | <math>. A strict version of foldr. Each application of
--   the operator is evaluated before using the result in the next
--   application. This function is strict in the starting value.
foldr' :: (a -> b -> b) -> b -> Set a -> b

-- | <math>. A strict version of foldl. Each application of
--   the operator is evaluated before using the result in the next
--   application. This function is strict in the starting value.
foldl' :: (a -> b -> a) -> a -> Set b -> a

-- | <math>. The minimal element of a set.
lookupMin :: Set a -> Maybe a

-- | <math>. The maximal element of a set.
lookupMax :: Set a -> Maybe a

-- | <math>. Delete the minimal element. Returns an empty set if the
--   set is empty.
deleteMin :: Set a -> Set a

-- | <math>. Delete the maximal element. Returns an empty set if the
--   set is empty.
deleteMax :: Set a -> Set a

-- | <math>. Retrieves the maximal key of the set, and the set
--   stripped of that element, or Nothing if passed an empty set.
maxView :: Set a -> Maybe (a, Set a)

-- | <math>. Retrieves the minimal key of the set, and the set
--   stripped of that element, or Nothing if passed an empty set.
minView :: Set a -> Maybe (a, Set a)

-- | <math>. An alias of toAscList. The elements of a set in
--   ascending order. Subject to list fusion.
elems :: Set a -> [a]

-- | <math>. Convert the set to a list of elements. Subject to list
--   fusion.
toList :: Set a -> [a]

-- | <math>. Create a set from a list of elements.
--   
--   If the elements are ordered, a linear-time implementation is used,
--   with the performance equal to fromDistinctAscList.
fromList :: Ord a => [a] -> Set a

-- | <math>. Convert the set to an ascending list of elements.
--   Subject to list fusion.
toAscList :: Set a -> [a]

-- | <math>. Convert the set to a descending list of elements.
--   Subject to list fusion.
toDescList :: Set a -> [a]

-- | <math>. Show the tree that implements the set. The tree is shown
--   in a compressed, hanging format.
showTree :: Show a => Set a -> String

-- | <math>. The expression (showTreeWith hang wide map)
--   shows the tree that implements the set. If hang is
--   True, a hanging tree is shown otherwise a rotated tree
--   is shown. If wide is True, an extra wide version is
--   shown.
--   
--   
--   Set> putStrLn $ showTreeWith True False $ fromDistinctAscList [1..5]
--   4
--   +--2
--   |  +--1
--   |  +--3
--   +--5
--   
--   Set> putStrLn $ showTreeWith True True $ fromDistinctAscList [1..5]
--   4
--   |
--   +--2
--   |  |
--   |  +--1
--   |  |
--   |  +--3
--   |
--   +--5
--   
--   Set> putStrLn $ showTreeWith False True $ fromDistinctAscList [1..5]
--   +--5
--   |
--   4
--   |
--   |  +--3
--   |  |
--   +--2
--      |
--      +--1
--   
showTreeWith :: Show a => Bool -> Bool -> Set a -> String

-- | <math>. Test if the internal set structure is valid.
valid :: Ord a => Set a -> Bool

-- | Set partial functions. Import as:
--   
--   
--   import qualified RIO.Set.Partial as Set'
--   
module RIO.Set.Partial

-- | <math>. Return the index of an element, which is its
--   zero-based index in the sorted sequence of elements. The index is a
--   number from 0 up to, but not including, the size of the
--   set. Calls error when the element is not a member of the
--   set.
--   
--   
--   findIndex 2 (fromList [5,3])    Error: element is not in the set
--   findIndex 3 (fromList [5,3]) == 0
--   findIndex 5 (fromList [5,3]) == 1
--   findIndex 6 (fromList [5,3])    Error: element is not in the set
--   
findIndex :: Ord a => a -> Set a -> Int

-- | <math>. Retrieve an element by its index, i.e. by its
--   zero-based index in the sorted sequence of elements. If the
--   index is out of range (less than zero, greater or equal to
--   size of the set), error is called.
--   
--   
--   elemAt 0 (fromList [5,3]) == 3
--   elemAt 1 (fromList [5,3]) == 5
--   elemAt 2 (fromList [5,3])    Error: index out of range
--   
elemAt :: Int -> Set a -> a

-- | <math>. Delete the element at index, i.e. by its
--   zero-based index in the sorted sequence of elements. If the
--   index is out of range (less than zero, greater or equal to
--   size of the set), error is called.
--   
--   
--   deleteAt 0    (fromList [5,3]) == singleton 5
--   deleteAt 1    (fromList [5,3]) == singleton 3
--   deleteAt 2    (fromList [5,3])    Error: index out of range
--   deleteAt (-1) (fromList [5,3])    Error: index out of range
--   
deleteAt :: Int -> Set a -> Set a

-- | <math>. The minimal element of a set.
findMin :: Set a -> a

-- | <math>. The maximal element of a set.
findMax :: Set a -> a

-- | <math>. Delete and find the minimal element.
--   
--   
--   deleteFindMin set = (findMin set, deleteMin set)
--   
deleteFindMin :: Set a -> (a, Set a)

-- | <math>. Delete and find the maximal element.
--   
--   
--   deleteFindMax set = (findMax set, deleteMax set)
--   
deleteFindMax :: Set a -> (a, Set a)

-- | This module contains functions from Data.Set that have
--   unchecked preconditions on their input. If these preconditions are not
--   satisfied, the data structure may end up in an invalid state and other
--   operations may misbehave. Import as:
--   
--   
--   import qualified RIO.Set.Unchecked as Set'
--   
module RIO.Set.Unchecked

-- | <math>. The
--   
--   mapMonotonic f s == map f s, but works only
--   when f is strictly increasing. The precondition is not
--   checked. Semi-formally, we have:
--   
--   
--   and [x < y ==> f x < f y | x <- ls, y <- ls]
--                       ==> mapMonotonic f s == map f s
--       where ls = toList s
--   
mapMonotonic :: (a -> b) -> Set a -> Set b

-- | <math>. Build a set from an ascending list in linear time.
--   The precondition (input list is ascending) is not checked.
fromAscList :: Eq a => [a] -> Set a

-- | <math>. Build a set from a descending list in linear time.
--   The precondition (input list is descending) is not checked.
fromDescList :: Eq a => [a] -> Set a

-- | <math>. Build a set from an ascending list of distinct elements
--   in linear time. The precondition (input list is strictly ascending)
--   is not checked.
fromDistinctAscList :: [a] -> Set a

-- | <math>. Build a set from a descending list of distinct elements
--   in linear time. The precondition (input list is strictly
--   descending) is not checked.
fromDistinctDescList :: [a] -> Set a

-- | Provides reexports of MonadState and related helpers.
module RIO.State

-- | Minimal definition is either both of get and put or
--   just state
class Monad m => MonadState s (m :: Type -> Type) | m -> s

-- | Return the state from the internals of the monad.
get :: MonadState s m => m s

-- | Replace the state inside the monad.
put :: MonadState s m => s -> m ()

-- | Embed a simple state action into the monad.
state :: MonadState s m => (s -> (a, s)) -> m a

-- | Gets specific component of the state, using a projection function
--   supplied.
gets :: MonadState s m => (s -> a) -> m a

-- | Monadic state transformer.
--   
--   Maps an old state to a new state inside a state monad. The old state
--   is thrown away.
--   
--   
--   Main> :t modify ((+1) :: Int -> Int)
--   modify (...) :: (MonadState Int a) => a ()
--   
--   
--   This says that modify (+1) acts over any Monad that is a
--   member of the MonadState class, with an Int state.
modify :: MonadState s m => (s -> s) -> m ()

-- | A variant of modify in which the computation is strict in the
--   new state.
modify' :: MonadState s m => (s -> s) -> m ()

-- | A state monad parameterized by the type s of the state to
--   carry.
--   
--   The return function leaves the state unchanged, while
--   >>= uses the final state of the first computation as
--   the initial state of the second.
type State s = StateT s Identity

-- | Unwrap a state monad computation as a function. (The inverse of
--   state.)
runState :: State s a -> s -> (a, s)

-- | Evaluate a state computation with the given initial state and return
--   the final value, discarding the final state.
--   
--   
--   
- 
evalState m s = fst (runState m
--   s)

--   
evalState :: State s a -> s -> a

-- | Evaluate a state computation with the given initial state and return
--   the final state, discarding the final value.
--   
--   
--   
- 
execState m s = snd (runState m
--   s)

--   
execState :: State s a -> s -> s

-- | Map both the return value and final state of a computation using the
--   given function.
--   
--   
--   
- 
runState (mapState f m) = f . runState
--   m

--   
mapState :: ((a, s) -> (b, s)) -> State s a -> State s b

-- | withState f m executes action m on a state
--   modified by applying f.
--   
--   
--   
- 
withState f m = modify f >> m

--   
withState :: (s -> s) -> State s a -> State s a

-- | A state transformer monad parameterized by:
--   
--   
--   
- s - The state.
--   
- m - The inner monad.
--   
--   
--   The return function leaves the state unchanged, while
--   >>= uses the final state of the first computation as
--   the initial state of the second.
newtype () => StateT s (m :: Type -> Type) a
StateT :: (s -> m (a, s)) -> StateT s (m :: Type -> Type) a
[runStateT] :: StateT s (m :: Type -> Type) a -> s -> m (a, s)

-- | Evaluate a state computation with the given initial state and return
--   the final value, discarding the final state.
--   
--   
--   
- 
evalStateT m s = liftM fst
--   (runStateT m s)

--   
evalStateT :: Monad m => StateT s m a -> s -> m a

-- | Evaluate a state computation with the given initial state and return
--   the final state, discarding the final value.
--   
--   
--   
- 
execStateT m s = liftM snd
--   (runStateT m s)

--   
execStateT :: Monad m => StateT s m a -> s -> m s

-- | Map both the return value and final state of a computation using the
--   given function.
--   
--   
--   
- 
runStateT (mapStateT f m) = f .
--   runStateT m

--   
mapStateT :: (m (a, s) -> n (b, s)) -> StateT s m a -> StateT s n b

-- | withStateT f m executes action m on a state
--   modified by applying f.
--   
--   
--   
- 
withStateT f m = modify f >> m

--   
withStateT :: forall s (m :: Type -> Type) a. (s -> s) -> StateT s m a -> StateT s m a

-- | Strict Text. Import as:
--   
--   
--   import qualified RIO.Text as T
--   
--   
--   This module does not export any partial functions. For those, see
--   RIO.Text.Partial
module RIO.Text

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

-- | O(n) Convert a String into a Text. Performs
--   replacement on invalid scalar values, so unpack .
--   pack is not id:
--   
--   
--   >>> Data.Text.unpack (pack "\55555")
--   "\65533"
--   
pack :: String -> Text

-- | O(n) Convert a Text into a String.
unpack :: Text -> String

-- | O(1) Convert a character into a Text. Performs replacement on
--   invalid scalar values.
singleton :: Char -> Text

-- | O(1) The empty Text.
empty :: Text

-- | O(n) Adds a character to the front of a Text. This
--   function is more costly than its List counterpart because it
--   requires copying a new array. Performs replacement on invalid scalar
--   values.
cons :: Char -> Text -> Text
infixr 5 `cons`

-- | O(n) Adds a character to the end of a Text. This copies
--   the entire array in the process. Performs replacement on invalid
--   scalar values.
snoc :: Text -> Char -> Text

-- | O(n) Appends one Text to the other by copying both of
--   them into a new Text.
append :: Text -> Text -> Text

-- | O(1) Returns the first character and rest of a Text, or
--   Nothing if empty.
uncons :: Text -> Maybe (Char, Text)

-- | O(1) Tests whether a Text is empty or not.
null :: Text -> Bool

-- | O(n) Returns the number of characters in a Text.
length :: Text -> Int

-- | O(min(n,c)) Compare the count of characters in a Text to
--   a number.
--   
--   
--   compareLength t c = compare (length t) c
--   
--   
--   This function gives the same answer as comparing against the result of
--   length, but can short circuit if the count of characters is
--   greater than the number, and hence be more efficient.
compareLength :: Text -> Int -> Ordering

-- | O(n) map f t is the Text
--   obtained by applying f to each element of t.
--   
--   Example:
--   
--   
--   >>> let message = pack "I am not angry. Not at all."
--   
--   >>> T.map (\c -> if c == '.' then '!' else c) message
--   "I am not angry! Not at all!"
--   
--   
--   Performs replacement on invalid scalar values.
map :: (Char -> Char) -> Text -> Text

-- | O(n) The intercalate function takes a Text and a
--   list of Texts and concatenates the list after interspersing the
--   first argument between each element of the list.
--   
--   Example:
--   
--   
--   >>> T.intercalate "NI!" ["We", "seek", "the", "Holy", "Grail"]
--   "WeNI!seekNI!theNI!HolyNI!Grail"
--   
intercalate :: Text -> [Text] -> Text

-- | O(n) The intersperse function takes a character and
--   places it between the characters of a Text.
--   
--   Example:
--   
--   
--   >>> T.intersperse '.' "SHIELD"
--   "S.H.I.E.L.D"
--   
--   
--   Performs replacement on invalid scalar values.
intersperse :: Char -> Text -> Text

-- | O(n) The transpose function transposes the rows and
--   columns of its Text argument. Note that this function uses
--   pack, unpack, and the list version of transpose, and is
--   thus not very efficient.
--   
--   Examples:
--   
--   
--   >>> transpose ["green","orange"]
--   ["go","rr","ea","en","ng","e"]
--   
--   
--   
--   >>> transpose ["blue","red"]
--   ["br","le","ud","e"]
--   
transpose :: [Text] -> [Text]

-- | O(n) Reverse the characters of a string.
--   
--   Example:
--   
--   
--   >>> T.reverse "desrever"
--   "reversed"
--   
reverse :: Text -> Text

-- | O(n) Convert a string to folded case.
--   
--   This function is mainly useful for performing caseless (also known as
--   case insensitive) string comparisons.
--   
--   A string x is a caseless match for a string y if and
--   only if:
--   
--   
--   toCaseFold x == toCaseFold y
--   
--   
--   The result string may be longer than the input string, and may differ
--   from applying toLower to the input string. For instance, the
--   Armenian small ligature "ﬓ" (men now, U+FB13) is case folded to the
--   sequence "մ" (men, U+0574) followed by "ն" (now, U+0576), while the
--   Greek "µ" (micro sign, U+00B5) is case folded to "μ" (small letter mu,
--   U+03BC) instead of itself.
toCaseFold :: Text -> Text

-- | O(n) Convert a string to lower case, using simple case
--   conversion.
--   
--   The result string may be longer than the input string. For instance,
--   "İ" (Latin capital letter I with dot above, U+0130) maps to the
--   sequence "i" (Latin small letter i, U+0069) followed by " ̇"
--   (combining dot above, U+0307).
toLower :: Text -> Text

-- | O(n) Convert a string to upper case, using simple case
--   conversion.
--   
--   The result string may be longer than the input string. For instance,
--   the German "ß" (eszett, U+00DF) maps to the two-letter sequence "SS".
toUpper :: Text -> Text

-- | O(n) Convert a string to title case, using simple case
--   conversion.
--   
--   The first letter (as determined by isLetter) of the input is
--   converted to title case, as is every subsequent letter that
--   immediately follows a non-letter. Every letter that immediately
--   follows another letter is converted to lower case.
--   
--   This function is not idempotent. Consider lower-case letter ŉ
--   (U+0149 LATIN SMALL LETTER N PRECEDED BY APOSTROPHE). Then
--   toTitle "ŉ" = "ʼN": the first (and the only)
--   letter of the input is converted to title case, becoming two letters.
--   Now ʼ (U+02BC MODIFIER LETTER APOSTROPHE) is a modifier
--   letter and as such is recognised as a letter by isLetter, so
--   toTitle "ʼN" = "'n".
--   
--   The result string may be longer than the input string. For example,
--   the Latin small ligature ﬂ (U+FB02) is converted to the sequence Latin
--   capital letter F (U+0046) followed by Latin small letter l (U+006C).
--   
--   Note: this function does not take language or culture specific
--   rules into account. For instance, in English, different style guides
--   disagree on whether the book name "The Hill of the Red Fox" is
--   correctly title cased—but this function will capitalize every
--   word.
toTitle :: Text -> Text

-- | O(n) Left-justify a string to the given length, using the
--   specified fill character on the right. Performs replacement on invalid
--   scalar values.
--   
--   Examples:
--   
--   
--   >>> justifyLeft 7 'x' "foo"
--   "fooxxxx"
--   
--   
--   
--   >>> justifyLeft 3 'x' "foobar"
--   "foobar"
--   
justifyLeft :: Int -> Char -> Text -> Text

-- | O(n) Right-justify a string to the given length, using the
--   specified fill character on the left. Performs replacement on invalid
--   scalar values.
--   
--   Examples:
--   
--   
--   >>> justifyRight 7 'x' "bar"
--   "xxxxbar"
--   
--   
--   
--   >>> justifyRight 3 'x' "foobar"
--   "foobar"
--   
justifyRight :: Int -> Char -> Text -> Text

-- | O(n) Center a string to the given length, using the specified
--   fill character on either side. Performs replacement on invalid scalar
--   values.
--   
--   Examples:
--   
--   
--   >>> center 8 'x' "HS"
--   "xxxHSxxx"
--   
center :: Int -> Char -> Text -> Text

-- | O(n) foldl, applied to a binary operator, a starting
--   value (typically the left-identity of the operator), and a
--   Text, reduces the Text using the binary operator, from
--   left to right.
foldl :: (a -> Char -> a) -> a -> Text -> a

-- | O(n) A strict version of foldl.
foldl' :: (a -> Char -> a) -> a -> Text -> a

-- | O(n) foldr, applied to a binary operator, a starting
--   value (typically the right-identity of the operator), and a
--   Text, reduces the Text using the binary operator, from
--   right to left.
--   
--   If the binary operator is strict in its second argument, use
--   foldr' instead.
--   
--   foldr is lazy like foldr for lists: evaluation actually
--   traverses the Text from left to right, only as far as it needs
--   to.
--   
--   For example, head can be defined with O(1) complexity
--   using foldr:
--   
--   
--   head :: Text -> Char
--   head = foldr const (error "head empty")
--   
--   
--   Searches from left to right with short-circuiting behavior can also be
--   defined using foldr (e.g., any, all,
--   find, elem).
foldr :: (Char -> a -> a) -> a -> Text -> a

-- | O(n) Concatenate a list of Texts.
concat :: [Text] -> Text

-- | O(n) Map a function over a Text that results in a
--   Text, and concatenate the results.
concatMap :: (Char -> Text) -> Text -> Text

-- | O(n) any p t determines whether any
--   character in the Text t satisfies the predicate
--   p.
any :: (Char -> Bool) -> Text -> Bool

-- | O(n) all p t determines whether all
--   characters in the Text t satisfy the predicate
--   p.
all :: (Char -> Bool) -> Text -> Bool

-- | O(n) scanl is similar to foldl, but returns a
--   list of successive reduced values from the left. Performs replacement
--   on invalid scalar values.
--   
--   
--   scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
--   
--   
--   Properties
--   
--   
--   head (scanl f z xs) = z
--   
--   
--   
--   last (scanl f z xs) = foldl f z xs
--   
scanl :: (Char -> Char -> Char) -> Char -> Text -> Text

-- | O(n) scanl1 is a variant of scanl that has no
--   starting value argument. Performs replacement on invalid scalar
--   values.
--   
--   
--   scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
--   
scanl1 :: (Char -> Char -> Char) -> Text -> Text

-- | O(n) scanr is the right-to-left dual of scanl.
--   Performs replacement on invalid scalar values.
--   
--   
--   scanr f v == reverse . scanl (flip f) v . reverse
--   
scanr :: (Char -> Char -> Char) -> Char -> Text -> Text

-- | O(n) scanr1 is a variant of scanr that has no
--   starting value argument. Performs replacement on invalid scalar
--   values.
scanr1 :: (Char -> Char -> Char) -> Text -> Text

-- | O(n) Like a combination of map and foldl'.
--   Applies a function to each element of a Text, passing an
--   accumulating parameter from left to right, and returns a final
--   Text. Performs replacement on invalid scalar values.
mapAccumL :: (a -> Char -> (a, Char)) -> a -> Text -> (a, Text)

-- | The mapAccumR function behaves like a combination of map
--   and a strict foldr; it applies a function to each element of a
--   Text, passing an accumulating parameter from right to left, and
--   returning a final value of this accumulator together with the new
--   Text. Performs replacement on invalid scalar values.
mapAccumR :: (a -> Char -> (a, Char)) -> a -> Text -> (a, Text)

-- | O(n*m) replicate n t is a Text
--   consisting of the input t repeated n times.
replicate :: Int -> Text -> Text

-- | O(n), where n is the length of the result. The
--   unfoldr function is analogous to the List unfoldr.
--   unfoldr builds a Text from a seed value. The function
--   takes the element and returns Nothing if it is done producing
--   the Text, otherwise Just (a,b). In this case,
--   a is the next Char in the string, and b is
--   the seed value for further production. Performs replacement on invalid
--   scalar values.
unfoldr :: (a -> Maybe (Char, a)) -> a -> Text

-- | O(n) Like unfoldr, unfoldrN builds a Text
--   from a seed value. However, the length of the result should be limited
--   by the first argument to unfoldrN. This function is more
--   efficient than unfoldr when the maximum length of the result is
--   known and correct, otherwise its performance is similar to
--   unfoldr. Performs replacement on invalid scalar values.
unfoldrN :: Int -> (a -> Maybe (Char, a)) -> a -> Text

-- | O(n) take n, applied to a Text, returns
--   the prefix of the Text of length n, or the Text
--   itself if n is greater than the length of the Text.
take :: Int -> Text -> Text

-- | O(n) takeEnd n t returns the suffix
--   remaining after taking n characters from the end of
--   t.
--   
--   Examples:
--   
--   
--   >>> takeEnd 3 "foobar"
--   "bar"
--   
takeEnd :: Int -> Text -> Text

-- | O(n) drop n, applied to a Text, returns
--   the suffix of the Text after the first n characters,
--   or the empty Text if n is greater than the length of
--   the Text.
drop :: Int -> Text -> Text

-- | O(n) dropEnd n t returns the prefix
--   remaining after dropping n characters from the end of
--   t.
--   
--   Examples:
--   
--   
--   >>> dropEnd 3 "foobar"
--   "foo"
--   
dropEnd :: Int -> Text -> Text

-- | O(n) takeWhile, applied to a predicate p and a
--   Text, returns the longest prefix (possibly empty) of elements
--   that satisfy p.
takeWhile :: (Char -> Bool) -> Text -> Text

-- | O(n) takeWhileEnd, applied to a predicate p and
--   a Text, returns the longest suffix (possibly empty) of elements
--   that satisfy p. Examples:
--   
--   
--   >>> takeWhileEnd (=='o') "foo"
--   "oo"
--   
takeWhileEnd :: (Char -> Bool) -> Text -> Text

-- | O(n) dropWhile p t returns the suffix
--   remaining after takeWhile p t.
dropWhile :: (Char -> Bool) -> Text -> Text

-- | O(n) dropWhileEnd p t returns the
--   prefix remaining after dropping characters that satisfy the predicate
--   p from the end of t.
--   
--   Examples:
--   
--   
--   >>> dropWhileEnd (=='.') "foo..."
--   "foo"
--   
dropWhileEnd :: (Char -> Bool) -> Text -> Text

-- | O(n) dropAround p t returns the
--   substring remaining after dropping characters that satisfy the
--   predicate p from both the beginning and end of t.
dropAround :: (Char -> Bool) -> Text -> Text

-- | O(n) Remove leading and trailing white space from a string.
--   Equivalent to:
--   
--   
--   dropAround isSpace
--   
strip :: Text -> Text

-- | O(n) Remove leading white space from a string. Equivalent to:
--   
--   
--   dropWhile isSpace
--   
stripStart :: Text -> Text

-- | O(n) Remove trailing white space from a string. Equivalent to:
--   
--   
--   dropWhileEnd isSpace
--   
stripEnd :: Text -> Text

-- | O(n) splitAt n t returns a pair whose first
--   element is a prefix of t of length n, and whose
--   second is the remainder of the string. It is equivalent to
--   (take n t, drop n t).
splitAt :: Int -> Text -> (Text, Text)

-- | O(n) break is like span, but the prefix returned
--   is over elements that fail the predicate p.
--   
--   
--   >>> T.break (=='c') "180cm"
--   ("180","cm")
--   
break :: (Char -> Bool) -> Text -> (Text, Text)

-- | O(n) span, applied to a predicate p and text
--   t, returns a pair whose first element is the longest prefix
--   (possibly empty) of t of elements that satisfy p,
--   and whose second is the remainder of the text.
--   
--   
--   >>> T.span (=='0') "000AB"
--   ("000","AB")
--   
span :: (Char -> Bool) -> Text -> (Text, Text)

-- | O(n) Group characters in a string by equality.
group :: Text -> [Text]

-- | O(n) Group characters in a string according to a predicate.
groupBy :: (Char -> Char -> Bool) -> Text -> [Text]

-- | O(n) Return all initial segments of the given Text,
--   shortest first.
inits :: Text -> [Text]

-- | O(n) Return all final segments of the given Text,
--   longest first.
tails :: Text -> [Text]

-- | O(n) Splits a Text into components delimited by
--   separators, where the predicate returns True for a separator element.
--   The resulting components do not contain the separators. Two adjacent
--   separators result in an empty component in the output. eg.
--   
--   
--   >>> split (=='a') "aabbaca"
--   ["","","bb","c",""]
--   
--   
--   
--   >>> split (=='a') ""
--   [""]
--   
split :: (Char -> Bool) -> Text -> [Text]

-- | O(n) Splits a Text into components of length k.
--   The last element may be shorter than the other chunks, depending on
--   the length of the input. Examples:
--   
--   
--   >>> chunksOf 3 "foobarbaz"
--   ["foo","bar","baz"]
--   
--   
--   
--   >>> chunksOf 4 "haskell.org"
--   ["hask","ell.","org"]
--   
chunksOf :: Int -> Text -> [Text]

-- | O(n) Breaks a Text up into a list of Texts at
--   newline characters '\n' (LF, line feed). The resulting
--   strings do not contain newlines.
--   
--   lines does not treat '\r' (CR, carriage return)
--   as a newline character.
lines :: Text -> [Text]

-- | linesCR breaks a Text up into a list of Texts at
--   newline Chars. It is very similar to lines, but it also
--   removes any trailing 'r' characters. The resulting
--   Text values do not contain newlines or trailing 'r'
--   characters.
linesCR :: Text -> [Text]

-- | O(n) Breaks a Text up into a list of words, delimited by
--   Chars representing white space.
words :: Text -> [Text]

-- | O(n) Joins lines, after appending a terminating newline to
--   each.
unlines :: [Text] -> Text

-- | O(n) Joins words using single space characters.
unwords :: [Text] -> Text

-- | O(n) The isPrefixOf function takes two Texts and
--   returns True if and only if the first is a prefix of the
--   second.
isPrefixOf :: Text -> Text -> Bool

-- | O(n) The isSuffixOf function takes two Texts and
--   returns True if and only if the first is a suffix of the
--   second.
isSuffixOf :: Text -> Text -> Bool

-- | O(n+m) The isInfixOf function takes two Texts and
--   returns True if and only if the first is contained, wholly and
--   intact, anywhere within the second.
--   
--   In (unlikely) bad cases, this function's time complexity degrades
--   towards O(n*m).
isInfixOf :: Text -> Text -> Bool

-- | O(n) Return the suffix of the second string if its prefix
--   matches the entire first string.
--   
--   Examples:
--   
--   
--   >>> stripPrefix "foo" "foobar"
--   Just "bar"
--   
--   
--   
--   >>> stripPrefix ""    "baz"
--   Just "baz"
--   
--   
--   
--   >>> stripPrefix "foo" "quux"
--   Nothing
--   
--   
--   This is particularly useful with the ViewPatterns extension
--   to GHC, as follows:
--   
--   
--   {-# LANGUAGE ViewPatterns #-}
--   import Data.Text as T
--   
--   fnordLength :: Text -> Int
--   fnordLength (stripPrefix "fnord" -> Just suf) = T.length suf
--   fnordLength _                                 = -1
--   
stripPrefix :: Text -> Text -> Maybe Text

-- | O(n) Return the prefix of the second string if its suffix
--   matches the entire first string.
--   
--   Examples:
--   
--   
--   >>> stripSuffix "bar" "foobar"
--   Just "foo"
--   
--   
--   
--   >>> stripSuffix ""    "baz"
--   Just "baz"
--   
--   
--   
--   >>> stripSuffix "foo" "quux"
--   Nothing
--   
--   
--   This is particularly useful with the ViewPatterns extension
--   to GHC, as follows:
--   
--   
--   {-# LANGUAGE ViewPatterns #-}
--   import Data.Text as T
--   
--   quuxLength :: Text -> Int
--   quuxLength (stripSuffix "quux" -> Just pre) = T.length pre
--   quuxLength _                                = -1
--   
stripSuffix :: Text -> Text -> Maybe Text

-- | Drop prefix if present, otherwise return original Text.
dropPrefix :: Text -> Text -> Text

-- | Drop prefix if present, otherwise return original Text.
dropSuffix :: Text -> Text -> Text

-- | O(n) Find the longest non-empty common prefix of two strings
--   and return it, along with the suffixes of each string at which they no
--   longer match.
--   
--   If the strings do not have a common prefix or either one is empty,
--   this function returns Nothing.
--   
--   Examples:
--   
--   
--   >>> commonPrefixes "foobar" "fooquux"
--   Just ("foo","bar","quux")
--   
--   
--   
--   >>> commonPrefixes "veeble" "fetzer"
--   Nothing
--   
--   
--   
--   >>> commonPrefixes "" "baz"
--   Nothing
--   
commonPrefixes :: Text -> Text -> Maybe (Text, Text, Text)

-- | O(n) filter, applied to a predicate and a Text,
--   returns a Text containing those characters that satisfy the
--   predicate.
filter :: (Char -> Bool) -> Text -> Text

-- | O(n) The find function takes a predicate and a
--   Text, and returns the first element matching the predicate, or
--   Nothing if there is no such element.
find :: (Char -> Bool) -> Text -> Maybe Char

-- | O(n) The partition function takes a predicate and a
--   Text, and returns the pair of Texts with elements which
--   do and do not satisfy the predicate, respectively; i.e.
--   
--   
--   partition p t == (filter p t, filter (not . p) t)
--   
partition :: (Char -> Bool) -> Text -> (Text, Text)

-- | O(n) Text index (subscript) operator, starting from 0.
index :: HasCallStack => Text -> Int -> Char

-- | O(n) The findIndex function takes a predicate and a
--   Text and returns the index of the first element in the
--   Text satisfying the predicate.
findIndex :: (Char -> Bool) -> Text -> Maybe Int

-- | O(n) zip takes two Texts and returns a list of
--   corresponding pairs of bytes. If one input Text is short,
--   excess elements of the longer Text are discarded. This is
--   equivalent to a pair of unpack operations.
zip :: Text -> Text -> [(Char, Char)]

-- | O(n) zipWith generalises zip by zipping with the
--   function given as the first argument, instead of a tupling function.
--   Performs replacement on invalid scalar values.
zipWith :: (Char -> Char -> Char) -> Text -> Text -> Text

-- | O(n) Make a distinct copy of the given string, sharing no
--   storage with the original string.
--   
--   As an example, suppose you read a large string, of which you need only
--   a small portion. If you do not use copy, the entire original
--   array will be kept alive in memory by the smaller string. Making a
--   copy "breaks the link" to the original array, allowing it to be
--   garbage collected if there are no other live references to it.
copy :: Text -> Text

-- | O(n) Convert a null-terminated modified UTF-8 (but with
--   a standard UTF-8 representation of characters from supplementary
--   planes) string to a Text. Counterpart to
--   unpackCStringUtf8#. No validation is performed, malformed input
--   can lead to memory access violation.
unpackCString# :: Addr# -> Text

-- | Encode text using UTF-8 encoding.
encodeUtf8 :: Text -> ByteString

-- | Decode a ByteString containing UTF-8 encoded text.
--   
--   Surrogate code points in replacement character returned by
--   OnDecodeError will be automatically remapped to the replacement
--   char U+FFFD.
decodeUtf8With :: OnDecodeError -> ByteString -> Text

-- | Decode a ByteString containing UTF-8 encoded text.
--   
--   If the input contains any invalid UTF-8 data, the relevant exception
--   will be returned, otherwise the decoded text.
decodeUtf8' :: ByteString -> Either UnicodeException Text

-- | Replace an invalid input byte with the Unicode replacement character
--   U+FFFD.
lenientDecode :: OnDecodeError

module RIO

-- | The Reader+IO monad. This is different from a ReaderT because:
--   
--   
--   
- It's not a transformer, it hardcodes IO for simpler usage and
--   error messages.
--   
- Instances of typeclasses like MonadLogger are implemented
--   using classes defined on the environment, instead of using an
--   underlying monad.
--   
newtype RIO env a
RIO :: ReaderT env IO a -> RIO env a
[unRIO] :: RIO env a -> ReaderT env IO a

-- | Abstract RIO to an arbitrary MonadReader instance, which
--   can handle IO.
liftRIO :: (MonadIO m, MonadReader env m) => RIO env a -> m a

-- | Using the environment run in IO the action that requires that
--   environment.
runRIO :: MonadIO m => env -> RIO env a -> m a

-- | Given a LogOptions value, run the given function with the
--   specified LogFunc. A common way to use this function is:
--   
--   
--   let isVerbose = False -- get from the command line instead
--   logOptions' <- logOptionsHandle stderr isVerbose
--   let logOptions = setLogUseTime True logOptions'
--   withLogFunc logOptions $ \lf -> do
--     let app = App -- application specific environment
--           { appLogFunc = lf
--           , appOtherStuff = ...
--           }
--     runRIO app $ do
--       logInfo "Starting app"
--       myApp
--   
withLogFunc :: MonadUnliftIO m => LogOptions -> (LogFunc -> m a) -> m a

-- | Given a LogOptions value, returns both a new LogFunc and
--   a sub-routine that disposes it.
--   
--   Intended for use if you want to deal with the teardown of
--   LogFunc yourself, otherwise prefer the withLogFunc
--   function instead.
newLogFunc :: (MonadIO n, MonadIO m) => LogOptions -> n (LogFunc, m ())

-- | A logging function, wrapped in a newtype for better error messages.
--   
--   An implementation may choose any behavior of this value it wishes,
--   including printing to standard output or no action at all.
data LogFunc

-- | Environment values with a logging function.
class HasLogFunc env
logFuncL :: HasLogFunc env => Lens' env LogFunc

-- | Create a LogOptions value from the given Handle and
--   whether to perform verbose logging or not. Individiual settings can be
--   overridden using appropriate set functions. Logging output is
--   guaranteed to be non-interleaved only for a UTF-8 Handle in a
--   multi-thread environment.
--   
--   When Verbose Flag is True, the following happens:
--   
--   
--   
- setLogVerboseFormat is called with True
--   
- setLogUseColor is called with True (except on
--   Windows)
--   
- setLogUseLoc is called with True
--   
- setLogUseTime is called with True
--   
- setLogMinLevel is called with Debug log
--   level
--   
logOptionsHandle :: MonadIO m => Handle -> Bool -> m LogOptions

-- | Configuration for how to create a LogFunc. Intended to be used
--   with the withLogFunc function.
data LogOptions

-- | Set the minimum log level. Messages below this level will not be
--   printed.
--   
--   Default: in verbose mode, LevelDebug. Otherwise,
--   LevelInfo.
setLogMinLevel :: LogLevel -> LogOptions -> LogOptions

-- | Refer to setLogMinLevel. This modifier allows to alter the
--   verbose format value dynamically at runtime.
--   
--   Default: in verbose mode, LevelDebug. Otherwise,
--   LevelInfo.
setLogMinLevelIO :: IO LogLevel -> LogOptions -> LogOptions

-- | Use the verbose format for printing log messages.
--   
--   Default: follows the value of the verbose flag.
setLogVerboseFormat :: Bool -> LogOptions -> LogOptions

-- | Refer to setLogVerboseFormat. This modifier allows to alter the
--   verbose format value dynamically at runtime.
--   
--   Default: follows the value of the verbose flag.
setLogVerboseFormatIO :: IO Bool -> LogOptions -> LogOptions

-- | Do we treat output as a terminal. If True, we will enable
--   sticky logging functionality.
--   
--   Default: checks if the Handle provided to
--   logOptionsHandle is a terminal with hIsTerminalDevice.
setLogTerminal :: Bool -> LogOptions -> LogOptions

-- | Include the time when printing log messages.
--   
--   Default: True in debug mode, False otherwise.
setLogUseTime :: Bool -> LogOptions -> LogOptions

-- | Use ANSI color codes in the log output.
--   
--   Default: True if in verbose mode and the Handle
--   is a terminal device.
setLogUseColor :: Bool -> LogOptions -> LogOptions

-- | Use code location in the log output.
--   
--   Default: True if in verbose mode, False otherwise.
setLogUseLoc :: Bool -> LogOptions -> LogOptions

-- | Set format method for messages
--   
--   Default: id
setLogFormat :: (Utf8Builder -> Utf8Builder) -> LogOptions -> LogOptions

-- | ANSI color codes for LogLevel in the log output.
--   
--   Default: LevelDebug = "\ESC[32m" -- Green LevelInfo =
--   "\ESC[34m" -- Blue LevelWarn = "\ESC[33m" -- Yellow
--   LevelError = "\ESC[31m" -- Red LevelOther _ = "\ESC[35m"
--   -- Magenta
setLogLevelColors :: (LogLevel -> Utf8Builder) -> LogOptions -> LogOptions

-- | ANSI color codes for secondary content in the log output.
--   
--   Default: "\ESC[90m" -- Bright black (gray)
setLogSecondaryColor :: Utf8Builder -> LogOptions -> LogOptions

-- | ANSI color codes for accents in the log output. Accent colors are
--   indexed by Int.
--   
--   Default: const "\ESC[92m" -- Bright green, for all indicies
setLogAccentColors :: (Int -> Utf8Builder) -> LogOptions -> LogOptions

-- | Log a debug level message with no source.
logDebug :: (MonadIO m, MonadReader env m, HasLogFunc env, HasCallStack) => Utf8Builder -> m ()

-- | Log an info level message with no source.
logInfo :: (MonadIO m, MonadReader env m, HasLogFunc env, HasCallStack) => Utf8Builder -> m ()

-- | Log a warn level message with no source.
logWarn :: (MonadIO m, MonadReader env m, HasLogFunc env, HasCallStack) => Utf8Builder -> m ()

-- | Log an error level message with no source.
logError :: (MonadIO m, MonadReader env m, HasLogFunc env, HasCallStack) => Utf8Builder -> m ()

-- | Log a message with the specified textual level and no source.
logOther :: (MonadIO m, MonadReader env m, HasLogFunc env, HasCallStack) => Text -> Utf8Builder -> m ()

-- | Write a "sticky" line to the terminal. Any subsequent lines will
--   overwrite this one, and that same line will be repeated below again.
--   In other words, the line sticks at the bottom of the output forever.
--   Running this function again will replace the sticky line with a new
--   sticky line. When you want to get rid of the sticky line, run
--   logStickyDone.
--   
--   Note that not all LogFunc implementations will support sticky
--   messages as described. However, the withLogFunc implementation
--   provided by this module does.
logSticky :: (MonadIO m, HasCallStack, MonadReader env m, HasLogFunc env) => Utf8Builder -> m ()

-- | This will print out the given message with a newline and disable any
--   further stickiness of the line until a new call to logSticky
--   happens.
logStickyDone :: (MonadIO m, HasCallStack, MonadReader env m, HasLogFunc env) => Utf8Builder -> m ()

-- | Log a debug level message with the given source.
logDebugS :: (MonadIO m, MonadReader env m, HasLogFunc env, HasCallStack) => LogSource -> Utf8Builder -> m ()

-- | Log an info level message with the given source.
logInfoS :: (MonadIO m, MonadReader env m, HasLogFunc env, HasCallStack) => LogSource -> Utf8Builder -> m ()

-- | Log a warn level message with the given source.
logWarnS :: (MonadIO m, MonadReader env m, HasLogFunc env, HasCallStack) => LogSource -> Utf8Builder -> m ()

-- | Log an error level message with the given source.
logErrorS :: (MonadIO m, MonadReader env m, HasLogFunc env, HasCallStack) => LogSource -> Utf8Builder -> m ()

-- | Log a message with the specified textual level and the given source.
logOtherS :: (MonadIO m, MonadReader env m, HasLogFunc env, HasCallStack) => Text -> LogSource -> Utf8Builder -> m ()

-- | Generic, basic function for creating other logging functions.
logGeneric :: (MonadIO m, MonadReader env m, HasLogFunc env, HasCallStack) => LogSource -> LogLevel -> Utf8Builder -> m ()

-- | Create a LogFunc from the given function.
mkLogFunc :: (CallStack -> LogSource -> LogLevel -> Utf8Builder -> IO ()) -> LogFunc

-- | Create a LogOptions value which will store its data in memory.
--   This is primarily intended for testing purposes. This will return both
--   a LogOptions value and an IORef containing the resulting
--   Builder value.
--   
--   This will default to non-verbose settings and assume there is a
--   terminal attached. These assumptions can be overridden using the
--   appropriate set functions.
logOptionsMemory :: MonadIO m => m (IORef Builder, LogOptions)

-- | The log level of a message.
data LogLevel
LevelDebug :: LogLevel
LevelInfo :: LogLevel
LevelWarn :: LogLevel
LevelError :: LogLevel
LevelOther :: !Text -> LogLevel

-- | Where in the application a log message came from. Used for display
--   purposes only.
type LogSource = Text

-- | CallStacks are a lightweight method of obtaining a partial
--   call-stack at any point in the program.
--   
--   A function can request its call-site with the HasCallStack
--   constraint. For example, we can define
--   
--   
--   putStrLnWithCallStack :: HasCallStack => String -> IO ()
--   
--   
--   as a variant of putStrLn that will get its call-site and
--   print it, along with the string given as argument. We can access the
--   call-stack inside putStrLnWithCallStack with
--   callStack.
--   
--   
--   >>> :{
--   putStrLnWithCallStack :: HasCallStack => String -> IO ()
--   putStrLnWithCallStack msg = do
--     putStrLn msg
--     putStrLn (prettyCallStack callStack)
--   :}
--   
--   
--   Thus, if we call putStrLnWithCallStack we will get a
--   formatted call-stack alongside our string.
--   
--   
--   >>> putStrLnWithCallStack "hello"
--   hello
--   CallStack (from HasCallStack):
--     putStrLnWithCallStack, called at <interactive>:... in interactive:Ghci...
--   
--   
--   GHC solves HasCallStack constraints in three steps:
--   
--   
--   
- If there is a CallStack in scope -- i.e. the enclosing
--   function has a HasCallStack constraint -- GHC will append the
--   new call-site to the existing CallStack.
--   
- If there is no CallStack in scope -- e.g. in the GHCi
--   session above -- and the enclosing definition does not have an
--   explicit type signature, GHC will infer a HasCallStack
--   constraint for the enclosing definition (subject to the monomorphism
--   restriction).
--   
- If there is no CallStack in scope and the enclosing
--   definition has an explicit type signature, GHC will solve the
--   HasCallStack constraint for the singleton CallStack
--   containing just the current call-site.
--   
--   
--   CallStacks do not interact with the RTS and do not require
--   compilation with -prof. On the other hand, as they are built
--   up explicitly via the HasCallStack constraints, they will
--   generally not contain as much information as the simulated call-stacks
--   maintained by the RTS.
--   
--   A CallStack is a [(String, SrcLoc)]. The
--   String is the name of function that was called, the
--   SrcLoc is the call-site. The list is ordered with the most
--   recently called function at the head.
--   
--   NOTE: The intrepid user may notice that HasCallStack is just an
--   alias for an implicit parameter ?callStack :: CallStack. This
--   is an implementation detail and should not be considered part
--   of the CallStack API, we may decide to change the
--   implementation in the future.
data () => CallStack

-- | Convert a CallStack value into a Utf8Builder indicating
--   the first source location.
--   
--   TODO Consider showing the entire call stack instead.
displayCallStack :: CallStack -> Utf8Builder

-- | Disable logging capabilities in a given sub-routine
--   
--   Intended to skip logging in general purpose implementations, where
--   secrets might be logged accidently.
noLogging :: (HasLogFunc env, MonadReader env m) => m a -> m a

-- | Is the log func configured to use color output?
--   
--   Intended for use by code which wants to optionally add additional
--   color to its log messages.
logFuncUseColorL :: HasLogFunc env => SimpleGetter env Bool

-- | What color is the log func configured to use for each LogLevel?
--   
--   Intended for use by code which wants to optionally add additional
--   color to its log messages.
logFuncLogLevelColorsL :: HasLogFunc env => SimpleGetter env (LogLevel -> Utf8Builder)

-- | What color is the log func configured to use for secondary content?
--   
--   Intended for use by code which wants to optionally add additional
--   color to its log messages.
logFuncSecondaryColorL :: HasLogFunc env => SimpleGetter env Utf8Builder

-- | What accent colors, indexed by Int, is the log func configured
--   to use?
--   
--   Intended for use by code which wants to optionally add additional
--   color to its log messages.
logFuncAccentColorsL :: HasLogFunc env => SimpleGetter env (Int -> Utf8Builder)

-- | Log a value generically.
glog :: (MonadIO m, HasCallStack, HasGLogFunc env, MonadReader env m) => GMsg env -> m ()

-- | A generic logger of some type msg.
--   
--   Your GLocFunc can re-use the existing classical logging
--   framework of RIO, and/or implement additional transforms, filters.
--   Alternatively, you may log to a JSON source in a database, or anywhere
--   else as needed. You can decide how to log levels or severities based
--   on the constructors in your type. You will normally determine this in
--   your main app entry point.
data GLogFunc msg

-- | Make a GLogFunc via classic LogFunc. Use this if you'd
--   like to log your generic data type via the classic RIO terminal
--   logger.
gLogFuncClassic :: (HasLogLevel msg, HasLogSource msg, Display msg) => LogFunc -> GLogFunc msg

-- | Make a custom generic logger. With this you could, for example, write
--   to a database or a log digestion service. For example:
--   
--   
--   mkGLogFunc (\stack msg -> send (Data.Aeson.encode (JsonLog stack msg)))
--   
mkGLogFunc :: (CallStack -> msg -> IO ()) -> GLogFunc msg

-- | A vesion of contramapMaybeGLogFunc which supports filering.
contramapMaybeGLogFunc :: (a -> Maybe b) -> GLogFunc b -> GLogFunc a

-- | A contramap. Use this to wrap sub-loggers via mapRIO.
--   
--   If you are on base > 4.12.0, you can just use contramap.
contramapGLogFunc :: (a -> b) -> GLogFunc b -> GLogFunc a

-- | An app is capable of generic logging if it implements this.
class HasGLogFunc env where {
    type GMsg env;
}
gLogFuncL :: HasGLogFunc env => Lens' env (GLogFunc (GMsg env))

-- | Level, if any, of your logs. If unknown, use LogOther. Use
--   for your generic log data types that want to sit inside the classic
--   log framework.
class HasLogLevel msg
getLogLevel :: HasLogLevel msg => msg -> LogLevel

-- | Source of a log. This can be whatever you want. Use for your generic
--   log data types that want to sit inside the classic log framework.
class HasLogSource msg
getLogSource :: HasLogSource msg => msg -> LogSource

-- | A builder of binary data, with the invariant that the underlying data
--   is supposed to be UTF-8 encoded.
newtype Utf8Builder
Utf8Builder :: Builder -> Utf8Builder
[getUtf8Builder] :: Utf8Builder -> Builder

-- | A typeclass for values which can be converted to a Utf8Builder.
--   The intention of this typeclass is to provide a human-friendly display
--   of the data.
class Display a
display :: Display a => a -> Utf8Builder

-- | Display data as Text, which will also be used for
--   display if it is not overriden.
textDisplay :: Display a => a -> Text

-- | Use the Show instance for a value to convert it to a
--   Utf8Builder.
displayShow :: Show a => a -> Utf8Builder

-- | Convert a Utf8Builder value into a strict Text.
utf8BuilderToText :: Utf8Builder -> Text

-- | Convert a Utf8Builder value into a lazy Text.
utf8BuilderToLazyText :: Utf8Builder -> Text

-- | Convert a ByteString into a Utf8Builder.
--   
--   NOTE This function performs no checks to ensure that the data
--   is, in fact, UTF8 encoded. If you provide non-UTF8 data, later
--   functions may fail.
displayBytesUtf8 :: ByteString -> Utf8Builder

-- | Write the given Utf8Builder value to a file.
writeFileUtf8Builder :: MonadIO m => FilePath -> Utf8Builder -> m ()

-- | view is a synonym for (^.), generalised for
--   MonadReader (we are able to use it instead of (^.) since
--   functions are instances of the MonadReader class):
--   
--   
--   >>> view _1 (1, 2)
--   1
--   
--   
--   When you're using Reader for config and your config type has
--   lenses generated for it, most of the time you'll be using view
--   instead of asks:
--   
--   
--   doSomething :: (MonadReader Config m) => m Int
--   doSomething = do
--     thingy        <- view setting1  -- same as “asks (^. setting1)”
--     anotherThingy <- view setting2
--     ...
--   
view :: MonadReader s m => Getting a s a -> m a

-- | preview is a synonym for (^?), generalised for
--   MonadReader (just like view, which is a synonym for
--   (^.)).
--   
--   
--   >>> preview each [1..5]
--   Just 1
--   
preview :: MonadReader s m => Getting (First a) s a -> m (Maybe a)

-- | ASetter s t a b is something that turns a function modifying
--   a value into a function modifying a structure. If you ignore
--   Identity (as Identity a is the same thing as
--   a), the type is:
--   
--   
--   type ASetter s t a b = (a -> b) -> s -> t
--   
--   
--   The reason Identity is used here is for ASetter to be
--   composable with other types, such as Lens.
--   
--   Technically, if you're writing a library, you shouldn't use this type
--   for setters you are exporting from your library; the right type to use
--   is Setter, but it is not provided by this package
--   (because then it'd have to depend on distributive). It's
--   completely alright, however, to export functions which take an
--   ASetter as an argument.
type ASetter s t a b = a -> Identity b -> s -> Identity t

-- | This is a type alias for monomorphic setters which don't change the
--   type of the container (or of the value inside). It's useful more often
--   than the same type in lens, because we can't provide real setters and
--   so it does the job of both ASetter' and
--   Setter'.
type ASetter' s a = ASetter s s a a

-- | Functions that operate on getters and folds – such as (^.),
--   (^..), (^?) – use Getter r s a (with different
--   values of r) to describe what kind of result they need. For
--   instance, (^.) needs the getter to be able to return a single
--   value, and so it accepts a getter of type Getting a s a.
--   (^..) wants the getter to gather values together, so it uses
--   Getting (Endo [a]) s a (it could've used Getting [a] s
--   a instead, but it's faster with Endo). The choice of
--   r depends on what you want to do with elements you're
--   extracting from s.
type Getting r s a = a -> Const r a -> s -> Const r s

-- | Lens s t a b is the lowest common denominator of a setter and
--   a getter, something that has the power of both; it has a
--   Functor constraint, and since both Const and
--   Identity are functors, it can be used whenever a getter or a
--   setter is needed.
--   
--   
--   
- a is the type of the value inside of structure
--   
- b is the type of the replaced value
--   
- s is the type of the whole structure
--   
- t is the type of the structure after replacing a
--   in it with b
--   
type Lens s t a b = forall (f :: Type -> Type). Functor f => a -> f b -> s -> f t

-- | This is a type alias for monomorphic lenses which don't change the
--   type of the container (or of the value inside).
type Lens' s a = Lens s s a a

-- | A SimpleGetter s a extracts a from s; so,
--   it's the same thing as (s -> a), but you can use it in
--   lens chains because its type looks like this:
--   
--   
--   type SimpleGetter s a =
--     forall r. (a -> Const r a) -> s -> Const r s
--   
--   
--   Since Const r is a functor, SimpleGetter has the same
--   shape as other lens types and can be composed with them. To get (s
--   -> a) out of a SimpleGetter, choose r ~ a and
--   feed Const :: a -> Const a a to the getter:
--   
--   
--   -- the actual signature is more permissive:
--   -- view :: Getting a s a -> s -> a
--   view :: SimpleGetter s a -> s -> a
--   view getter = getConst . getter Const
--   
--   
--   The actual Getter from lens is more general:
--   
--   
--   type Getter s a =
--     forall f. (Contravariant f, Functor f) => (a -> f a) -> s -> f s
--   
--   
--   I'm not currently aware of any functions that take lens's
--   Getter but won't accept SimpleGetter, but you should
--   try to avoid exporting SimpleGetters anyway to minimise
--   confusion. Alternatively, look at microlens-contra, which
--   provides a fully lens-compatible Getter.
--   
--   Lens users: you can convert a SimpleGetter to Getter
--   by applying to . view to it.
type SimpleGetter s a = forall r. () => Getting r s a

-- | lens creates a Lens from a getter and a setter. The
--   resulting lens isn't the most effective one (because of having to
--   traverse the structure twice when modifying), but it shouldn't matter
--   much.
--   
--   A (partial) lens for list indexing:
--   
--   
--   ix :: Int -> Lens' [a] a
--   ix i = lens (!! i)                                   -- getter
--               (\s b -> take i s ++ b : drop (i+1) s)   -- setter
--   
--   
--   Usage:
--   
--   
--   >>> [1..9] ^. ix 3
--   4
--   
--   >>> [1..9] & ix 3 %~ negate
--   [1,2,3,-4,5,6,7,8,9]
--   
--   
--   When getting, the setter is completely unused; when setting, the
--   getter is unused. Both are used only when the value is being modified.
--   For instance, here we define a lens for the 1st element of a list, but
--   instead of a legitimate getter we use undefined. Then we use
--   the resulting lens for setting and it works, which proves that
--   the getter wasn't used:
--   
--   
--   >>> [1,2,3] & lens undefined (\s b -> b : tail s) .~ 10
--   [10,2,3]
--   
lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b

-- | over is a synonym for (%~).
--   
--   Getting fmap in a roundabout way:
--   
--   
--   over mapped :: Functor f => (a -> b) -> f a -> f b
--   over mapped = fmap
--   
--   
--   Applying a function to both components of a pair:
--   
--   
--   over both :: (a -> b) -> (a, a) -> (b, b)
--   over both = \f t -> (f (fst t), f (snd t))
--   
--   
--   Using over _2 as a replacement for
--   second:
--   
--   
--   >>> over _2 show (10,20)
--   (10,"20")
--   
over :: ASetter s t a b -> (a -> b) -> s -> t

-- | set is a synonym for (.~).
--   
--   Setting the 1st component of a pair:
--   
--   
--   set _1 :: x -> (a, b) -> (x, b)
--   set _1 = \x t -> (x, snd t)
--   
--   
--   Using it to rewrite (<$):
--   
--   
--   set mapped :: Functor f => a -> f b -> f a
--   set mapped = (<$)
--   
set :: ASetter s t a b -> b -> s -> t

-- | sets creates an ASetter from an ordinary function. (The
--   only thing it does is wrapping and unwrapping Identity.)
sets :: ((a -> b) -> s -> t) -> ASetter s t a b

-- | to creates a getter from any function:
--   
--   
--   a ^. to f = f a
--   
--   
--   It's most useful in chains, because it lets you mix lenses and
--   ordinary functions. Suppose you have a record which comes from some
--   third-party library and doesn't have any lens accessors. You want to
--   do something like this:
--   
--   
--   value ^. _1 . field . at 2
--   
--   
--   However, field isn't a getter, and you have to do this
--   instead:
--   
--   
--   field (value ^. _1) ^. at 2
--   
--   
--   but now value is in the middle and it's hard to read the
--   resulting code. A variant with to is prettier and more
--   readable:
--   
--   
--   value ^. _1 . to field . at 2
--   
to :: (s -> a) -> SimpleGetter s a

-- | (^.) applies a getter to a value; in other words, it gets a
--   value out of a structure using a getter (which can be a lens,
--   traversal, fold, etc.).
--   
--   Getting 1st field of a tuple:
--   
--   
--   (^. _1) :: (a, b) -> a
--   (^. _1) = fst
--   
--   
--   When (^.) is used with a traversal, it combines all results
--   using the Monoid instance for the resulting type. For instance,
--   for lists it would be simple concatenation:
--   
--   
--   >>> ("str","ing") ^. each
--   "string"
--   
--   
--   The reason for this is that traversals use Applicative, and the
--   Applicative instance for Const uses monoid concatenation
--   to combine “effects” of Const.
--   
--   A non-operator version of (^.) is called view, and
--   it's a bit more general than (^.) (it works in
--   MonadReader). If you need the general version, you can get it
--   from microlens-mtl; otherwise there's view available in
--   Lens.Micro.Extras.
(^.) :: s -> Getting a s a -> a
infixl 8 ^.

-- | s ^? t returns the 1st element t returns, or
--   Nothing if t doesn't return anything. It's trivially
--   implemented by passing the First monoid to the getter.
--   
--   Safe head:
--   
--   
--   >>> [] ^? each
--   Nothing
--   
--   
--   
--   >>> [1..3] ^? each
--   Just 1
--   
--   
--   Converting Either to Maybe:
--   
--   
--   >>> Left 1 ^? _Right
--   Nothing
--   
--   
--   
--   >>> Right 1 ^? _Right
--   Just 1
--   
--   
--   A non-operator version of (^?) is called preview, and
--   – like view – it's a bit more general than (^?) (it
--   works in MonadReader). If you need the general version, you
--   can get it from microlens-mtl; otherwise there's preview
--   available in Lens.Micro.Extras.
(^?) :: s -> Getting (First a) s a -> Maybe a
infixl 8 ^?

-- | s ^.. t returns the list of all values that t gets
--   from s.
--   
--   A Maybe contains either 0 or 1 values:
--   
--   
--   >>> Just 3 ^.. _Just
--   [3]
--   
--   
--   Gathering all values in a list of tuples:
--   
--   
--   >>> [(1,2),(3,4)] ^.. each.each
--   [1,2,3,4]
--   
(^..) :: s -> Getting (Endo [a]) s a -> [a]
infixl 8 ^..

-- | (%~) applies a function to the target; an alternative
--   explanation is that it is an inverse of sets, which turns a
--   setter into an ordinary function. mapped %~
--   reverse is the same thing as fmap
--   reverse.
--   
--   See over if you want a non-operator synonym.
--   
--   Negating the 1st element of a pair:
--   
--   
--   >>> (1,2) & _1 %~ negate
--   (-1,2)
--   
--   
--   Turning all Lefts in a list to upper case:
--   
--   
--   >>> (mapped._Left.mapped %~ toUpper) [Left "foo", Right "bar"]
--   [Left "FOO",Right "bar"]
--   
(%~) :: ASetter s t a b -> (a -> b) -> s -> t
infixr 4 %~

-- | (.~) assigns a value to the target. It's the same thing as
--   using (%~) with const:
--   
--   
--   l .~ x = l %~ const x
--   
--   
--   See set if you want a non-operator synonym.
--   
--   Here it is used to change 2 fields of a 3-tuple:
--   
--   
--   >>> (0,0,0) & _1 .~ 1 & _3 .~ 3
--   (1,0,3)
--   
(.~) :: ASetter s t a b -> b -> s -> t
infixr 4 .~

-- | A ThreadId is an abstract type representing a handle to a
--   thread. ThreadId is an instance of Eq, Ord and
--   Show, where the Ord instance implements an arbitrary
--   total ordering over ThreadIds. The Show instance lets
--   you convert an arbitrary-valued ThreadId to string form;
--   showing a ThreadId value is occasionally useful when debugging
--   or diagnosing the behaviour of a concurrent program.
--   
--   Note: in GHC, if you have a ThreadId, you essentially
--   have a pointer to the thread itself. This means the thread itself
--   can't be garbage collected until you drop the ThreadId. This
--   misfeature will hopefully be corrected at a later date.
data () => ThreadId

-- | Lifted version of myThreadId.
myThreadId :: MonadIO m => m ThreadId

-- | Lifted version of isCurrentThreadBound.
isCurrentThreadBound :: MonadIO m => m Bool

-- | Lifted version of threadWaitRead.
threadWaitRead :: MonadIO m => Fd -> m ()

-- | Lifted version of threadWaitWrite.
threadWaitWrite :: MonadIO m => Fd -> m ()

-- | Lifted version of threadDelay.
threadDelay :: MonadIO m => Int -> m ()
yieldThread :: MonadIO m => m ()

-- | Throw an exception. Note that this throws when this action is run in
--   the monad m, not when it is applied. It is a generalization
--   of Control.Exception's throwIO.
--   
--   Should satisfy the law:
--   
--   
--   throwM e >> f = throwM e
--   
throwM :: (MonadThrow m, Exception e) => e -> m a

-- | Lazily get the contents of a file. Unlike readFile, this
--   ensures that if an exception is thrown, the file handle is closed
--   immediately.
withLazyFile :: MonadUnliftIO m => FilePath -> (ByteString -> m a) -> m a

-- | Lazily read a file in UTF8 encoding.
withLazyFileUtf8 :: MonadUnliftIO m => FilePath -> (Text -> m a) -> m a

-- | Same as readFile, but generalized to MonadIO
readFileBinary :: MonadIO m => FilePath -> m ByteString

-- | Same as writeFile, but generalized to MonadIO
writeFileBinary :: MonadIO m => FilePath -> ByteString -> m ()

-- | Read a file in UTF8 encoding, throwing an exception on invalid
--   character encoding.
--   
--   This function will use OS-specific line ending handling.
readFileUtf8 :: MonadIO m => FilePath -> m Text

-- | Write a file in UTF8 encoding
--   
--   This function will use OS-specific line ending handling.
writeFileUtf8 :: MonadIO m => FilePath -> Text -> m ()
hPutBuilder :: MonadIO m => Handle -> Builder -> m ()

-- | Lifted version of "System.Exit.exitFailure".
--   
--   @since 0.1.9.0.
exitFailure :: MonadIO m => m a

-- | Lifted version of "System.Exit.exitSuccess".
--   
--   @since 0.1.9.0.
exitSuccess :: MonadIO m => m a

-- | Lifted version of "System.Exit.exitWith".
--   
--   @since 0.1.9.0.
exitWith :: MonadIO m => ExitCode -> m a

-- | Defines the exit codes that a program can return.
data () => ExitCode

-- | indicates successful termination;
ExitSuccess :: ExitCode

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

-- | Abstraction over how to read from and write to a mutable reference
data SomeRef a

-- | Environment values with stateful capabilities to SomeRef
class HasStateRef s env | env -> s
stateRefL :: HasStateRef s env => Lens' env (SomeRef s)

-- | Environment values with writing capabilities to SomeRef
class HasWriteRef w env | env -> w
writeRefL :: HasWriteRef w env => Lens' env (SomeRef w)

-- | Lift one RIO env to another.
mapRIO :: (outer -> inner) -> RIO inner a -> RIO outer a

-- | create a new boxed SomeRef
newSomeRef :: MonadIO m => a -> m (SomeRef a)

-- | create a new unboxed SomeRef
newUnboxedSomeRef :: (MonadIO m, Unbox a) => a -> m (SomeRef a)

-- | Read from a SomeRef
readSomeRef :: MonadIO m => SomeRef a -> m a

-- | Write to a SomeRef
writeSomeRef :: MonadIO m => SomeRef a -> a -> m ()

-- | Modify a SomeRef This function is subject to change due to the lack of
--   atomic operations
modifySomeRef :: MonadIO m => SomeRef a -> (a -> a) -> m ()

-- | An unboxed reference. This works like an IORef, but the data is
--   stored in a bytearray instead of a heap object, avoiding significant
--   allocation overhead in some cases. For a concrete example, see this
--   Stack Overflow question:
--   https://stackoverflow.com/questions/27261813/why-is-my-little-stref-int-require-allocating-gigabytes.
--   
--   The first parameter is the state token type, the same as would be used
--   for the ST monad. If you're using an IO-based monad, you
--   can use the convenience IOURef type synonym instead.
data URef s a

-- | Helpful type synonym for using a URef from an IO-based
--   stack.
type IOURef = URef (PrimState IO)

-- | Create a new URef
newURef :: (PrimMonad m, Unbox a) => a -> m (URef (PrimState m) a)

-- | Read the value in a URef
readURef :: (PrimMonad m, Unbox a) => URef (PrimState m) a -> m a

-- | Write a value into a URef. Note that this action is strict, and
--   will force evalution of the value.
writeURef :: (PrimMonad m, Unbox a) => URef (PrimState m) a -> a -> m ()

-- | Modify a value in a URef. Note that this action is strict, and
--   will force evaluation of the result value.
modifyURef :: (PrimMonad m, Unbox a) => URef (PrimState m) a -> (a -> a) -> m ()

-- | Warning: Trace statement left in code
trace :: Text -> a -> a

-- | Warning: Trace statement left in code
traceId :: Text -> Text

-- | Warning: Trace statement left in code
traceIO :: MonadIO m => Text -> m ()

-- | Warning: Trace statement left in code
traceM :: Applicative f => Text -> f ()

-- | Warning: Trace statement left in code
traceEvent :: Text -> a -> a

-- | Warning: Trace statement left in code
traceEventIO :: MonadIO m => Text -> m ()

-- | Warning: Trace statement left in code
traceMarker :: Text -> a -> a

-- | Warning: Trace statement left in code
traceMarkerIO :: MonadIO m => Text -> m ()

-- | Warning: Trace statement left in code
traceStack :: Text -> a -> a

-- | Warning: Trace statement left in code
traceShow :: Show a => a -> b -> b

-- | Warning: Trace statement left in code
traceShowId :: Show a => a -> a

-- | Warning: Trace statement left in code
traceShowIO :: (Show a, MonadIO m) => a -> m ()

-- | Warning: Trace statement left in code
traceShowM :: (Show a, Applicative f) => a -> f ()

-- | Warning: Trace statement left in code
traceShowEvent :: Show a => a -> b -> b

-- | Warning: Trace statement left in code
traceShowEventIO :: (Show a, MonadIO m) => a -> m ()

-- | Warning: Trace statement left in code
traceShowMarker :: Show a => a -> b -> b

-- | Warning: Trace statement left in code
traceShowMarkerIO :: (Show a, MonadIO m) => a -> m ()

-- | Warning: Trace statement left in code
traceShowStack :: Show a => a -> b -> b

-- | Warning: Trace statement left in code
traceDisplay :: Display a => a -> b -> b

-- | Warning: Trace statement left in code
traceDisplayId :: Display a => a -> a

-- | Warning: Trace statement left in code
traceDisplayIO :: (Display a, MonadIO m) => a -> m ()

-- | Warning: Trace statement left in code
traceDisplayM :: (Display a, Applicative f) => a -> f ()

-- | Warning: Trace statement left in code
traceDisplayEvent :: Display a => a -> b -> b

-- | Warning: Trace statement left in code
traceDisplayEventIO :: (Display a, MonadIO m) => a -> m ()

-- | Warning: Trace statement left in code
traceDisplayMarker :: Display a => a -> b -> b

-- | Warning: Trace statement left in code
traceDisplayMarkerIO :: (Display a, MonadIO m) => a -> m ()

-- | Warning: Trace statement left in code
traceDisplayStack :: Display a => a -> b -> b

-- | Lazy ByteString. Import as:
--   
--   
--   import qualified RIO.ByteString.Lazy as BL
--   
--   
--   This module does not export any partial functions. For those, see
--   RIO.ByteString.Lazy.Partial
module RIO.ByteString.Lazy

-- | A space-efficient representation of a Word8 vector, supporting
--   many efficient operations.
--   
--   A lazy ByteString contains 8-bit bytes, or by using the
--   operations from Data.ByteString.Lazy.Char8 it can be
--   interpreted as containing 8-bit characters.
data () => ByteString

-- | O(1) The empty ByteString
empty :: ByteString

-- | O(1) Convert a Word8 into a ByteString
singleton :: Word8 -> ByteString

-- | O(n) Convert a '[Word8]' into a ByteString.
pack :: [Word8] -> ByteString

-- | O(n) Converts a ByteString to a '[Word8]'.
unpack :: ByteString -> [Word8]

-- | O(1) Convert a strict ByteString into a lazy
--   ByteString.
fromStrict :: ByteString -> ByteString

-- | O(n) Convert a lazy ByteString into a strict
--   ByteString.
--   
--   Note that this is an expensive operation that forces the whole
--   lazy ByteString into memory and then copies all the data. If possible,
--   try to avoid converting back and forth between strict and lazy
--   bytestrings.
toStrict :: ByteString -> ByteString

-- | O(c) Convert a list of strict ByteString into a lazy
--   ByteString
fromChunks :: [ByteString] -> ByteString

-- | O(c) Convert a lazy ByteString into a list of strict
--   ByteString
toChunks :: ByteString -> [ByteString]

-- | Consume the chunks of a lazy ByteString with a natural right fold.
foldrChunks :: (ByteString -> a -> a) -> a -> ByteString -> a

-- | Consume the chunks of a lazy ByteString with a strict, tail-recursive,
--   accumulating left fold.
foldlChunks :: (a -> ByteString -> a) -> a -> ByteString -> a

-- | O(1) cons is analogous to (:) for lists.
cons :: Word8 -> ByteString -> ByteString
infixr 5 `cons`

-- | O(1) Unlike cons, cons' is strict in the
--   ByteString that we are consing onto. More precisely, it forces the
--   head and the first chunk. It does this because, for space efficiency,
--   it may coalesce the new byte onto the first 'chunk' rather than
--   starting a new 'chunk'.
--   
--   So that means you can't use a lazy recursive contruction like this:
--   
--   
--   let xs = cons' c xs in xs
--   
--   
--   You can however use cons, as well as repeat and
--   cycle, to build infinite lazy ByteStrings.
cons' :: Word8 -> ByteString -> ByteString
infixr 5 `cons'`

-- | O(n/c) Append a byte to the end of a ByteString
snoc :: ByteString -> Word8 -> ByteString
infixl 5 `snoc`

-- | O(n/c) Append two ByteStrings
append :: ByteString -> ByteString -> ByteString

-- | O(1) Extract the head and tail of a ByteString,
--   returning Nothing if it is empty.
uncons :: ByteString -> Maybe (Word8, ByteString)

-- | O(n/c) Extract the init and last of a ByteString,
--   returning Nothing if it is empty.
--   
--   
--   
- It is no faster than using init and last
--   
unsnoc :: ByteString -> Maybe (ByteString, Word8)

-- | O(1) Test whether a ByteString is empty.
null :: ByteString -> Bool

-- | O(c) length returns the length of a ByteString as an
--   Int64
length :: ByteString -> Int64

-- | O(n) map f xs is the ByteString obtained by
--   applying f to each element of xs.
map :: (Word8 -> Word8) -> ByteString -> ByteString

-- | O(n) reverse xs returns the elements of
--   xs in reverse order.
reverse :: ByteString -> ByteString

-- | The intersperse function takes a Word8 and a
--   ByteString and `intersperses' that byte between the elements of
--   the ByteString. It is analogous to the intersperse function on
--   Lists.
intersperse :: Word8 -> ByteString -> ByteString

-- | O(n) The intercalate function takes a ByteString
--   and a list of ByteStrings and concatenates the list after
--   interspersing the first argument between each element of the list.
intercalate :: ByteString -> [ByteString] -> ByteString

-- | The transpose function transposes the rows and columns of its
--   ByteString argument.
transpose :: [ByteString] -> [ByteString]

-- | foldl, applied to a binary operator, a starting value
--   (typically the left-identity of the operator), and a ByteString,
--   reduces the ByteString using the binary operator, from left to right.
foldl :: (a -> Word8 -> a) -> a -> ByteString -> a

-- | foldl' is like foldl, but strict in the accumulator.
foldl' :: (a -> Word8 -> a) -> a -> ByteString -> a

-- | foldr, applied to a binary operator, a starting value
--   (typically the right-identity of the operator), and a ByteString,
--   reduces the ByteString using the binary operator, from right to left.
foldr :: (Word8 -> a -> a) -> a -> ByteString -> a

-- | O(n) Concatenate a list of ByteStrings.
concat :: [ByteString] -> ByteString

-- | Map a function over a ByteString and concatenate the results
concatMap :: (Word8 -> ByteString) -> ByteString -> ByteString

-- | O(n) Applied to a predicate and a ByteString, any
--   determines if any element of the ByteString satisfies the
--   predicate.
any :: (Word8 -> Bool) -> ByteString -> Bool

-- | O(n) Applied to a predicate and a ByteString, all
--   determines if all elements of the ByteString satisfy the
--   predicate.
all :: (Word8 -> Bool) -> ByteString -> Bool

-- | 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
--   
--   
--   head (scanl f z xs) == z
--   last (scanl f z xs) == foldl f z xs
--   
scanl :: (Word8 -> Word8 -> Word8) -> Word8 -> ByteString -> ByteString

-- | The mapAccumL function behaves like a combination of map
--   and foldl; it applies a function to each element of a
--   ByteString, passing an accumulating parameter from left to right, and
--   returning a final value of this accumulator together with the new
--   ByteString.
mapAccumL :: (acc -> Word8 -> (acc, Word8)) -> acc -> ByteString -> (acc, ByteString)

-- | The mapAccumR function behaves like a combination of map
--   and foldr; it applies a function to each element of a
--   ByteString, passing an accumulating parameter from right to left, and
--   returning a final value of this accumulator together with the new
--   ByteString.
mapAccumR :: (acc -> Word8 -> (acc, Word8)) -> acc -> ByteString -> (acc, ByteString)

-- | repeat x is an infinite ByteString, with x
--   the value of every element.
repeat :: Word8 -> ByteString

-- | O(n) replicate n x is a ByteString of length
--   n with x the value of every element.
replicate :: Int64 -> Word8 -> ByteString

-- | cycle ties a finite ByteString into a circular one, or
--   equivalently, the infinite repetition of the original ByteString.
cycle :: HasCallStack => ByteString -> ByteString

-- | iterate f x returns an infinite ByteString of repeated
--   applications of f to x:
--   
--   
--   iterate f x == [x, f x, f (f x), ...]
--   
iterate :: (Word8 -> Word8) -> Word8 -> ByteString

-- | O(n) The unfoldr function is analogous to the List
--   'unfoldr'. unfoldr builds a ByteString from a seed value. The
--   function takes the element and returns Nothing if it is done
--   producing the ByteString or returns Just (a,b), in
--   which case, a is a prepending to the ByteString and
--   b is used as the next element in a recursive call.
unfoldr :: (a -> Maybe (Word8, a)) -> a -> ByteString

-- | O(n/c) take n, applied to a ByteString
--   xs, returns the prefix of xs of length n,
--   or xs itself if n > length xs.
take :: Int64 -> ByteString -> ByteString

-- | O(n/c) drop n xs returns the suffix of
--   xs after the first n elements, or empty if
--   n > length xs.
drop :: Int64 -> ByteString -> ByteString

-- | O(n/c) splitAt n xs is equivalent to
--   (take n xs, drop n xs).
splitAt :: Int64 -> ByteString -> (ByteString, ByteString)

-- | Similar to takeWhile, returns the longest (possibly empty)
--   prefix of elements satisfying the predicate.
takeWhile :: (Word8 -> Bool) -> ByteString -> ByteString

-- | Similar to dropWhile, drops the longest (possibly empty) prefix
--   of elements satisfying the predicate and returns the remainder.
dropWhile :: (Word8 -> Bool) -> ByteString -> ByteString

-- | Similar to span, returns the longest (possibly empty) prefix of
--   elements satisfying the predicate and the remainder of the string.
--   
--   span p is equivalent to break (not .
--   p) and to (takeWhile p &&&
--   dropWhile p).
span :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)

-- | Similar to break, returns the longest (possibly empty) prefix
--   of elements which do not satisfy the predicate and the
--   remainder of the string.
--   
--   break p is equivalent to span (not .
--   p) and to (takeWhile (not . p) &&&
--   dropWhile (not . p)).
break :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)

-- | The group function takes a ByteString and returns a list of
--   ByteStrings such that the concatenation of the result is equal to the
--   argument. Moreover, each string in the result contains only equal
--   elements. For example,
--   
--   
--   group "Mississippi" = ["M","i","ss","i","ss","i","pp","i"]
--   
--   
--   It is a special case of groupBy, which allows the programmer to
--   supply their own equality test.
group :: ByteString -> [ByteString]

-- | The groupBy function is the non-overloaded version of
--   group.
groupBy :: (Word8 -> Word8 -> Bool) -> ByteString -> [ByteString]

-- | Returns all initial segments of the given ByteString, shortest
--   first.
inits :: ByteString -> [ByteString]

-- | O(n) Returns all final segments of the given ByteString,
--   longest first.
tails :: ByteString -> [ByteString]

-- | O(n) The stripPrefix function takes two ByteStrings and
--   returns Just the remainder of the second iff the first is its
--   prefix, and otherwise Nothing.
stripPrefix :: ByteString -> ByteString -> Maybe ByteString

-- | O(n) The stripSuffix function takes two ByteStrings and
--   returns Just the remainder of the second iff the first is its
--   suffix, and otherwise Nothing.
stripSuffix :: ByteString -> ByteString -> Maybe ByteString

-- | O(n) Break a ByteString into pieces separated by the
--   byte argument, consuming the delimiter. I.e.
--   
--   
--   split 10  "a\nb\nd\ne" == ["a","b","d","e"]   -- fromEnum '\n' == 10
--   split 97  "aXaXaXa"    == ["","X","X","X",""] -- fromEnum 'a' == 97
--   split 120 "x"          == ["",""]             -- fromEnum 'x' == 120
--   split undefined ""     == []                  -- and not [""]
--   
--   
--   and
--   
--   
--   intercalate [c] . split c == id
--   split == splitWith . (==)
--   
--   
--   As for all splitting functions in this library, this function does not
--   copy the substrings, it just constructs new ByteStrings that
--   are slices of the original.
split :: Word8 -> ByteString -> [ByteString]

-- | O(n) Splits a ByteString into components delimited by
--   separators, where the predicate returns True for a separator element.
--   The resulting components do not contain the separators. Two adjacent
--   separators result in an empty component in the output. eg.
--   
--   
--   splitWith (==97) "aabbaca" == ["","","bb","c",""] -- fromEnum 'a' == 97
--   splitWith undefined ""     == []                  -- and not [""]
--   
splitWith :: (Word8 -> Bool) -> ByteString -> [ByteString]

-- | O(n) The isPrefixOf function takes two ByteStrings and
--   returns True iff the first is a prefix of the second.
isPrefixOf :: ByteString -> ByteString -> Bool

-- | O(n) The isSuffixOf function takes two ByteStrings and
--   returns True iff the first is a suffix of the second.
--   
--   The following holds:
--   
--   
--   isSuffixOf x y == reverse x `isPrefixOf` reverse y
--   
isSuffixOf :: ByteString -> ByteString -> Bool

-- | O(n) elem is the ByteString membership predicate.
elem :: Word8 -> ByteString -> Bool

-- | O(n) notElem is the inverse of elem
notElem :: Word8 -> ByteString -> Bool

-- | O(n) The find function takes a predicate and a
--   ByteString, and returns the first element in matching the predicate,
--   or Nothing if there is no such element.
--   
--   
--   find f p = case findIndex f p of Just n -> Just (p ! n) ; _ -> Nothing
--   
find :: (Word8 -> Bool) -> ByteString -> Maybe Word8

-- | O(n) filter, applied to a predicate and a ByteString,
--   returns a ByteString containing those characters that satisfy the
--   predicate.
filter :: (Word8 -> Bool) -> ByteString -> ByteString

-- | O(n) The partition function takes a predicate a
--   ByteString and returns the pair of ByteStrings with elements which do
--   and do not satisfy the predicate, respectively; i.e.,
--   
--   
--   partition p bs == (filter p xs, filter (not . p) xs)
--   
partition :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)

-- | O(c) ByteString index (subscript) operator, starting
--   from 0.
--   
--   This is a partial function, consider using indexMaybe instead.
index :: HasCallStack => ByteString -> Int64 -> Word8

-- | O(n) The elemIndex function returns the index of the
--   first element in the given ByteString which is equal to the
--   query element, or Nothing if there is no such element. This
--   implementation uses memchr(3).
elemIndex :: Word8 -> ByteString -> Maybe Int64

-- | O(n) The elemIndexEnd function returns the last index of
--   the element in the given ByteString which is equal to the query
--   element, or Nothing if there is no such element. The following
--   holds:
--   
--   
--   elemIndexEnd c xs = case elemIndex c (reverse xs) of
--     Nothing -> Nothing
--     Just i  -> Just (length xs - 1 - i)
--   
elemIndexEnd :: Word8 -> ByteString -> Maybe Int64

-- | O(n) The elemIndices function extends elemIndex,
--   by returning the indices of all elements equal to the query element,
--   in ascending order. This implementation uses memchr(3).
elemIndices :: Word8 -> ByteString -> [Int64]

-- | The findIndex function takes a predicate and a
--   ByteString and returns the index of the first element in the
--   ByteString satisfying the predicate.
findIndex :: (Word8 -> Bool) -> ByteString -> Maybe Int64

-- | The findIndices function extends findIndex, by returning
--   the indices of all elements satisfying the predicate, in ascending
--   order.
findIndices :: (Word8 -> Bool) -> ByteString -> [Int64]

-- | count returns the number of times its argument appears in the
--   ByteString
--   
--   
--   count = length . elemIndices
--   
--   
--   But more efficiently than using length on the intermediate list.
count :: Word8 -> ByteString -> Int64

-- | O(n) zip takes two ByteStrings and returns a list of
--   corresponding pairs of bytes. If one input ByteString is short, excess
--   elements of the longer ByteString are discarded. This is equivalent to
--   a pair of unpack operations.
zip :: ByteString -> ByteString -> [(Word8, Word8)]

-- | zipWith generalises zip by zipping with the function
--   given as the first argument, instead of a tupling function. For
--   example, zipWith (+) is applied to two ByteStrings to
--   produce the list of corresponding sums.
zipWith :: (Word8 -> Word8 -> a) -> ByteString -> ByteString -> [a]

-- | O(n) unzip transforms a list of pairs of bytes into a
--   pair of ByteStrings. Note that this performs two pack
--   operations.
unzip :: [(Word8, Word8)] -> (ByteString, ByteString)

-- | O(n) Make a copy of the ByteString with its own storage.
--   This is mainly useful to allow the rest of the data pointed to by the
--   ByteString to be garbage collected, for example if a large
--   string has been read in, and only a small part of it is needed in the
--   rest of the program.
copy :: ByteString -> ByteString

-- | Lifted getContents
getContents :: MonadIO m => m LByteString

-- | Lifted putStr
putStr :: MonadIO m => LByteString -> m ()

-- | Lifted putStrLn
putStrLn :: MonadIO m => LByteString -> m ()

-- | Lifted interact
interact :: MonadIO m => (LByteString -> LByteString) -> m ()

-- | Lifted readFile
readFile :: MonadIO m => FilePath -> m LByteString

-- | Lifted writeFile
writeFile :: MonadIO m => FilePath -> LByteString -> m ()

-- | Lifted appendFile
appendFile :: MonadIO m => FilePath -> LByteString -> m ()

-- | Lifted hGetContents
hGetContents :: MonadIO m => Handle -> m LByteString

-- | Lifted hGet
hGet :: MonadIO m => Handle -> Int -> m LByteString

-- | Lifted hGetNonBlocking
hGetNonBlocking :: MonadIO m => Handle -> Int -> m LByteString

-- | Lifted hPut
hPut :: MonadIO m => Handle -> LByteString -> m ()

-- | Lifted hPutNonBlocking
hPutNonBlocking :: MonadIO m => Handle -> LByteString -> m LByteString

-- | Lifted hPutStr
hPutStr :: MonadIO m => Handle -> LByteString -> m ()

-- | Strict ByteString. Import as:
--   
--   
--   import qualified RIO.ByteString as B
--   
--   
--   This module does not export any partial functions. For those, see
--   RIO.ByteString.Partial
module RIO.ByteString

-- | A space-efficient representation of a Word8 vector, supporting
--   many efficient operations.
--   
--   A ByteString contains 8-bit bytes, or by using the operations
--   from Data.ByteString.Char8 it can be interpreted as containing
--   8-bit characters.
data () => ByteString

-- | Type synonym for the strict flavour of ByteString.
type StrictByteString = ByteString

-- | O(1) ByteString index (subscript) operator, starting
--   from 0.
--   
--   This is a partial function, consider using indexMaybe instead.
index :: HasCallStack => ByteString -> Int -> Word8

-- | zipWith generalises zip by zipping with the function
--   given as the first argument, instead of a tupling function. For
--   example, zipWith (+) is applied to two ByteStrings to
--   produce the list of corresponding sums.
zipWith :: (Word8 -> Word8 -> a) -> ByteString -> ByteString -> [a]

-- | O(1) length returns the length of a ByteString as an
--   Int.
length :: ByteString -> Int

-- | O(n) filter, applied to a predicate and a ByteString,
--   returns a ByteString containing those characters that satisfy the
--   predicate.
filter :: (Word8 -> Bool) -> ByteString -> ByteString

-- | foldl, applied to a binary operator, a starting value
--   (typically the left-identity of the operator), and a ByteString,
--   reduces the ByteString using the binary operator, from left to right.
foldl :: (a -> Word8 -> a) -> a -> ByteString -> a

-- | O(n), where n is the length of the result. The
--   unfoldr function is analogous to the List 'unfoldr'.
--   unfoldr builds a ByteString from a seed value. The function
--   takes the element and returns Nothing if it is done producing
--   the ByteString or returns Just (a,b), in which case,
--   a is the next byte in the string, and b is the seed
--   value for further production.
--   
--   Examples:
--   
--   
--      unfoldr (\x -> if x <= 5 then Just (x, x + 1) else Nothing) 0
--   == pack [0, 1, 2, 3, 4, 5]
--   
unfoldr :: (a -> Maybe (Word8, a)) -> a -> ByteString

-- | The transpose function transposes the rows and columns of its
--   ByteString argument.
transpose :: [ByteString] -> [ByteString]

-- | foldr, applied to a binary operator, a starting value
--   (typically the right-identity of the operator), and a ByteString,
--   reduces the ByteString using the binary operator, from right to left.
foldr :: (Word8 -> a -> a) -> a -> ByteString -> a

-- | O(n) Concatenate a list of ByteStrings.
concat :: [ByteString] -> ByteString

-- | O(n) zip takes two ByteStrings and returns a list of
--   corresponding pairs of bytes. If one input ByteString is short, excess
--   elements of the longer ByteString are discarded. This is equivalent to
--   a pair of unpack operations.
zip :: ByteString -> ByteString -> [(Word8, Word8)]

-- | O(n) map f xs is the ByteString obtained by
--   applying f to each element of xs.
map :: (Word8 -> Word8) -> ByteString -> ByteString

-- | O(1) The empty ByteString
empty :: ByteString

-- | O(1) Extract the head and tail of a ByteString,
--   returning Nothing if it is empty.
uncons :: ByteString -> Maybe (Word8, ByteString)

-- | O(1) Test whether a ByteString is empty.
null :: ByteString -> Bool

-- | foldl' is like foldl, but strict in the accumulator.
foldl' :: (a -> Word8 -> a) -> a -> ByteString -> a

-- | 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
--   
--   
--   head (scanl f z xs) == z
--   last (scanl f z xs) == foldl f z xs
--   
scanl :: (Word8 -> Word8 -> Word8) -> Word8 -> ByteString -> ByteString

-- | scanl1 is a variant of scanl that has no starting value
--   argument.
--   
--   
--   scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
--   
scanl1 :: (Word8 -> Word8 -> Word8) -> ByteString -> ByteString

-- | foldr' is like foldr, but strict in the accumulator.
foldr' :: (Word8 -> a -> a) -> a -> ByteString -> a

-- | scanr is similar to foldr, but returns a list of
--   successive reduced values from the right.
--   
--   
--   scanr f z [..., x{n-1}, xn] == [..., x{n-1} `f` (xn `f` z), xn `f` z, z]
--   
--   
--   Note that
--   
--   
--   head (scanr f z xs) == foldr f z xs
--   last (scanr f z xs) == z
--   
scanr :: (Word8 -> Word8 -> Word8) -> Word8 -> ByteString -> ByteString

-- | scanr1 is a variant of scanr that has no starting value
--   argument.
scanr1 :: (Word8 -> Word8 -> Word8) -> ByteString -> ByteString

-- | O(n) replicate n x is a ByteString of length
--   n with x the value of every element. The following
--   holds:
--   
--   
--   replicate w c = fst (unfoldrN w (\u -> Just (u,u)) c)
--   
replicate :: Int -> Word8 -> ByteString

-- | Similar to takeWhile, returns the longest (possibly empty)
--   prefix of elements satisfying the predicate.
takeWhile :: (Word8 -> Bool) -> ByteString -> ByteString

-- | Similar to dropWhile, drops the longest (possibly empty) prefix
--   of elements satisfying the predicate and returns the remainder.
dropWhile :: (Word8 -> Bool) -> ByteString -> ByteString

-- | O(1) take n, applied to a ByteString
--   xs, returns the prefix of xs of length n,
--   or xs itself if n > length xs.
take :: Int -> ByteString -> ByteString

-- | O(1) drop n xs returns the suffix of
--   xs after the first n elements, or empty if
--   n > length xs.
drop :: Int -> ByteString -> ByteString

-- | O(1) splitAt n xs is equivalent to
--   (take n xs, drop n xs).
splitAt :: Int -> ByteString -> (ByteString, ByteString)

-- | Similar to span, returns the longest (possibly empty) prefix of
--   elements satisfying the predicate and the remainder of the string.
--   
--   span p is equivalent to break (not .
--   p) and to (takeWhile p &&&
--   dropWhile p).
span :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)

-- | Similar to break, returns the longest (possibly empty) prefix
--   of elements which do not satisfy the predicate and the
--   remainder of the string.
--   
--   break p is equivalent to span (not .
--   p) and to (takeWhile (not . p) &&&
--   dropWhile (not . p)).
--   
--   Under GHC, a rewrite rule will transform break (==) into a call to the
--   specialised breakByte:
--   
--   
--   break ((==) x) = breakByte x
--   break (==x) = breakByte x
--   
break :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)

-- | O(n) reverse xs efficiently returns the
--   elements of xs in reverse order.
reverse :: ByteString -> ByteString

-- | O(n) Applied to a predicate and a ByteString, any
--   determines if any element of the ByteString satisfies the
--   predicate.
any :: (Word8 -> Bool) -> ByteString -> Bool

-- | O(n) Applied to a predicate and a ByteString, all
--   determines if all elements of the ByteString satisfy the
--   predicate.
all :: (Word8 -> Bool) -> ByteString -> Bool

-- | O(n) elem is the ByteString membership predicate.
elem :: Word8 -> ByteString -> Bool

-- | O(n) notElem is the inverse of elem
notElem :: Word8 -> ByteString -> Bool

-- | Map a function over a ByteString and concatenate the results
concatMap :: (Word8 -> ByteString) -> ByteString -> ByteString

-- | O(n) unzip transforms a list of pairs of bytes into a
--   pair of ByteStrings. Note that this performs two pack
--   operations.
unzip :: [(Word8, Word8)] -> (ByteString, ByteString)

-- | count returns the number of times its argument appears in the
--   ByteString
--   
--   
--   count = length . elemIndices
--   
--   
--   But more efficiently than using length on the intermediate list.
count :: Word8 -> ByteString -> Int

-- | O(n) The find function takes a predicate and a
--   ByteString, and returns the first element in matching the predicate,
--   or Nothing if there is no such element.
--   
--   
--   find f p = case findIndex f p of Just n -> Just (p ! n) ; _ -> Nothing
--   
find :: (Word8 -> Bool) -> ByteString -> Maybe Word8

-- | Similar to dropWhileEnd, drops the longest (possibly empty)
--   suffix of elements satisfying the predicate and returns the remainder.
--   
--   dropWhileEnd p is equivalent to reverse .
--   dropWhile p . reverse.
dropWhileEnd :: (Word8 -> Bool) -> ByteString -> ByteString

-- | O(n) The stripPrefix function takes two ByteStrings and
--   returns Just the remainder of the second iff the first is its
--   prefix, and otherwise Nothing.
stripPrefix :: ByteString -> ByteString -> Maybe ByteString

-- | O(n) The elemIndex function returns the index of the
--   first element in the given ByteString which is equal to the
--   query element, or Nothing if there is no such element. This
--   implementation uses memchr(3).
elemIndex :: Word8 -> ByteString -> Maybe Int

-- | O(n) The elemIndices function extends elemIndex,
--   by returning the indices of all elements equal to the query element,
--   in ascending order. This implementation uses memchr(3).
elemIndices :: Word8 -> ByteString -> [Int]

-- | O(n) The findIndex function takes a predicate and a
--   ByteString and returns the index of the first element in the
--   ByteString satisfying the predicate.
findIndex :: (Word8 -> Bool) -> ByteString -> Maybe Int

-- | O(n) The findIndices function extends findIndex,
--   by returning the indices of all elements satisfying the predicate, in
--   ascending order.
findIndices :: (Word8 -> Bool) -> ByteString -> [Int]

-- | O(n) The isPrefixOf function takes two ByteStrings and
--   returns True if the first is a prefix of the second.
isPrefixOf :: ByteString -> ByteString -> Bool

-- | O(n) The isSuffixOf function takes two ByteStrings and
--   returns True iff the first is a suffix of the second.
--   
--   The following holds:
--   
--   
--   isSuffixOf x y == reverse x `isPrefixOf` reverse y
--   
--   
--   However, the real implementation uses memcmp to compare the end of the
--   string only, with no reverse required..
isSuffixOf :: ByteString -> ByteString -> Bool

-- | Check whether one string is a substring of another.
isInfixOf :: ByteString -> ByteString -> Bool

-- | O(n) The intersperse function takes a Word8 and a
--   ByteString and `intersperses' that byte between the elements of
--   the ByteString. It is analogous to the intersperse function on
--   Lists.
intersperse :: Word8 -> ByteString -> ByteString

-- | O(n) The intercalate function takes a ByteString
--   and a list of ByteStrings and concatenates the list after
--   interspersing the first argument between each element of the list.
intercalate :: ByteString -> [ByteString] -> ByteString

-- | O(n) The partition function takes a predicate a
--   ByteString and returns the pair of ByteStrings with elements which do
--   and do not satisfy the predicate, respectively; i.e.,
--   
--   
--   partition p bs == (filter p xs, filter (not . p) xs)
--   
partition :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)

-- | The mapAccumL function behaves like a combination of map
--   and foldl; it applies a function to each element of a
--   ByteString, passing an accumulating parameter from left to right, and
--   returning a final value of this accumulator together with the new
--   ByteString.
mapAccumL :: (acc -> Word8 -> (acc, Word8)) -> acc -> ByteString -> (acc, ByteString)

-- | The mapAccumR function behaves like a combination of map
--   and foldr; it applies a function to each element of a
--   ByteString, passing an accumulating parameter from right to left, and
--   returning a final value of this accumulator together with the new
--   ByteString.
mapAccumR :: (acc -> Word8 -> (acc, Word8)) -> acc -> ByteString -> (acc, ByteString)

-- | The group function takes a ByteString and returns a list of
--   ByteStrings such that the concatenation of the result is equal to the
--   argument. Moreover, each string in the result contains only equal
--   elements. For example,
--   
--   
--   group "Mississippi" = ["M","i","ss","i","ss","i","pp","i"]
--   
--   
--   It is a special case of groupBy, which allows the programmer to
--   supply their own equality test. It is about 40% faster than groupBy
--   (==)
group :: ByteString -> [ByteString]

-- | The groupBy function is the non-overloaded version of
--   group.
groupBy :: (Word8 -> Word8 -> Bool) -> ByteString -> [ByteString]

-- | O(n) Returns all initial segments of the given
--   ByteString, shortest first.
inits :: ByteString -> [ByteString]

-- | O(n) Returns all final segments of the given ByteString,
--   longest first.
tails :: ByteString -> [ByteString]

-- | O(n) Sort a ByteString efficiently, using counting sort.
sort :: ByteString -> ByteString

-- | O(1) Convert a Word8 into a ByteString
singleton :: Word8 -> ByteString

-- | O(n) cons is analogous to (:) for lists, but of
--   different complexity, as it requires making a copy.
cons :: Word8 -> ByteString -> ByteString
infixr 5 `cons`

-- | O(n) Append two ByteStrings
append :: ByteString -> ByteString -> ByteString

-- | O(n) Make a copy of the ByteString with its own storage.
--   This is mainly useful to allow the rest of the data pointed to by the
--   ByteString to be garbage collected, for example if a large
--   string has been read in, and only a small part of it is needed in the
--   rest of the program.
copy :: ByteString -> ByteString

-- | O(n) Append a byte to the end of a ByteString
snoc :: ByteString -> Word8 -> ByteString
infixl 5 `snoc`

-- | O(1) Convert a strict ByteString into a lazy
--   ByteString.
fromStrict :: ByteString -> ByteString

-- | O(n) Convert a lazy ByteString into a strict
--   ByteString.
--   
--   Note that this is an expensive operation that forces the whole
--   lazy ByteString into memory and then copies all the data. If possible,
--   try to avoid converting back and forth between strict and lazy
--   bytestrings.
toStrict :: ByteString -> ByteString

-- | O(1) ByteString index, starting from 0, that returns
--   Just if:
--   
--   
--   0 <= n < length bs
--   
indexMaybe :: ByteString -> Int -> Maybe Word8

-- | O(1) ByteString index, starting from 0, that returns
--   Just if:
--   
--   
--   0 <= n < length bs
--   
(!?) :: ByteString -> Int -> Maybe Word8

-- | O(n) Convert a [Word8] into a
--   ByteString.
--   
--   For applications with large numbers of string literals, pack
--   can be a bottleneck. In such cases, consider using
--   unsafePackAddress (GHC only).
pack :: [Word8] -> ByteString

-- | O(n) Converts a ByteString to a [Word8].
unpack :: ByteString -> [Word8]

-- | O(1) Extract the init and last of a ByteString,
--   returning Nothing if it is empty.
unsnoc :: ByteString -> Maybe (ByteString, Word8)

-- | O(1) takeEnd n xs is equivalent to
--   drop (length xs - n) xs. Takes n
--   elements from end of bytestring.
--   
--   
--   >>> takeEnd 3 "abcdefg"
--   "efg"
--   
--   >>> takeEnd 0 "abcdefg"
--   ""
--   
--   >>> takeEnd 4 "abc"
--   "abc"
--   
takeEnd :: Int -> ByteString -> ByteString

-- | Returns the longest (possibly empty) suffix of elements satisfying the
--   predicate.
--   
--   takeWhileEnd p is equivalent to reverse .
--   takeWhile p . reverse.
takeWhileEnd :: (Word8 -> Bool) -> ByteString -> ByteString

-- | O(1) dropEnd n xs is equivalent to
--   take (length xs - n) xs. Drops n
--   elements from end of bytestring.
--   
--   
--   >>> dropEnd 3 "abcdefg"
--   "abcd"
--   
--   >>> dropEnd 0 "abcdefg"
--   "abcdefg"
--   
--   >>> dropEnd 4 "abc"
--   ""
--   
dropEnd :: Int -> ByteString -> ByteString

-- | Returns the longest (possibly empty) suffix of elements which do
--   not satisfy the predicate and the remainder of the string.
--   
--   breakEnd p is equivalent to spanEnd (not .
--   p) and to (takeWhileEnd (not . p) &&&
--   dropWhileEnd (not . p)).
breakEnd :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)

-- | Returns the longest (possibly empty) suffix of elements satisfying the
--   predicate and the remainder of the string.
--   
--   spanEnd p is equivalent to breakEnd (not .
--   p) and to (takeWhileEnd p &&&
--   dropWhileEnd p).
--   
--   We have
--   
--   
--   spanEnd (not . isSpace) "x y z" == ("x y ", "z")
--   
--   
--   and
--   
--   
--   spanEnd (not . isSpace) ps
--      ==
--   let (x, y) = span (not . isSpace) (reverse ps) in (reverse y, reverse x)
--   
spanEnd :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)

-- | O(n) Break a ByteString into pieces separated by the
--   byte argument, consuming the delimiter. I.e.
--   
--   
--   split 10  "a\nb\nd\ne" == ["a","b","d","e"]   -- fromEnum '\n' == 10
--   split 97  "aXaXaXa"    == ["","X","X","X",""] -- fromEnum 'a' == 97
--   split 120 "x"          == ["",""]             -- fromEnum 'x' == 120
--   split undefined ""     == []                  -- and not [""]
--   
--   
--   and
--   
--   
--   intercalate [c] . split c == id
--   split == splitWith . (==)
--   
--   
--   As for all splitting functions in this library, this function does not
--   copy the substrings, it just constructs new ByteStrings that
--   are slices of the original.
split :: Word8 -> ByteString -> [ByteString]

-- | O(n) Splits a ByteString into components delimited by
--   separators, where the predicate returns True for a separator element.
--   The resulting components do not contain the separators. Two adjacent
--   separators result in an empty component in the output. eg.
--   
--   
--   splitWith (==97) "aabbaca" == ["","","bb","c",""] -- fromEnum 'a' == 97
--   splitWith undefined ""     == []                  -- and not [""]
--   
splitWith :: (Word8 -> Bool) -> ByteString -> [ByteString]

-- | O(n) The stripSuffix function takes two ByteStrings and
--   returns Just the remainder of the second iff the first is its
--   suffix, and otherwise Nothing.
stripSuffix :: ByteString -> ByteString -> Maybe ByteString

-- | O(n) Like unfoldr, unfoldrN builds a ByteString
--   from a seed value. However, the length of the result is limited by the
--   first argument to unfoldrN. This function is more efficient
--   than unfoldr when the maximum length of the result is known.
--   
--   The following equation relates unfoldrN and unfoldr:
--   
--   
--   fst (unfoldrN n f s) == take n (unfoldr f s)
--   
unfoldrN :: Int -> (a -> Maybe (Word8, a)) -> a -> (ByteString, Maybe a)

-- | Break a string on a substring, returning a pair of the part of the
--   string prior to the match, and the rest of the string.
--   
--   The following relationships hold:
--   
--   
--   break (== c) l == breakSubstring (singleton c) l
--   
--   
--   For example, to tokenise a string, dropping delimiters:
--   
--   
--   tokenise x y = h : if null t then [] else tokenise x (drop (length x) t)
--       where (h,t) = breakSubstring x y
--   
--   
--   To skip to the first occurrence of a string:
--   
--   
--   snd (breakSubstring x y)
--   
--   
--   To take the parts of a string before a delimiter:
--   
--   
--   fst (breakSubstring x y)
--   
--   
--   Note that calling `breakSubstring x` does some preprocessing work, so
--   you should avoid unnecessarily duplicating breakSubstring calls with
--   the same pattern.
breakSubstring :: ByteString -> ByteString -> (ByteString, ByteString)

-- | O(n) Check whether a ByteString represents valid UTF-8.
isValidUtf8 :: ByteString -> Bool

-- | Convert a FilePath to a ByteString.
--   
--   The FilePath type is expected to use the file system encoding
--   as reported by getFileSystemEncoding. This encoding allows for
--   round-tripping of arbitrary data on platforms that allow arbitrary
--   bytes in their paths. This conversion function does the same thing
--   that openFile would do when decoding the FilePath.
--   
--   This function is in IO because the file system encoding can be
--   changed. If the encoding can be assumed to be constant in your use
--   case, you may invoke this function via unsafePerformIO.
fromFilePath :: FilePath -> IO ByteString

-- | Convert a ByteString to a FilePath.
--   
--   This function uses the file system encoding, and resulting
--   FilePaths can be safely used with standard IO functions and
--   will reference the correct path in the presence of arbitrary non-UTF-8
--   encoded paths.
--   
--   This function is in IO because the file system encoding can be
--   changed. If the encoding can be assumed to be constant in your use
--   case, you may invoke this function via unsafePerformIO.
toFilePath :: ByteString -> IO FilePath

-- | O(n) The elemIndexEnd function returns the last index of
--   the element in the given ByteString which is equal to the query
--   element, or Nothing if there is no such element. The following
--   holds:
--   
--   
--   elemIndexEnd c xs = case elemIndex c (reverse xs) of
--     Nothing -> Nothing
--     Just i  -> Just (length xs - 1 - i)
--   
elemIndexEnd :: Word8 -> ByteString -> Maybe Int

-- | O(n) The findIndexEnd function takes a predicate and a
--   ByteString and returns the index of the last element in the
--   ByteString satisfying the predicate.
findIndexEnd :: (Word8 -> Bool) -> ByteString -> Maybe Int

-- | A specialised version of zipWith for the common case of a
--   simultaneous map over two ByteStrings, to build a 3rd.
packZipWith :: (Word8 -> Word8 -> Word8) -> ByteString -> ByteString -> ByteString

-- | O(n) Returns all initial segments of the given
--   ByteString, shortest first.
initsNE :: ByteString -> NonEmpty ByteString

-- | O(n) Returns all final segments of the given ByteString,
--   longest first.
tailsNE :: ByteString -> NonEmpty ByteString

-- | Lifted hGetContents
hGetContents :: MonadIO m => Handle -> m ByteString

-- | Lifted writeFile
writeFile :: MonadIO m => FilePath -> ByteString -> m ()

-- | Lifted getLine
getLine :: MonadIO m => m ByteString

-- | Lifted hGetLine
hGetLine :: MonadIO m => Handle -> m ByteString

-- | Lifted hPutStr
hPutStr :: MonadIO m => Handle -> ByteString -> m ()

-- | Lifted putStr
putStr :: MonadIO m => ByteString -> m ()

-- | Lifted getContents
getContents :: MonadIO m => m ByteString

-- | Lifted interact
interact :: MonadIO m => (ByteString -> ByteString) -> m ()

-- | Lifted readFile
readFile :: MonadIO m => FilePath -> m ByteString

-- | Lifted appendFile
appendFile :: MonadIO m => FilePath -> ByteString -> m ()

-- | Unlifted useAsCString
useAsCString :: MonadUnliftIO m => ByteString -> (CString -> m a) -> m a

-- | Unlifted useAsCStringLen
useAsCStringLen :: MonadUnliftIO m => ByteString -> (CStringLen -> m a) -> m a

-- | Lifted hPut
hPut :: MonadIO m => Handle -> ByteString -> m ()

-- | Lifted packCString
packCString :: MonadIO m => CString -> m ByteString

-- | Lifted packCStringLen
packCStringLen :: MonadIO m => CStringLen -> m ByteString

-- | Lifted hPutNonBlocking
hPutNonBlocking :: MonadIO m => Handle -> ByteString -> m ByteString

-- | Lifted hGet
hGet :: MonadIO m => Handle -> Int -> m ByteString

-- | Lifted hGetNonBlocking
hGetNonBlocking :: MonadIO m => Handle -> Int -> m ByteString

-- | Lifted hGetSome
hGetSome :: MonadIO m => Handle -> Int -> m ByteString

-- | Lazy Text. Import as:
--   
--   
--   import qualified RIO.Text.Lazy as TL
--   
--   
--   This module does not export any partial functions. For those, see
--   RIO.Text.Lazy.Partial
module RIO.Text.Lazy
data () => Text

-- | O(n) Convert a String into a Text.
--   
--   Performs replacement on invalid scalar values, so unpack .
--   pack is not id:
--   
--   
--   >>> Data.Text.Lazy.unpack (Data.Text.Lazy.pack "\55555")
--   "\65533"
--   
pack :: String -> Text

-- | O(n) Convert a Text into a String.
unpack :: Text -> String

-- | O(1) Convert a character into a Text. Performs replacement on
--   invalid scalar values.
singleton :: Char -> Text

-- | Smart constructor for Empty.
empty :: Text

-- | O(c) Convert a list of strict Texts into a lazy
--   Text.
fromChunks :: [Text] -> Text

-- | O(n) Convert a lazy Text into a list of strict
--   Texts.
toChunks :: Text -> [Text]

-- | O(n) Convert a lazy Text into a strict Text.
toStrict :: Text -> Text

-- | O(c) Convert a strict Text into a lazy Text.
fromStrict :: Text -> Text

-- | Consume the chunks of a lazy Text with a natural right fold.
foldrChunks :: (Text -> a -> a) -> a -> Text -> a

-- | Consume the chunks of a lazy Text with a strict,
--   tail-recursive, accumulating left fold.
foldlChunks :: (a -> Text -> a) -> a -> Text -> a

-- | O(1) Adds a character to the front of a Text.
cons :: Char -> Text -> Text
infixr 5 `cons`

-- | O(n) Adds a character to the end of a Text. This copies
--   the entire array in the process.
snoc :: Text -> Char -> Text

-- | O(n/c) Appends one Text to another.
append :: Text -> Text -> Text

-- | O(1) Returns the first character and rest of a Text, or
--   Nothing if empty.
uncons :: Text -> Maybe (Char, Text)

-- | O(1) Tests whether a Text is empty or not.
null :: Text -> Bool

-- | O(n) Returns the number of characters in a Text.
length :: Text -> Int64

-- | O(min(n,c)) Compare the count of characters in a Text to
--   a number.
--   
--   
--   compareLength t c = compare (length t) c
--   
--   
--   This function gives the same answer as comparing against the result of
--   length, but can short circuit if the count of characters is
--   greater than the number, and hence be more efficient.
compareLength :: Text -> Int64 -> Ordering

-- | O(n) map f t is the Text
--   obtained by applying f to each element of t.
--   Performs replacement on invalid scalar values.
map :: (Char -> Char) -> Text -> Text

-- | O(n) The intercalate function takes a Text and a
--   list of Texts and concatenates the list after interspersing the
--   first argument between each element of the list.
intercalate :: Text -> [Text] -> Text

-- | O(n) The intersperse function takes a character and
--   places it between the characters of a Text. Performs
--   replacement on invalid scalar values.
intersperse :: Char -> Text -> Text

-- | O(n) The transpose function transposes the rows and
--   columns of its Text argument. Note that this function uses
--   pack, unpack, and the list version of transpose, and is
--   thus not very efficient.
transpose :: [Text] -> [Text]

-- | O(n) reverse t returns the elements of
--   t in reverse order.
reverse :: Text -> Text

-- | O(n) Convert a string to folded case.
--   
--   This function is mainly useful for performing caseless (or case
--   insensitive) string comparisons.
--   
--   A string x is a caseless match for a string y if and
--   only if:
--   
--   
--   toCaseFold x == toCaseFold y
--   
--   
--   The result string may be longer than the input string, and may differ
--   from applying toLower to the input string. For instance, the
--   Armenian small ligature men now (U+FB13) is case folded to the bigram
--   men now (U+0574 U+0576), while the micro sign (U+00B5) is case folded
--   to the Greek small letter letter mu (U+03BC) instead of itself.
toCaseFold :: Text -> Text

-- | O(n) Convert a string to lower case, using simple case
--   conversion.
--   
--   The result string may be longer than the input string. For instance,
--   the Latin capital letter I with dot above (U+0130) maps to the
--   sequence Latin small letter i (U+0069) followed by combining dot above
--   (U+0307).
toLower :: Text -> Text

-- | O(n) Convert a string to upper case, using simple case
--   conversion.
--   
--   The result string may be longer than the input string. For instance,
--   the German eszett (U+00DF) maps to the two-letter sequence SS.
toUpper :: Text -> Text

-- | O(n) Convert a string to title case, using simple case
--   conversion.
--   
--   The first letter (as determined by isLetter) of the input is
--   converted to title case, as is every subsequent letter that
--   immediately follows a non-letter. Every letter that immediately
--   follows another letter is converted to lower case.
--   
--   The result string may be longer than the input string. For example,
--   the Latin small ligature ﬂ (U+FB02) is converted to the sequence Latin
--   capital letter F (U+0046) followed by Latin small letter l (U+006C).
--   
--   This function is not idempotent. Consider lower-case letter ŉ
--   (U+0149 LATIN SMALL LETTER N PRECEDED BY APOSTROPHE). Then
--   toTitle "ŉ" = "ʼN": the first (and the only)
--   letter of the input is converted to title case, becoming two letters.
--   Now ʼ (U+02BC MODIFIER LETTER APOSTROPHE) is a modifier
--   letter and as such is recognised as a letter by isLetter, so
--   toTitle "ʼN" = "'n".
--   
--   Note: this function does not take language or culture specific
--   rules into account. For instance, in English, different style guides
--   disagree on whether the book name "The Hill of the Red Fox" is
--   correctly title cased—but this function will capitalize every
--   word.
toTitle :: Text -> Text

-- | O(n) Left-justify a string to the given length, using the
--   specified fill character on the right. Performs replacement on invalid
--   scalar values.
--   
--   Examples:
--   
--   
--   justifyLeft 7 'x' "foo"    == "fooxxxx"
--   justifyLeft 3 'x' "foobar" == "foobar"
--   
justifyLeft :: Int64 -> Char -> Text -> Text

-- | O(n) Right-justify a string to the given length, using the
--   specified fill character on the left. Performs replacement on invalid
--   scalar values.
--   
--   Examples:
--   
--   
--   justifyRight 7 'x' "bar"    == "xxxxbar"
--   justifyRight 3 'x' "foobar" == "foobar"
--   
justifyRight :: Int64 -> Char -> Text -> Text

-- | O(n) Center a string to the given length, using the specified
--   fill character on either side. Performs replacement on invalid scalar
--   values.
--   
--   Examples:
--   
--   
--   center 8 'x' "HS" = "xxxHSxxx"
--   
center :: Int64 -> Char -> Text -> Text

-- | O(n) foldl, applied to a binary operator, a starting
--   value (typically the left-identity of the operator), and a
--   Text, reduces the Text using the binary operator, from
--   left to right.
foldl :: (a -> Char -> a) -> a -> Text -> a

-- | O(n) A strict version of foldl.
foldl' :: (a -> Char -> a) -> a -> Text -> a

-- | O(n) foldr, applied to a binary operator, a starting
--   value (typically the right-identity of the operator), and a
--   Text, reduces the Text using the binary operator, from
--   right to left.
--   
--   foldr is lazy like foldr for lists: evaluation actually
--   traverses the Text from left to right, only as far as it needs
--   to.
--   
--   For example, head can be defined with O(1) complexity
--   using foldr:
--   
--   
--   head :: Text -> Char
--   head = foldr const (error "head empty")
--   
foldr :: (Char -> a -> a) -> a -> Text -> a

-- | O(n) Concatenate a list of Texts.
concat :: [Text] -> Text

-- | O(n) Map a function over a Text that results in a
--   Text, and concatenate the results.
concatMap :: (Char -> Text) -> Text -> Text

-- | O(n) any p t determines whether any
--   character in the Text t satisfies the predicate
--   p.
any :: (Char -> Bool) -> Text -> Bool

-- | O(n) all p t determines whether all
--   characters in the Text t satisfy the predicate
--   p.
all :: (Char -> Bool) -> Text -> Bool

-- | O(n) scanl is similar to foldl, but returns a
--   list of successive reduced values from the left. Performs replacement
--   on invalid scalar values.
--   
--   
--   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.
--   
scanl :: (Char -> Char -> Char) -> Char -> Text -> Text

-- | O(n) scanl1 is a variant of scanl that has no
--   starting value argument. Performs replacement on invalid scalar
--   values.
--   
--   
--   scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
--   
scanl1 :: (Char -> Char -> Char) -> Text -> Text

-- | O(n) scanr is the right-to-left dual of scanl.
--   Performs replacement on invalid scalar values.
--   
--   
--   scanr f v == reverse . scanl (flip f) v . reverse
--   
scanr :: (Char -> Char -> Char) -> Char -> Text -> Text

-- | O(n) scanr1 is a variant of scanr that has no
--   starting value argument. Performs replacement on invalid scalar
--   values.
scanr1 :: (Char -> Char -> Char) -> Text -> Text

-- | O(n) Like a combination of map and foldl'.
--   Applies a function to each element of a Text, passing an
--   accumulating parameter from left to right, and returns a final
--   Text. Performs replacement on invalid scalar values.
mapAccumL :: (a -> Char -> (a, Char)) -> a -> Text -> (a, Text)

-- | The mapAccumR function behaves like a combination of map
--   and a strict foldr; it applies a function to each element of a
--   Text, passing an accumulating parameter from right to left, and
--   returning a final value of this accumulator together with the new
--   Text. Performs replacement on invalid scalar values.
mapAccumR :: (a -> Char -> (a, Char)) -> a -> Text -> (a, Text)

-- | repeat x is an infinite Text, with x
--   the value of every element.
repeat :: Char -> Text

-- | O(n*m) replicate n t is a Text
--   consisting of the input t repeated n times.
replicate :: Int64 -> Text -> Text

-- | cycle ties a finite, non-empty Text into a circular one,
--   or equivalently, the infinite repetition of the original Text.
cycle :: HasCallStack => Text -> Text

-- | iterate f x returns an infinite Text of
--   repeated applications of f to x:
--   
--   
--   iterate f x == [x, f x, f (f x), ...]
--   
iterate :: (Char -> Char) -> Char -> Text

-- | O(n), where n is the length of the result. The
--   unfoldr function is analogous to the List unfoldr.
--   unfoldr builds a Text from a seed value. The function
--   takes the element and returns Nothing if it is done producing
--   the Text, otherwise Just (a,b). In this case,
--   a is the next Char in the string, and b is
--   the seed value for further production. Performs replacement on invalid
--   scalar values.
unfoldr :: (a -> Maybe (Char, a)) -> a -> Text

-- | O(n) Like unfoldr, unfoldrN builds a Text
--   from a seed value. However, the length of the result should be limited
--   by the first argument to unfoldrN. This function is more
--   efficient than unfoldr when the maximum length of the result is
--   known and correct, otherwise its performance is similar to
--   unfoldr. Performs replacement on invalid scalar values.
unfoldrN :: Int64 -> (a -> Maybe (Char, a)) -> a -> Text

-- | O(n) take n, applied to a Text, returns
--   the prefix of the Text of length n, or the Text
--   itself if n is greater than the length of the Text.
take :: Int64 -> Text -> Text

-- | O(n) takeEnd n t returns the suffix
--   remaining after taking n characters from the end of
--   t.
--   
--   Examples:
--   
--   
--   takeEnd 3 "foobar" == "bar"
--   
takeEnd :: Int64 -> Text -> Text

-- | O(n) drop n, applied to a Text, returns
--   the suffix of the Text after the first n characters,
--   or the empty Text if n is greater than the length of
--   the Text.
drop :: Int64 -> Text -> Text

-- | O(n) dropEnd n t returns the prefix
--   remaining after dropping n characters from the end of
--   t.
--   
--   Examples:
--   
--   
--   dropEnd 3 "foobar" == "foo"
--   
dropEnd :: Int64 -> Text -> Text

-- | O(n) takeWhile, applied to a predicate p and a
--   Text, returns the longest prefix (possibly empty) of elements
--   that satisfy p.
takeWhile :: (Char -> Bool) -> Text -> Text

-- | O(n) takeWhileEnd, applied to a predicate p and
--   a Text, returns the longest suffix (possibly empty) of elements
--   that satisfy p. Examples:
--   
--   
--   takeWhileEnd (=='o') "foo" == "oo"
--   
takeWhileEnd :: (Char -> Bool) -> Text -> Text

-- | O(n) dropWhile p t returns the suffix
--   remaining after takeWhile p t.
dropWhile :: (Char -> Bool) -> Text -> Text

-- | O(n) dropWhileEnd p t returns the
--   prefix remaining after dropping characters that satisfy the predicate
--   p from the end of t.
--   
--   Examples:
--   
--   
--   dropWhileEnd (=='.') "foo..." == "foo"
--   
dropWhileEnd :: (Char -> Bool) -> Text -> Text

-- | O(n) dropAround p t returns the
--   substring remaining after dropping characters that satisfy the
--   predicate p from both the beginning and end of t.
dropAround :: (Char -> Bool) -> Text -> Text

-- | O(n) Remove leading and trailing white space from a string.
--   Equivalent to:
--   
--   
--   dropAround isSpace
--   
strip :: Text -> Text

-- | O(n) Remove leading white space from a string. Equivalent to:
--   
--   
--   dropWhile isSpace
--   
stripStart :: Text -> Text

-- | O(n) Remove trailing white space from a string. Equivalent to:
--   
--   
--   dropWhileEnd isSpace
--   
stripEnd :: Text -> Text

-- | O(n) splitAt n t returns a pair whose first
--   element is a prefix of t of length n, and whose
--   second is the remainder of the string. It is equivalent to
--   (take n t, drop n t).
splitAt :: Int64 -> Text -> (Text, Text)

-- | O(n) span, applied to a predicate p and text
--   t, returns a pair whose first element is the longest prefix
--   (possibly empty) of t of elements that satisfy p,
--   and whose second is the remainder of the text.
--   
--   
--   >>> T.span (=='0') "000AB"
--   ("000","AB")
--   
span :: (Char -> Bool) -> Text -> (Text, Text)

-- | O(n) break is like span, but the prefix returned
--   is over elements that fail the predicate p.
--   
--   
--   >>> T.break (=='c') "180cm"
--   ("180","cm")
--   
break :: (Char -> Bool) -> Text -> (Text, Text)

-- | The group function takes a Text and returns a list of
--   Texts such that the concatenation of the result is equal to the
--   argument. Moreover, each sublist in the result contains only equal
--   elements. For example,
--   
--   
--   group "Mississippi" = ["M","i","ss","i","ss","i","pp","i"]
--   
--   
--   It is a special case of groupBy, which allows the programmer to
--   supply their own equality test.
group :: Text -> [Text]

-- | The groupBy function is the non-overloaded version of
--   group.
groupBy :: (Char -> Char -> Bool) -> Text -> [Text]

-- | O(n) Return all initial segments of the given Text,
--   shortest first.
inits :: Text -> [Text]

-- | O(n) Return all final segments of the given Text,
--   longest first.
tails :: Text -> [Text]

-- | O(n) Splits a Text into components delimited by
--   separators, where the predicate returns True for a separator element.
--   The resulting components do not contain the separators. Two adjacent
--   separators result in an empty component in the output. eg.
--   
--   
--   split (=='a') "aabbaca" == ["","","bb","c",""]
--   split (=='a') []        == [""]
--   
split :: (Char -> Bool) -> Text -> [Text]

-- | O(n) Splits a Text into components of length k.
--   The last element may be shorter than the other chunks, depending on
--   the length of the input. Examples:
--   
--   
--   chunksOf 3 "foobarbaz"   == ["foo","bar","baz"]
--   chunksOf 4 "haskell.org" == ["hask","ell.","org"]
--   
chunksOf :: Int64 -> Text -> [Text]

-- | O(n) Breaks a Text up into a list of Texts at
--   newline characters '\n' (LF, line feed). The resulting
--   strings do not contain newlines.
--   
--   lines does not treat '\r' (CR, carriage return)
--   as a newline character.
lines :: Text -> [Text]

-- | O(n) Breaks a Text up into a list of words, delimited by
--   Chars representing white space.
words :: Text -> [Text]

-- | O(n) Joins lines, after appending a terminating newline to
--   each.
unlines :: [Text] -> Text

-- | O(n) Joins words using single space characters.
unwords :: [Text] -> Text

-- | O(n) The isPrefixOf function takes two Texts and
--   returns True if and only if the first is a prefix of the
--   second.
isPrefixOf :: Text -> Text -> Bool

-- | O(n) The isSuffixOf function takes two Texts and
--   returns True if and only if the first is a suffix of the
--   second.
isSuffixOf :: Text -> Text -> Bool

-- | O(n+m) The isInfixOf function takes two Texts and
--   returns True if and only if the first is contained, wholly and
--   intact, anywhere within the second.
--   
--   This function is strict in its first argument, and lazy in its second.
--   
--   In (unlikely) bad cases, this function's time complexity degrades
--   towards O(n*m).
isInfixOf :: Text -> Text -> Bool

-- | O(n) Return the suffix of the second string if its prefix
--   matches the entire first string.
--   
--   Examples:
--   
--   
--   stripPrefix "foo" "foobar" == Just "bar"
--   stripPrefix ""    "baz"    == Just "baz"
--   stripPrefix "foo" "quux"   == Nothing
--   
--   
--   This is particularly useful with the ViewPatterns extension
--   to GHC, as follows:
--   
--   
--   {-# LANGUAGE ViewPatterns #-}
--   import Data.Text.Lazy as T
--   
--   fnordLength :: Text -> Int
--   fnordLength (stripPrefix "fnord" -> Just suf) = T.length suf
--   fnordLength _                                 = -1
--   
stripPrefix :: Text -> Text -> Maybe Text

-- | O(n) Return the prefix of the second string if its suffix
--   matches the entire first string.
--   
--   Examples:
--   
--   
--   stripSuffix "bar" "foobar" == Just "foo"
--   stripSuffix ""    "baz"    == Just "baz"
--   stripSuffix "foo" "quux"   == Nothing
--   
--   
--   This is particularly useful with the ViewPatterns extension
--   to GHC, as follows:
--   
--   
--   {-# LANGUAGE ViewPatterns #-}
--   import Data.Text.Lazy as T
--   
--   quuxLength :: Text -> Int
--   quuxLength (stripSuffix "quux" -> Just pre) = T.length pre
--   quuxLength _                                = -1
--   
stripSuffix :: Text -> Text -> Maybe Text

-- | O(n) Find the longest non-empty common prefix of two strings
--   and return it, along with the suffixes of each string at which they no
--   longer match.
--   
--   If the strings do not have a common prefix or either one is empty,
--   this function returns Nothing.
--   
--   Examples:
--   
--   
--   commonPrefixes "foobar" "fooquux" == Just ("foo","bar","quux")
--   commonPrefixes "veeble" "fetzer"  == Nothing
--   commonPrefixes "" "baz"           == Nothing
--   
commonPrefixes :: Text -> Text -> Maybe (Text, Text, Text)

-- | O(n) filter, applied to a predicate and a Text,
--   returns a Text containing those characters that satisfy the
--   predicate.
filter :: (Char -> Bool) -> Text -> Text

-- | O(n) The find function takes a predicate and a
--   Text, and returns the first element in matching the predicate,
--   or Nothing if there is no such element.
find :: (Char -> Bool) -> Text -> Maybe Char

-- | O(n) The partition function takes a predicate and a
--   Text, and returns the pair of Texts with elements which
--   do and do not satisfy the predicate, respectively; i.e.
--   
--   
--   partition p t == (filter p t, filter (not . p) t)
--   
partition :: (Char -> Bool) -> Text -> (Text, Text)

-- | O(n) Text index (subscript) operator, starting from 0.
index :: HasCallStack => Text -> Int64 -> Char

-- | O(n+m) The count function returns the number of times
--   the query string appears in the given Text. An empty query
--   string is invalid, and will cause an error to be raised.
--   
--   In (unlikely) bad cases, this function's time complexity degrades
--   towards O(n*m).
count :: HasCallStack => Text -> Text -> Int64

-- | O(n) zip takes two Texts and returns a list of
--   corresponding pairs of bytes. If one input Text is short,
--   excess elements of the longer Text are discarded. This is
--   equivalent to a pair of unpack operations.
zip :: Text -> Text -> [(Char, Char)]

-- | O(n) zipWith generalises zip by zipping with the
--   function given as the first argument, instead of a tupling function.
--   Performs replacement on invalid scalar values.
zipWith :: (Char -> Char -> Char) -> Text -> Text -> Text

-- | Lazy Text partial functions. Import as:
--   
--   
--   import qualified RIO.Text.Lazy.Partial as TL'
--   
module RIO.Text.Lazy.Partial

-- | O(1) Returns the first character of a Text, which must
--   be non-empty. This is a partial function, consider using uncons
--   instead.
head :: HasCallStack => Text -> Char

-- | O(n/c) Returns the last character of a Text, which must
--   be non-empty. This is a partial function, consider using unsnoc
--   instead.
last :: HasCallStack => Text -> Char

-- | O(1) Returns all characters after the head of a Text,
--   which must be non-empty. This is a partial function, consider using
--   uncons instead.
tail :: HasCallStack => Text -> Text

-- | O(n/c) Returns all but the last character of a Text,
--   which must be non-empty. This is a partial function, consider using
--   unsnoc instead.
init :: HasCallStack => Text -> Text

-- | O(m+n) Replace every non-overlapping occurrence of
--   needle in haystack with replacement.
--   
--   This function behaves as though it was defined as follows:
--   
--   
--   replace needle replacement haystack =
--     intercalate replacement (splitOn needle haystack)
--   
--   
--   As this suggests, each occurrence is replaced exactly once. So if
--   needle occurs in replacement, that occurrence will
--   not itself be replaced recursively:
--   
--   
--   replace "oo" "foo" "oo" == "foo"
--   
--   
--   In cases where several instances of needle overlap, only the
--   first one will be replaced:
--   
--   
--   replace "ofo" "bar" "ofofo" == "barfo"
--   
--   
--   In (unlikely) bad cases, this function's time complexity degrades
--   towards O(n*m).
replace :: HasCallStack => Text -> Text -> Text -> Text

-- | O(n) A variant of foldl that has no starting value
--   argument, and thus must be applied to a non-empty Text.
foldl1 :: HasCallStack => (Char -> Char -> Char) -> Text -> Char

-- | O(n) A strict version of foldl1.
foldl1' :: HasCallStack => (Char -> Char -> Char) -> Text -> Char

-- | O(n) A variant of foldr that has no starting value
--   argument, and thus must be applied to a non-empty Text.
foldr1 :: HasCallStack => (Char -> Char -> Char) -> Text -> Char

-- | O(n) maximum returns the maximum value from a
--   Text, which must be non-empty.
maximum :: HasCallStack => Text -> Char

-- | O(n) minimum returns the minimum value from a
--   Text, which must be non-empty.
minimum :: HasCallStack => Text -> Char

-- | O(n+m) Find the first instance of needle (which must
--   be non-null) in haystack. The first element of the
--   returned tuple is the prefix of haystack before
--   needle is matched. The second is the remainder of
--   haystack, starting with the match.
--   
--   Examples:
--   
--   
--   breakOn "::" "a::b::c" ==> ("a", "::b::c")
--   breakOn "/" "foobar"   ==> ("foobar", "")
--   
--   
--   Laws:
--   
--   
--   append prefix match == haystack
--     where (prefix, match) = breakOn needle haystack
--   
--   
--   If you need to break a string by a substring repeatedly (e.g. you want
--   to break on every instance of a substring), use breakOnAll
--   instead, as it has lower startup overhead.
--   
--   This function is strict in its first argument, and lazy in its second.
--   
--   In (unlikely) bad cases, this function's time complexity degrades
--   towards O(n*m).
breakOn :: HasCallStack => Text -> Text -> (Text, Text)

-- | O(n+m) Similar to breakOn, but searches from the end of
--   the string.
--   
--   The first element of the returned tuple is the prefix of
--   haystack up to and including the last match of
--   needle. The second is the remainder of haystack,
--   following the match.
--   
--   
--   breakOnEnd "::" "a::b::c" ==> ("a::b::", "c")
--   
breakOnEnd :: HasCallStack => Text -> Text -> (Text, Text)

-- | O(m+n) Break a Text into pieces separated by the first
--   Text argument (which cannot be an empty string), consuming the
--   delimiter. An empty delimiter is invalid, and will cause an error to
--   be raised.
--   
--   Examples:
--   
--   
--   splitOn "\r\n" "a\r\nb\r\nd\r\ne" == ["a","b","d","e"]
--   splitOn "aaa"  "aaaXaaaXaaaXaaa"  == ["","X","X","X",""]
--   splitOn "x"    "x"                == ["",""]
--   
--   
--   and
--   
--   
--   intercalate s . splitOn s         == id
--   splitOn (singleton c)             == split (==c)
--   
--   
--   (Note: the string s to split on above cannot be empty.)
--   
--   This function is strict in its first argument, and lazy in its second.
--   
--   In (unlikely) bad cases, this function's time complexity degrades
--   towards O(n*m).
splitOn :: HasCallStack => Text -> Text -> [Text]

-- | O(n+m) Find all non-overlapping instances of needle in
--   haystack. Each element of the returned list consists of a
--   pair:
--   
--   
--   
- The entire string prior to the kth match (i.e. the
--   prefix)
--   
- The kth match, followed by the remainder of the string
--   
--   
--   Examples:
--   
--   
--   breakOnAll "::" ""
--   ==> []
--   breakOnAll "/" "a/b/c/"
--   ==> [("a", "/b/c/"), ("a/b", "/c/"), ("a/b/c", "/")]
--   
--   
--   This function is strict in its first argument, and lazy in its second.
--   
--   In (unlikely) bad cases, this function's time complexity degrades
--   towards O(n*m).
--   
--   The needle parameter may not be empty.
breakOnAll :: HasCallStack => Text -> Text -> [(Text, Text)]

-- | Strict Text partial functions. Import as:
--   
--   
--   import qualified RIO.Text.Partial as T'
--   
module RIO.Text.Partial

-- | O(1) Returns the first character of a Text, which must
--   be non-empty. This is a partial function, consider using uncons
--   instead.
head :: HasCallStack => Text -> Char

-- | O(1) Returns the last character of a Text, which must be
--   non-empty. This is a partial function, consider using unsnoc
--   instead.
last :: HasCallStack => Text -> Char

-- | O(1) Returns all characters after the head of a Text,
--   which must be non-empty. This is a partial function, consider using
--   uncons instead.
tail :: HasCallStack => Text -> Text

-- | O(1) Returns all but the last character of a Text, which
--   must be non-empty. This is a partial function, consider using
--   unsnoc instead.
init :: HasCallStack => Text -> Text

-- | O(m+n) Replace every non-overlapping occurrence of
--   needle in haystack with replacement.
--   
--   This function behaves as though it was defined as follows:
--   
--   
--   replace needle replacement haystack =
--     intercalate replacement (splitOn needle haystack)
--   
--   
--   As this suggests, each occurrence is replaced exactly once. So if
--   needle occurs in replacement, that occurrence will
--   not itself be replaced recursively:
--   
--   
--   >>> replace "oo" "foo" "oo"
--   "foo"
--   
--   
--   In cases where several instances of needle overlap, only the
--   first one will be replaced:
--   
--   
--   >>> replace "ofo" "bar" "ofofo"
--   "barfo"
--   
--   
--   In (unlikely) bad cases, this function's time complexity degrades
--   towards O(n*m).
replace :: HasCallStack => Text -> Text -> Text -> Text

-- | O(n) A variant of foldl that has no starting value
--   argument, and thus must be applied to a non-empty Text.
foldl1 :: HasCallStack => (Char -> Char -> Char) -> Text -> Char

-- | O(n) A strict version of foldl1.
foldl1' :: HasCallStack => (Char -> Char -> Char) -> Text -> Char

-- | O(n) A variant of foldr that has no starting value
--   argument, and thus must be applied to a non-empty Text.
foldr1 :: HasCallStack => (Char -> Char -> Char) -> Text -> Char

-- | O(n) maximum returns the maximum value from a
--   Text, which must be non-empty.
maximum :: HasCallStack => Text -> Char

-- | O(n) minimum returns the minimum value from a
--   Text, which must be non-empty.
minimum :: HasCallStack => Text -> Char

-- | O(n+m) Find the first instance of needle (which must
--   be non-null) in haystack. The first element of the
--   returned tuple is the prefix of haystack before
--   needle is matched. The second is the remainder of
--   haystack, starting with the match.
--   
--   Examples:
--   
--   
--   >>> breakOn "::" "a::b::c"
--   ("a","::b::c")
--   
--   
--   
--   >>> breakOn "/" "foobar"
--   ("foobar","")
--   
--   
--   Laws:
--   
--   
--   append prefix match == haystack
--     where (prefix, match) = breakOn needle haystack
--   
--   
--   If you need to break a string by a substring repeatedly (e.g. you want
--   to break on every instance of a substring), use breakOnAll
--   instead, as it has lower startup overhead.
--   
--   In (unlikely) bad cases, this function's time complexity degrades
--   towards O(n*m).
breakOn :: HasCallStack => Text -> Text -> (Text, Text)

-- | O(n+m) Similar to breakOn, but searches from the end of
--   the string.
--   
--   The first element of the returned tuple is the prefix of
--   haystack up to and including the last match of
--   needle. The second is the remainder of haystack,
--   following the match.
--   
--   
--   >>> breakOnEnd "::" "a::b::c"
--   ("a::b::","c")
--   
breakOnEnd :: HasCallStack => Text -> Text -> (Text, Text)

-- | O(m+n) Break a Text into pieces separated by the first
--   Text argument (which cannot be empty), consuming the delimiter.
--   An empty delimiter is invalid, and will cause an error to be raised.
--   
--   Examples:
--   
--   
--   >>> splitOn "\r\n" "a\r\nb\r\nd\r\ne"
--   ["a","b","d","e"]
--   
--   
--   
--   >>> splitOn "aaa"  "aaaXaaaXaaaXaaa"
--   ["","X","X","X",""]
--   
--   
--   
--   >>> splitOn "x"    "x"
--   ["",""]
--   
--   
--   and
--   
--   
--   intercalate s . splitOn s         == id
--   splitOn (singleton c)             == split (==c)
--   
--   
--   (Note: the string s to split on above cannot be empty.)
--   
--   In (unlikely) bad cases, this function's time complexity degrades
--   towards O(n*m).
splitOn :: HasCallStack => Text -> Text -> [Text]

-- | O(n+m) Find all non-overlapping instances of needle in
--   haystack. Each element of the returned list consists of a
--   pair:
--   
--   
--   
- The entire string prior to the kth match (i.e. the
--   prefix)
--   
- The kth match, followed by the remainder of the string
--   
--   
--   Examples:
--   
--   
--   >>> breakOnAll "::" ""
--   []
--   
--   
--   
--   >>> breakOnAll "/" "a/b/c/"
--   [("a","/b/c/"),("a/b","/c/"),("a/b/c","/")]
--   
--   
--   In (unlikely) bad cases, this function's time complexity degrades
--   towards O(n*m).
--   
--   The needle parameter may not be empty.
breakOnAll :: HasCallStack => Text -> Text -> [(Text, Text)]

-- | O(n+m) The count function returns the number of times
--   the query string appears in the given Text. An empty query
--   string is invalid, and will cause an error to be raised.
--   
--   In (unlikely) bad cases, this function's time complexity degrades
--   towards O(n*m).
count :: HasCallStack => Text -> Text -> Int

module RIO.Time
data () => CalendarDiffDays
CalendarDiffDays :: Integer -> Integer -> CalendarDiffDays
[cdMonths] :: CalendarDiffDays -> Integer
[cdDays] :: CalendarDiffDays -> Integer

-- | The class of types which can be represented as a period of days.
class Ord p => DayPeriod p

-- | Returns the first Day in a period of days.
periodFirstDay :: DayPeriod p => p -> Day

-- | Returns the last Day in a period of days.
periodLastDay :: DayPeriod p => p -> Day

-- | Get the period this day is in.
dayPeriod :: DayPeriod p => Day -> p

-- | The Modified Julian Day is a standard count of days, with zero being
--   the day 1858-11-17.
newtype () => Day
ModifiedJulianDay :: Integer -> Day
[toModifiedJulianDay] :: Day -> Integer

-- | Day of month, in range 1 to 31.
type DayOfMonth = Int

-- | Month of year, in range 1 (January) to 12 (December).
type MonthOfYear = Int

-- | Year of Common Era (when positive).
type Year = Integer
data () => DayOfWeek
Monday :: DayOfWeek
Tuesday :: DayOfWeek
Wednesday :: DayOfWeek
Thursday :: DayOfWeek
Friday :: DayOfWeek
Saturday :: DayOfWeek
Sunday :: DayOfWeek

-- | This is a length of time, as measured by a clock. Conversion functions
--   such as fromInteger and realToFrac will treat it as
--   seconds. For example, (0.010 :: DiffTime) corresponds to 10
--   milliseconds.
--   
--   It has a precision of one picosecond (= 10^-12 s). Enumeration
--   functions will treat it as picoseconds.
data () => DiffTime

-- | This is a length of time, as measured by UTC. It has a precision of
--   10^-12 s.
--   
--   Conversion functions such as fromInteger and realToFrac
--   will treat it as seconds. For example, (0.010 ::
--   NominalDiffTime) corresponds to 10 milliseconds.
--   
--   It has a precision of one picosecond (= 10^-12 s). Enumeration
--   functions will treat it as picoseconds.
--   
--   It ignores leap-seconds, so it's not necessarily a fixed amount of
--   clock time. For instance, 23:00 UTC + 2 hours of NominalDiffTime =
--   01:00 UTC (+ 1 day), regardless of whether a leap-second intervened.
data () => NominalDiffTime

-- | This is the simplest representation of UTC. It consists of the day
--   number, and a time offset from midnight. Note that if a day has a leap
--   second added to it, it will have 86401 seconds.
data () => UTCTime
UTCTime :: Day -> DiffTime -> UTCTime

-- | the day
[utctDay] :: UTCTime -> Day

-- | the time from midnight, 0 <= t < 86401s (because of
--   leap-seconds)
[utctDayTime] :: UTCTime -> DiffTime

-- | The Modified Julian Date is the day with the fraction of the day,
--   measured from UT midnight. It's used to represent UT1, which is time
--   as measured by the earth's rotation, adjusted for various wobbles.
newtype () => UniversalTime
ModJulianDate :: Rational -> UniversalTime
[getModJulianDate] :: UniversalTime -> Rational
data () => CalendarDiffTime
CalendarDiffTime :: Integer -> NominalDiffTime -> CalendarDiffTime
[ctMonths] :: CalendarDiffTime -> Integer
[ctTime] :: CalendarDiffTime -> NominalDiffTime

-- | A TimeZone is a whole number of minutes offset from UTC, together with
--   a name and a "just for summer" flag.
data () => TimeZone
TimeZone :: Int -> Bool -> String -> TimeZone

-- | The number of minutes offset from UTC. Positive means local time will
--   be later in the day than UTC.
[timeZoneMinutes] :: TimeZone -> Int

-- | Is this time zone just persisting for the summer?
[timeZoneSummerOnly] :: TimeZone -> Bool

-- | The name of the zone, typically a three- or four-letter acronym.
[timeZoneName] :: TimeZone -> String

-- | Time of day as represented in hour, minute and second (with
--   picoseconds), typically used to express local time of day.
--   
--   TimeOfDay 24 0 0 is considered invalid for the purposes of
--   makeTimeOfDayValid, as well as reading and parsing, but valid
--   for ISO 8601 parsing in Data.Time.Format.ISO8601.
data () => TimeOfDay
TimeOfDay :: Int -> Int -> Pico -> TimeOfDay

-- | range 0 - 23
[todHour] :: TimeOfDay -> Int

-- | range 0 - 59
[todMin] :: TimeOfDay -> Int

-- | Note that 0 <= todSec < 61, accomodating leap seconds.
--   Any local minute may have a leap second, since leap seconds happen in
--   all zones simultaneously
[todSec] :: TimeOfDay -> Pico

-- | A simple day and time aggregate, where the day is of the specified
--   parameter, and the time is a TimeOfDay. Conversion of this (as local
--   civil time) to UTC depends on the time zone. Conversion of this (as
--   local mean time) to UT1 depends on the longitude.
data () => LocalTime
LocalTime :: Day -> TimeOfDay -> LocalTime
[localDay] :: LocalTime -> Day
[localTimeOfDay] :: LocalTime -> TimeOfDay
data () => TimeLocale
TimeLocale :: [(String, String)] -> [(String, String)] -> (String, String) -> String -> String -> String -> String -> [TimeZone] -> TimeLocale

-- | full and abbreviated week days, starting with Sunday
[wDays] :: TimeLocale -> [(String, String)]

-- | full and abbreviated months
[months] :: TimeLocale -> [(String, String)]

-- | AM/PM symbols
[amPm] :: TimeLocale -> (String, String)

-- | formatting strings
[dateTimeFmt] :: TimeLocale -> String

-- | formatting strings
[dateFmt] :: TimeLocale -> String

-- | formatting strings
[timeFmt] :: TimeLocale -> String

-- | formatting strings
[time12Fmt] :: TimeLocale -> String

-- | time zones known by name
[knownTimeZones] :: TimeLocale -> [TimeZone]

-- | The class of types which can be parsed given a UNIX-style time format
--   string.
class () => ParseTime t
class () => FormatTime t

-- | A local time together with a time zone.
--   
--   There is no Eq instance for ZonedTime. If you want to
--   compare local times, use zonedTimeToLocalTime. If you want to
--   compare absolute times, use zonedTimeToUTC.
data () => ZonedTime
ZonedTime :: LocalTime -> TimeZone -> ZonedTime
[zonedTimeToLocalTime] :: ZonedTime -> LocalTime
[zonedTimeZone] :: ZonedTime -> TimeZone
pattern May :: MonthOfYear

-- | The twelve MonthOfYear patterns form a COMPLETE set.
pattern December :: MonthOfYear
pattern November :: MonthOfYear
pattern October :: MonthOfYear
pattern September :: MonthOfYear
pattern August :: MonthOfYear
pattern July :: MonthOfYear
pattern June :: MonthOfYear
pattern April :: MonthOfYear
pattern March :: MonthOfYear
pattern February :: MonthOfYear
pattern January :: MonthOfYear

-- | Also known as Before Christ. Note that Year 1 = 1 CE, and the previous
--   Year 0 = 1 BCE. CommonEra and BeforeCommonEra form a
--   COMPLETE set.
pattern BeforeCommonEra :: Integer -> Year

-- | Also known as Anno Domini.
pattern CommonEra :: Integer -> Year

-- | Bidirectional abstract constructor for the proleptic Gregorian
--   calendar. Invalid values will be clipped to the correct range, month
--   first, then day.
pattern YearMonthDay :: Year -> MonthOfYear -> DayOfMonth -> Day

-- | Substitute various time-related information for each %-code in the
--   string, as per formatCharacter.
--   
--   The general form is
--   %<modifier><width><alternate><specifier>,
--   where <modifier>, <width>, and
--   <alternate> are optional.
--   
--   
<modifier>
--   
--   glibc-style modifiers can be used before the specifier (here marked as
--   z):
--   
--   
--   
- %-z no padding
--   
- %_z pad with spaces
--   
- %0z pad with zeros
--   
- %^z convert to upper case
--   
- %#z convert to lower case (consistently, unlike
--   glibc)
--   
--   
--   
<width>
--   
--   Width digits can also be used after any modifiers and before the
--   specifier (here marked as z), for example:
--   
--   
--   
- %4z pad to 4 characters (with default padding
--   character)
--   
- %_12z pad with spaces to 12 characters
--   
--   
--   
<alternate>
--   
--   An optional E character indicates an alternate formatting.
--   Currently this only affects %Z and %z.
--   
--   
--   
- %Ez alternate formatting
--   
--   
--   
<specifier>
--   
--   For all types (note these three are done by formatTime, not by
--   formatCharacter):
--   
--   
--   
- %% %
--   
- %t tab
--   
- %n newline
--   
--   
--   
TimeZone
--   
--   For TimeZone (and ZonedTime and UTCTime):
--   
--   
--   
- %z timezone offset in the format
--   ±HHMM
--   
- %Ez timezone offset in the format
--   ±HH:MM
--   
- %Z timezone name (or else offset in the format
--   ±HHMM)
--   
- %EZ timezone name (or else offset in the format
--   ±HH:MM)
--   
--   
--   
LocalTime
--   
--   For LocalTime (and ZonedTime and UTCTime
--   and UniversalTime):
--   
--   
--   
- %c as dateTimeFmt locale (e.g.
--   %a %b %e %H:%M:%S %Z %Y)
--   
--   
--   
TimeOfDay
--   
--   For TimeOfDay (and LocalTime and ZonedTime
--   and UTCTime and UniversalTime):
--   
--   
--   
- %R same as %H:%M
--   
- %T same as %H:%M:%S
--   
- %X as timeFmt locale (e.g.
--   %H:%M:%S)
--   
- %r as time12Fmt locale (e.g.
--   %I:%M:%S %p)
--   
- %P day-half of day from (amPm
--   locale), converted to lowercase, am,
--   pm
--   
- %p day-half of day from (amPm
--   locale), AM, PM
--   
- %H hour of day (24-hour), 0-padded to two chars,
--   00 - 23
--   
- %k hour of day (24-hour), space-padded to two
--   chars,  0 - 23
--   
- %I hour of day-half (12-hour), 0-padded to two
--   chars, 01 - 12
--   
- %l hour of day-half (12-hour), space-padded to two
--   chars,  1 - 12
--   
- %M minute of hour, 0-padded to two chars,
--   00 - 59
--   
- %S second of minute (without decimal part),
--   0-padded to two chars, 00 - 60
--   
- %q picosecond of second, 0-padded to twelve chars,
--   000000000000 - 999999999999.
--   
- %Q decimal point and fraction of second, up to 12
--   second decimals, without trailing zeros. For a whole number of
--   seconds, %Q omits the decimal point unless padding is
--   specified.
--   
--   
--   
UTCTime and ZonedTime
--   
--   For UTCTime and ZonedTime:
--   
--   
--   
- %s number of whole seconds since the Unix epoch.
--   For times before the Unix epoch, this is a negative number. Note that
--   in %s.%q and %s%Q the decimals are positive, not
--   negative. For example, 0.9 seconds before the Unix epoch is formatted
--   as -1.1 with %s%Q.
--   
--   
--   
DayOfWeek
--   
--   For DayOfWeek (and Day and LocalTime and
--   ZonedTime and UTCTime and UniversalTime):
--   
--   
--   
- %u day of week number for Week Date format,
--   1 (= Monday) - 7 (= Sunday)
--   
- %w day of week number, 0 (= Sunday) -
--   6 (= Saturday)
--   
- %a day of week, short form (snd from
--   wDays locale), Sun - Sat
--   
- %A day of week, long form (fst from
--   wDays locale), Sunday -
--   Saturday
--   
--   
--   
Month
--   
--   For Month (and Day and LocalTime and
--   ZonedTime and UTCTime and UniversalTime):
--   
--   
--   
- %Y year, no padding. Note %0Y and
--   %_Y pad to four chars
--   
- %y year of century, 0-padded to two chars,
--   00 - 99
--   
- %C century, no padding. Note %0C and
--   %_C pad to two chars
--   
- %B month name, long form (fst from
--   months locale), January -
--   December
--   
- %b, %h month name, short form (snd
--   from months locale), Jan - Dec
--   
- %m month of year, 0-padded to two chars,
--   01 - 12
--   
--   
--   
Day
--   
--   For Day (and LocalTime and ZonedTime and
--   UTCTime and UniversalTime):
--   
--   
--   
- %D same as %m/%d/%y
--   
- %F same as %Y-%m-%d
--   
- %x as dateFmt locale (e.g.
--   %m/%d/%y)
--   
- %d day of month, 0-padded to two chars,
--   01 - 31
--   
- %e day of month, space-padded to two chars, 
--   1 - 31
--   
- %j day of year, 0-padded to three chars,
--   001 - 366
--   
- %f century for Week Date format, no padding. Note
--   %0f and %_f pad to two chars
--   
- %V week of year for Week Date format, 0-padded to
--   two chars, 01 - 53
--   
- %U week of year where weeks start on Sunday (as
--   sundayStartWeek), 0-padded to two chars, 00 -
--   53
--   
- %W week of year where weeks start on Monday (as
--   mondayStartWeek), 0-padded to two chars, 00 -
--   53
--   
--   
--   
Duration types
--   
--   The specifiers for DiffTime, NominalDiffTime,
--   CalendarDiffDays, and CalendarDiffTime are
--   semantically separate from the other types. Specifiers on negative
--   time differences will generally be negative (think rem rather
--   than mod).
--   
--   
NominalDiffTime and DiffTime
--   
--   Note that a "minute" of DiffTime is simply 60 SI seconds,
--   rather than a minute of civil time. Use NominalDiffTime to
--   work with civil time, ignoring any leap seconds.
--   
--   For NominalDiffTime and DiffTime:
--   
--   
--   
- %w total whole weeks
--   
- %d total whole days
--   
- %D whole days of week
--   
- %h total whole hours
--   
- %H whole hours of day
--   
- %m total whole minutes
--   
- %M whole minutes of hour
--   
- %s total whole seconds
--   
- %Es total seconds, with decimal point and up to
--   <width> (default 12) decimal places, without trailing zeros. For
--   a whole number of seconds, %Es omits the decimal point unless
--   padding is specified.
--   
- %0Es total seconds, with decimal point and
--   <width> (default 12) decimal places.
--   
- %S whole seconds of minute
--   
- %ES seconds of minute, with decimal point and up
--   to <width> (default 12) decimal places, without trailing zeros.
--   For a whole number of seconds, %ES omits the decimal point
--   unless padding is specified.
--   
- %0ES seconds of minute as two digits, with decimal
--   point and <width> (default 12) decimal places.
--   
--   
--   
CalendarDiffDays
--   
--   For CalendarDiffDays (and CalendarDiffTime):
--   
--   
--   
- %y total years
--   
- %b total months
--   
- %B months of year
--   
- %w total weeks, not including months
--   
- %d total days, not including months
--   
- %D days of week
--   
--   
--   
CalendarDiffTime
--   
--   For CalendarDiffTime:
--   
--   
--   
- %h total hours, not including months
--   
- %H hours of day
--   
- %m total minutes, not including months
--   
- %M minutes of hour
--   
- %s total whole seconds, not including months
--   
- %Es total seconds, not including months, with
--   decimal point and up to <width> (default 12) decimal places,
--   without trailing zeros. For a whole number of seconds, %Es
--   omits the decimal point unless padding is specified.
--   
- %0Es total seconds, not including months, with
--   decimal point and <width> (default 12) decimal places.
--   
- %S whole seconds of minute
--   
- %ES seconds of minute, with decimal point and up
--   to <width> (default 12) decimal places, without trailing zeros.
--   For a whole number of seconds, %ES omits the decimal point
--   unless padding is specified.
--   
- %0ES seconds of minute as two digits, with decimal
--   point and <width> (default 12) decimal places.
--   
formatTime :: FormatTime t => TimeLocale -> String -> t -> String

-- | Convert from proleptic Gregorian calendar. Invalid values will be
--   clipped to the correct range, month first, then day.
fromGregorian :: Year -> MonthOfYear -> DayOfMonth -> Day
calendarDay :: CalendarDiffDays
calendarWeek :: CalendarDiffDays
calendarMonth :: CalendarDiffDays
calendarYear :: CalendarDiffDays

-- | Scale by a factor. Note that scaleCalendarDiffDays (-1) will
--   not perfectly invert a duration, due to variable month lengths.
scaleCalendarDiffDays :: Integer -> CalendarDiffDays -> CalendarDiffDays
addDays :: Integer -> Day -> Day
diffDays :: Day -> Day -> Integer

-- | A list of all the days in this period.
periodAllDays :: DayPeriod p => p -> [Day]

-- | The number of days in this period.
periodLength :: DayPeriod p => p -> Int

-- | Get the period this day is in, with the 1-based day number within the
--   period.
--   
--   
--   periodFromDay (periodFirstDay p) = (p,1)
--   
periodFromDay :: DayPeriod p => Day -> (p, Int)

-- | Inverse of periodFromDay.
periodToDay :: DayPeriod p => p -> Int -> Day

-- | Validating inverse of periodFromDay.
periodToDayValid :: DayPeriod p => p -> Int -> Maybe Day

-- | Is this year a leap year according to the proleptic Gregorian
--   calendar?
isLeapYear :: Year -> Bool

-- | Convert to proleptic Gregorian calendar.
toGregorian :: Day -> (Year, MonthOfYear, DayOfMonth)

-- | Convert from proleptic Gregorian calendar. Invalid values will return
--   Nothing
fromGregorianValid :: Year -> MonthOfYear -> DayOfMonth -> Maybe Day

-- | Show in ISO 8601 format (yyyy-mm-dd)
showGregorian :: Day -> String

-- | The number of days in a given month according to the proleptic
--   Gregorian calendar.
gregorianMonthLength :: Year -> MonthOfYear -> DayOfMonth

-- | Add months, with days past the last day of the month clipped to the
--   last day. For instance, 2005-01-30 + 1 month = 2005-02-28.
addGregorianMonthsClip :: Integer -> Day -> Day

-- | Add months, with days past the last day of the month rolling over to
--   the next month. For instance, 2005-01-30 + 1 month = 2005-03-02.
addGregorianMonthsRollOver :: Integer -> Day -> Day

-- | Add years, matching month and day, with Feb 29th clipped to Feb 28th
--   if necessary. For instance, 2004-02-29 + 2 years = 2006-02-28.
addGregorianYearsClip :: Integer -> Day -> Day

-- | Add years, matching month and day, with Feb 29th rolled over to Mar
--   1st if necessary. For instance, 2004-02-29 + 2 years = 2006-03-01.
addGregorianYearsRollOver :: Integer -> Day -> Day

-- | Add months (clipped to last day), then add days
addGregorianDurationClip :: CalendarDiffDays -> Day -> Day

-- | Add months (rolling over to next month), then add days
addGregorianDurationRollOver :: CalendarDiffDays -> Day -> Day

-- | Calendrical difference, with as many whole months as possible
diffGregorianDurationClip :: Day -> Day -> CalendarDiffDays

-- | Calendrical difference, with as many whole months as possible. Same as
--   diffGregorianDurationClip for positive durations.
diffGregorianDurationRollOver :: Day -> Day -> CalendarDiffDays
dayOfWeek :: Day -> DayOfWeek

-- | dayOfWeekDiff a b = a - b in range 0 to 6. The number of days
--   from b to the next a.
dayOfWeekDiff :: DayOfWeek -> DayOfWeek -> Int

-- | The first day-of-week on or after some day
firstDayOfWeekOnAfter :: DayOfWeek -> Day -> Day

-- | Returns a week containing the given Day where the first day is
--   the DayOfWeek specified.
--   
--   Examples:
--   
--   
--   >>> weekAllDays Sunday (YearMonthDay 2022 02 21)
--   [YearMonthDay 2022 2 20 .. YearMonthDay 2022 2 26]
--   
--   
--   
--   >>> weekAllDays Monday (YearMonthDay 2022 02 21)
--   [YearMonthDay 2022 2 21 .. YearMonthDay 2022 2 27]
--   
--   
--   
--   >>> weekAllDays Tuesday (YearMonthDay 2022 02 21)
--   [YearMonthDay 2022 2 15 .. YearMonthDay 2022 2 21]
--   
weekAllDays :: DayOfWeek -> Day -> [Day]

-- | Returns the first day of a week containing the given Day.
--   
--   Examples:
--   
--   
--   >>> weekFirstDay Sunday (YearMonthDay 2022 02 21)
--   YearMonthDay 2022 2 20
--   
--   
--   
--   >>> weekFirstDay Monday (YearMonthDay 2022 02 21)
--   YearMonthDay 2022 2 21
--   
--   
--   
--   >>> weekFirstDay Tuesday (YearMonthDay 2022 02 21)
--   YearMonthDay 2022 2 15
--   
weekFirstDay :: DayOfWeek -> Day -> Day

-- | Returns the last day of a week containing the given Day.
--   
--   Examples:
--   
--   
--   >>> weekLastDay Sunday (YearMonthDay 2022 02 21)
--   YearMonthDay 2022 2 26
--   
--   
--   
--   >>> weekLastDay Monday (YearMonthDay 2022 02 21)
--   YearMonthDay 2022 2 27
--   
--   
--   
--   >>> weekLastDay Tuesday (YearMonthDay 2022 02 21)
--   YearMonthDay 2022 2 21
--   
weekLastDay :: DayOfWeek -> Day -> Day

-- | Create a DiffTime which represents an integral number of
--   seconds.
secondsToDiffTime :: Integer -> DiffTime

-- | Create a DiffTime from a number of picoseconds.
picosecondsToDiffTime :: Integer -> DiffTime

-- | Get the number of picoseconds in a DiffTime.
diffTimeToPicoseconds :: DiffTime -> Integer

-- | Create a NominalDiffTime from a number of seconds.
secondsToNominalDiffTime :: Pico -> NominalDiffTime

-- | Get the seconds in a NominalDiffTime.
nominalDiffTimeToSeconds :: NominalDiffTime -> Pico

-- | One day in NominalDiffTime.
nominalDay :: NominalDiffTime

-- | The resolution of getSystemTime, getCurrentTime,
--   getPOSIXTime. On UNIX systems this uses
--   clock_getres, which may be wrong on WSL2.
getTime_resolution :: DiffTime

-- | addUTCTime a b = a + b
addUTCTime :: NominalDiffTime -> UTCTime -> UTCTime

-- | diffUTCTime a b = a - b
diffUTCTime :: UTCTime -> UTCTime -> NominalDiffTime
calendarTimeDays :: CalendarDiffDays -> CalendarDiffTime
calendarTimeTime :: NominalDiffTime -> CalendarDiffTime

-- | Scale by a factor. Note that scaleCalendarDiffTime (-1) will
--   not perfectly invert a duration, due to variable month lengths.
scaleCalendarDiffTime :: Integer -> CalendarDiffTime -> CalendarDiffTime

-- | Create a nameless non-summer timezone for this number of minutes.
minutesToTimeZone :: Int -> TimeZone

-- | Create a nameless non-summer timezone for this number of hours.
hoursToTimeZone :: Int -> TimeZone

-- | Text representing the offset of this timezone, such as "-0800" or
--   "+0400" (like %z in formatTime), with arbitrary padding.
timeZoneOffsetString' :: Maybe Char -> TimeZone -> String

-- | Text representing the offset of this timezone, such as "-0800" or
--   "+0400" (like %z in formatTime).
timeZoneOffsetString :: TimeZone -> String

-- | The UTC time zone.
utc :: TimeZone

-- | Hour zero
midnight :: TimeOfDay

-- | Hour twelve
midday :: TimeOfDay
makeTimeOfDayValid :: Int -> Int -> Pico -> Maybe TimeOfDay

-- | Convert a period of time into a count of days and a time of day since
--   midnight. The time of day will never have a leap second.
timeToDaysAndTimeOfDay :: NominalDiffTime -> (Integer, TimeOfDay)

-- | Convert a count of days and a time of day since midnight into a period
--   of time.
daysAndTimeOfDayToTime :: Integer -> TimeOfDay -> NominalDiffTime

-- | Convert a time of day in UTC to a time of day in some timezone,
--   together with a day adjustment.
utcToLocalTimeOfDay :: TimeZone -> TimeOfDay -> (Integer, TimeOfDay)

-- | Convert a time of day in some timezone to a time of day in UTC,
--   together with a day adjustment.
localToUTCTimeOfDay :: TimeZone -> TimeOfDay -> (Integer, TimeOfDay)

-- | Get the time of day given a time since midnight. Time more than 24h
--   will be converted to leap-seconds.
timeToTimeOfDay :: DiffTime -> TimeOfDay

-- | Same as timeToTimeOfDay.
pastMidnight :: DiffTime -> TimeOfDay

-- | Get the time since midnight for a given time of day.
timeOfDayToTime :: TimeOfDay -> DiffTime

-- | Same as timeOfDayToTime.
sinceMidnight :: TimeOfDay -> DiffTime

-- | Get the time of day given the fraction of a day since midnight.
dayFractionToTimeOfDay :: Rational -> TimeOfDay

-- | Get the fraction of a day since midnight given a time of day.
timeOfDayToDayFraction :: TimeOfDay -> Rational

-- | addLocalTime a b = a + b
addLocalTime :: NominalDiffTime -> LocalTime -> LocalTime

-- | diffLocalTime a b = a - b
diffLocalTime :: LocalTime -> LocalTime -> NominalDiffTime

-- | Get the local time of a UTC time in a time zone.
utcToLocalTime :: TimeZone -> UTCTime -> LocalTime

-- | Get the UTC time of a local time in a time zone.
localTimeToUTC :: TimeZone -> LocalTime -> UTCTime

-- | Get the local time of a UT1 time on a particular meridian (in degrees,
--   positive is East).
ut1ToLocalTime :: Rational -> UniversalTime -> LocalTime

-- | Get the UT1 time of a local time on a particular meridian (in degrees,
--   positive is East).
localTimeToUT1 :: Rational -> LocalTime -> UniversalTime

-- | Locale representing American usage.
--   
--   knownTimeZones contains only the ten time-zones mentioned in
--   RFC 822 sec. 5: "UT", "GMT", "EST", "EDT", "CST", "CDT", "MST", "MDT",
--   "PST", "PDT". Note that the parsing functions will regardless parse
--   "UTC", single-letter military time-zones, and +HHMM format.
defaultTimeLocale :: TimeLocale

-- | Construct format string according to ISO-8601.
--   
--   The Maybe String argument allows to supply an optional time
--   specification. E.g.:
--   
--   
--   iso8601DateFormat Nothing            == "%Y-%m-%d"           -- i.e. YYYY-MM-DD
--   iso8601DateFormat (Just "%H:%M:%S")  == "%Y-%m-%dT%H:%M:%S"  -- i.e. YYYY-MM-DDTHH:MM:SS
--   
iso8601DateFormat :: Maybe String -> String

-- | Format string according to RFC822.
rfc822DateFormat :: String
utcToZonedTime :: TimeZone -> UTCTime -> ZonedTime
zonedTimeToUTC :: ZonedTime -> UTCTime

-- | Parses a time value given a format string. Missing information will be
--   derived from 1970-01-01 00:00 UTC (which was a Thursday). Supports the
--   same %-codes as formatTime, including %-,
--   %_ and %0 modifiers, however padding widths are not
--   supported. Case is not significant in the input string. Some
--   variations in the input are accepted:
--   
--   
--   
- %z %Ez accepts any of ±HHMM or
--   ±HH:MM.
--   
- %Z %EZ accepts any string of letters, or
--   any of the formats accepted by %z.
--   
- %0Y accepts exactly four digits.
--   
- %0G accepts exactly four digits.
--   
- %0C accepts exactly two digits.
--   
- %0f accepts exactly two digits.
--   
--   
--   For example, to parse a date in YYYY-MM-DD format, while allowing the
--   month and date to have optional leading zeros (notice the -
--   modifier used for %m and %d):
--   
--   
--   Prelude Data.Time> parseTimeM True defaultTimeLocale "%Y-%-m-%-d" "2010-3-04" :: Maybe Day
--   Just 2010-03-04
--   
parseTimeM :: (MonadFail m, ParseTime t) => Bool -> TimeLocale -> String -> String -> m t

-- | Parses a time value given a list of pairs of format and input.
--   Resulting value is constructed from all provided specifiers.
parseTimeMultipleM :: (MonadFail m, ParseTime t) => Bool -> TimeLocale -> [(String, String)] -> m t

-- | Parse a time value given a format string. Fails if the input could not
--   be parsed using the given format. See parseTimeM for details.
parseTimeOrError :: ParseTime t => Bool -> TimeLocale -> String -> String -> t

-- | Parse a time value given a format string. See parseTimeM for
--   details.
readSTime :: ParseTime t => Bool -> TimeLocale -> String -> ReadS t

-- | Parse a time value given a format string. See parseTimeM for
--   details.
readPTime :: ParseTime t => Bool -> TimeLocale -> String -> ReadP t
getCurrentTime :: MonadIO m => m UTCTime
getTimeZone :: MonadIO m => UTCTime -> m TimeZone
getCurrentTimeZone :: MonadIO m => m TimeZone
getZonedTime :: MonadIO m => m ZonedTime
utcToLocalZonedTime :: MonadIO m => UTCTime -> m ZonedTime

-- | Generic Vector interface. Import as:
--   
--   
--   import qualified RIO.Vector as V
--   
--   
--   This module does not export any partial or unsafe functions. For
--   those, see RIO.Vector.Partial and RIO.Vector.Unsafe
module RIO.Vector

-- | Class of immutable vectors. Every immutable vector is associated with
--   its mutable version through the Mutable type family. Methods of
--   this class should not be used directly. Instead,
--   Data.Vector.Generic and other Data.Vector modules
--   provide safe and fusible wrappers.
--   
--   Minimum complete implementation:
--   
--   
--   
- basicUnsafeFreeze
--   
- basicUnsafeThaw
--   
- basicLength
--   
- basicUnsafeSlice
--   
- basicUnsafeIndexM
--   
class MVector Mutable v a => Vector (v :: Type -> Type) a

-- | O(1) Yield the length of the vector.
length :: Vector v a => v a -> Int

-- | O(1) Test whether a vector is empty.
null :: Vector v a => v a -> Bool

-- | O(1) Safe indexing.
(!?) :: Vector v a => v a -> Int -> Maybe a
infixl 9 !?

-- | O(1) Yield a slice of the vector without copying it. The vector
--   must contain at least i+n elements.
slice :: (HasCallStack, Vector v a) => Int -> Int -> v a -> v a

-- | O(1) Yield the first n elements without copying. The
--   vector may contain less than n elements, in which case it is
--   returned unchanged.
take :: Vector v a => Int -> v a -> v a

-- | O(1) Yield all but the first n elements without
--   copying. The vector may contain less than n elements, in
--   which case an empty vector is returned.
drop :: Vector v a => Int -> v a -> v a

-- | O(1) Yield the first n elements paired with the
--   remainder, without copying.
--   
--   Note that splitAt n v is equivalent to
--   (take n v, drop n v), but slightly more
--   efficient.
splitAt :: Vector v a => Int -> v a -> (v a, v a)

-- | O(1) The empty vector.
empty :: Vector v a => v a

-- | O(1) A vector with exactly one element.
singleton :: Vector v a => a -> v a

-- | O(n) A vector of the given length with the same value in each
--   position.
replicate :: Vector v a => Int -> a -> v a

-- | O(n) Construct a vector of the given length by applying the
--   function to each index.
generate :: Vector v a => Int -> (Int -> a) -> v a

-- | O(n) Apply the function <math> times to an initial value,
--   producing a vector of length <math>. The 0th element will
--   contain the initial value, which is why there is one less function
--   application than the number of elements in the produced vector.
--   
--   <math>
iterateN :: Vector v a => Int -> (a -> a) -> a -> v a

-- | O(n) Execute the monadic action the given number of times and
--   store the results in a vector.
replicateM :: (Monad m, Vector v a) => Int -> m a -> m (v a)

-- | O(n) Construct a vector of the given length by applying the
--   monadic action to each index.
generateM :: (Monad m, Vector v a) => Int -> (Int -> m a) -> m (v a)

-- | O(n) Apply the monadic function <math> times to an
--   initial value, producing a vector of length <math>. The 0th
--   element will contain the initial value, which is why there is one less
--   function application than the number of elements in the produced
--   vector.
--   
--   For a non-monadic version, see iterateN.
iterateNM :: (Monad m, Vector v a) => Int -> (a -> m a) -> a -> m (v a)

-- | Execute the monadic action and freeze the resulting vector.
--   
--   
--   create (do { v <- new 2; write v 0 'a'; write v 1 'b'; return v }) = <a,b>
--   
create :: Vector v a => (forall s. () => ST s (Mutable v s a)) -> v a

-- | Execute the monadic action and freeze the resulting vectors.
createT :: (Traversable f, Vector v a) => (forall s. () => ST s (f (Mutable v s a))) -> f (v a)

-- | O(n) Construct a vector by repeatedly applying the generator
--   function to a seed. The generator function yields Just the next
--   element and the new seed or Nothing if there are no more
--   elements.
--   
--   
--   unfoldr (\n -> if n == 0 then Nothing else Just (n,n-1)) 10
--    = <10,9,8,7,6,5,4,3,2,1>
--   
unfoldr :: Vector v a => (b -> Maybe (a, b)) -> b -> v a

-- | O(n) Construct a vector with at most n elements by
--   repeatedly applying the generator function to a seed. The generator
--   function yields Just the next element and the new seed or
--   Nothing if there are no more elements.
--   
--   
--   unfoldrN 3 (\n -> Just (n,n-1)) 10 = <10,9,8>
--   
unfoldrN :: Vector v a => Int -> (b -> Maybe (a, b)) -> b -> v a

-- | O(n) Construct a vector by repeatedly applying the monadic
--   generator function to a seed. The generator function yields
--   Just the next element and the new seed or Nothing if
--   there are no more elements.
unfoldrM :: (Monad m, Vector v a) => (b -> m (Maybe (a, b))) -> b -> m (v a)

-- | O(n) Construct a vector by repeatedly applying the monadic
--   generator function to a seed. The generator function yields
--   Just the next element and the new seed or Nothing if
--   there are no more elements.
unfoldrNM :: (Monad m, Vector v a) => Int -> (b -> m (Maybe (a, b))) -> b -> m (v a)

-- | O(n) Construct a vector with n elements by repeatedly
--   applying the generator function to the already constructed part of the
--   vector.
--   
--   
--   constructN 3 f = let a = f <> ; b = f <a> ; c = f <a,b> in <a,b,c>
--   
constructN :: Vector v a => Int -> (v a -> a) -> v a

-- | O(n) Construct a vector with n elements from right to
--   left by repeatedly applying the generator function to the already
--   constructed part of the vector.
--   
--   
--   constructrN 3 f = let a = f <> ; b = f<a> ; c = f <b,a> in <c,b,a>
--   
constructrN :: Vector v a => Int -> (v a -> a) -> v a

-- | O(n) Yield a vector of the given length, containing the values
--   x, x+1 etc. This operation is usually more efficient
--   than enumFromTo.
--   
--   
--   enumFromN 5 3 = <5,6,7>
--   
enumFromN :: (Vector v a, Num a) => a -> Int -> v a

-- | O(n) Yield a vector of the given length, containing the values
--   x, x+y, x+y+y etc. This operations is
--   usually more efficient than enumFromThenTo.
--   
--   
--   enumFromStepN 1 2 5 = <1,3,5,7,9>
--   
enumFromStepN :: (Vector v a, Num a) => a -> a -> Int -> v a

-- | O(n) Enumerate values from x to y.
--   
--   WARNING: This operation can be very inefficient. If possible,
--   use enumFromN instead.
enumFromTo :: (Vector v a, Enum a) => a -> a -> v a

-- | O(n) Enumerate values from x to y with a
--   specific step z.
--   
--   WARNING: This operation can be very inefficient. If possible,
--   use enumFromStepN instead.
enumFromThenTo :: (Vector v a, Enum a) => a -> a -> a -> v a

-- | O(n) Prepend an element.
cons :: Vector v a => a -> v a -> v a

-- | O(n) Append an element.
snoc :: Vector v a => v a -> a -> v a

-- | O(m+n) Concatenate two vectors.
(++) :: Vector v a => v a -> v a -> v a
infixr 5 ++

-- | O(n) Concatenate all vectors in the list.
concat :: Vector v a => [v a] -> v a

-- | O(n) Concatenate all vectors in the non-empty list.
concatNE :: Vector v a => NonEmpty (v a) -> v a

-- | O(n) Yield the argument, but force it not to retain any extra
--   memory, possibly by copying it.
--   
--   This is especially useful when dealing with slices. For example:
--   
--   
--   force (slice 0 2 <huge vector>)
--   
--   
--   Here, the slice retains a reference to the huge vector. Forcing it
--   creates a copy of just the elements that belong to the slice and
--   allows the huge vector to be garbage collected.
force :: Vector v a => v a -> v a

-- | O(n) Reverse a vector.
reverse :: Vector v a => v a -> v a

-- | Apply a destructive operation to a vector. The operation may be
--   performed in place if it is safe to do so and will modify a copy of
--   the vector otherwise (see New for details).
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> import qualified Data.Vector.Mutable as MV
--   
--   >>> V.modify (\v -> MV.write v 0 'x') $ V.replicate 4 'a'
--   "xaaa"
--   
modify :: Vector v a => (forall s. () => Mutable v s a -> ST s ()) -> v a -> v a

-- | O(n) Pair each element in a vector with its index.
indexed :: (Vector v a, Vector v (Int, a)) => v a -> v (Int, a)

-- | O(n) Map a function over a vector.
map :: (Vector v a, Vector v b) => (a -> b) -> v a -> v b

-- | O(n) Apply a function to every element of a vector and its
--   index.
imap :: (Vector v a, Vector v b) => (Int -> a -> b) -> v a -> v b

-- | Map a function over a vector and concatenate the results.
concatMap :: (Vector v a, Vector v b) => (a -> v b) -> v a -> v b

-- | O(n) Apply the monadic action to all elements of the vector,
--   yielding a vector of results.
mapM :: (Monad m, Vector v a, Vector v b) => (a -> m b) -> v a -> m (v b)

-- | O(n) Apply the monadic action to every element of a vector and
--   its index, yielding a vector of results.
imapM :: (Monad m, Vector v a, Vector v b) => (Int -> a -> m b) -> v a -> m (v b)

-- | O(n) Apply the monadic action to all elements of a vector and
--   ignore the results.
mapM_ :: (Monad m, Vector v a) => (a -> m b) -> v a -> m ()

-- | O(n) Apply the monadic action to every element of a vector and
--   its index, ignoring the results.
imapM_ :: (Monad m, Vector v a) => (Int -> a -> m b) -> v a -> m ()

-- | O(n) Apply the monadic action to all elements of the vector,
--   yielding a vector of results. Equivalent to flip mapM.
forM :: (Monad m, Vector v a, Vector v b) => v a -> (a -> m b) -> m (v b)

-- | O(n) Apply the monadic action to all elements of a vector and
--   ignore the results. Equivalent to flip mapM_.
forM_ :: (Monad m, Vector v a) => v a -> (a -> m b) -> m ()

-- | O(min(m,n)) Zip two vectors with the given function.
zipWith :: (Vector v a, Vector v b, Vector v c) => (a -> b -> c) -> v a -> v b -> v c

-- | Zip three vectors with the given function.
zipWith3 :: (Vector v a, Vector v b, Vector v c, Vector v d) => (a -> b -> c -> d) -> v a -> v b -> v c -> v d
zipWith4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e) => (a -> b -> c -> d -> e) -> v a -> v b -> v c -> v d -> v e
zipWith5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f) => (a -> b -> c -> d -> e -> f) -> v a -> v b -> v c -> v d -> v e -> v f
zipWith6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v g) => (a -> b -> c -> d -> e -> f -> g) -> v a -> v b -> v c -> v d -> v e -> v f -> v g

-- | O(min(m,n)) Zip two vectors with a function that also takes the
--   elements' indices.
izipWith :: (Vector v a, Vector v b, Vector v c) => (Int -> a -> b -> c) -> v a -> v b -> v c

-- | Zip three vectors and their indices with the given function.
izipWith3 :: (Vector v a, Vector v b, Vector v c, Vector v d) => (Int -> a -> b -> c -> d) -> v a -> v b -> v c -> v d
izipWith4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e) => (Int -> a -> b -> c -> d -> e) -> v a -> v b -> v c -> v d -> v e
izipWith5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f) => (Int -> a -> b -> c -> d -> e -> f) -> v a -> v b -> v c -> v d -> v e -> v f
izipWith6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v g) => (Int -> a -> b -> c -> d -> e -> f -> g) -> v a -> v b -> v c -> v d -> v e -> v f -> v g

-- | O(min(m,n)) Zip two vectors.
zip :: (Vector v a, Vector v b, Vector v (a, b)) => v a -> v b -> v (a, b)

-- | Zip together three vectors into a vector of triples.
zip3 :: (Vector v a, Vector v b, Vector v c, Vector v (a, b, c)) => v a -> v b -> v c -> v (a, b, c)
zip4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v (a, b, c, d)) => v a -> v b -> v c -> v d -> v (a, b, c, d)
zip5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v (a, b, c, d, e)) => v a -> v b -> v c -> v d -> v e -> v (a, b, c, d, e)
zip6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v (a, b, c, d, e, f)) => v a -> v b -> v c -> v d -> v e -> v f -> v (a, b, c, d, e, f)

-- | O(min(m,n)) Zip the two vectors with the monadic action and
--   yield a vector of results.
zipWithM :: (Monad m, Vector v a, Vector v b, Vector v c) => (a -> b -> m c) -> v a -> v b -> m (v c)

-- | O(min(m,n)) Zip the two vectors with a monadic action that also
--   takes the element index and yield a vector of results.
izipWithM :: (Monad m, Vector v a, Vector v b, Vector v c) => (Int -> a -> b -> m c) -> v a -> v b -> m (v c)

-- | O(min(m,n)) Zip the two vectors with the monadic action and
--   ignore the results.
zipWithM_ :: (Monad m, Vector v a, Vector v b) => (a -> b -> m c) -> v a -> v b -> m ()

-- | O(min(m,n)) Zip the two vectors with a monadic action that also
--   takes the element index and ignore the results.
izipWithM_ :: (Monad m, Vector v a, Vector v b) => (Int -> a -> b -> m c) -> v a -> v b -> m ()

-- | O(min(m,n)) Unzip a vector of pairs.
unzip :: (Vector v a, Vector v b, Vector v (a, b)) => v (a, b) -> (v a, v b)
unzip3 :: (Vector v a, Vector v b, Vector v c, Vector v (a, b, c)) => v (a, b, c) -> (v a, v b, v c)
unzip4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v (a, b, c, d)) => v (a, b, c, d) -> (v a, v b, v c, v d)
unzip5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v (a, b, c, d, e)) => v (a, b, c, d, e) -> (v a, v b, v c, v d, v e)
unzip6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v (a, b, c, d, e, f)) => v (a, b, c, d, e, f) -> (v a, v b, v c, v d, v e, v f)

-- | O(n) Drop all elements that do not satisfy the predicate.
filter :: Vector v a => (a -> Bool) -> v a -> v a

-- | O(n) Drop all elements that do not satisfy the predicate which
--   is applied to the values and their indices.
ifilter :: Vector v a => (Int -> a -> Bool) -> v a -> v a

-- | O(n) Drop repeated adjacent elements. The first element in each
--   group is returned.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.uniq $ V.fromList [1,3,3,200,3]
--   [1,3,200,3]
--   
--   >>> import Data.Semigroup
--   
--   >>> V.uniq $ V.fromList [ Arg 1 'a', Arg 1 'b', Arg 1 'c']
--   [Arg 1 'a']
--   
uniq :: (Vector v a, Eq a) => v a -> v a

-- | O(n) Map the values and collect the Just results.
mapMaybe :: (Vector v a, Vector v b) => (a -> Maybe b) -> v a -> v b

-- | O(n) Map the indices/values and collect the Just
--   results.
imapMaybe :: (Vector v a, Vector v b) => (Int -> a -> Maybe b) -> v a -> v b

-- | O(n) Drop all elements that do not satisfy the monadic
--   predicate.
filterM :: (Monad m, Vector v a) => (a -> m Bool) -> v a -> m (v a)

-- | O(n) Yield the longest prefix of elements satisfying the
--   predicate. The current implementation is not copy-free, unless the
--   result vector is fused away.
takeWhile :: Vector v a => (a -> Bool) -> v a -> v a

-- | O(n) Drop the longest prefix of elements that satisfy the
--   predicate without copying.
dropWhile :: Vector v a => (a -> Bool) -> v a -> v a

-- | O(n) Split the vector in two parts, the first one containing
--   those elements that satisfy the predicate and the second one those
--   that don't. The relative order of the elements is preserved at the
--   cost of a sometimes reduced performance compared to
--   unstablePartition.
partition :: Vector v a => (a -> Bool) -> v a -> (v a, v a)

-- | O(n) Split the vector in two parts, the first one containing
--   those elements that satisfy the predicate and the second one those
--   that don't. The order of the elements is not preserved, but the
--   operation is often faster than partition.
unstablePartition :: Vector v a => (a -> Bool) -> v a -> (v a, v a)

-- | O(n) Split the vector into the longest prefix of elements that
--   satisfy the predicate and the rest without copying.
span :: Vector v a => (a -> Bool) -> v a -> (v a, v a)

-- | O(n) Split the vector into the longest prefix of elements that
--   do not satisfy the predicate and the rest without copying.
break :: Vector v a => (a -> Bool) -> v a -> (v a, v a)

-- | O(n) Check if the vector contains an element.
elem :: (Vector v a, Eq a) => a -> v a -> Bool
infix 4 `elem`

-- | O(n) Check if the vector does not contain an element (inverse
--   of elem).
notElem :: (Vector v a, Eq a) => a -> v a -> Bool
infix 4 `notElem`

-- | O(n) Yield Just the first element matching the predicate
--   or Nothing if no such element exists.
find :: Vector v a => (a -> Bool) -> v a -> Maybe a

-- | O(n) Yield Just the index of the first element matching
--   the predicate or Nothing if no such element exists.
findIndex :: Vector v a => (a -> Bool) -> v a -> Maybe Int

-- | O(n) Yield the indices of elements satisfying the predicate in
--   ascending order.
findIndices :: (Vector v a, Vector v Int) => (a -> Bool) -> v a -> v Int

-- | O(n) Yield Just the index of the first occurrence of the
--   given element or Nothing if the vector does not contain the
--   element. This is a specialised version of findIndex.
elemIndex :: (Vector v a, Eq a) => a -> v a -> Maybe Int

-- | O(n) Yield the indices of all occurrences of the given element
--   in ascending order. This is a specialised version of
--   findIndices.
elemIndices :: (Vector v a, Vector v Int, Eq a) => a -> v a -> v Int

-- | O(n) Left fold.
foldl :: Vector v b => (a -> b -> a) -> a -> v b -> a

-- | O(n) Left fold with strict accumulator.
foldl' :: Vector v b => (a -> b -> a) -> a -> v b -> a

-- | O(n) Right fold.
foldr :: Vector v a => (a -> b -> b) -> b -> v a -> b

-- | O(n) Right fold with a strict accumulator.
foldr' :: Vector v a => (a -> b -> b) -> b -> v a -> b

-- | O(n) Left fold using a function applied to each element and its
--   index.
ifoldl :: Vector v b => (a -> Int -> b -> a) -> a -> v b -> a

-- | O(n) Left fold with strict accumulator using a function applied
--   to each element and its index.
ifoldl' :: Vector v b => (a -> Int -> b -> a) -> a -> v b -> a

-- | O(n) Right fold using a function applied to each element and
--   its index.
ifoldr :: Vector v a => (Int -> a -> b -> b) -> b -> v a -> b

-- | O(n) Right fold with strict accumulator using a function
--   applied to each element and its index.
ifoldr' :: Vector v a => (Int -> a -> b -> b) -> b -> v a -> b

-- | O(n) Check if all elements satisfy the predicate.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.all even $ V.fromList [2, 4, 12]
--   True
--   
--   >>> V.all even $ V.fromList [2, 4, 13]
--   False
--   
--   >>> V.all even (V.empty :: V.Vector Int)
--   True
--   
all :: Vector v a => (a -> Bool) -> v a -> Bool

-- | O(n) Check if any element satisfies the predicate.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.any even $ V.fromList [1, 3, 7]
--   False
--   
--   >>> V.any even $ V.fromList [3, 2, 13]
--   True
--   
--   >>> V.any even (V.empty :: V.Vector Int)
--   False
--   
any :: Vector v a => (a -> Bool) -> v a -> Bool

-- | O(n) Check if all elements are True.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.and $ V.fromList [True, False]
--   False
--   
--   >>> V.and V.empty
--   True
--   
and :: Vector v Bool => v Bool -> Bool

-- | O(n) Check if any element is True.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.or $ V.fromList [True, False]
--   True
--   
--   >>> V.or V.empty
--   False
--   
or :: Vector v Bool => v Bool -> Bool

-- | O(n) Compute the sum of the elements.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.sum $ V.fromList [300,20,1]
--   321
--   
--   >>> V.sum (V.empty :: V.Vector Int)
--   0
--   
sum :: (Vector v a, Num a) => v a -> a

-- | O(n) Compute the product of the elements.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.product $ V.fromList [1,2,3,4]
--   24
--   
--   >>> V.product (V.empty :: V.Vector Int)
--   1
--   
product :: (Vector v a, Num a) => v a -> a

-- | O(n) Monadic fold.
foldM :: (Monad m, Vector v b) => (a -> b -> m a) -> a -> v b -> m a

-- | O(n) Monadic fold using a function applied to each element and
--   its index.
ifoldM :: (Monad m, Vector v b) => (a -> Int -> b -> m a) -> a -> v b -> m a

-- | O(n) Monadic fold with strict accumulator.
foldM' :: (Monad m, Vector v b) => (a -> b -> m a) -> a -> v b -> m a

-- | O(n) Monadic fold with strict accumulator using a function
--   applied to each element and its index.
ifoldM' :: (Monad m, Vector v b) => (a -> Int -> b -> m a) -> a -> v b -> m a

-- | O(n) Monadic fold that discards the result.
foldM_ :: (Monad m, Vector v b) => (a -> b -> m a) -> a -> v b -> m ()

-- | O(n) Monadic fold that discards the result using a function
--   applied to each element and its index.
ifoldM_ :: (Monad m, Vector v b) => (a -> Int -> b -> m a) -> a -> v b -> m ()

-- | O(n) Monadic fold with strict accumulator that discards the
--   result.
foldM'_ :: (Monad m, Vector v b) => (a -> b -> m a) -> a -> v b -> m ()

-- | O(n) Monadic fold with strict accumulator that discards the
--   result using a function applied to each element and its index.
ifoldM'_ :: (Monad m, Vector v b) => (a -> Int -> b -> m a) -> a -> v b -> m ()

-- | Evaluate each action and collect the results.
sequence :: (Monad m, Vector v a, Vector v (m a)) => v (m a) -> m (v a)

-- | Evaluate each action and discard the results.
sequence_ :: (Monad m, Vector v (m a)) => v (m a) -> m ()

-- | O(n) Left-to-right prescan.
--   
--   
--   prescanl f z = init . scanl f z
--   
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.prescanl (+) 0 (V.fromList [1,2,3,4])
--   [0,1,3,6]
--   
prescanl :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a

-- | O(n) Left-to-right prescan with strict accumulator.
prescanl' :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a

-- | O(n) Left-to-right postscan.
--   
--   
--   postscanl f z = tail . scanl f z
--   
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.postscanl (+) 0 (V.fromList [1,2,3,4])
--   [1,3,6,10]
--   
postscanl :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a

-- | O(n) Left-to-right postscan with strict accumulator.
postscanl' :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a

-- | O(n) Left-to-right scan.
--   
--   
--   scanl f z <x1,...,xn> = <y1,...,y(n+1)>
--     where y1 = z
--           yi = f y(i-1) x(i-1)
--   
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.scanl (+) 0 (V.fromList [1,2,3,4])
--   [0,1,3,6,10]
--   
scanl :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a

-- | O(n) Left-to-right scan with strict accumulator.
scanl' :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a

-- | O(n) Left-to-right scan over a vector with its index.
iscanl :: (Vector v a, Vector v b) => (Int -> a -> b -> a) -> a -> v b -> v a

-- | O(n) Left-to-right scan over a vector (strictly) with its
--   index.
iscanl' :: (Vector v a, Vector v b) => (Int -> a -> b -> a) -> a -> v b -> v a

-- | O(n) Right-to-left prescan.
--   
--   
--   prescanr f z = reverse . prescanl (flip f) z . reverse
--   
prescanr :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b

-- | O(n) Right-to-left prescan with strict accumulator.
prescanr' :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b

-- | O(n) Right-to-left postscan.
postscanr :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b

-- | O(n) Right-to-left postscan with strict accumulator.
postscanr' :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b

-- | O(n) Right-to-left scan.
scanr :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b

-- | O(n) Right-to-left scan with strict accumulator.
scanr' :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b

-- | O(n) Right-to-left scan over a vector with its index.
iscanr :: (Vector v a, Vector v b) => (Int -> a -> b -> b) -> b -> v a -> v b

-- | O(n) Right-to-left scan over a vector (strictly) with its
--   index.
iscanr' :: (Vector v a, Vector v b) => (Int -> a -> b -> b) -> b -> v a -> v b

-- | O(n) Convert a vector to a list.
toList :: Vector v a => v a -> [a]

-- | O(n) Convert a list to a vector.
fromList :: Vector v a => [a] -> v a

-- | O(n) Convert the first n elements of a list to a
--   vector. It's expected that the supplied list will be exactly
--   n elements long. As an optimization, this function allocates
--   a buffer for n elements, which could be used for DoS-attacks
--   by exhausting the memory if an attacker controls that parameter.
--   
--   
--   fromListN n xs = fromList (take n xs)
--   
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.fromListN 3 [1,2,3,4,5]
--   [1,2,3]
--   
--   >>> V.fromListN 3 [1]
--   [1]
--   
fromListN :: Vector v a => Int -> [a] -> v a

-- | O(n) Convert between different vector types.
convert :: (Vector v a, Vector w a) => v a -> w a

-- | O(n) Yield an immutable copy of the mutable vector.
freeze :: (PrimMonad m, Vector v a) => Mutable v (PrimState m) a -> m (v a)

-- | O(n) Yield a mutable copy of an immutable vector.
thaw :: (PrimMonad m, Vector v a) => v a -> m (Mutable v (PrimState m) a)

-- | O(n) Copy an immutable vector into a mutable one. The two
--   vectors must have the same length.
copy :: (HasCallStack, PrimMonad m, Vector v a) => Mutable v (PrimState m) a -> v a -> m ()

-- | O(1) Convert a vector to a Bundle.
stream :: Vector v a => v a -> Bundle v a

-- | O(n) Construct a vector from a Bundle.
unstream :: Vector v a => Bundle v a -> v a

-- | O(1) Convert a vector to a Bundle, proceeding from right
--   to left.
streamR :: forall v a (u :: Type -> Type). Vector v a => v a -> Bundle u a

-- | O(n) Construct a vector from a Bundle, proceeding from
--   right to left.
unstreamR :: Vector v a => Bundle v a -> v a

-- | Construct a vector from a monadic initialiser.
new :: Vector v a => New v a -> v a

-- | Convert a vector to an initialiser which, when run, produces a copy of
--   the vector.
clone :: Vector v a => v a -> New v a

-- | O(n) Check if two vectors are equal. All Vector
--   instances are also instances of Eq and it is usually more
--   appropriate to use those. This function is primarily intended for
--   implementing Eq instances for new vector types.
eq :: (Vector v a, Eq a) => v a -> v a -> Bool

-- | O(n) Compare two vectors lexicographically. All Vector
--   instances are also instances of Ord and it is usually more
--   appropriate to use those. This function is primarily intended for
--   implementing Ord instances for new vector types.
cmp :: (Vector v a, Ord a) => v a -> v a -> Ordering

-- | O(n) Check if two vectors are equal using the supplied equality
--   predicate.
eqBy :: (Vector v a, Vector v b) => (a -> b -> Bool) -> v a -> v b -> Bool

-- | O(n) Compare two vectors using the supplied comparison function
--   for vector elements. Comparison works the same as for lists.
--   
--   
--   cmpBy compare == cmp
--   
cmpBy :: (Vector v a, Vector v b) => (a -> b -> Ordering) -> v a -> v b -> Ordering

-- | Generic definition of showsPrec.
showsPrec :: (Vector v a, Show a) => Int -> v a -> ShowS

-- | Generic definition of readPrec.
readPrec :: (Vector v a, Read a) => ReadPrec (v a)
liftShowsPrec :: Vector v a => (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> v a -> ShowS

-- | Note: uses ReadS.
liftReadsPrec :: Vector v a => (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (v a)

-- | Generic definion of gfoldl that views a Vector as a
--   list.
gfoldl :: (Vector v a, Data a) => (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. () => g -> c g) -> v a -> c (v a)
dataCast :: (Vector v a, Data a, Typeable v, Typeable t) => (forall d. Data d => c (t d)) -> Maybe (c (v a))
mkType :: String -> DataType

-- | Boxed Vector. Import as:
--   
--   
--   import qualified RIO.Vector.Boxed as VB
--   
--   
--   This module does not export any partial or unsafe functions. For
--   those, see RIO.Vector.Boxed.Partial and
--   RIO.Vector.Boxed.Unsafe
module RIO.Vector.Boxed

-- | Boxed vectors, supporting efficient slicing.
data () => Vector a

-- | Mutable boxed vectors keyed on the monad they live in (IO or
--   ST s).
data () => MVector s a

-- | O(1) Yield the length of the vector.
length :: Vector a -> Int

-- | O(1) Test whether a vector is empty.
null :: Vector a -> Bool

-- | O(1) Safe indexing.
(!?) :: Vector a -> Int -> Maybe a

-- | O(1) Yield a slice of the vector without copying it. The vector
--   must contain at least i+n elements.
slice :: Int -> Int -> Vector a -> Vector a

-- | O(1) Yield at the first n elements without copying.
--   The vector may contain less than n elements, in which case it
--   is returned unchanged.
take :: Int -> Vector a -> Vector a

-- | O(1) Yield all but the first n elements without
--   copying. The vector may contain less than n elements, in
--   which case an empty vector is returned.
drop :: Int -> Vector a -> Vector a

-- | O(1) Yield the first n elements paired with the
--   remainder, without copying.
--   
--   Note that splitAt n v is equivalent to
--   (take n v, drop n v), but slightly more
--   efficient.
splitAt :: Int -> Vector a -> (Vector a, Vector a)

-- | O(1) The empty vector.
empty :: Vector a

-- | O(1) A vector with exactly one element.
singleton :: a -> Vector a

-- | O(n) A vector of the given length with the same value in each
--   position.
replicate :: Int -> a -> Vector a

-- | O(n) Construct a vector of the given length by applying the
--   function to each index.
generate :: Int -> (Int -> a) -> Vector a

-- | O(n) Apply the function <math> times to an initial value,
--   producing a vector of length <math>. The 0th element will
--   contain the initial value, which is why there is one less function
--   application than the number of elements in the produced vector.
--   
--   <math>
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.iterateN 0 undefined undefined :: V.Vector String
--   []
--   
--   >>> V.iterateN 4 (\x -> x <> x) "Hi"
--   ["Hi","HiHi","HiHiHiHi","HiHiHiHiHiHiHiHi"]
--   
iterateN :: Int -> (a -> a) -> a -> Vector a

-- | O(n) Execute the monadic action the given number of times and
--   store the results in a vector.
replicateM :: Monad m => Int -> m a -> m (Vector a)

-- | O(n) Construct a vector of the given length by applying the
--   monadic action to each index.
generateM :: Monad m => Int -> (Int -> m a) -> m (Vector a)

-- | O(n) Apply the monadic function <math> times to an
--   initial value, producing a vector of length <math>. The 0th
--   element will contain the initial value, which is why there is one less
--   function application than the number of elements in the produced
--   vector.
--   
--   For a non-monadic version, see iterateN.
iterateNM :: Monad m => Int -> (a -> m a) -> a -> m (Vector a)

-- | Execute the monadic action and freeze the resulting vector.
--   
--   
--   create (do { v <- new 2; write v 0 'a'; write v 1 'b'; return v }) = <a,b>
--   
create :: (forall s. () => ST s (MVector s a)) -> Vector a

-- | Execute the monadic action and freeze the resulting vectors.
createT :: Traversable f => (forall s. () => ST s (f (MVector s a))) -> f (Vector a)

-- | O(n) Construct a vector by repeatedly applying the generator
--   function to a seed. The generator function yields Just the
--   next element and the new seed or Nothing if there are no more
--   elements.
--   
--   
--   unfoldr (\n -> if n == 0 then Nothing else Just (n,n-1)) 10
--    = <10,9,8,7,6,5,4,3,2,1>
--   
unfoldr :: (b -> Maybe (a, b)) -> b -> Vector a

-- | O(n) Construct a vector with at most n elements by
--   repeatedly applying the generator function to a seed. The generator
--   function yields Just the next element and the new seed or
--   Nothing if there are no more elements.
--   
--   
--   unfoldrN 3 (\n -> Just (n,n-1)) 10 = <10,9,8>
--   
unfoldrN :: Int -> (b -> Maybe (a, b)) -> b -> Vector a

-- | O(n) Construct a vector by repeatedly applying the monadic
--   generator function to a seed. The generator function yields
--   Just the next element and the new seed or Nothing if
--   there are no more elements.
unfoldrM :: Monad m => (b -> m (Maybe (a, b))) -> b -> m (Vector a)

-- | O(n) Construct a vector by repeatedly applying the monadic
--   generator function to a seed. The generator function yields
--   Just the next element and the new seed or Nothing if
--   there are no more elements.
unfoldrNM :: Monad m => Int -> (b -> m (Maybe (a, b))) -> b -> m (Vector a)

-- | O(n) Construct a vector with n elements by repeatedly
--   applying the generator function to the already constructed part of the
--   vector.
--   
--   
--   constructN 3 f = let a = f <> ; b = f <a> ; c = f <a,b> in <a,b,c>
--   
constructN :: Int -> (Vector a -> a) -> Vector a

-- | O(n) Construct a vector with n elements from right to
--   left by repeatedly applying the generator function to the already
--   constructed part of the vector.
--   
--   
--   constructrN 3 f = let a = f <> ; b = f<a> ; c = f <b,a> in <c,b,a>
--   
constructrN :: Int -> (Vector a -> a) -> Vector a

-- | O(n) Yield a vector of the given length, containing the values
--   x, x+1 etc. This operation is usually more efficient
--   than enumFromTo.
--   
--   
--   enumFromN 5 3 = <5,6,7>
--   
enumFromN :: Num a => a -> Int -> Vector a

-- | O(n) Yield a vector of the given length, containing the values
--   x, x+y, x+y+y etc. This operations is
--   usually more efficient than enumFromThenTo.
--   
--   
--   enumFromStepN 1 2 5 = <1,3,5,7,9>
--   
enumFromStepN :: Num a => a -> a -> Int -> Vector a

-- | O(n) Enumerate values from x to y.
--   
--   WARNING: This operation can be very inefficient. If possible,
--   use enumFromN instead.
enumFromTo :: Enum a => a -> a -> Vector a

-- | O(n) Enumerate values from x to y with a
--   specific step z.
--   
--   WARNING: This operation can be very inefficient. If possible,
--   use enumFromStepN instead.
enumFromThenTo :: Enum a => a -> a -> a -> Vector a

-- | O(n) Prepend an element.
cons :: a -> Vector a -> Vector a

-- | O(n) Append an element.
snoc :: Vector a -> a -> Vector a

-- | O(m+n) Concatenate two vectors.
(++) :: Vector a -> Vector a -> Vector a
infixr 5 ++

-- | O(n) Concatenate all vectors in the list.
concat :: [Vector a] -> Vector a

-- | O(n) Yield the argument, but force it not to retain any extra
--   memory, possibly by copying it.
--   
--   This is especially useful when dealing with slices. For example:
--   
--   
--   force (slice 0 2 <huge vector>)
--   
--   
--   Here, the slice retains a reference to the huge vector. Forcing it
--   creates a copy of just the elements that belong to the slice and
--   allows the huge vector to be garbage collected.
force :: Vector a -> Vector a

-- | O(n) Reverse a vector.
reverse :: Vector a -> Vector a

-- | Apply a destructive operation to a vector. The operation may be
--   performed in place if it is safe to do so and will modify a copy of
--   the vector otherwise (see New for details).
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> import qualified Data.Vector.Mutable as MV
--   
--   >>> V.modify (\v -> MV.write v 0 'x') $ V.replicate 4 'a'
--   "xaaa"
--   
modify :: (forall s. () => MVector s a -> ST s ()) -> Vector a -> Vector a

-- | O(n) Pair each element in a vector with its index.
indexed :: Vector a -> Vector (Int, a)

-- | O(n) Map a function over a vector.
map :: (a -> b) -> Vector a -> Vector b

-- | O(n) Apply a function to every element of a vector and its
--   index.
imap :: (Int -> a -> b) -> Vector a -> Vector b

-- | Map a function over a vector and concatenate the results.
concatMap :: (a -> Vector b) -> Vector a -> Vector b

-- | O(n) Apply the monadic action to all elements of the vector,
--   yielding a vector of results.
mapM :: Monad m => (a -> m b) -> Vector a -> m (Vector b)

-- | O(n) Apply the monadic action to every element of a vector and
--   its index, yielding a vector of results.
imapM :: Monad m => (Int -> a -> m b) -> Vector a -> m (Vector b)

-- | O(n) Apply the monadic action to all elements of a vector and
--   ignore the results.
mapM_ :: Monad m => (a -> m b) -> Vector a -> m ()

-- | O(n) Apply the monadic action to every element of a vector and
--   its index, ignoring the results.
imapM_ :: Monad m => (Int -> a -> m b) -> Vector a -> m ()

-- | O(n) Apply the monadic action to all elements of the vector,
--   yielding a vector of results. Equivalent to flip mapM.
forM :: Monad m => Vector a -> (a -> m b) -> m (Vector b)

-- | O(n) Apply the monadic action to all elements of a vector and
--   ignore the results. Equivalent to flip mapM_.
forM_ :: Monad m => Vector a -> (a -> m b) -> m ()

-- | O(min(m,n)) Zip two vectors with the given function.
zipWith :: (a -> b -> c) -> Vector a -> Vector b -> Vector c

-- | Zip three vectors with the given function.
zipWith3 :: (a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d
zipWith4 :: (a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
zipWith5 :: (a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f
zipWith6 :: (a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g

-- | O(min(m,n)) Zip two vectors with a function that also takes the
--   elements' indices.
izipWith :: (Int -> a -> b -> c) -> Vector a -> Vector b -> Vector c

-- | Zip three vectors and their indices with the given function.
izipWith3 :: (Int -> a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d
izipWith4 :: (Int -> a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
izipWith5 :: (Int -> a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f
izipWith6 :: (Int -> a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g

-- | O(min(m,n)) Zip two vectors.
zip :: Vector a -> Vector b -> Vector (a, b)

-- | Zip together three vectors into a vector of triples.
zip3 :: Vector a -> Vector b -> Vector c -> Vector (a, b, c)
zip4 :: Vector a -> Vector b -> Vector c -> Vector d -> Vector (a, b, c, d)
zip5 :: Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector (a, b, c, d, e)
zip6 :: Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector (a, b, c, d, e, f)

-- | O(min(m,n)) Zip the two vectors with the monadic action and
--   yield a vector of results.
zipWithM :: Monad m => (a -> b -> m c) -> Vector a -> Vector b -> m (Vector c)

-- | O(min(m,n)) Zip the two vectors with a monadic action that also
--   takes the element index and yield a vector of results.
izipWithM :: Monad m => (Int -> a -> b -> m c) -> Vector a -> Vector b -> m (Vector c)

-- | O(min(m,n)) Zip the two vectors with the monadic action and
--   ignore the results.
zipWithM_ :: Monad m => (a -> b -> m c) -> Vector a -> Vector b -> m ()

-- | O(min(m,n)) Zip the two vectors with a monadic action that also
--   takes the element index and ignore the results.
izipWithM_ :: Monad m => (Int -> a -> b -> m c) -> Vector a -> Vector b -> m ()

-- | O(min(m,n)) Unzip a vector of pairs.
unzip :: Vector (a, b) -> (Vector a, Vector b)
unzip3 :: Vector (a, b, c) -> (Vector a, Vector b, Vector c)
unzip4 :: Vector (a, b, c, d) -> (Vector a, Vector b, Vector c, Vector d)
unzip5 :: Vector (a, b, c, d, e) -> (Vector a, Vector b, Vector c, Vector d, Vector e)
unzip6 :: Vector (a, b, c, d, e, f) -> (Vector a, Vector b, Vector c, Vector d, Vector e, Vector f)

-- | O(n) Drop all elements that do not satisfy the predicate.
filter :: (a -> Bool) -> Vector a -> Vector a

-- | O(n) Drop all elements that do not satisfy the predicate which
--   is applied to the values and their indices.
ifilter :: (Int -> a -> Bool) -> Vector a -> Vector a

-- | O(n) Drop repeated adjacent elements. The first element in each
--   group is returned.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.uniq $ V.fromList [1,3,3,200,3]
--   [1,3,200,3]
--   
--   >>> import Data.Semigroup
--   
--   >>> V.uniq $ V.fromList [ Arg 1 'a', Arg 1 'b', Arg 1 'c']
--   [Arg 1 'a']
--   
uniq :: Eq a => Vector a -> Vector a

-- | O(n) Map the values and collect the Just results.
mapMaybe :: (a -> Maybe b) -> Vector a -> Vector b

-- | O(n) Map the indices/values and collect the Just
--   results.
imapMaybe :: (Int -> a -> Maybe b) -> Vector a -> Vector b

-- | O(n) Drop all elements that do not satisfy the monadic
--   predicate.
filterM :: Monad m => (a -> m Bool) -> Vector a -> m (Vector a)

-- | O(n) Yield the longest prefix of elements satisfying the
--   predicate. The current implementation is not copy-free, unless the
--   result vector is fused away.
takeWhile :: (a -> Bool) -> Vector a -> Vector a

-- | O(n) Drop the longest prefix of elements that satisfy the
--   predicate without copying.
dropWhile :: (a -> Bool) -> Vector a -> Vector a

-- | O(n) Split the vector in two parts, the first one containing
--   those elements that satisfy the predicate and the second one those
--   that don't. The relative order of the elements is preserved at the
--   cost of a sometimes reduced performance compared to
--   unstablePartition.
partition :: (a -> Bool) -> Vector a -> (Vector a, Vector a)

-- | O(n) Split the vector in two parts, the first one containing
--   those elements that satisfy the predicate and the second one those
--   that don't. The order of the elements is not preserved, but the
--   operation is often faster than partition.
unstablePartition :: (a -> Bool) -> Vector a -> (Vector a, Vector a)

-- | O(n) Split the vector into the longest prefix of elements that
--   satisfy the predicate and the rest without copying.
span :: (a -> Bool) -> Vector a -> (Vector a, Vector a)

-- | O(n) Split the vector into the longest prefix of elements that
--   do not satisfy the predicate and the rest without copying.
break :: (a -> Bool) -> Vector a -> (Vector a, Vector a)

-- | O(n) Check if the vector contains an element.
elem :: Eq a => a -> Vector a -> Bool
infix 4 `elem`

-- | O(n) Check if the vector does not contain an element (inverse
--   of elem).
notElem :: Eq a => a -> Vector a -> Bool
infix 4 `notElem`

-- | O(n) Yield Just the first element matching the
--   predicate or Nothing if no such element exists.
find :: (a -> Bool) -> Vector a -> Maybe a

-- | O(n) Yield Just the index of the first element
--   matching the predicate or Nothing if no such element exists.
findIndex :: (a -> Bool) -> Vector a -> Maybe Int

-- | O(n) Yield the indices of elements satisfying the predicate in
--   ascending order.
findIndices :: (a -> Bool) -> Vector a -> Vector Int

-- | O(n) Yield Just the index of the first occurrence of
--   the given element or Nothing if the vector does not contain
--   the element. This is a specialised version of findIndex.
elemIndex :: Eq a => a -> Vector a -> Maybe Int

-- | O(n) Yield the indices of all occurrences of the given element
--   in ascending order. This is a specialised version of
--   findIndices.
elemIndices :: Eq a => a -> Vector a -> Vector Int

-- | O(n) Left fold.
foldl :: (a -> b -> a) -> a -> Vector b -> a

-- | O(n) Left fold with strict accumulator.
foldl' :: (a -> b -> a) -> a -> Vector b -> a

-- | O(n) Right fold.
foldr :: (a -> b -> b) -> b -> Vector a -> b

-- | O(n) Right fold with a strict accumulator.
foldr' :: (a -> b -> b) -> b -> Vector a -> b

-- | O(n) Left fold using a function applied to each element and its
--   index.
ifoldl :: (a -> Int -> b -> a) -> a -> Vector b -> a

-- | O(n) Left fold with strict accumulator using a function applied
--   to each element and its index.
ifoldl' :: (a -> Int -> b -> a) -> a -> Vector b -> a

-- | O(n) Right fold using a function applied to each element and
--   its index.
ifoldr :: (Int -> a -> b -> b) -> b -> Vector a -> b

-- | O(n) Right fold with strict accumulator using a function
--   applied to each element and its index.
ifoldr' :: (Int -> a -> b -> b) -> b -> Vector a -> b

-- | O(n) Check if all elements satisfy the predicate.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.all even $ V.fromList [2, 4, 12]
--   True
--   
--   >>> V.all even $ V.fromList [2, 4, 13]
--   False
--   
--   >>> V.all even (V.empty :: V.Vector Int)
--   True
--   
all :: (a -> Bool) -> Vector a -> Bool

-- | O(n) Check if any element satisfies the predicate.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.any even $ V.fromList [1, 3, 7]
--   False
--   
--   >>> V.any even $ V.fromList [3, 2, 13]
--   True
--   
--   >>> V.any even (V.empty :: V.Vector Int)
--   False
--   
any :: (a -> Bool) -> Vector a -> Bool

-- | O(n) Check if all elements are True.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.and $ V.fromList [True, False]
--   False
--   
--   >>> V.and V.empty
--   True
--   
and :: Vector Bool -> Bool

-- | O(n) Check if any element is True.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.or $ V.fromList [True, False]
--   True
--   
--   >>> V.or V.empty
--   False
--   
or :: Vector Bool -> Bool

-- | O(n) Compute the sum of the elements.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.sum $ V.fromList [300,20,1]
--   321
--   
--   >>> V.sum (V.empty :: V.Vector Int)
--   0
--   
sum :: Num a => Vector a -> a

-- | O(n) Compute the product of the elements.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.product $ V.fromList [1,2,3,4]
--   24
--   
--   >>> V.product (V.empty :: V.Vector Int)
--   1
--   
product :: Num a => Vector a -> a

-- | O(n) Monadic fold.
foldM :: Monad m => (a -> b -> m a) -> a -> Vector b -> m a

-- | O(n) Monadic fold using a function applied to each element and
--   its index.
ifoldM :: Monad m => (a -> Int -> b -> m a) -> a -> Vector b -> m a

-- | O(n) Monadic fold with strict accumulator.
foldM' :: Monad m => (a -> b -> m a) -> a -> Vector b -> m a

-- | O(n) Monadic fold with strict accumulator using a function
--   applied to each element and its index.
ifoldM' :: Monad m => (a -> Int -> b -> m a) -> a -> Vector b -> m a

-- | O(n) Monadic fold that discards the result.
foldM_ :: Monad m => (a -> b -> m a) -> a -> Vector b -> m ()

-- | O(n) Monadic fold that discards the result using a function
--   applied to each element and its index.
ifoldM_ :: Monad m => (a -> Int -> b -> m a) -> a -> Vector b -> m ()

-- | O(n) Monadic fold with strict accumulator that discards the
--   result.
foldM'_ :: Monad m => (a -> b -> m a) -> a -> Vector b -> m ()

-- | O(n) Monadic fold with strict accumulator that discards the
--   result using a function applied to each element and its index.
ifoldM'_ :: Monad m => (a -> Int -> b -> m a) -> a -> Vector b -> m ()

-- | Evaluate each action and collect the results.
sequence :: Monad m => Vector (m a) -> m (Vector a)

-- | Evaluate each action and discard the results.
sequence_ :: Monad m => Vector (m a) -> m ()

-- | O(n) Left-to-right prescan.
--   
--   
--   prescanl f z = init . scanl f z
--   
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.prescanl (+) 0 (V.fromList [1,2,3,4])
--   [0,1,3,6]
--   
prescanl :: (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Left-to-right prescan with strict accumulator.
prescanl' :: (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Left-to-right postscan.
--   
--   
--   postscanl f z = tail . scanl f z
--   
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.postscanl (+) 0 (V.fromList [1,2,3,4])
--   [1,3,6,10]
--   
postscanl :: (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Left-to-right postscan with strict accumulator.
postscanl' :: (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Left-to-right scan.
--   
--   
--   scanl f z <x1,...,xn> = <y1,...,y(n+1)>
--     where y1 = z
--           yi = f y(i-1) x(i-1)
--   
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.scanl (+) 0 (V.fromList [1,2,3,4])
--   [0,1,3,6,10]
--   
scanl :: (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Left-to-right scan with strict accumulator.
scanl' :: (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Left-to-right scan over a vector with its index.
iscanl :: (Int -> a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Left-to-right scan over a vector (strictly) with its
--   index.
iscanl' :: (Int -> a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Right-to-left prescan.
--   
--   
--   prescanr f z = reverse . prescanl (flip f) z . reverse
--   
prescanr :: (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left prescan with strict accumulator.
prescanr' :: (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left postscan.
postscanr :: (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left postscan with strict accumulator.
postscanr' :: (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left scan.
scanr :: (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left scan with strict accumulator.
scanr' :: (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left scan over a vector with its index.
iscanr :: (Int -> a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left scan over a vector (strictly) with its
--   index.
iscanr' :: (Int -> a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Convert a vector to a list.
toList :: Vector a -> [a]

-- | O(n) Convert a list to a vector.
fromList :: [a] -> Vector a

-- | O(n) Convert the first n elements of a list to a
--   vector. It's expected that the supplied list will be exactly
--   n elements long. As an optimization, this function allocates
--   a buffer for n elements, which could be used for DoS-attacks
--   by exhausting the memory if an attacker controls that parameter.
--   
--   
--   fromListN n xs = fromList (take n xs)
--   
fromListN :: Int -> [a] -> Vector a

-- | O(n) Convert between different vector types.
convert :: (Vector v a, Vector w a) => v a -> w a

-- | O(n) Yield an immutable copy of the mutable vector.
freeze :: PrimMonad m => MVector (PrimState m) a -> m (Vector a)

-- | O(n) Yield a mutable copy of an immutable vector.
thaw :: PrimMonad m => Vector a -> m (MVector (PrimState m) a)

-- | O(n) Copy an immutable vector into a mutable one. The two
--   vectors must have the same length.
copy :: PrimMonad m => MVector (PrimState m) a -> Vector a -> m ()

-- | Boxed Vector partial functions. Import as:
--   
--   
--   import qualified RIO.Vector.Boxed.Partial as VB'
--   
module RIO.Vector.Boxed.Partial

-- | O(1) Indexing.
(!) :: Vector a -> Int -> a

-- | O(1) First element.
head :: Vector a -> a

-- | O(1) Last element.
last :: Vector a -> a

-- | O(1) Indexing in a monad.
--   
--   The monad allows operations to be strict in the vector when necessary.
--   Suppose vector copying is implemented like this:
--   
--   
--   copy mv v = ... write mv i (v ! i) ...
--   
--   
--   For lazy vectors, v ! i would not be evaluated which means
--   that mv would unnecessarily retain a reference to v
--   in each element written.
--   
--   With indexM, copying can be implemented like this instead:
--   
--   
--   copy mv v = ... do
--                     x <- indexM v i
--                     write mv i x
--   
--   
--   Here, no references to v are retained because indexing (but
--   not the element) is evaluated eagerly.
indexM :: Monad m => Vector a -> Int -> m a

-- | O(1) First element of a vector in a monad. See indexM
--   for an explanation of why this is useful.
headM :: Monad m => Vector a -> m a

-- | O(1) Last element of a vector in a monad. See indexM for
--   an explanation of why this is useful.
lastM :: Monad m => Vector a -> m a

-- | O(1) Yield all but the last element without copying. The vector
--   may not be empty.
init :: Vector a -> Vector a

-- | O(1) Yield all but the first element without copying. The
--   vector may not be empty.
tail :: Vector a -> Vector a

-- | O(m+n) For each pair (i,a) from the list of
--   index/value pairs, replace the vector element at position i
--   by a.
--   
--   
--   <5,9,2,7> // [(2,1),(0,3),(2,8)] = <3,9,8,7>
--   
(//) :: Vector a -> [(Int, a)] -> Vector a

-- | O(m+n) For each pair (i,a) from the vector of
--   index/value pairs, replace the vector element at position i
--   by a.
--   
--   
--   update <5,9,2,7> <(2,1),(0,3),(2,8)> = <3,9,8,7>
--   
update :: Vector a -> Vector (Int, a) -> Vector a

-- | O(m+min(n1,n2)) For each index i from the index vector
--   and the corresponding value a from the value vector, replace
--   the element of the initial vector at position i by
--   a.
--   
--   
--   update_ <5,9,2,7>  <2,0,2> <1,3,8> = <3,9,8,7>
--   
--   
--   The function update provides the same functionality and is
--   usually more convenient.
--   
--   
--   update_ xs is ys = update xs (zip is ys)
--   
update_ :: Vector a -> Vector Int -> Vector a -> Vector a

-- | O(m+n) For each pair (i,b) from the list, replace the
--   vector element a at position i by f a b.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.accum (+) (V.fromList [1000,2000,3000]) [(2,4),(1,6),(0,3),(1,10)]
--   [1003,2016,3004]
--   
accum :: (a -> b -> a) -> Vector a -> [(Int, b)] -> Vector a

-- | O(m+n) For each pair (i,b) from the vector of pairs,
--   replace the vector element a at position i by f
--   a b.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.accumulate (+) (V.fromList [1000,2000,3000]) (V.fromList [(2,4),(1,6),(0,3),(1,10)])
--   [1003,2016,3004]
--   
accumulate :: (a -> b -> a) -> Vector a -> Vector (Int, b) -> Vector a

-- | O(m+min(n1,n2)) For each index i from the index vector
--   and the corresponding value b from the the value vector,
--   replace the element of the initial vector at position i by
--   f a b.
--   
--   
--   accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>
--   
--   
--   The function accumulate provides the same functionality and is
--   usually more convenient.
--   
--   
--   accumulate_ f as is bs = accumulate f as (zip is bs)
--   
accumulate_ :: (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector a

-- | O(n) Yield the vector obtained by replacing each element
--   i of the index vector by xs!i. This is
--   equivalent to map (xs!) is, but is often much
--   more efficient.
--   
--   
--   backpermute <a,b,c,d> <0,3,2,3,1,0> = <a,d,c,d,b,a>
--   
backpermute :: Vector a -> Vector Int -> Vector a

-- | O(n) Left fold on non-empty vectors.
foldl1 :: (a -> a -> a) -> Vector a -> a

-- | O(n) Left fold on non-empty vectors with strict accumulator.
foldl1' :: (a -> a -> a) -> Vector a -> a

-- | O(n) Right fold on non-empty vectors.
foldr1 :: (a -> a -> a) -> Vector a -> a

-- | O(n) Right fold on non-empty vectors with strict accumulator.
foldr1' :: (a -> a -> a) -> Vector a -> a

-- | O(n) Yield the maximum element of the vector. The vector may
--   not be empty. In case of a tie, the first occurrence wins.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.maximum $ V.fromList [2, 1]
--   2
--   
--   >>> import Data.Semigroup
--   
--   >>> V.maximum $ V.fromList [Arg 1 'a', Arg 2 'b']
--   Arg 2 'b'
--   
--   >>> V.maximum $ V.fromList [Arg 1 'a', Arg 1 'b']
--   Arg 1 'a'
--   
maximum :: Ord a => Vector a -> a

-- | O(n) Yield the maximum element of the vector according to the
--   given comparison function. The vector may not be empty. In case of a
--   tie, the first occurrence wins. This behavior is different from
--   maximumBy which returns the last tie.
--   
--   
Examples
--   
--   
--   >>> import Data.Ord
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.maximumBy (comparing fst) $ V.fromList [(2,'a'), (1,'b')]
--   (2,'a')
--   
--   >>> V.maximumBy (comparing fst) $ V.fromList [(1,'a'), (1,'b')]
--   (1,'a')
--   
maximumBy :: (a -> a -> Ordering) -> Vector a -> a

-- | O(n) Yield the minimum element of the vector. The vector may
--   not be empty. In case of a tie, the first occurrence wins.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.minimum $ V.fromList [2, 1]
--   1
--   
--   >>> import Data.Semigroup
--   
--   >>> V.minimum $ V.fromList [Arg 2 'a', Arg 1 'b']
--   Arg 1 'b'
--   
--   >>> V.minimum $ V.fromList [Arg 1 'a', Arg 1 'b']
--   Arg 1 'a'
--   
minimum :: Ord a => Vector a -> a

-- | O(n) Yield the minimum element of the vector according to the
--   given comparison function. The vector may not be empty. In case of a
--   tie, the first occurrence wins.
--   
--   
Examples
--   
--   
--   >>> import Data.Ord
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.minimumBy (comparing fst) $ V.fromList [(2,'a'), (1,'b')]
--   (1,'b')
--   
--   >>> V.minimumBy (comparing fst) $ V.fromList [(1,'a'), (1,'b')]
--   (1,'a')
--   
minimumBy :: (a -> a -> Ordering) -> Vector a -> a

-- | O(n) Yield the index of the minimum element of the vector. The
--   vector may not be empty.
minIndex :: Ord a => Vector a -> Int

-- | O(n) Yield the index of the minimum element of the vector
--   according to the given comparison function. The vector may not be
--   empty.
--   
--   
Examples
--   
--   
--   >>> import Data.Ord
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.minIndexBy (comparing fst) $ V.fromList [(2,'a'), (1,'b')]
--   1
--   
--   >>> V.minIndexBy (comparing fst) $ V.fromList [(1,'a'), (1,'b')]
--   0
--   
minIndexBy :: (a -> a -> Ordering) -> Vector a -> Int

-- | O(n) Yield the index of the maximum element of the vector. The
--   vector may not be empty.
maxIndex :: Ord a => Vector a -> Int

-- | O(n) Yield the index of the maximum element of the vector
--   according to the given comparison function. The vector may not be
--   empty. In case of a tie, the first occurrence wins.
--   
--   
Examples
--   
--   
--   >>> import Data.Ord
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.maxIndexBy (comparing fst) $ V.fromList [(2,'a'), (1,'b')]
--   0
--   
--   >>> V.maxIndexBy (comparing fst) $ V.fromList [(1,'a'), (1,'b')]
--   0
--   
maxIndexBy :: (a -> a -> Ordering) -> Vector a -> Int

-- | O(n) Monadic fold over non-empty vectors.
fold1M :: Monad m => (a -> a -> m a) -> Vector a -> m a

-- | O(n) Monadic fold over non-empty vectors with strict
--   accumulator.
fold1M' :: Monad m => (a -> a -> m a) -> Vector a -> m a

-- | O(n) Monadic fold over non-empty vectors that discards the
--   result.
fold1M_ :: Monad m => (a -> a -> m a) -> Vector a -> m ()

-- | O(n) Monadic fold over non-empty vectors with strict
--   accumulator that discards the result.
fold1M'_ :: Monad m => (a -> a -> m a) -> Vector a -> m ()

-- | O(n) Initial-value free left-to-right scan over a vector.
--   
--   
--   scanl f <x1,...,xn> = <y1,...,yn>
--     where y1 = x1
--           yi = f y(i-1) xi
--   
--   
--   Note: Since 0.13, application of this to an empty vector no longer
--   results in an error; instead it produces an empty vector.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.scanl1 min $ V.fromListN 5 [4,2,4,1,3]
--   [4,2,2,1,1]
--   
--   >>> V.scanl1 max $ V.fromListN 5 [1,3,2,5,4]
--   [1,3,3,5,5]
--   
--   >>> V.scanl1 min (V.empty :: V.Vector Int)
--   []
--   
scanl1 :: (a -> a -> a) -> Vector a -> Vector a

-- | O(n) Initial-value free left-to-right scan over a vector with a
--   strict accumulator.
--   
--   Note: Since 0.13, application of this to an empty vector no longer
--   results in an error; instead it produces an empty vector.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.scanl1' min $ V.fromListN 5 [4,2,4,1,3]
--   [4,2,2,1,1]
--   
--   >>> V.scanl1' max $ V.fromListN 5 [1,3,2,5,4]
--   [1,3,3,5,5]
--   
--   >>> V.scanl1' min (V.empty :: V.Vector Int)
--   []
--   
scanl1' :: (a -> a -> a) -> Vector a -> Vector a

-- | O(n) Right-to-left, initial-value free scan over a vector.
--   
--   Note: Since 0.13, application of this to an empty vector no longer
--   results in an error; instead it produces an empty vector.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.scanr1 min $ V.fromListN 5 [3,1,4,2,4]
--   [1,1,2,2,4]
--   
--   >>> V.scanr1 max $ V.fromListN 5 [4,5,2,3,1]
--   [5,5,3,3,1]
--   
--   >>> V.scanr1 min (V.empty :: V.Vector Int)
--   []
--   
scanr1 :: (a -> a -> a) -> Vector a -> Vector a

-- | O(n) Right-to-left, initial-value free scan over a vector with
--   a strict accumulator.
--   
--   Note: Since 0.13, application of this to an empty vector no longer
--   results in an error; instead it produces an empty vector.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.scanr1' min $ V.fromListN 5 [3,1,4,2,4]
--   [1,1,2,2,4]
--   
--   >>> V.scanr1' max $ V.fromListN 5 [4,5,2,3,1]
--   [5,5,3,3,1]
--   
--   >>> V.scanr1' min (V.empty :: V.Vector Int)
--   []
--   
scanr1' :: (a -> a -> a) -> Vector a -> Vector a

-- | Boxed Vector unsafe functions. These perform no bounds
--   checking, and may cause segmentation faults etc.! Import as:
--   
--   
--   import qualified RIO.Vector.Boxed.Unsafe as VB'
--   
module RIO.Vector.Boxed.Unsafe

-- | O(1) Unsafe indexing without bounds checking.
unsafeIndex :: Vector a -> Int -> a

-- | O(1) First element, without checking if the vector is empty.
unsafeHead :: Vector a -> a

-- | O(1) Last element, without checking if the vector is empty.
unsafeLast :: Vector a -> a

-- | O(1) Indexing in a monad, without bounds checks. See
--   indexM for an explanation of why this is useful.
unsafeIndexM :: Monad m => Vector a -> Int -> m a

-- | O(1) First element in a monad, without checking for empty
--   vectors. See indexM for an explanation of why this is useful.
unsafeHeadM :: Monad m => Vector a -> m a

-- | O(1) Last element in a monad, without checking for empty
--   vectors. See indexM for an explanation of why this is useful.
unsafeLastM :: Monad m => Vector a -> m a

-- | O(1) Yield a slice of the vector without copying. The vector
--   must contain at least i+n elements, but this is not checked.
unsafeSlice :: Int -> Int -> Vector a -> Vector a

-- | O(1) Yield all but the last element without copying. The vector
--   may not be empty, but this is not checked.
unsafeInit :: Vector a -> Vector a

-- | O(1) Yield all but the first element without copying. The
--   vector may not be empty, but this is not checked.
unsafeTail :: Vector a -> Vector a

-- | O(1) Yield the first n elements without copying. The
--   vector must contain at least n elements, but this is not
--   checked.
unsafeTake :: Int -> Vector a -> Vector a

-- | O(1) Yield all but the first n elements without
--   copying. The vector must contain at least n elements, but
--   this is not checked.
unsafeDrop :: Int -> Vector a -> Vector a

-- | Same as (//), but without bounds checking.
unsafeUpd :: Vector a -> [(Int, a)] -> Vector a

-- | Same as update, but without bounds checking.
unsafeUpdate :: Vector a -> Vector (Int, a) -> Vector a

-- | Same as update_, but without bounds checking.
unsafeUpdate_ :: Vector a -> Vector Int -> Vector a -> Vector a

-- | Same as accum, but without bounds checking.
unsafeAccum :: (a -> b -> a) -> Vector a -> [(Int, b)] -> Vector a

-- | Same as accumulate, but without bounds checking.
unsafeAccumulate :: (a -> b -> a) -> Vector a -> Vector (Int, b) -> Vector a

-- | Same as accumulate_, but without bounds checking.
unsafeAccumulate_ :: (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector a

-- | Same as backpermute, but without bounds checking.
unsafeBackpermute :: Vector a -> Vector Int -> Vector a

-- | O(1) Unsafely convert a mutable vector to an immutable one
--   without copying. The mutable vector may not be used after this
--   operation.
unsafeFreeze :: PrimMonad m => MVector (PrimState m) a -> m (Vector a)

-- | O(1) Unsafely convert an immutable vector to a mutable one
--   without copying. Note that this is a very dangerous function and
--   generally it's only safe to read from the resulting vector. In this
--   case, the immutable vector could be used safely as well.
--   
--   Problems with mutation happen because GHC has a lot of freedom to
--   introduce sharing. As a result mutable vectors produced by
--   unsafeThaw may or may not share the same underlying buffer.
--   For example:
--   
--   
--   foo = do
--     let vec = V.generate 10 id
--     mvec <- V.unsafeThaw vec
--     do_something mvec
--   
--   
--   Here GHC could lift vec outside of foo which means that all
--   calls to do_something will use same buffer with possibly
--   disastrous results. Whether such aliasing happens or not depends on
--   the program in question, optimization levels, and GHC flags.
--   
--   All in all, attempts to modify a vector produced by
--   unsafeThaw fall out of domain of software engineering and
--   into realm of black magic, dark rituals, and unspeakable horrors. The
--   only advice that could be given is: "Don't attempt to mutate a vector
--   produced by unsafeThaw unless you know how to prevent GHC
--   from aliasing buffers accidentally. We don't."
unsafeThaw :: PrimMonad m => Vector a -> m (MVector (PrimState m) a)

-- | O(n) Copy an immutable vector into a mutable one. The two
--   vectors must have the same length. This is not checked.
unsafeCopy :: PrimMonad m => MVector (PrimState m) a -> Vector a -> m ()

-- | Generic Vector interface partial functions. Import as:
--   
--   
--   import qualified RIO.Vector.Partial as V'
--   
module RIO.Vector.Partial

-- | O(1) Indexing.
(!) :: (HasCallStack, Vector v a) => v a -> Int -> a
infixl 9 !

-- | O(1) First element.
head :: Vector v a => v a -> a

-- | O(1) Last element.
last :: Vector v a => v a -> a

-- | O(1) Indexing in a monad.
--   
--   The monad allows operations to be strict in the vector when necessary.
--   Suppose vector copying is implemented like this:
--   
--   
--   copy mv v = ... write mv i (v ! i) ...
--   
--   
--   For lazy vectors, v ! i would not be evaluated which means
--   that mv would unnecessarily retain a reference to v
--   in each element written.
--   
--   With indexM, copying can be implemented like this instead:
--   
--   
--   copy mv v = ... do
--                     x <- indexM v i
--                     write mv i x
--   
--   
--   Here, no references to v are retained because indexing (but
--   not the element) is evaluated eagerly.
indexM :: (HasCallStack, Vector v a, Monad m) => v a -> Int -> m a

-- | O(1) First element of a vector in a monad. See indexM
--   for an explanation of why this is useful.
headM :: (Vector v a, Monad m) => v a -> m a

-- | O(1) Last element of a vector in a monad. See indexM for
--   an explanation of why this is useful.
lastM :: (Vector v a, Monad m) => v a -> m a

-- | O(1) Yield all but the last element without copying. The vector
--   may not be empty.
init :: Vector v a => v a -> v a

-- | O(1) Yield all but the first element without copying. The
--   vector may not be empty.
tail :: Vector v a => v a -> v a

-- | O(m+n) For each pair (i,a) from the list of
--   index/value pairs, replace the vector element at position i
--   by a.
--   
--   
--   <5,9,2,7> // [(2,1),(0,3),(2,8)] = <3,9,8,7>
--   
(//) :: Vector v a => v a -> [(Int, a)] -> v a

-- | O(m+n) For each pair (i,a) from the vector of
--   index/value pairs, replace the vector element at position i
--   by a.
--   
--   
--   update <5,9,2,7> <(2,1),(0,3),(2,8)> = <3,9,8,7>
--   
update :: (Vector v a, Vector v (Int, a)) => v a -> v (Int, a) -> v a

-- | O(m+min(n1,n2)) For each index i from the index vector
--   and the corresponding value a from the value vector, replace
--   the element of the initial vector at position i by
--   a.
--   
--   
--   update_ <5,9,2,7>  <2,0,2> <1,3,8> = <3,9,8,7>
--   
--   
--   This function is useful for instances of Vector that cannot
--   store pairs. Otherwise, update is probably more convenient.
--   
--   
--   update_ xs is ys = update xs (zip is ys)
--   
update_ :: (Vector v a, Vector v Int) => v a -> v Int -> v a -> v a

-- | O(m+n) For each pair (i,b) from the list, replace the
--   vector element a at position i by f a b.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.accum (+) (V.fromList [1000,2000,3000]) [(2,4),(1,6),(0,3),(1,10)]
--   [1003,2016,3004]
--   
accum :: Vector v a => (a -> b -> a) -> v a -> [(Int, b)] -> v a

-- | O(m+n) For each pair (i,b) from the vector of pairs,
--   replace the vector element a at position i by f
--   a b.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.accumulate (+) (V.fromList [1000,2000,3000]) (V.fromList [(2,4),(1,6),(0,3),(1,10)])
--   [1003,2016,3004]
--   
accumulate :: (Vector v a, Vector v (Int, b)) => (a -> b -> a) -> v a -> v (Int, b) -> v a

-- | O(m+min(n1,n2)) For each index i from the index vector
--   and the corresponding value b from the the value vector,
--   replace the element of the initial vector at position i by
--   f a b.
--   
--   
--   accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>
--   
--   
--   This function is useful for instances of Vector that cannot
--   store pairs. Otherwise, accumulate is probably more convenient:
--   
--   
--   accumulate_ f as is bs = accumulate f as (zip is bs)
--   
accumulate_ :: (Vector v a, Vector v Int, Vector v b) => (a -> b -> a) -> v a -> v Int -> v b -> v a

-- | O(n) Yield the vector obtained by replacing each element
--   i of the index vector by xs!i. This is
--   equivalent to map (xs!) is, but is often much
--   more efficient.
--   
--   
--   backpermute <a,b,c,d> <0,3,2,3,1,0> = <a,d,c,d,b,a>
--   
backpermute :: (HasCallStack, Vector v a, Vector v Int) => v a -> v Int -> v a

-- | O(n) Left fold on non-empty vectors.
foldl1 :: Vector v a => (a -> a -> a) -> v a -> a

-- | O(n) Left fold on non-empty vectors with strict accumulator.
foldl1' :: Vector v a => (a -> a -> a) -> v a -> a

-- | O(n) Right fold on non-empty vectors.
foldr1 :: Vector v a => (a -> a -> a) -> v a -> a

-- | O(n) Right fold on non-empty vectors with strict accumulator.
foldr1' :: Vector v a => (a -> a -> a) -> v a -> a

-- | O(n) Yield the maximum element of the vector. The vector may
--   not be empty. In case of a tie, the first occurrence wins.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.maximum $ V.fromList [2, 1]
--   2
--   
--   >>> import Data.Semigroup
--   
--   >>> V.maximum $ V.fromList [Arg 1 'a', Arg 2 'b']
--   Arg 2 'b'
--   
--   >>> V.maximum $ V.fromList [Arg 1 'a', Arg 1 'b']
--   Arg 1 'a'
--   
maximum :: (Vector v a, Ord a) => v a -> a

-- | O(n) Yield the maximum element of the vector according to the
--   given comparison function. The vector may not be empty. In case of a
--   tie, the first occurrence wins. This behavior is different from
--   maximumBy which returns the last tie.
--   
--   
Examples
--   
--   
--   >>> import Data.Ord
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.maximumBy (comparing fst) $ V.fromList [(2,'a'), (1,'b')]
--   (2,'a')
--   
--   >>> V.maximumBy (comparing fst) $ V.fromList [(1,'a'), (1,'b')]
--   (1,'a')
--   
maximumBy :: Vector v a => (a -> a -> Ordering) -> v a -> a

-- | O(n) Yield the minimum element of the vector. The vector may
--   not be empty. In case of a tie, the first occurrence wins.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.minimum $ V.fromList [2, 1]
--   1
--   
--   >>> import Data.Semigroup
--   
--   >>> V.minimum $ V.fromList [Arg 2 'a', Arg 1 'b']
--   Arg 1 'b'
--   
--   >>> V.minimum $ V.fromList [Arg 1 'a', Arg 1 'b']
--   Arg 1 'a'
--   
minimum :: (Vector v a, Ord a) => v a -> a

-- | O(n) Yield the minimum element of the vector according to the
--   given comparison function. The vector may not be empty. In case of a
--   tie, the first occurrence wins.
--   
--   
Examples
--   
--   
--   >>> import Data.Ord
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.minimumBy (comparing fst) $ V.fromList [(2,'a'), (1,'b')]
--   (1,'b')
--   
--   >>> V.minimumBy (comparing fst) $ V.fromList [(1,'a'), (1,'b')]
--   (1,'a')
--   
minimumBy :: Vector v a => (a -> a -> Ordering) -> v a -> a

-- | O(n) Yield the index of the minimum element of the vector. The
--   vector may not be empty.
minIndex :: (Vector v a, Ord a) => v a -> Int

-- | O(n) Yield the index of the minimum element of the vector
--   according to the given comparison function. The vector may not be
--   empty.
--   
--   
Examples
--   
--   
--   >>> import Data.Ord
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.minIndexBy (comparing fst) $ V.fromList [(2,'a'), (1,'b')]
--   1
--   
--   >>> V.minIndexBy (comparing fst) $ V.fromList [(1,'a'), (1,'b')]
--   0
--   
minIndexBy :: Vector v a => (a -> a -> Ordering) -> v a -> Int

-- | O(n) Yield the index of the maximum element of the vector. The
--   vector may not be empty.
maxIndex :: (Vector v a, Ord a) => v a -> Int

-- | O(n) Yield the index of the maximum element of the vector
--   according to the given comparison function. The vector may not be
--   empty. In case of a tie, the first occurrence wins.
--   
--   
Examples
--   
--   
--   >>> import Data.Ord
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.maxIndexBy (comparing fst) $ V.fromList [(2,'a'), (1,'b')]
--   0
--   
--   >>> V.maxIndexBy (comparing fst) $ V.fromList [(1,'a'), (1,'b')]
--   0
--   
maxIndexBy :: Vector v a => (a -> a -> Ordering) -> v a -> Int

-- | O(n) Monadic fold over non-empty vectors.
fold1M :: (Monad m, Vector v a) => (a -> a -> m a) -> v a -> m a

-- | O(n) Monadic fold over non-empty vectors with strict
--   accumulator.
fold1M' :: (Monad m, Vector v a) => (a -> a -> m a) -> v a -> m a

-- | O(n) Monadic fold over non-empty vectors that discards the
--   result.
fold1M_ :: (Monad m, Vector v a) => (a -> a -> m a) -> v a -> m ()

-- | O(n) Monad fold over non-empty vectors with strict accumulator
--   that discards the result.
fold1M'_ :: (Monad m, Vector v a) => (a -> a -> m a) -> v a -> m ()

-- | O(n) Initial-value free left-to-right scan over a vector.
--   
--   
--   scanl f <x1,...,xn> = <y1,...,yn>
--     where y1 = x1
--           yi = f y(i-1) xi
--   
--   
--   Note: Since 0.13, application of this to an empty vector no longer
--   results in an error; instead it produces an empty vector.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.scanl1 min $ V.fromListN 5 [4,2,4,1,3]
--   [4,2,2,1,1]
--   
--   >>> V.scanl1 max $ V.fromListN 5 [1,3,2,5,4]
--   [1,3,3,5,5]
--   
--   >>> V.scanl1 min (V.empty :: V.Vector Int)
--   []
--   
scanl1 :: Vector v a => (a -> a -> a) -> v a -> v a

-- | O(n) Initial-value free left-to-right scan over a vector with a
--   strict accumulator.
--   
--   Note: Since 0.13, application of this to an empty vector no longer
--   results in an error; instead it produces an empty vector.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.scanl1' min $ V.fromListN 5 [4,2,4,1,3]
--   [4,2,2,1,1]
--   
--   >>> V.scanl1' max $ V.fromListN 5 [1,3,2,5,4]
--   [1,3,3,5,5]
--   
--   >>> V.scanl1' min (V.empty :: V.Vector Int)
--   []
--   
scanl1' :: Vector v a => (a -> a -> a) -> v a -> v a

-- | O(n) Right-to-left, initial-value free scan over a vector.
--   
--   Note: Since 0.13, application of this to an empty vector no longer
--   results in an error; instead it produces an empty vector.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.scanr1 min $ V.fromListN 5 [3,1,4,2,4]
--   [1,1,2,2,4]
--   
--   >>> V.scanr1 max $ V.fromListN 5 [4,5,2,3,1]
--   [5,5,3,3,1]
--   
--   >>> V.scanr1 min (V.empty :: V.Vector Int)
--   []
--   
scanr1 :: Vector v a => (a -> a -> a) -> v a -> v a

-- | O(n) Right-to-left, initial-value free scan over a vector with
--   a strict accumulator.
--   
--   Note: Since 0.13, application of this to an empty vector no longer
--   results in an error; instead it produces an empty vector.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as V
--   
--   >>> V.scanr1' min $ V.fromListN 5 [3,1,4,2,4]
--   [1,1,2,2,4]
--   
--   >>> V.scanr1' max $ V.fromListN 5 [4,5,2,3,1]
--   [5,5,3,3,1]
--   
--   >>> V.scanr1' min (V.empty :: V.Vector Int)
--   []
--   
scanr1' :: Vector v a => (a -> a -> a) -> v a -> v a

-- | Storable Vector. Import as:
--   
--   
--   import qualified RIO.Vector.Storable as VS
--   
--   
--   This module does not export any partial or unsafe functions. For
--   those, see RIO.Vector.Storable.Partial and
--   RIO.Vector.Storable.Unsafe
module RIO.Vector.Storable

-- | Storable-based vectors.
data () => Vector a

-- | Mutable Storable-based vectors.
data () => MVector s a
MVector :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !ForeignPtr a -> MVector s a

-- | The member functions of this class facilitate writing values of
--   primitive types to raw memory (which may have been allocated with the
--   above mentioned routines) and reading values from blocks of raw
--   memory. The class, furthermore, includes support for computing the
--   storage requirements and alignment restrictions of storable types.
--   
--   Memory addresses are represented as values of type Ptr
--   a, for some a which is an instance of class
--   Storable. The type argument to Ptr helps provide some
--   valuable type safety in FFI code (you can't mix pointers of different
--   types without an explicit cast), while helping the Haskell type system
--   figure out which marshalling method is needed for a given pointer.
--   
--   All marshalling between Haskell and a foreign language ultimately
--   boils down to translating Haskell data structures into the binary
--   representation of a corresponding data structure of the foreign
--   language and vice versa. To code this marshalling in Haskell, it is
--   necessary to manipulate primitive data types stored in unstructured
--   memory blocks. The class Storable facilitates this manipulation
--   on all types for which it is instantiated, which are the standard
--   basic types of Haskell, the fixed size Int types
--   (Int8, Int16, Int32, Int64), the fixed
--   size Word types (Word8, Word16, Word32,
--   Word64), StablePtr, all types from
--   Foreign.C.Types, as well as Ptr.
class () => Storable a

-- | O(1) Yield the length of the vector.
length :: Storable a => Vector a -> Int

-- | O(1) Test whether a vector is empty.
null :: Storable a => Vector a -> Bool

-- | O(1) Safe indexing.
(!?) :: Storable a => Vector a -> Int -> Maybe a

-- | O(1) Yield a slice of the vector without copying it. The vector
--   must contain at least i+n elements.
slice :: Storable a => Int -> Int -> Vector a -> Vector a

-- | O(1) Yield at the first n elements without copying.
--   The vector may contain less than n elements, in which case it
--   is returned unchanged.
take :: Storable a => Int -> Vector a -> Vector a

-- | O(1) Yield all but the first n elements without
--   copying. The vector may contain less than n elements, in
--   which case an empty vector is returned.
drop :: Storable a => Int -> Vector a -> Vector a

-- | O(1) Yield the first n elements paired with the
--   remainder, without copying.
--   
--   Note that splitAt n v is equivalent to
--   (take n v, drop n v), but slightly more
--   efficient.
splitAt :: Storable a => Int -> Vector a -> (Vector a, Vector a)

-- | O(1) The empty vector.
empty :: Storable a => Vector a

-- | O(1) A vector with exactly one element.
singleton :: Storable a => a -> Vector a

-- | O(n) A vector of the given length with the same value in each
--   position.
replicate :: Storable a => Int -> a -> Vector a

-- | O(n) Construct a vector of the given length by applying the
--   function to each index.
generate :: Storable a => Int -> (Int -> a) -> Vector a

-- | O(n) Apply the function <math> times to an initial value,
--   producing a vector of length <math>. The 0th element will
--   contain the initial value, which is why there is one less function
--   application than the number of elements in the produced vector.
--   
--   <math>
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Storable as VS
--   
--   >>> VS.iterateN 0 undefined undefined :: VS.Vector Int
--   []
--   
--   >>> VS.iterateN 26 succ 'a'
--   "abcdefghijklmnopqrstuvwxyz"
--   
iterateN :: Storable a => Int -> (a -> a) -> a -> Vector a

-- | O(n) Execute the monadic action the given number of times and
--   store the results in a vector.
replicateM :: (Monad m, Storable a) => Int -> m a -> m (Vector a)

-- | O(n) Construct a vector of the given length by applying the
--   monadic action to each index.
generateM :: (Monad m, Storable a) => Int -> (Int -> m a) -> m (Vector a)

-- | O(n) Apply the monadic function <math> times to an
--   initial value, producing a vector of length <math>. The 0th
--   element will contain the initial value, which is why there is one less
--   function application than the number of elements in the produced
--   vector.
--   
--   For a non-monadic version, see iterateN.
iterateNM :: (Monad m, Storable a) => Int -> (a -> m a) -> a -> m (Vector a)

-- | Execute the monadic action and freeze the resulting vector.
--   
--   
--   create (do { v <- new 2; write v 0 'a'; write v 1 'b'; return v }) = <a,b>
--   
create :: Storable a => (forall s. () => ST s (MVector s a)) -> Vector a

-- | Execute the monadic action and freeze the resulting vectors.
createT :: (Traversable f, Storable a) => (forall s. () => ST s (f (MVector s a))) -> f (Vector a)

-- | O(n) Construct a vector by repeatedly applying the generator
--   function to a seed. The generator function yields Just the
--   next element and the new seed or Nothing if there are no more
--   elements.
--   
--   
--   unfoldr (\n -> if n == 0 then Nothing else Just (n,n-1)) 10
--    = <10,9,8,7,6,5,4,3,2,1>
--   
unfoldr :: Storable a => (b -> Maybe (a, b)) -> b -> Vector a

-- | O(n) Construct a vector with at most n elements by
--   repeatedly applying the generator function to a seed. The generator
--   function yields Just the next element and the new seed or
--   Nothing if there are no more elements.
--   
--   
--   unfoldrN 3 (\n -> Just (n,n-1)) 10 = <10,9,8>
--   
unfoldrN :: Storable a => Int -> (b -> Maybe (a, b)) -> b -> Vector a

-- | O(n) Construct a vector by repeatedly applying the monadic
--   generator function to a seed. The generator function yields
--   Just the next element and the new seed or Nothing if
--   there are no more elements.
unfoldrM :: (Monad m, Storable a) => (b -> m (Maybe (a, b))) -> b -> m (Vector a)

-- | O(n) Construct a vector by repeatedly applying the monadic
--   generator function to a seed. The generator function yields
--   Just the next element and the new seed or Nothing if
--   there are no more elements.
unfoldrNM :: (Monad m, Storable a) => Int -> (b -> m (Maybe (a, b))) -> b -> m (Vector a)

-- | O(n) Construct a vector with n elements by repeatedly
--   applying the generator function to the already constructed part of the
--   vector.
--   
--   
--   constructN 3 f = let a = f <> ; b = f <a> ; c = f <a,b> in <a,b,c>
--   
constructN :: Storable a => Int -> (Vector a -> a) -> Vector a

-- | O(n) Construct a vector with n elements from right to
--   left by repeatedly applying the generator function to the already
--   constructed part of the vector.
--   
--   
--   constructrN 3 f = let a = f <> ; b = f<a> ; c = f <b,a> in <c,b,a>
--   
constructrN :: Storable a => Int -> (Vector a -> a) -> Vector a

-- | O(n) Yield a vector of the given length, containing the values
--   x, x+1 etc. This operation is usually more efficient
--   than enumFromTo.
--   
--   
--   enumFromN 5 3 = <5,6,7>
--   
enumFromN :: (Storable a, Num a) => a -> Int -> Vector a

-- | O(n) Yield a vector of the given length, containing the values
--   x, x+y, x+y+y etc. This operations is
--   usually more efficient than enumFromThenTo.
--   
--   
--   enumFromStepN 1 2 5 = <1,3,5,7,9>
--   
enumFromStepN :: (Storable a, Num a) => a -> a -> Int -> Vector a

-- | O(n) Enumerate values from x to y.
--   
--   WARNING: This operation can be very inefficient. If possible,
--   use enumFromN instead.
enumFromTo :: (Storable a, Enum a) => a -> a -> Vector a

-- | O(n) Enumerate values from x to y with a
--   specific step z.
--   
--   WARNING: This operation can be very inefficient. If possible,
--   use enumFromStepN instead.
enumFromThenTo :: (Storable a, Enum a) => a -> a -> a -> Vector a

-- | O(n) Prepend an element.
cons :: Storable a => a -> Vector a -> Vector a

-- | O(n) Append an element.
snoc :: Storable a => Vector a -> a -> Vector a

-- | O(m+n) Concatenate two vectors.
(++) :: Storable a => Vector a -> Vector a -> Vector a
infixr 5 ++

-- | O(n) Concatenate all vectors in the list.
concat :: Storable a => [Vector a] -> Vector a

-- | O(n) Yield the argument, but force it not to retain any extra
--   memory, possibly by copying it.
--   
--   This is especially useful when dealing with slices. For example:
--   
--   
--   force (slice 0 2 <huge vector>)
--   
--   
--   Here, the slice retains a reference to the huge vector. Forcing it
--   creates a copy of just the elements that belong to the slice and
--   allows the huge vector to be garbage collected.
force :: Storable a => Vector a -> Vector a

-- | O(n) Reverse a vector.
reverse :: Storable a => Vector a -> Vector a

-- | Apply a destructive operation to a vector. The operation may be
--   performed in place if it is safe to do so and will modify a copy of
--   the vector otherwise (see New for details).
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Storable as VS
--   
--   >>> import qualified Data.Vector.Storable.Mutable as MVS
--   
--   >>> VS.modify (\v -> MVS.write v 0 'x') $ VS.replicate 4 'a'
--   "xaaa"
--   
modify :: Storable a => (forall s. () => MVector s a -> ST s ()) -> Vector a -> Vector a

-- | O(n) Map a function over a vector.
map :: (Storable a, Storable b) => (a -> b) -> Vector a -> Vector b

-- | O(n) Apply a function to every element of a vector and its
--   index.
imap :: (Storable a, Storable b) => (Int -> a -> b) -> Vector a -> Vector b

-- | Map a function over a vector and concatenate the results.
concatMap :: (Storable a, Storable b) => (a -> Vector b) -> Vector a -> Vector b

-- | O(n) Apply the monadic action to all elements of the vector,
--   yielding a vector of results.
mapM :: (Monad m, Storable a, Storable b) => (a -> m b) -> Vector a -> m (Vector b)

-- | O(n) Apply the monadic action to all elements of a vector and
--   ignore the results.
mapM_ :: (Monad m, Storable a) => (a -> m b) -> Vector a -> m ()

-- | O(n) Apply the monadic action to all elements of the vector,
--   yielding a vector of results. Equivalent to flip mapM.
forM :: (Monad m, Storable a, Storable b) => Vector a -> (a -> m b) -> m (Vector b)

-- | O(n) Apply the monadic action to all elements of a vector and
--   ignore the results. Equivalent to flip mapM_.
forM_ :: (Monad m, Storable a) => Vector a -> (a -> m b) -> m ()

-- | O(min(m,n)) Zip two vectors with the given function.
zipWith :: (Storable a, Storable b, Storable c) => (a -> b -> c) -> Vector a -> Vector b -> Vector c

-- | Zip three vectors with the given function.
zipWith3 :: (Storable a, Storable b, Storable c, Storable d) => (a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d
zipWith4 :: (Storable a, Storable b, Storable c, Storable d, Storable e) => (a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
zipWith5 :: (Storable a, Storable b, Storable c, Storable d, Storable e, Storable f) => (a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f
zipWith6 :: (Storable a, Storable b, Storable c, Storable d, Storable e, Storable f, Storable g) => (a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g

-- | O(min(m,n)) Zip two vectors with a function that also takes the
--   elements' indices.
izipWith :: (Storable a, Storable b, Storable c) => (Int -> a -> b -> c) -> Vector a -> Vector b -> Vector c

-- | Zip three vectors and their indices with the given function.
izipWith3 :: (Storable a, Storable b, Storable c, Storable d) => (Int -> a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d
izipWith4 :: (Storable a, Storable b, Storable c, Storable d, Storable e) => (Int -> a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
izipWith5 :: (Storable a, Storable b, Storable c, Storable d, Storable e, Storable f) => (Int -> a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f
izipWith6 :: (Storable a, Storable b, Storable c, Storable d, Storable e, Storable f, Storable g) => (Int -> a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g

-- | O(min(m,n)) Zip the two vectors with the monadic action and
--   yield a vector of results.
zipWithM :: (Monad m, Storable a, Storable b, Storable c) => (a -> b -> m c) -> Vector a -> Vector b -> m (Vector c)

-- | O(min(m,n)) Zip the two vectors with the monadic action and
--   ignore the results.
zipWithM_ :: (Monad m, Storable a, Storable b) => (a -> b -> m c) -> Vector a -> Vector b -> m ()

-- | O(n) Drop all elements that do not satisfy the predicate.
filter :: Storable a => (a -> Bool) -> Vector a -> Vector a

-- | O(n) Drop all elements that do not satisfy the predicate which
--   is applied to the values and their indices.
ifilter :: Storable a => (Int -> a -> Bool) -> Vector a -> Vector a

-- | O(n) Drop repeated adjacent elements. The first element in each
--   group is returned.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Storable as VS
--   
--   >>> VS.uniq $ VS.fromList [1,3,3,200,3 :: Int]
--   [1,3,200,3]
--   
uniq :: (Storable a, Eq a) => Vector a -> Vector a

-- | O(n) Map the values and collect the Just results.
mapMaybe :: (Storable a, Storable b) => (a -> Maybe b) -> Vector a -> Vector b

-- | O(n) Map the indices/values and collect the Just
--   results.
imapMaybe :: (Storable a, Storable b) => (Int -> a -> Maybe b) -> Vector a -> Vector b

-- | O(n) Drop all elements that do not satisfy the monadic
--   predicate.
filterM :: (Monad m, Storable a) => (a -> m Bool) -> Vector a -> m (Vector a)

-- | O(n) Yield the longest prefix of elements satisfying the
--   predicate. The current implementation is not copy-free, unless the
--   result vector is fused away.
takeWhile :: Storable a => (a -> Bool) -> Vector a -> Vector a

-- | O(n) Drop the longest prefix of elements that satisfy the
--   predicate without copying.
dropWhile :: Storable a => (a -> Bool) -> Vector a -> Vector a

-- | O(n) Split the vector in two parts, the first one containing
--   those elements that satisfy the predicate and the second one those
--   that don't. The relative order of the elements is preserved at the
--   cost of a sometimes reduced performance compared to
--   unstablePartition.
partition :: Storable a => (a -> Bool) -> Vector a -> (Vector a, Vector a)

-- | O(n) Split the vector in two parts, the first one containing
--   those elements that satisfy the predicate and the second one those
--   that don't. The order of the elements is not preserved, but the
--   operation is often faster than partition.
unstablePartition :: Storable a => (a -> Bool) -> Vector a -> (Vector a, Vector a)

-- | O(n) Split the vector into the longest prefix of elements that
--   satisfy the predicate and the rest without copying.
span :: Storable a => (a -> Bool) -> Vector a -> (Vector a, Vector a)

-- | O(n) Split the vector into the longest prefix of elements that
--   do not satisfy the predicate and the rest without copying.
break :: Storable a => (a -> Bool) -> Vector a -> (Vector a, Vector a)

-- | O(n) Check if the vector contains an element.
elem :: (Storable a, Eq a) => a -> Vector a -> Bool
infix 4 `elem`

-- | O(n) Check if the vector does not contain an element (inverse
--   of elem).
notElem :: (Storable a, Eq a) => a -> Vector a -> Bool
infix 4 `notElem`

-- | O(n) Yield Just the first element matching the
--   predicate or Nothing if no such element exists.
find :: Storable a => (a -> Bool) -> Vector a -> Maybe a

-- | O(n) Yield Just the index of the first element
--   matching the predicate or Nothing if no such element exists.
findIndex :: Storable a => (a -> Bool) -> Vector a -> Maybe Int

-- | O(n) Yield the indices of elements satisfying the predicate in
--   ascending order.
findIndices :: Storable a => (a -> Bool) -> Vector a -> Vector Int

-- | O(n) Yield Just the index of the first occurrence of
--   the given element or Nothing if the vector does not contain
--   the element. This is a specialised version of findIndex.
elemIndex :: (Storable a, Eq a) => a -> Vector a -> Maybe Int

-- | O(n) Yield the indices of all occurrences of the given element
--   in ascending order. This is a specialised version of
--   findIndices.
elemIndices :: (Storable a, Eq a) => a -> Vector a -> Vector Int

-- | O(n) Left fold.
foldl :: Storable b => (a -> b -> a) -> a -> Vector b -> a

-- | O(n) Left fold with strict accumulator.
foldl' :: Storable b => (a -> b -> a) -> a -> Vector b -> a

-- | O(n) Right fold.
foldr :: Storable a => (a -> b -> b) -> b -> Vector a -> b

-- | O(n) Right fold with a strict accumulator.
foldr' :: Storable a => (a -> b -> b) -> b -> Vector a -> b

-- | O(n) Left fold using a function applied to each element and its
--   index.
ifoldl :: Storable b => (a -> Int -> b -> a) -> a -> Vector b -> a

-- | O(n) Left fold with strict accumulator using a function applied
--   to each element and its index.
ifoldl' :: Storable b => (a -> Int -> b -> a) -> a -> Vector b -> a

-- | O(n) Right fold using a function applied to each element and
--   its index.
ifoldr :: Storable a => (Int -> a -> b -> b) -> b -> Vector a -> b

-- | O(n) Right fold with strict accumulator using a function
--   applied to each element and its index.
ifoldr' :: Storable a => (Int -> a -> b -> b) -> b -> Vector a -> b

-- | O(n) Check if all elements satisfy the predicate.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Storable as VS
--   
--   >>> VS.all even $ VS.fromList [2, 4, 12 :: Int]
--   True
--   
--   >>> VS.all even $ VS.fromList [2, 4, 13 :: Int]
--   False
--   
--   >>> VS.all even (VS.empty :: VS.Vector Int)
--   True
--   
all :: Storable a => (a -> Bool) -> Vector a -> Bool

-- | O(n) Check if any element satisfies the predicate.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Storable as VS
--   
--   >>> VS.any even $ VS.fromList [1, 3, 7 :: Int]
--   False
--   
--   >>> VS.any even $ VS.fromList [3, 2, 13 :: Int]
--   True
--   
--   >>> VS.any even (VS.empty :: VS.Vector Int)
--   False
--   
any :: Storable a => (a -> Bool) -> Vector a -> Bool

-- | O(n) Check if all elements are True.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Storable as VS
--   
--   >>> VS.and $ VS.fromList [True, False]
--   False
--   
--   >>> VS.and VS.empty
--   True
--   
and :: Vector Bool -> Bool

-- | O(n) Check if any element is True.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Storable as VS
--   
--   >>> VS.or $ VS.fromList [True, False]
--   True
--   
--   >>> VS.or VS.empty
--   False
--   
or :: Vector Bool -> Bool

-- | O(n) Compute the sum of the elements.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Storable as VS
--   
--   >>> VS.sum $ VS.fromList [300,20,1 :: Int]
--   321
--   
--   >>> VS.sum (VS.empty :: VS.Vector Int)
--   0
--   
sum :: (Storable a, Num a) => Vector a -> a

-- | O(n) Compute the product of the elements.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Storable as VS
--   
--   >>> VS.product $ VS.fromList [1,2,3,4 :: Int]
--   24
--   
--   >>> VS.product (VS.empty :: VS.Vector Int)
--   1
--   
product :: (Storable a, Num a) => Vector a -> a

-- | O(n) Monadic fold.
foldM :: (Monad m, Storable b) => (a -> b -> m a) -> a -> Vector b -> m a

-- | O(n) Monadic fold with strict accumulator.
foldM' :: (Monad m, Storable b) => (a -> b -> m a) -> a -> Vector b -> m a

-- | O(n) Monadic fold that discards the result.
foldM_ :: (Monad m, Storable b) => (a -> b -> m a) -> a -> Vector b -> m ()

-- | O(n) Monadic fold with strict accumulator that discards the
--   result.
foldM'_ :: (Monad m, Storable b) => (a -> b -> m a) -> a -> Vector b -> m ()

-- | O(n) Left-to-right prescan.
--   
--   
--   prescanl f z = init . scanl f z
--   
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Storable as VS
--   
--   >>> VS.prescanl (+) 0 (VS.fromList [1,2,3,4 :: Int])
--   [0,1,3,6]
--   
prescanl :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Left-to-right prescan with strict accumulator.
prescanl' :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Left-to-right postscan.
--   
--   
--   postscanl f z = tail . scanl f z
--   
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Storable as VS
--   
--   >>> VS.postscanl (+) 0 (VS.fromList [1,2,3,4 :: Int])
--   [1,3,6,10]
--   
postscanl :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Left-to-right postscan with strict accumulator.
postscanl' :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Left-to-right scan.
--   
--   
--   scanl f z <x1,...,xn> = <y1,...,y(n+1)>
--     where y1 = z
--           yi = f y(i-1) x(i-1)
--   
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Storable as VS
--   
--   >>> VS.scanl (+) 0 (VS.fromList [1,2,3,4 :: Int])
--   [0,1,3,6,10]
--   
scanl :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Left-to-right scan with strict accumulator.
scanl' :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Right-to-left prescan.
--   
--   
--   prescanr f z = reverse . prescanl (flip f) z . reverse
--   
prescanr :: (Storable a, Storable b) => (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left prescan with strict accumulator.
prescanr' :: (Storable a, Storable b) => (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left postscan.
postscanr :: (Storable a, Storable b) => (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left postscan with strict accumulator.
postscanr' :: (Storable a, Storable b) => (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left scan.
scanr :: (Storable a, Storable b) => (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left scan with strict accumulator.
scanr' :: (Storable a, Storable b) => (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Convert a vector to a list.
toList :: Storable a => Vector a -> [a]

-- | O(n) Convert a list to a vector.
fromList :: Storable a => [a] -> Vector a

-- | O(n) Convert the first n elements of a list to a
--   vector. It's expected that the supplied list will be exactly
--   n elements long. As an optimization, this function allocates
--   a buffer for n elements, which could be used for DoS-attacks
--   by exhausting the memory if an attacker controls that parameter.
--   
--   
--   fromListN n xs = fromList (take n xs)
--   
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Storable as VS
--   
--   >>> VS.fromListN 3 [1,2,3,4,5 :: Int]
--   [1,2,3]
--   
--   >>> VS.fromListN 3 [1 :: Int]
--   [1]
--   
fromListN :: Storable a => Int -> [a] -> Vector a

-- | O(n) Convert between different vector types.
convert :: (Vector v a, Vector w a) => v a -> w a

-- | O(n) Yield an immutable copy of the mutable vector.
freeze :: (Storable a, PrimMonad m) => MVector (PrimState m) a -> m (Vector a)

-- | O(n) Yield a mutable copy of an immutable vector.
thaw :: (Storable a, PrimMonad m) => Vector a -> m (MVector (PrimState m) a)

-- | O(n) Copy an immutable vector into a mutable one. The two
--   vectors must have the same length.
copy :: (Storable a, PrimMonad m) => MVector (PrimState m) a -> Vector a -> m ()

-- | Storable Vector partial functions. Import as:
--   
--   
--   import qualified RIO.Vector.Storable.Partial as VS'
--   
module RIO.Vector.Storable.Partial

-- | O(1) Indexing.
(!) :: Storable a => Vector a -> Int -> a

-- | O(1) First element.
head :: Storable a => Vector a -> a

-- | O(1) Last element.
last :: Storable a => Vector a -> a

-- | O(1) Indexing in a monad.
--   
--   The monad allows operations to be strict in the vector when necessary.
--   Suppose vector copying is implemented like this:
--   
--   
--   copy mv v = ... write mv i (v ! i) ...
--   
--   
--   For lazy vectors, v ! i would not be evaluated which means
--   that mv would unnecessarily retain a reference to v
--   in each element written.
--   
--   With indexM, copying can be implemented like this instead:
--   
--   
--   copy mv v = ... do
--                     x <- indexM v i
--                     write mv i x
--   
--   
--   Here, no references to v are retained because indexing (but
--   not the element) is evaluated eagerly.
indexM :: (Storable a, Monad m) => Vector a -> Int -> m a

-- | O(1) First element of a vector in a monad. See indexM
--   for an explanation of why this is useful.
headM :: (Storable a, Monad m) => Vector a -> m a

-- | O(1) Last element of a vector in a monad. See indexM for
--   an explanation of why this is useful.
lastM :: (Storable a, Monad m) => Vector a -> m a

-- | O(1) Yield all but the last element without copying. The vector
--   may not be empty.
init :: Storable a => Vector a -> Vector a

-- | O(1) Yield all but the first element without copying. The
--   vector may not be empty.
tail :: Storable a => Vector a -> Vector a

-- | O(m+n) For each pair (i,a) from the list of
--   index/value pairs, replace the vector element at position i
--   by a.
--   
--   
--   <5,9,2,7> // [(2,1),(0,3),(2,8)] = <3,9,8,7>
--   
(//) :: Storable a => Vector a -> [(Int, a)] -> Vector a

-- | O(m+min(n1,n2)) For each index i from the index vector
--   and the corresponding value a from the value vector, replace
--   the element of the initial vector at position i by
--   a.
--   
--   
--   update_ <5,9,2,7>  <2,0,2> <1,3,8> = <3,9,8,7>
--   
update_ :: Storable a => Vector a -> Vector Int -> Vector a -> Vector a

-- | O(m+n) For each pair (i,b) from the list, replace the
--   vector element a at position i by f a b.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Storable as VS
--   
--   >>> VS.accum (+) (VS.fromList [1000,2000,3000 :: Int]) [(2,4),(1,6),(0,3),(1,10)]
--   [1003,2016,3004]
--   
accum :: Storable a => (a -> b -> a) -> Vector a -> [(Int, b)] -> Vector a

-- | O(m+min(n1,n2)) For each index i from the index vector
--   and the corresponding value b from the the value vector,
--   replace the element of the initial vector at position i by
--   f a b.
--   
--   
--   accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>
--   
accumulate_ :: (Storable a, Storable b) => (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector a

-- | O(n) Yield the vector obtained by replacing each element
--   i of the index vector by xs!i. This is
--   equivalent to map (xs!) is, but is often much
--   more efficient.
--   
--   
--   backpermute <a,b,c,d> <0,3,2,3,1,0> = <a,d,c,d,b,a>
--   
backpermute :: Storable a => Vector a -> Vector Int -> Vector a

-- | O(n) Left fold on non-empty vectors.
foldl1 :: Storable a => (a -> a -> a) -> Vector a -> a

-- | O(n) Left fold on non-empty vectors with strict accumulator.
foldl1' :: Storable a => (a -> a -> a) -> Vector a -> a

-- | O(n) Right fold on non-empty vectors.
foldr1 :: Storable a => (a -> a -> a) -> Vector a -> a

-- | O(n) Right fold on non-empty vectors with strict accumulator.
foldr1' :: Storable a => (a -> a -> a) -> Vector a -> a

-- | O(n) Yield the maximum element of the vector. The vector may
--   not be empty. In case of a tie, the first occurrence wins.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Storable as VS
--   
--   >>> VS.maximum $ VS.fromList [2, 1 :: Int]
--   2
--   
maximum :: (Storable a, Ord a) => Vector a -> a

-- | O(n) Yield the maximum element of the vector according to the
--   given comparison function. The vector may not be empty. In case of a
--   tie, the first occurrence wins. This behavior is different from
--   maximumBy which returns the last tie.
maximumBy :: Storable a => (a -> a -> Ordering) -> Vector a -> a

-- | O(n) Yield the minimum element of the vector. The vector may
--   not be empty. In case of a tie, the first occurrence wins.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Storable as VS
--   
--   >>> VS.minimum $ VS.fromList [2, 1 :: Int]
--   1
--   
minimum :: (Storable a, Ord a) => Vector a -> a

-- | O(n) Yield the minimum element of the vector according to the
--   given comparison function. The vector may not be empty. In case of a
--   tie, the first occurrence wins.
minimumBy :: Storable a => (a -> a -> Ordering) -> Vector a -> a

-- | O(n) Yield the index of the minimum element of the vector. The
--   vector may not be empty.
minIndex :: (Storable a, Ord a) => Vector a -> Int

-- | O(n) Yield the index of the minimum element of the vector
--   according to the given comparison function. The vector may not be
--   empty.
minIndexBy :: Storable a => (a -> a -> Ordering) -> Vector a -> Int

-- | O(n) Yield the index of the maximum element of the vector. The
--   vector may not be empty.
maxIndex :: (Storable a, Ord a) => Vector a -> Int

-- | O(n) Yield the index of the maximum element of the vector
--   according to the given comparison function. The vector may not be
--   empty. In case of a tie, the first occurrence wins.
maxIndexBy :: Storable a => (a -> a -> Ordering) -> Vector a -> Int

-- | O(n) Monadic fold over non-empty vectors.
fold1M :: (Monad m, Storable a) => (a -> a -> m a) -> Vector a -> m a

-- | O(n) Monadic fold over non-empty vectors with strict
--   accumulator.
fold1M' :: (Monad m, Storable a) => (a -> a -> m a) -> Vector a -> m a

-- | O(n) Monadic fold over non-empty vectors that discards the
--   result.
fold1M_ :: (Monad m, Storable a) => (a -> a -> m a) -> Vector a -> m ()

-- | O(n) Monadic fold over non-empty vectors with strict
--   accumulator that discards the result.
fold1M'_ :: (Monad m, Storable a) => (a -> a -> m a) -> Vector a -> m ()

-- | O(n) Initial-value free left-to-right scan over a vector.
--   
--   
--   scanl f <x1,...,xn> = <y1,...,yn>
--     where y1 = x1
--           yi = f y(i-1) xi
--   
--   
--   Note: Since 0.13, application of this to an empty vector no longer
--   results in an error; instead it produces an empty vector.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Storable as VS
--   
--   >>> VS.scanl1 min $ VS.fromListN 5 [4,2,4,1,3 :: Int]
--   [4,2,2,1,1]
--   
--   >>> VS.scanl1 max $ VS.fromListN 5 [1,3,2,5,4 :: Int]
--   [1,3,3,5,5]
--   
--   >>> VS.scanl1 min (VS.empty :: VS.Vector Int)
--   []
--   
scanl1 :: Storable a => (a -> a -> a) -> Vector a -> Vector a

-- | O(n) Initial-value free left-to-right scan over a vector with a
--   strict accumulator.
--   
--   Note: Since 0.13, application of this to an empty vector no longer
--   results in an error; instead it produces an empty vector.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Storable as VS
--   
--   >>> VS.scanl1' min $ VS.fromListN 5 [4,2,4,1,3 :: Int]
--   [4,2,2,1,1]
--   
--   >>> VS.scanl1' max $ VS.fromListN 5 [1,3,2,5,4 :: Int]
--   [1,3,3,5,5]
--   
--   >>> VS.scanl1' min (VS.empty :: VS.Vector Int)
--   []
--   
scanl1' :: Storable a => (a -> a -> a) -> Vector a -> Vector a

-- | O(n) Right-to-left, initial-value free scan over a vector.
--   
--   Note: Since 0.13, application of this to an empty vector no longer
--   results in an error; instead it produces an empty vector.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Storable as VS
--   
--   >>> VS.scanr1 min $ VS.fromListN 5 [3,1,4,2,4 :: Int]
--   [1,1,2,2,4]
--   
--   >>> VS.scanr1 max $ VS.fromListN 5 [4,5,2,3,1 :: Int]
--   [5,5,3,3,1]
--   
--   >>> VS.scanr1 min (VS.empty :: VS.Vector Int)
--   []
--   
scanr1 :: Storable a => (a -> a -> a) -> Vector a -> Vector a

-- | O(n) Right-to-left, initial-value free scan over a vector with
--   a strict accumulator.
--   
--   Note: Since 0.13, application of this to an empty vector no longer
--   results in an error; instead it produces an empty vector.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Storable as VS
--   
--   >>> VS.scanr1' min $ VS.fromListN 5 [3,1,4,2,4 :: Int]
--   [1,1,2,2,4]
--   
--   >>> VS.scanr1' max $ VS.fromListN 5 [4,5,2,3,1 :: Int]
--   [5,5,3,3,1]
--   
--   >>> VS.scanr1' min (VS.empty :: VS.Vector Int)
--   []
--   
scanr1' :: Storable a => (a -> a -> a) -> Vector a -> Vector a

-- | Storable Vector unsafe functions. These perform no bounds
--   checking, and may cause segmentation faults etc.! Import as:
--   
--   
--   import qualified RIO.Vector.Storable.Unsafe as VS'
--   
module RIO.Vector.Storable.Unsafe

-- | O(1) Unsafe indexing without bounds checking.
unsafeIndex :: Storable a => Vector a -> Int -> a

-- | O(1) First element, without checking if the vector is empty.
unsafeHead :: Storable a => Vector a -> a

-- | O(1) Last element, without checking if the vector is empty.
unsafeLast :: Storable a => Vector a -> a

-- | O(1) Indexing in a monad, without bounds checks. See
--   indexM for an explanation of why this is useful.
unsafeIndexM :: (Storable a, Monad m) => Vector a -> Int -> m a

-- | O(1) First element in a monad, without checking for empty
--   vectors. See indexM for an explanation of why this is useful.
unsafeHeadM :: (Storable a, Monad m) => Vector a -> m a

-- | O(1) Last element in a monad, without checking for empty
--   vectors. See indexM for an explanation of why this is useful.
unsafeLastM :: (Storable a, Monad m) => Vector a -> m a

-- | O(1) Yield a slice of the vector without copying. The vector
--   must contain at least i+n elements, but this is not checked.
unsafeSlice :: Storable a => Int -> Int -> Vector a -> Vector a

-- | O(1) Yield all but the last element without copying. The vector
--   may not be empty, but this is not checked.
unsafeInit :: Storable a => Vector a -> Vector a

-- | O(1) Yield all but the first element without copying. The
--   vector may not be empty, but this is not checked.
unsafeTail :: Storable a => Vector a -> Vector a

-- | O(1) Yield the first n elements without copying. The
--   vector must contain at least n elements, but this is not
--   checked.
unsafeTake :: Storable a => Int -> Vector a -> Vector a

-- | O(1) Yield all but the first n elements without
--   copying. The vector must contain at least n elements, but
--   this is not checked.
unsafeDrop :: Storable a => Int -> Vector a -> Vector a

-- | Same as (//), but without bounds checking.
unsafeUpd :: Storable a => Vector a -> [(Int, a)] -> Vector a

-- | Same as update_, but without bounds checking.
unsafeUpdate_ :: Storable a => Vector a -> Vector Int -> Vector a -> Vector a

-- | Same as accum, but without bounds checking.
unsafeAccum :: Storable a => (a -> b -> a) -> Vector a -> [(Int, b)] -> Vector a

-- | Same as accumulate_, but without bounds checking.
unsafeAccumulate_ :: (Storable a, Storable b) => (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector a

-- | Same as backpermute, but without bounds checking.
unsafeBackpermute :: Storable a => Vector a -> Vector Int -> Vector a

-- | O(1) Unsafely convert a mutable vector to an immutable one
--   without copying. The mutable vector may not be used after this
--   operation.
unsafeFreeze :: (Storable a, PrimMonad m) => MVector (PrimState m) a -> m (Vector a)

-- | O(1) Unsafely convert an immutable vector to a mutable one
--   without copying. Note that this is a very dangerous function and
--   generally it's only safe to read from the resulting vector. In this
--   case, the immutable vector could be used safely as well.
--   
--   Problems with mutation happen because GHC has a lot of freedom to
--   introduce sharing. As a result mutable vectors produced by
--   unsafeThaw may or may not share the same underlying buffer.
--   For example:
--   
--   
--   foo = do
--     let vec = V.generate 10 id
--     mvec <- V.unsafeThaw vec
--     do_something mvec
--   
--   
--   Here GHC could lift vec outside of foo which means that all
--   calls to do_something will use same buffer with possibly
--   disastrous results. Whether such aliasing happens or not depends on
--   the program in question, optimization levels, and GHC flags.
--   
--   All in all, attempts to modify a vector produced by
--   unsafeThaw fall out of domain of software engineering and
--   into realm of black magic, dark rituals, and unspeakable horrors. The
--   only advice that could be given is: "Don't attempt to mutate a vector
--   produced by unsafeThaw unless you know how to prevent GHC
--   from aliasing buffers accidentally. We don't."
unsafeThaw :: (Storable a, PrimMonad m) => Vector a -> m (MVector (PrimState m) a)

-- | O(n) Copy an immutable vector into a mutable one. The two
--   vectors must have the same length. This is not checked.
unsafeCopy :: (Storable a, PrimMonad m) => MVector (PrimState m) a -> Vector a -> m ()

-- | O(1) Create a vector from a ForeignPtr with an offset
--   and a length.
--   
--   The data may not be modified through the pointer afterwards.
--   
--   If your offset is 0 it is more efficient to use
--   unsafeFromForeignPtr0.
unsafeFromForeignPtr :: Storable a => ForeignPtr a -> Int -> Int -> Vector a

-- | O(1) Create a vector from a ForeignPtr and a length.
--   
--   It is assumed the pointer points directly to the data (no offset). Use
--   unsafeFromForeignPtr if you need to specify an offset.
--   
--   The data may not be modified through the pointer afterwards.
unsafeFromForeignPtr0 :: ForeignPtr a -> Int -> Vector a

-- | O(1) Yield the underlying ForeignPtr together with the
--   offset to the data and its length. The data may not be modified
--   through the ForeignPtr.
unsafeToForeignPtr :: Vector a -> (ForeignPtr a, Int, Int)

-- | O(1) Yield the underlying ForeignPtr together with its
--   length.
--   
--   You can assume that the pointer points directly to the data (no
--   offset).
--   
--   The data may not be modified through the ForeignPtr.
unsafeToForeignPtr0 :: Vector a -> (ForeignPtr a, Int)

-- | Lifted version of unsafeWith
unsafeWith :: (MonadUnliftIO m, Storable a) => Vector a -> (Ptr a -> m b) -> m b

-- | Unboxed Vector. Import as:
--   
--   
--   import qualified RIO.Vector.Unboxed as VU
--   
--   
--   This module does not export any partial or unsafe functions. For
--   those, see RIO.Vector.Unboxed.Partial and
--   RIO.Vector.Unboxed.Unsafe
module RIO.Vector.Unboxed
data family Vector a
data family MVector s a
class (Vector Vector a, MVector MVector a) => Unbox a

-- | O(1) Yield the length of the vector.
length :: Unbox a => Vector a -> Int

-- | O(1) Test whether a vector is empty.
null :: Unbox a => Vector a -> Bool

-- | O(1) Safe indexing.
(!?) :: Unbox a => Vector a -> Int -> Maybe a

-- | O(1) Yield a slice of the vector without copying it. The vector
--   must contain at least i+n elements.
slice :: Unbox a => Int -> Int -> Vector a -> Vector a

-- | O(1) Yield at the first n elements without copying.
--   The vector may contain less than n elements, in which case it
--   is returned unchanged.
take :: Unbox a => Int -> Vector a -> Vector a

-- | O(1) Yield all but the first n elements without
--   copying. The vector may contain less than n elements, in
--   which case an empty vector is returned.
drop :: Unbox a => Int -> Vector a -> Vector a

-- | O(1) Yield the first n elements paired with the
--   remainder, without copying.
--   
--   Note that splitAt n v is equivalent to
--   (take n v, drop n v), but slightly more
--   efficient.
splitAt :: Unbox a => Int -> Vector a -> (Vector a, Vector a)

-- | O(1) The empty vector.
empty :: Unbox a => Vector a

-- | O(1) A vector with exactly one element.
singleton :: Unbox a => a -> Vector a

-- | O(n) A vector of the given length with the same value in each
--   position.
replicate :: Unbox a => Int -> a -> Vector a

-- | O(n) Construct a vector of the given length by applying the
--   function to each index.
generate :: Unbox a => Int -> (Int -> a) -> Vector a

-- | O(n) Apply the function <math> times to an initial value,
--   producing a vector of length <math>. The 0th element will
--   contain the initial value, which is why there is one less function
--   application than the number of elements in the produced vector.
--   
--   <math>
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.iterateN 0 undefined undefined :: VU.Vector Int
--   []
--   
--   >>> VU.iterateN 3 (\(i, c) -> (pred i, succ c)) (0 :: Int, 'a')
--   [(0,'a'),(-1,'b'),(-2,'c')]
--   
iterateN :: Unbox a => Int -> (a -> a) -> a -> Vector a

-- | O(n) Execute the monadic action the given number of times and
--   store the results in a vector.
replicateM :: (Monad m, Unbox a) => Int -> m a -> m (Vector a)

-- | O(n) Construct a vector of the given length by applying the
--   monadic action to each index.
generateM :: (Monad m, Unbox a) => Int -> (Int -> m a) -> m (Vector a)

-- | O(n) Apply the monadic function <math> times to an
--   initial value, producing a vector of length <math>. The 0th
--   element will contain the initial value, which is why there is one less
--   function application than the number of elements in the produced
--   vector.
--   
--   For a non-monadic version, see iterateN.
iterateNM :: (Monad m, Unbox a) => Int -> (a -> m a) -> a -> m (Vector a)

-- | Execute the monadic action and freeze the resulting vector.
--   
--   
--   create (do { v <- new 2; write v 0 'a'; write v 1 'b'; return v }) = <a,b>
--   
create :: Unbox a => (forall s. () => ST s (MVector s a)) -> Vector a

-- | Execute the monadic action and freeze the resulting vectors.
createT :: (Traversable f, Unbox a) => (forall s. () => ST s (f (MVector s a))) -> f (Vector a)

-- | O(n) Construct a vector by repeatedly applying the generator
--   function to a seed. The generator function yields Just the
--   next element and the new seed or Nothing if there are no more
--   elements.
--   
--   
--   unfoldr (\n -> if n == 0 then Nothing else Just (n,n-1)) 10
--    = <10,9,8,7,6,5,4,3,2,1>
--   
unfoldr :: Unbox a => (b -> Maybe (a, b)) -> b -> Vector a

-- | O(n) Construct a vector with at most n elements by
--   repeatedly applying the generator function to a seed. The generator
--   function yields Just the next element and the new seed or
--   Nothing if there are no more elements.
--   
--   
--   unfoldrN 3 (\n -> Just (n,n-1)) 10 = <10,9,8>
--   
unfoldrN :: Unbox a => Int -> (b -> Maybe (a, b)) -> b -> Vector a

-- | O(n) Construct a vector by repeatedly applying the monadic
--   generator function to a seed. The generator function yields
--   Just the next element and the new seed or Nothing if
--   there are no more elements.
unfoldrM :: (Monad m, Unbox a) => (b -> m (Maybe (a, b))) -> b -> m (Vector a)

-- | O(n) Construct a vector by repeatedly applying the monadic
--   generator function to a seed. The generator function yields
--   Just the next element and the new seed or Nothing if
--   there are no more elements.
unfoldrNM :: (Monad m, Unbox a) => Int -> (b -> m (Maybe (a, b))) -> b -> m (Vector a)

-- | O(n) Construct a vector with n elements by repeatedly
--   applying the generator function to the already constructed part of the
--   vector.
--   
--   
--   constructN 3 f = let a = f <> ; b = f <a> ; c = f <a,b> in <a,b,c>
--   
constructN :: Unbox a => Int -> (Vector a -> a) -> Vector a

-- | O(n) Construct a vector with n elements from right to
--   left by repeatedly applying the generator function to the already
--   constructed part of the vector.
--   
--   
--   constructrN 3 f = let a = f <> ; b = f<a> ; c = f <b,a> in <c,b,a>
--   
constructrN :: Unbox a => Int -> (Vector a -> a) -> Vector a

-- | O(n) Yield a vector of the given length, containing the values
--   x, x+1 etc. This operation is usually more efficient
--   than enumFromTo.
--   
--   
--   enumFromN 5 3 = <5,6,7>
--   
enumFromN :: (Unbox a, Num a) => a -> Int -> Vector a

-- | O(n) Yield a vector of the given length, containing the values
--   x, x+y, x+y+y etc. This operations is
--   usually more efficient than enumFromThenTo.
--   
--   
--   enumFromStepN 1 2 5 = <1,3,5,7,9>
--   
enumFromStepN :: (Unbox a, Num a) => a -> a -> Int -> Vector a

-- | O(n) Enumerate values from x to y.
--   
--   WARNING: This operation can be very inefficient. If possible,
--   use enumFromN instead.
enumFromTo :: (Unbox a, Enum a) => a -> a -> Vector a

-- | O(n) Enumerate values from x to y with a
--   specific step z.
--   
--   WARNING: This operation can be very inefficient. If possible,
--   use enumFromStepN instead.
enumFromThenTo :: (Unbox a, Enum a) => a -> a -> a -> Vector a

-- | O(n) Prepend an element.
cons :: Unbox a => a -> Vector a -> Vector a

-- | O(n) Append an element.
snoc :: Unbox a => Vector a -> a -> Vector a

-- | O(m+n) Concatenate two vectors.
(++) :: Unbox a => Vector a -> Vector a -> Vector a
infixr 5 ++

-- | O(n) Concatenate all vectors in the list.
concat :: Unbox a => [Vector a] -> Vector a

-- | O(n) Yield the argument, but force it not to retain any extra
--   memory, possibly by copying it.
--   
--   This is especially useful when dealing with slices. For example:
--   
--   
--   force (slice 0 2 <huge vector>)
--   
--   
--   Here, the slice retains a reference to the huge vector. Forcing it
--   creates a copy of just the elements that belong to the slice and
--   allows the huge vector to be garbage collected.
force :: Unbox a => Vector a -> Vector a

-- | O(n) Reverse a vector.
reverse :: Unbox a => Vector a -> Vector a

-- | Apply a destructive operation to a vector. The operation may be
--   performed in place if it is safe to do so and will modify a copy of
--   the vector otherwise (see New for details).
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> import qualified Data.Vector.Unboxed.Mutable as MVU
--   
--   >>> VU.modify (\v -> MVU.write v 0 'x') $ VU.replicate 4 'a'
--   "xaaa"
--   
modify :: Unbox a => (forall s. () => MVector s a -> ST s ()) -> Vector a -> Vector a

-- | O(n) Pair each element in a vector with its index.
indexed :: Unbox a => Vector a -> Vector (Int, a)

-- | O(n) Map a function over a vector.
map :: (Unbox a, Unbox b) => (a -> b) -> Vector a -> Vector b

-- | O(n) Apply a function to every element of a vector and its
--   index.
imap :: (Unbox a, Unbox b) => (Int -> a -> b) -> Vector a -> Vector b

-- | Map a function over a vector and concatenate the results.
concatMap :: (Unbox a, Unbox b) => (a -> Vector b) -> Vector a -> Vector b

-- | O(n) Apply the monadic action to all elements of the vector,
--   yielding a vector of results.
mapM :: (Monad m, Unbox a, Unbox b) => (a -> m b) -> Vector a -> m (Vector b)

-- | O(n) Apply the monadic action to every element of a vector and
--   its index, yielding a vector of results.
imapM :: (Monad m, Unbox a, Unbox b) => (Int -> a -> m b) -> Vector a -> m (Vector b)

-- | O(n) Apply the monadic action to all elements of a vector and
--   ignore the results.
mapM_ :: (Monad m, Unbox a) => (a -> m b) -> Vector a -> m ()

-- | O(n) Apply the monadic action to every element of a vector and
--   its index, ignoring the results.
imapM_ :: (Monad m, Unbox a) => (Int -> a -> m b) -> Vector a -> m ()

-- | O(n) Apply the monadic action to all elements of the vector,
--   yielding a vector of results. Equivalent to flip mapM.
forM :: (Monad m, Unbox a, Unbox b) => Vector a -> (a -> m b) -> m (Vector b)

-- | O(n) Apply the monadic action to all elements of a vector and
--   ignore the results. Equivalent to flip mapM_.
forM_ :: (Monad m, Unbox a) => Vector a -> (a -> m b) -> m ()

-- | O(min(m,n)) Zip two vectors with the given function.
zipWith :: (Unbox a, Unbox b, Unbox c) => (a -> b -> c) -> Vector a -> Vector b -> Vector c

-- | Zip three vectors with the given function.
zipWith3 :: (Unbox a, Unbox b, Unbox c, Unbox d) => (a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d
zipWith4 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => (a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
zipWith5 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => (a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f
zipWith6 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f, Unbox g) => (a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g

-- | O(min(m,n)) Zip two vectors with a function that also takes the
--   elements' indices.
izipWith :: (Unbox a, Unbox b, Unbox c) => (Int -> a -> b -> c) -> Vector a -> Vector b -> Vector c

-- | Zip three vectors and their indices with the given function.
izipWith3 :: (Unbox a, Unbox b, Unbox c, Unbox d) => (Int -> a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d
izipWith4 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => (Int -> a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
izipWith5 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => (Int -> a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f
izipWith6 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f, Unbox g) => (Int -> a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g

-- | O(1) Zip 2 vectors.
zip :: (Unbox a, Unbox b) => Vector a -> Vector b -> Vector (a, b)

-- | O(1) Zip 3 vectors.
zip3 :: (Unbox a, Unbox b, Unbox c) => Vector a -> Vector b -> Vector c -> Vector (a, b, c)

-- | O(1) Zip 4 vectors.
zip4 :: (Unbox a, Unbox b, Unbox c, Unbox d) => Vector a -> Vector b -> Vector c -> Vector d -> Vector (a, b, c, d)

-- | O(1) Zip 5 vectors.
zip5 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector (a, b, c, d, e)

-- | O(1) Zip 6 vectors.
zip6 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector (a, b, c, d, e, f)

-- | O(min(m,n)) Zip the two vectors with the monadic action and
--   yield a vector of results.
zipWithM :: (Monad m, Unbox a, Unbox b, Unbox c) => (a -> b -> m c) -> Vector a -> Vector b -> m (Vector c)

-- | O(min(m,n)) Zip the two vectors with a monadic action that also
--   takes the element index and yield a vector of results.
izipWithM :: (Monad m, Unbox a, Unbox b, Unbox c) => (Int -> a -> b -> m c) -> Vector a -> Vector b -> m (Vector c)

-- | O(min(m,n)) Zip the two vectors with the monadic action and
--   ignore the results.
zipWithM_ :: (Monad m, Unbox a, Unbox b) => (a -> b -> m c) -> Vector a -> Vector b -> m ()

-- | O(min(m,n)) Zip the two vectors with a monadic action that also
--   takes the element index and ignore the results.
izipWithM_ :: (Monad m, Unbox a, Unbox b) => (Int -> a -> b -> m c) -> Vector a -> Vector b -> m ()

-- | O(1) Unzip 2 vectors.
unzip :: (Unbox a, Unbox b) => Vector (a, b) -> (Vector a, Vector b)

-- | O(1) Unzip 3 vectors.
unzip3 :: (Unbox a, Unbox b, Unbox c) => Vector (a, b, c) -> (Vector a, Vector b, Vector c)

-- | O(1) Unzip 4 vectors.
unzip4 :: (Unbox a, Unbox b, Unbox c, Unbox d) => Vector (a, b, c, d) -> (Vector a, Vector b, Vector c, Vector d)

-- | O(1) Unzip 5 vectors.
unzip5 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => Vector (a, b, c, d, e) -> (Vector a, Vector b, Vector c, Vector d, Vector e)

-- | O(1) Unzip 6 vectors.
unzip6 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => Vector (a, b, c, d, e, f) -> (Vector a, Vector b, Vector c, Vector d, Vector e, Vector f)

-- | O(n) Drop all elements that do not satisfy the predicate.
filter :: Unbox a => (a -> Bool) -> Vector a -> Vector a

-- | O(n) Drop all elements that do not satisfy the predicate which
--   is applied to the values and their indices.
ifilter :: Unbox a => (Int -> a -> Bool) -> Vector a -> Vector a

-- | O(n) Drop repeated adjacent elements. The first element in each
--   group is returned.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.uniq $ VU.fromList [1,3,3,200,3 :: Int]
--   [1,3,200,3]
--   
--   >>> import Data.Semigroup
--   
--   >>> VU.uniq $ VU.fromList [ Arg 1 'a', Arg 1 'b', Arg (1 :: Int) 'c']
--   [Arg 1 'a']
--   
uniq :: (Unbox a, Eq a) => Vector a -> Vector a

-- | O(n) Map the values and collect the Just results.
mapMaybe :: (Unbox a, Unbox b) => (a -> Maybe b) -> Vector a -> Vector b

-- | O(n) Map the indices/values and collect the Just
--   results.
imapMaybe :: (Unbox a, Unbox b) => (Int -> a -> Maybe b) -> Vector a -> Vector b

-- | O(n) Drop all elements that do not satisfy the monadic
--   predicate.
filterM :: (Monad m, Unbox a) => (a -> m Bool) -> Vector a -> m (Vector a)

-- | O(n) Yield the longest prefix of elements satisfying the
--   predicate. The current implementation is not copy-free, unless the
--   result vector is fused away.
takeWhile :: Unbox a => (a -> Bool) -> Vector a -> Vector a

-- | O(n) Drop the longest prefix of elements that satisfy the
--   predicate without copying.
dropWhile :: Unbox a => (a -> Bool) -> Vector a -> Vector a

-- | O(n) Split the vector in two parts, the first one containing
--   those elements that satisfy the predicate and the second one those
--   that don't. The relative order of the elements is preserved at the
--   cost of a sometimes reduced performance compared to
--   unstablePartition.
partition :: Unbox a => (a -> Bool) -> Vector a -> (Vector a, Vector a)

-- | O(n) Split the vector in two parts, the first one containing
--   those elements that satisfy the predicate and the second one those
--   that don't. The order of the elements is not preserved, but the
--   operation is often faster than partition.
unstablePartition :: Unbox a => (a -> Bool) -> Vector a -> (Vector a, Vector a)

-- | O(n) Split the vector into the longest prefix of elements that
--   satisfy the predicate and the rest without copying.
span :: Unbox a => (a -> Bool) -> Vector a -> (Vector a, Vector a)

-- | O(n) Split the vector into the longest prefix of elements that
--   do not satisfy the predicate and the rest without copying.
break :: Unbox a => (a -> Bool) -> Vector a -> (Vector a, Vector a)

-- | O(n) Check if the vector contains an element.
elem :: (Unbox a, Eq a) => a -> Vector a -> Bool
infix 4 `elem`

-- | O(n) Check if the vector does not contain an element (inverse
--   of elem).
notElem :: (Unbox a, Eq a) => a -> Vector a -> Bool
infix 4 `notElem`

-- | O(n) Yield Just the first element matching the
--   predicate or Nothing if no such element exists.
find :: Unbox a => (a -> Bool) -> Vector a -> Maybe a

-- | O(n) Yield Just the index of the first element
--   matching the predicate or Nothing if no such element exists.
findIndex :: Unbox a => (a -> Bool) -> Vector a -> Maybe Int

-- | O(n) Yield the indices of elements satisfying the predicate in
--   ascending order.
findIndices :: Unbox a => (a -> Bool) -> Vector a -> Vector Int

-- | O(n) Yield Just the index of the first occurrence of
--   the given element or Nothing if the vector does not contain
--   the element. This is a specialised version of findIndex.
elemIndex :: (Unbox a, Eq a) => a -> Vector a -> Maybe Int

-- | O(n) Yield the indices of all occurrences of the given element
--   in ascending order. This is a specialised version of
--   findIndices.
elemIndices :: (Unbox a, Eq a) => a -> Vector a -> Vector Int

-- | O(n) Left fold.
foldl :: Unbox b => (a -> b -> a) -> a -> Vector b -> a

-- | O(n) Left fold with strict accumulator.
foldl' :: Unbox b => (a -> b -> a) -> a -> Vector b -> a

-- | O(n) Right fold.
foldr :: Unbox a => (a -> b -> b) -> b -> Vector a -> b

-- | O(n) Right fold with a strict accumulator.
foldr' :: Unbox a => (a -> b -> b) -> b -> Vector a -> b

-- | O(n) Left fold using a function applied to each element and its
--   index.
ifoldl :: Unbox b => (a -> Int -> b -> a) -> a -> Vector b -> a

-- | O(n) Left fold with strict accumulator using a function applied
--   to each element and its index.
ifoldl' :: Unbox b => (a -> Int -> b -> a) -> a -> Vector b -> a

-- | O(n) Right fold using a function applied to each element and
--   its index.
ifoldr :: Unbox a => (Int -> a -> b -> b) -> b -> Vector a -> b

-- | O(n) Right fold with strict accumulator using a function
--   applied to each element and its index.
ifoldr' :: Unbox a => (Int -> a -> b -> b) -> b -> Vector a -> b

-- | O(n) Check if all elements satisfy the predicate.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.all even $ VU.fromList [2, 4, 12 :: Int]
--   True
--   
--   >>> VU.all even $ VU.fromList [2, 4, 13 :: Int]
--   False
--   
--   >>> VU.all even (VU.empty :: VU.Vector Int)
--   True
--   
all :: Unbox a => (a -> Bool) -> Vector a -> Bool

-- | O(n) Check if any element satisfies the predicate.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.any even $ VU.fromList [1, 3, 7 :: Int]
--   False
--   
--   >>> VU.any even $ VU.fromList [3, 2, 13 :: Int]
--   True
--   
--   >>> VU.any even (VU.empty :: VU.Vector Int)
--   False
--   
any :: Unbox a => (a -> Bool) -> Vector a -> Bool

-- | O(n) Check if all elements are True.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.and $ VU.fromList [True, False]
--   False
--   
--   >>> VU.and VU.empty
--   True
--   
and :: Vector Bool -> Bool

-- | O(n) Check if any element is True.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.or $ VU.fromList [True, False]
--   True
--   
--   >>> VU.or VU.empty
--   False
--   
or :: Vector Bool -> Bool

-- | O(n) Compute the sum of the elements.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.sum $ VU.fromList [300,20,1 :: Int]
--   321
--   
--   >>> VU.sum (VU.empty :: VU.Vector Int)
--   0
--   
sum :: (Unbox a, Num a) => Vector a -> a

-- | O(n) Compute the product of the elements.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.product $ VU.fromList [1,2,3,4 :: Int]
--   24
--   
--   >>> VU.product (VU.empty :: VU.Vector Int)
--   1
--   
product :: (Unbox a, Num a) => Vector a -> a

-- | O(n) Monadic fold.
foldM :: (Monad m, Unbox b) => (a -> b -> m a) -> a -> Vector b -> m a

-- | O(n) Monadic fold using a function applied to each element and
--   its index.
ifoldM :: (Monad m, Unbox b) => (a -> Int -> b -> m a) -> a -> Vector b -> m a

-- | O(n) Monadic fold with strict accumulator.
foldM' :: (Monad m, Unbox b) => (a -> b -> m a) -> a -> Vector b -> m a

-- | O(n) Monadic fold with strict accumulator using a function
--   applied to each element and its index.
ifoldM' :: (Monad m, Unbox b) => (a -> Int -> b -> m a) -> a -> Vector b -> m a

-- | O(n) Monadic fold that discards the result.
foldM_ :: (Monad m, Unbox b) => (a -> b -> m a) -> a -> Vector b -> m ()

-- | O(n) Monadic fold that discards the result using a function
--   applied to each element and its index.
ifoldM_ :: (Monad m, Unbox b) => (a -> Int -> b -> m a) -> a -> Vector b -> m ()

-- | O(n) Monadic fold with strict accumulator that discards the
--   result.
foldM'_ :: (Monad m, Unbox b) => (a -> b -> m a) -> a -> Vector b -> m ()

-- | O(n) Monadic fold with strict accumulator that discards the
--   result using a function applied to each element and its index.
ifoldM'_ :: (Monad m, Unbox b) => (a -> Int -> b -> m a) -> a -> Vector b -> m ()

-- | O(n) Left-to-right prescan.
--   
--   
--   prescanl f z = init . scanl f z
--   
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector as VU
--   
--   >>> VU.prescanl (+) 0 (VU.fromList [1,2,3,4 :: Int])
--   [0,1,3,6]
--   
prescanl :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Left-to-right prescan with strict accumulator.
prescanl' :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Left-to-right postscan.
--   
--   
--   postscanl f z = tail . scanl f z
--   
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.postscanl (+) 0 (VU.fromList [1,2,3,4 :: Int])
--   [1,3,6,10]
--   
postscanl :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Left-to-right postscan with strict accumulator.
postscanl' :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Left-to-right scan.
--   
--   
--   scanl f z <x1,...,xn> = <y1,...,y(n+1)>
--     where y1 = z
--           yi = f y(i-1) x(i-1)
--   
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.scanl (+) 0 (VU.fromList [1,2,3,4 :: Int])
--   [0,1,3,6,10]
--   
scanl :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Left-to-right scan with strict accumulator.
scanl' :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Right-to-left prescan.
--   
--   
--   prescanr f z = reverse . prescanl (flip f) z . reverse
--   
prescanr :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left prescan with strict accumulator.
prescanr' :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left postscan.
postscanr :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left postscan with strict accumulator.
postscanr' :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left scan.
scanr :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left scan with strict accumulator.
scanr' :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Convert a vector to a list.
toList :: Unbox a => Vector a -> [a]

-- | O(n) Convert a list to a vector.
fromList :: Unbox a => [a] -> Vector a

-- | O(n) Convert the first n elements of a list to a
--   vector. It's expected that the supplied list will be exactly
--   n elements long. As an optimization, this function allocates
--   a buffer for n elements, which could be used for DoS-attacks
--   by exhausting the memory if an attacker controls that parameter.
--   
--   
--   fromListN n xs = fromList (take n xs)
--   
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.fromListN 3 [1,2,3,4,5 :: Int]
--   [1,2,3]
--   
--   >>> VU.fromListN 3 [1 :: Int]
--   [1]
--   
fromListN :: Unbox a => Int -> [a] -> Vector a

-- | O(n) Convert between different vector types.
convert :: (Vector v a, Vector w a) => v a -> w a

-- | O(n) Yield an immutable copy of the mutable vector.
freeze :: (Unbox a, PrimMonad m) => MVector (PrimState m) a -> m (Vector a)

-- | O(n) Yield a mutable copy of an immutable vector.
thaw :: (Unbox a, PrimMonad m) => Vector a -> m (MVector (PrimState m) a)

-- | O(n) Copy an immutable vector into a mutable one. The two
--   vectors must have the same length.
copy :: (Unbox a, PrimMonad m) => MVector (PrimState m) a -> Vector a -> m ()

-- | Unboxed Vector partial functions. Import as:
--   
--   
--   import qualified RIO.Vector.Unboxed.Partial as VU'
--   
module RIO.Vector.Unboxed.Partial

-- | O(1) Indexing.
(!) :: Unbox a => Vector a -> Int -> a

-- | O(1) First element.
head :: Unbox a => Vector a -> a

-- | O(1) Last element.
last :: Unbox a => Vector a -> a

-- | O(1) Indexing in a monad.
--   
--   The monad allows operations to be strict in the vector when necessary.
--   Suppose vector copying is implemented like this:
--   
--   
--   copy mv v = ... write mv i (v ! i) ...
--   
--   
--   For lazy vectors, v ! i would not be evaluated which means
--   that mv would unnecessarily retain a reference to v
--   in each element written.
--   
--   With indexM, copying can be implemented like this instead:
--   
--   
--   copy mv v = ... do
--                     x <- indexM v i
--                     write mv i x
--   
--   
--   Here, no references to v are retained because indexing (but
--   not the element) is evaluated eagerly.
indexM :: (Unbox a, Monad m) => Vector a -> Int -> m a

-- | O(1) First element of a vector in a monad. See indexM
--   for an explanation of why this is useful.
headM :: (Unbox a, Monad m) => Vector a -> m a

-- | O(1) Last element of a vector in a monad. See indexM for
--   an explanation of why this is useful.
lastM :: (Unbox a, Monad m) => Vector a -> m a

-- | O(1) Yield all but the last element without copying. The vector
--   may not be empty.
init :: Unbox a => Vector a -> Vector a

-- | O(1) Yield all but the first element without copying. The
--   vector may not be empty.
tail :: Unbox a => Vector a -> Vector a

-- | O(m+n) For each pair (i,a) from the list of
--   idnex/value pairs, replace the vector element at position i
--   by a.
--   
--   
--   <5,9,2,7> // [(2,1),(0,3),(2,8)] = <3,9,8,7>
--   
(//) :: Unbox a => Vector a -> [(Int, a)] -> Vector a

-- | O(m+n) For each pair (i,a) from the vector of
--   index/value pairs, replace the vector element at position i
--   by a.
--   
--   
--   update <5,9,2,7> <(2,1),(0,3),(2,8)> = <3,9,8,7>
--   
update :: Unbox a => Vector a -> Vector (Int, a) -> Vector a

-- | O(m+min(n1,n2)) For each index i from the index vector
--   and the corresponding value a from the value vector, replace
--   the element of the initial vector at position i by
--   a.
--   
--   
--   update_ <5,9,2,7>  <2,0,2> <1,3,8> = <3,9,8,7>
--   
--   
--   The function update provides the same functionality and is
--   usually more convenient.
--   
--   
--   update_ xs is ys = update xs (zip is ys)
--   
update_ :: Unbox a => Vector a -> Vector Int -> Vector a -> Vector a

-- | O(m+n) For each pair (i,b) from the list, replace the
--   vector element a at position i by f a b.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.accum (+) (VU.fromList [1000,2000,3000 :: Int]) [(2,4),(1,6),(0,3),(1,10)]
--   [1003,2016,3004]
--   
accum :: Unbox a => (a -> b -> a) -> Vector a -> [(Int, b)] -> Vector a

-- | O(m+n) For each pair (i,b) from the vector of pairs,
--   replace the vector element a at position i by f
--   a b.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.accumulate (+) (VU.fromList [1000,2000,3000 :: Int]) (VU.fromList [(2,4),(1,6),(0,3),(1,10)])
--   [1003,2016,3004]
--   
accumulate :: (Unbox a, Unbox b) => (a -> b -> a) -> Vector a -> Vector (Int, b) -> Vector a

-- | O(m+min(n1,n2)) For each index i from the index vector
--   and the corresponding value b from the the value vector,
--   replace the element of the initial vector at position i by
--   f a b.
--   
--   
--   accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>
--   
--   
--   The function accumulate provides the same functionality and is
--   usually more convenient.
--   
--   
--   accumulate_ f as is bs = accumulate f as (zip is bs)
--   
accumulate_ :: (Unbox a, Unbox b) => (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector a

-- | O(n) Yield the vector obtained by replacing each element
--   i of the index vector by xs!i. This is
--   equivalent to map (xs!) is, but is often much
--   more efficient.
--   
--   
--   backpermute <a,b,c,d> <0,3,2,3,1,0> = <a,d,c,d,b,a>
--   
backpermute :: Unbox a => Vector a -> Vector Int -> Vector a

-- | O(n) Left fold on non-empty vectors.
foldl1 :: Unbox a => (a -> a -> a) -> Vector a -> a

-- | O(n) Left fold on non-empty vectors with strict accumulator.
foldl1' :: Unbox a => (a -> a -> a) -> Vector a -> a

-- | O(n) Right fold on non-empty vectors.
foldr1 :: Unbox a => (a -> a -> a) -> Vector a -> a

-- | O(n) Right fold on non-empty vectors with strict accumulator.
foldr1' :: Unbox a => (a -> a -> a) -> Vector a -> a

-- | O(n) Yield the maximum element of the vector. The vector may
--   not be empty. In case of a tie, the first occurrence wins.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.maximum $ VU.fromList [2, 1 :: Int]
--   2
--   
--   >>> import Data.Semigroup
--   
--   >>> VU.maximum $ VU.fromList [Arg 1 'a', Arg (2 :: Int) 'b']
--   Arg 2 'b'
--   
--   >>> VU.maximum $ VU.fromList [Arg 1 'a', Arg (1 :: Int) 'b']
--   Arg 1 'a'
--   
maximum :: (Unbox a, Ord a) => Vector a -> a

-- | O(n) Yield the maximum element of the vector according to the
--   given comparison function. The vector may not be empty. In case of a
--   tie, the first occurrence wins. This behavior is different from
--   maximumBy which returns the last tie.
--   
--   
Examples
--   
--   
--   >>> import Data.Ord
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.maximumBy (comparing fst) $ VU.fromList [(2,'a'), (1 :: Int,'b')]
--   (2,'a')
--   
--   >>> VU.maximumBy (comparing fst) $ VU.fromList [(1,'a'), (1 :: Int,'b')]
--   (1,'a')
--   
maximumBy :: Unbox a => (a -> a -> Ordering) -> Vector a -> a

-- | O(n) Yield the minimum element of the vector. The vector may
--   not be empty. In case of a tie, the first occurrence wins.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.minimum $ VU.fromList [2, 1 :: Int]
--   1
--   
--   >>> import Data.Semigroup
--   
--   >>> VU.minimum $ VU.fromList [Arg 2 'a', Arg (1 :: Int) 'b']
--   Arg 1 'b'
--   
--   >>> VU.minimum $ VU.fromList [Arg 1 'a', Arg (1 :: Int) 'b']
--   Arg 1 'a'
--   
minimum :: (Unbox a, Ord a) => Vector a -> a

-- | O(n) Yield the minimum element of the vector according to the
--   given comparison function. The vector may not be empty.
--   
--   O(n) Yield the minimum element of the vector according to the
--   given comparison function. The vector may not be empty. In case of a
--   tie, the first occurrence wins.
--   
--   
Examples
--   
--   
--   >>> import Data.Ord
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.minimumBy (comparing fst) $ VU.fromList [(2,'a'), (1 :: Int,'b')]
--   (1,'b')
--   
--   >>> VU.minimumBy (comparing fst) $ VU.fromList [(1,'a'), (1 :: Int,'b')]
--   (1,'a')
--   
minimumBy :: Unbox a => (a -> a -> Ordering) -> Vector a -> a

-- | O(n) Yield the index of the minimum element of the vector. The
--   vector may not be empty.
minIndex :: (Unbox a, Ord a) => Vector a -> Int

-- | O(n) Yield the index of the minimum element of the vector
--   according to the given comparison function. The vector may not be
--   empty.
--   
--   
Examples
--   
--   
--   >>> import Data.Ord
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.minIndexBy (comparing fst) $ VU.fromList [(2,'a'), (1,'b')]
--   1
--   
--   >>> VU.minIndexBy (comparing fst) $ VU.fromList [(1,'a'), (1,'b')]
--   0
--   
minIndexBy :: Unbox a => (a -> a -> Ordering) -> Vector a -> Int

-- | O(n) Yield the index of the maximum element of the vector. The
--   vector may not be empty.
maxIndex :: (Unbox a, Ord a) => Vector a -> Int

-- | O(n) Yield the index of the maximum element of the vector
--   according to the given comparison function. The vector may not be
--   empty. In case of a tie, the first occurrence wins.
--   
--   
Examples
--   
--   
--   >>> import Data.Ord
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.maxIndexBy (comparing fst) $ VU.fromList [(2,'a'), (1,'b')]
--   0
--   
--   >>> VU.maxIndexBy (comparing fst) $ VU.fromList [(1,'a'), (1,'b')]
--   0
--   
maxIndexBy :: Unbox a => (a -> a -> Ordering) -> Vector a -> Int

-- | O(n) Monadic fold over non-empty vectors.
fold1M :: (Monad m, Unbox a) => (a -> a -> m a) -> Vector a -> m a

-- | O(n) Monadic fold over non-empty vectors with strict
--   accumulator.
fold1M' :: (Monad m, Unbox a) => (a -> a -> m a) -> Vector a -> m a

-- | O(n) Monadic fold over non-empty vectors that discards the
--   result.
fold1M_ :: (Monad m, Unbox a) => (a -> a -> m a) -> Vector a -> m ()

-- | O(n) Monadic fold over non-empty vectors with strict
--   accumulator that discards the result.
fold1M'_ :: (Monad m, Unbox a) => (a -> a -> m a) -> Vector a -> m ()

-- | O(n) Initial-value free left-to-right scan over a vector.
--   
--   
--   scanl f <x1,...,xn> = <y1,...,yn>
--     where y1 = x1
--           yi = f y(i-1) xi
--   
--   
--   Note: Since 0.13, application of this to an empty vector no longer
--   results in an error; instead it produces an empty vector.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.scanl1 min $ VU.fromListN 5 [4,2,4,1,3 :: Int]
--   [4,2,2,1,1]
--   
--   >>> VU.scanl1 max $ VU.fromListN 5 [1,3,2,5,4 :: Int]
--   [1,3,3,5,5]
--   
--   >>> VU.scanl1 min (VU.empty :: VU.Vector Int)
--   []
--   
scanl1 :: Unbox a => (a -> a -> a) -> Vector a -> Vector a

-- | O(n) Initial-value free left-to-right scan over a vector with a
--   strict accumulator.
--   
--   Note: Since 0.13, application of this to an empty vector no longer
--   results in an error; instead it produces an empty vector.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.scanl1' min $ VU.fromListN 5 [4,2,4,1,3 :: Int]
--   [4,2,2,1,1]
--   
--   >>> VU.scanl1' max $ VU.fromListN 5 [1,3,2,5,4 :: Int]
--   [1,3,3,5,5]
--   
--   >>> VU.scanl1' min (VU.empty :: VU.Vector Int)
--   []
--   
scanl1' :: Unbox a => (a -> a -> a) -> Vector a -> Vector a

-- | O(n) Right-to-left, initial-value free scan over a vector.
--   
--   Note: Since 0.13, application of this to an empty vector no longer
--   results in an error; instead it produces an empty vector.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.scanr1 min $ VU.fromListN 5 [3,1,4,2,4 :: Int]
--   [1,1,2,2,4]
--   
--   >>> VU.scanr1 max $ VU.fromListN 5 [4,5,2,3,1 :: Int]
--   [5,5,3,3,1]
--   
--   >>> VU.scanr1 min (VU.empty :: VU.Vector Int)
--   []
--   
scanr1 :: Unbox a => (a -> a -> a) -> Vector a -> Vector a

-- | O(n) Right-to-left, initial-value free scan over a vector with
--   a strict accumulator.
--   
--   Note: Since 0.13, application of this to an empty vector no longer
--   results in an error; instead it produces an empty vector.
--   
--   
Examples
--   
--   
--   >>> import qualified Data.Vector.Unboxed as VU
--   
--   >>> VU.scanr1' min $ VU.fromListN 5 [3,1,4,2,4 :: Int]
--   [1,1,2,2,4]
--   
--   >>> VU.scanr1' max $ VU.fromListN 5 [4,5,2,3,1 :: Int]
--   [5,5,3,3,1]
--   
--   >>> VU.scanr1' min (VU.empty :: VU.Vector Int)
--   []
--   
scanr1' :: Unbox a => (a -> a -> a) -> Vector a -> Vector a

-- | Unoxed Vector unsafe functions. These perform no bounds
--   checking, and may cause segmentation faults etc.! Import as:
--   
--   
--   import qualified RIO.Vector.Unoxed.Unsafe as VU'
--   
module RIO.Vector.Unboxed.Unsafe

-- | O(1) Unsafe indexing without bounds checking.
unsafeIndex :: Unbox a => Vector a -> Int -> a

-- | O(1) First element, without checking if the vector is empty.
unsafeHead :: Unbox a => Vector a -> a

-- | O(1) Last element, without checking if the vector is empty.
unsafeLast :: Unbox a => Vector a -> a

-- | O(1) Indexing in a monad, without bounds checks. See
--   indexM for an explanation of why this is useful.
unsafeIndexM :: (Unbox a, Monad m) => Vector a -> Int -> m a

-- | O(1) First element in a monad, without checking for empty
--   vectors. See indexM for an explanation of why this is useful.
unsafeHeadM :: (Unbox a, Monad m) => Vector a -> m a

-- | O(1) Last element in a monad, without checking for empty
--   vectors. See indexM for an explanation of why this is useful.
unsafeLastM :: (Unbox a, Monad m) => Vector a -> m a

-- | O(1) Yield a slice of the vector without copying. The vector
--   must contain at least i+n elements, but this is not checked.
unsafeSlice :: Unbox a => Int -> Int -> Vector a -> Vector a

-- | O(1) Yield all but the last element without copying. The vector
--   may not be empty, but this is not checked.
unsafeInit :: Unbox a => Vector a -> Vector a

-- | O(1) Yield all but the first element without copying. The
--   vector may not be empty, but this is not checked.
unsafeTail :: Unbox a => Vector a -> Vector a

-- | O(1) Yield the first n elements without copying. The
--   vector must contain at least n elements, but this is not
--   checked.
unsafeTake :: Unbox a => Int -> Vector a -> Vector a

-- | O(1) Yield all but the first n elements without
--   copying. The vector must contain at least n elements, but
--   this is not checked.
unsafeDrop :: Unbox a => Int -> Vector a -> Vector a

-- | Same as (//), but without bounds checking.
unsafeUpd :: Unbox a => Vector a -> [(Int, a)] -> Vector a

-- | Same as update, but without bounds checking.
unsafeUpdate :: Unbox a => Vector a -> Vector (Int, a) -> Vector a

-- | Same as update_, but without bounds checking.
unsafeUpdate_ :: Unbox a => Vector a -> Vector Int -> Vector a -> Vector a

-- | Same as accum, but without bounds checking.
unsafeAccum :: Unbox a => (a -> b -> a) -> Vector a -> [(Int, b)] -> Vector a

-- | Same as accumulate, but without bounds checking.
unsafeAccumulate :: (Unbox a, Unbox b) => (a -> b -> a) -> Vector a -> Vector (Int, b) -> Vector a

-- | Same as accumulate_, but without bounds checking.
unsafeAccumulate_ :: (Unbox a, Unbox b) => (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector a

-- | Same as backpermute, but without bounds checking.
unsafeBackpermute :: Unbox a => Vector a -> Vector Int -> Vector a

-- | O(1) Unsafely convert a mutable vector to an immutable one
--   without copying. The mutable vector may not be used after this
--   operation.
unsafeFreeze :: (Unbox a, PrimMonad m) => MVector (PrimState m) a -> m (Vector a)

-- | O(1) Unsafely convert an immutable vector to a mutable one
--   without copying. Note that this is a very dangerous function and
--   generally it's only safe to read from the resulting vector. In this
--   case, the immutable vector could be used safely as well.
--   
--   Problems with mutation happen because GHC has a lot of freedom to
--   introduce sharing. As a result mutable vectors produced by
--   unsafeThaw may or may not share the same underlying buffer.
--   For example:
--   
--   
--   foo = do
--     let vec = V.generate 10 id
--     mvec <- V.unsafeThaw vec
--     do_something mvec
--   
--   
--   Here GHC could lift vec outside of foo which means that all
--   calls to do_something will use same buffer with possibly
--   disastrous results. Whether such aliasing happens or not depends on
--   the program in question, optimization levels, and GHC flags.
--   
--   All in all, attempts to modify a vector produced by
--   unsafeThaw fall out of domain of software engineering and
--   into realm of black magic, dark rituals, and unspeakable horrors. The
--   only advice that could be given is: "Don't attempt to mutate a vector
--   produced by unsafeThaw unless you know how to prevent GHC
--   from aliasing buffers accidentally. We don't."
unsafeThaw :: (Unbox a, PrimMonad m) => Vector a -> m (MVector (PrimState m) a)

-- | O(n) Copy an immutable vector into a mutable one. The two
--   vectors must have the same length. This is not checked.
unsafeCopy :: (Unbox a, PrimMonad m) => MVector (PrimState m) a -> Vector a -> m ()

-- | Generic Vector interface unsafe functions. These perform no
--   bounds checking, and may cause segmentation faults etc.! Import as:
--   
--   
--   import qualified RIO.Vector.Unsafe as V'
--   
module RIO.Vector.Unsafe

-- | Class of immutable vectors. Every immutable vector is associated with
--   its mutable version through the Mutable type family. Methods of
--   this class should not be used directly. Instead,
--   Data.Vector.Generic and other Data.Vector modules
--   provide safe and fusible wrappers.
--   
--   Minimum complete implementation:
--   
--   
--   
- basicUnsafeFreeze
--   
- basicUnsafeThaw
--   
- basicLength
--   
- basicUnsafeSlice
--   
- basicUnsafeIndexM
--   
class MVector Mutable v a => Vector (v :: Type -> Type) a

-- | Assumed complexity: O(1)
--   
--   Unsafely convert a mutable vector to its immutable version without
--   copying. The mutable vector may not be used after this operation.
basicUnsafeFreeze :: Vector v a => Mutable v s a -> ST s (v a)

-- | Assumed complexity: O(1)
--   
--   Unsafely convert an immutable vector to its mutable version without
--   copying. The immutable vector may not be used after this operation.
basicUnsafeThaw :: Vector v a => v a -> ST s (Mutable v s a)

-- | Assumed complexity: O(1)
--   
--   Yield the length of the vector.
basicLength :: Vector v a => v a -> Int

-- | Assumed complexity: O(1)
--   
--   Yield a slice of the vector without copying it. No range checks are
--   performed.
basicUnsafeSlice :: Vector v a => Int -> Int -> v a -> v a

-- | Assumed complexity: O(1)
--   
--   Yield the element at the given position in a monad. No range checks
--   are performed.
--   
--   The monad allows us to be strict in the vector if we want. Suppose we
--   had
--   
--   
--   unsafeIndex :: v a -> Int -> a
--   
--   
--   instead. Now, if we wanted to copy a vector, we'd do something like
--   
--   
--   copy mv v ... = ... unsafeWrite mv i (unsafeIndex v i) ...
--   
--   
--   For lazy vectors, the indexing would not be evaluated, which means
--   that we would retain a reference to the original vector in each
--   element we write. This is not what we want!
--   
--   With basicUnsafeIndexM, we can do
--   
--   
--   copy mv v ... = ... case basicUnsafeIndexM v i of
--                         Box x -> unsafeWrite mv i x ...
--   
--   
--   which does not have this problem, because indexing (but not the
--   returned element!) is evaluated immediately.
basicUnsafeIndexM :: Vector v a => v a -> Int -> Box a

-- | Assumed complexity: O(n)
--   
--   Copy an immutable vector into a mutable one. The two vectors must have
--   the same length, but this is not checked.
--   
--   Instances of Vector should redefine this method if they wish to
--   support an efficient block copy operation.
--   
--   Default definition: copying based on basicUnsafeIndexM and
--   basicUnsafeWrite.
basicUnsafeCopy :: Vector v a => Mutable v s a -> v a -> ST s ()

-- | Evaluate a as far as storing it in a vector would and yield
--   b. The v a argument only fixes the type and is not
--   touched. This method is only used for optimisation purposes. Thus, it
--   is safe for instances of Vector to evaluate a less
--   than it would be when stored in a vector, although this might result
--   in suboptimal code.
--   
--   
--   elemseq v x y = (singleton x `asTypeOf` v) `seq` y
--   
--   
--   Default defintion: a is not evaluated at all.
elemseq :: Vector v a => v a -> a -> b -> b

-- | O(1) Unsafe indexing without bounds checking.
unsafeIndex :: Vector v a => v a -> Int -> a

-- | O(1) First element, without checking if the vector is empty.
unsafeHead :: Vector v a => v a -> a

-- | O(1) Last element, without checking if the vector is empty.
unsafeLast :: Vector v a => v a -> a

-- | O(1) Indexing in a monad, without bounds checks. See
--   indexM for an explanation of why this is useful.
unsafeIndexM :: (Vector v a, Monad m) => v a -> Int -> m a

-- | O(1) First element in a monad, without checking for empty
--   vectors. See indexM for an explanation of why this is useful.
unsafeHeadM :: (Vector v a, Monad m) => v a -> m a

-- | O(1) Last element in a monad, without checking for empty
--   vectors. See indexM for an explanation of why this is useful.
unsafeLastM :: (Vector v a, Monad m) => v a -> m a

-- | O(1) Yield a slice of the vector without copying. The vector
--   must contain at least i+n elements, but this is not checked.
unsafeSlice :: Vector v a => Int -> Int -> v a -> v a

-- | O(1) Yield all but the last element without copying. The vector
--   may not be empty, but this is not checked.
unsafeInit :: Vector v a => v a -> v a

-- | O(1) Yield all but the first element without copying. The
--   vector may not be empty, but this is not checked.
unsafeTail :: Vector v a => v a -> v a

-- | O(1) Yield the first n elements without copying. The
--   vector must contain at least n elements, but this is not
--   checked.
unsafeTake :: Vector v a => Int -> v a -> v a

-- | O(1) Yield all but the first n elements without
--   copying. The vector must contain at least n elements, but
--   this is not checked.
unsafeDrop :: Vector v a => Int -> v a -> v a

-- | Same as (//), but without bounds checking.
unsafeUpd :: Vector v a => v a -> [(Int, a)] -> v a

-- | Same as update, but without bounds checking.
unsafeUpdate :: (Vector v a, Vector v (Int, a)) => v a -> v (Int, a) -> v a

-- | Same as update_, but without bounds checking.
unsafeUpdate_ :: (Vector v a, Vector v Int) => v a -> v Int -> v a -> v a

-- | Same as accum, but without bounds checking.
unsafeAccum :: Vector v a => (a -> b -> a) -> v a -> [(Int, b)] -> v a

-- | Same as accumulate, but without bounds checking.
unsafeAccumulate :: (Vector v a, Vector v (Int, b)) => (a -> b -> a) -> v a -> v (Int, b) -> v a

-- | Same as accumulate_, but without bounds checking.
unsafeAccumulate_ :: (Vector v a, Vector v Int, Vector v b) => (a -> b -> a) -> v a -> v Int -> v b -> v a

-- | Same as backpermute, but without bounds checking.
unsafeBackpermute :: (Vector v a, Vector v Int) => v a -> v Int -> v a

-- | O(1) Unsafely convert a mutable vector to an immutable one
--   without copying. The mutable vector may not be used after this
--   operation.
unsafeFreeze :: (PrimMonad m, Vector v a) => Mutable v (PrimState m) a -> m (v a)

-- | O(1) Unsafely convert an immutable vector to a mutable one
--   without copying. Note that this is a very dangerous function and
--   generally it's only safe to read from the resulting vector. In this
--   case, the immutable vector could be used safely as well.
--   
--   Problems with mutation happen because GHC has a lot of freedom to
--   introduce sharing. As a result mutable vectors produced by
--   unsafeThaw may or may not share the same underlying buffer.
--   For example:
--   
--   
--   foo = do
--     let vec = V.generate 10 id
--     mvec <- V.unsafeThaw vec
--     do_something mvec
--   
--   
--   Here GHC could lift vec outside of foo which means that all
--   calls to do_something will use same buffer with possibly
--   disastrous results. Whether such aliasing happens or not depends on
--   the program in question, optimization levels, and GHC flags.
--   
--   All in all, attempts to modify a vector produced by
--   unsafeThaw fall out of domain of software engineering and
--   into realm of black magic, dark rituals, and unspeakable horrors. The
--   only advice that could be given is: "Don't attempt to mutate a vector
--   produced by unsafeThaw unless you know how to prevent GHC
--   from aliasing buffers accidentally. We don't."
unsafeThaw :: (PrimMonad m, Vector v a) => v a -> m (Mutable v (PrimState m) a)

-- | O(n) Copy an immutable vector into a mutable one. The two
--   vectors must have the same length. This is not checked.
unsafeCopy :: (PrimMonad m, Vector v a) => Mutable v (PrimState m) a -> v a -> m ()

-- | Provides reexports of MonadWriter and related helpers.
module RIO.Writer
class (Monoid w, Monad m) => MonadWriter w (m :: Type -> Type) | m -> w

-- | writer (a,w) embeds a simple writer action.
writer :: MonadWriter w m => (a, w) -> m a

-- | tell w is an action that produces the output
--   w.
tell :: MonadWriter w m => w -> m ()

-- | listen m is an action that executes the action
--   m and adds its output to the value of the computation.
listen :: MonadWriter w m => m a -> m (a, w)

-- | pass m is an action that executes the action
--   m, which returns a value and a function, and returns the
--   value, applying the function to the output.
pass :: MonadWriter w m => m (a, w -> w) -> m a

-- | listens f m is an action that executes the action
--   m and adds the result of applying f to the output to
--   the value of the computation.
--   
--   
--   
- 
listens f m = liftM (id *** f) (listen
--   m)

--   
listens :: MonadWriter w m => (w -> b) -> m a -> m (a, b)

-- | censor f m is an action that executes the action
--   m and applies the function f to its output, leaving
--   the return value unchanged.
--   
--   
--   
- 
censor f m = pass (liftM (\x ->
--   (x,f)) m)

--   
censor :: MonadWriter w m => (w -> w) -> m a -> m a

-- | A writer monad parameterized by the type w of output to
--   accumulate.
--   
--   The return function produces the output mempty, while
--   >>= combines the outputs of the subcomputations using
--   mappend.
type Writer w = WriterT w Identity

-- | Unwrap a writer computation as a (result, output) pair. (The inverse
--   of writer.)
runWriter :: Writer w a -> (a, w)

-- | Extract the output from a writer computation.
--   
--   
--   
- 
execWriter m = snd (runWriter
--   m)

--   
execWriter :: Writer w a -> w

-- | Map both the return value and output of a computation using the given
--   function.
--   
--   
--   
- 
runWriter (mapWriter f m) = f (runWriter
--   m)

--   
mapWriter :: ((a, w) -> (b, w')) -> Writer w a -> Writer w' b

-- | A writer monad parameterized by:
--   
--   
--   
- w - the output to accumulate.
--   
- m - The inner monad.
--   
--   
--   The return function produces the output mempty, while
--   >>= combines the outputs of the subcomputations using
--   mappend.
newtype () => WriterT w (m :: Type -> Type) a
WriterT :: m (a, w) -> WriterT w (m :: Type -> Type) a
[runWriterT] :: WriterT w (m :: Type -> Type) a -> m (a, w)

-- | Extract the output from a writer computation.
--   
--   
--   
- 
execWriterT m = liftM snd
--   (runWriterT m)

--   
execWriterT :: Monad m => WriterT w m a -> m w

-- | Map both the return value and output of a computation using the given
--   function.
--   
--   
--   
- 
runWriterT (mapWriterT f m) = f
--   (runWriterT m)

--   
mapWriterT :: (m (a, w) -> n (b, w')) -> WriterT w m a -> WriterT w' n b
