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

-- | This module exports all the partial functions from
--   Data.ByteString.Lazy
module RIO.ByteString.Lazy.Partial

-- | O(1) Extract the first element of a ByteString, which must be
--   non-empty.
head :: ByteString -> Word8

-- | O(n/c) Extract the last element of a ByteString, which must be
--   finite and non-empty.
last :: ByteString -> Word8

-- | O(1) Extract the elements after the head of a ByteString, which
--   must be non-empty.
tail :: ByteString -> ByteString

-- | O(n/c) Return all the elements of a ByteString except
--   the last one.
init :: ByteString -> ByteString

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

-- | 'foldl1\'' is like foldl1, but strict in the accumulator.
foldl1' :: (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 :: (Word8 -> Word8 -> Word8) -> ByteString -> Word8

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

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

-- | This module exports all the partial functions from ByteString
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.
head :: 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.
last :: 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.
tail :: ByteString -> ByteString

-- | O(1) Return all the elements of a ByteString except the
--   last one. An exception will be thrown in the case of an empty
--   ByteString.
init :: 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 :: (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' :: (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 :: (Word8 -> Word8 -> Word8) -> ByteString -> Word8

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

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

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

-- | Unicode Char. Import as:
--   
--   
--   import qualified RIO.Char as C
--   
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

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

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

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

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

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

-- | Normalise a file
--   
--   
--   
- // outside of the drive can be made blank
--   
- / -> pathSeparator
--   
- ./ -> ""
--   
--   
--   
--   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 "./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

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

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

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

-- | 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.
--   
--   
--            x == y ==> equalFilePath x y
--            normalise x == normalise y ==> equalFilePath x y
--            equalFilePath "foo" "foo/"
--            not (equalFilePath "foo" "/foo")
--   Posix:   not (equalFilePath "foo" "FOO")
--   Windows: equalFilePath "foo" "FOO"
--   Windows: not (equalFilePath "C:" "C:/")
--   
equalFilePath :: FilePath -> FilePath -> Bool

-- | Join path elements back together.
--   
--   
--   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

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

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

-- | An alias for </>.
combine :: FilePath -> 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

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

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

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

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

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

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

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

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

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

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

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

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

-- | Get the drive from a filepath.
--   
--   
--   takeDrive x == fst (splitDrive x)
--   
takeDrive :: 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

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

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

-- | Get all extensions.
--   
--   
--   takeExtensions "/directory/path.ext" == ".ext"
--   takeExtensions "file.tar.gz" == ".tar.gz"
--   
takeExtensions :: 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

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

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

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

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

-- | 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"
--   "/directory/path" <.> ".ext" == "/directory/path.ext"
--   
(<.>) :: 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

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

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

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

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

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

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

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

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

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

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

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

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

-- | Strict Map with hashed keys. Import as:
--   
--   
--   import qualified RIO.HashMap as HM
--   
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

-- | O(1) Construct an empty map.
empty :: () => HashMap k v

-- | O(1) Construct a map with a single element.
singleton :: Hashable k => k -> v -> HashMap k v

-- | O(1) Return True if this map is empty, False
--   otherwise.
null :: () => HashMap k v -> Bool

-- | O(n) Return the number of key-value mappings in this map.
size :: () => HashMap k v -> Int

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

-- | O(log n) 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

-- | O(log n) Return the value to which the specified key is mapped,
--   or the default value if this map contains no mapping for the key.
lookupDefault :: (Eq k, Hashable k) => v -> k -> HashMap k v -> v

-- | O(log n) 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

-- | O(log n) 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

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

-- | O(log n) 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

-- | O(log n) The expression (update 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.
update :: (Eq k, Hashable k) => (a -> Maybe a) -> k -> HashMap k a -> HashMap k a

-- | O(log n) 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

-- | O(n+m) The union of two maps. If a key occurs in both maps, the
--   mapping from the first will be the mapping in the result.
union :: (Eq k, Hashable k) => HashMap k v -> HashMap k v -> HashMap k v

-- | O(n+m) 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

-- | O(n+m) 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

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

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

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

-- | O(n*log m) 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

-- | O(n*log m) 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

-- | O(n*log m) 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

-- | O(n+m) 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

-- | O(n+m) 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

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

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

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

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

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

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

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

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

-- | O(n) Return a list of this map's keys. The list is produced
--   lazily.
keys :: () => HashMap k v -> [k]

-- | O(n) Return a list of this map's values. The list is produced
--   lazily.
elems :: () => HashMap k v -> [v]

-- | O(n) 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)]

-- | O(n*log n) 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

-- | O(n*log n) Construct a map from a list of elements. Uses the
--   provided function f to merge duplicate entries (f newVal oldVal).
--   
--   For example:
--   
--   
--   fromListWith (+) [ (x, 1) | x <- xs ]
--   
--   
--   will create a map with number of occurrences of each element in xs.
--   
--   
--   fromListWith (++) [ (k, [v]) | (k, v) <- xs ]
--   
--   
--   will group all values by their keys in a list 'xs :: [(k, v)]' and
--   return a 'HashMap k [v]'.
fromListWith :: (Eq k, Hashable k) => (v -> v -> v) -> [(k, v)] -> HashMap k v

module RIO.HashMap.Partial

-- | O(log n) 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) => 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

-- | O(1) Construct an empty set.
empty :: () => HashSet a

-- | O(1) Construct a set with a single element.
singleton :: Hashable a => a -> HashSet a

-- | O(n+m) Construct a set containing all elements from both sets.
--   
--   To obtain good performance, the smaller set must be presented as the
--   first argument.
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

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

-- | O(n) Return the number of elements in this set.
size :: () => HashSet a -> Int

-- | O(log n) Return True if the given value is present in
--   this set, False otherwise.
member :: (Eq a, Hashable a) => a -> HashSet a -> Bool

-- | O(log n) Add the specified value to this set.
insert :: (Eq a, Hashable a) => a -> HashSet a -> HashSet a

-- | O(log n) Remove the specified value from this set if present.
delete :: (Eq a, Hashable a) => a -> HashSet a -> HashSet a

-- | O(n) Transform this set by applying a function to every value.
--   The resulting set may be smaller than the source.
map :: (Hashable b, Eq b) => (a -> b) -> HashSet a -> HashSet b

-- | O(n) Difference of two sets. Return elements of the first set
--   not existing in the second.
difference :: (Eq a, Hashable a) => HashSet a -> HashSet a -> HashSet a

-- | O(n) Intersection of two sets. Return elements present in both
--   the first set and the second.
intersection :: (Eq a, Hashable a) => HashSet a -> HashSet a -> HashSet a

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

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

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

-- | O(n) Return a list of this set's elements. The list is produced
--   lazily.
toList :: () => HashSet a -> [a]

-- | O(n*min(W, n)) Construct a set from a list of elements.
fromList :: (Eq a, Hashable a) => [a] -> HashSet a

-- | O(1) Convert to the equivalent HashMap.
toMap :: () => HashSet a -> HashMap a ()

-- | O(1) Convert from the equivalent HashMap.
fromMap :: () => HashMap a () -> HashSet a

-- | List. Import as:
--   
--   
--   import qualified RIO.List as L
--   
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.
(++) :: () => [a] -> [a] -> [a]
infixr 5 ++

-- | 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 :: () => [a] -> Maybe (a, [a])

-- | Test whether the structure is empty. The default implementation is
--   optimized for structures that are similar to cons-lists, because there
--   is no general way to do better.
null :: Foldable t => t a -> Bool

-- | Returns the size/length of a finite structure as an Int. The
--   default implementation is optimized for structures that are similar to
--   cons-lists, because there is no general way to do better.
length :: Foldable t => t a -> Int

headMaybe :: [a] -> Maybe a

lastMaybe :: [a] -> Maybe a

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

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

-- | 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 :: () => (a -> b) -> [a] -> [b]

-- | reverse xs returns the elements of xs in
--   reverse order. xs must be finite.
reverse :: () => [a] -> [a]

-- | 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.
--   
--   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. This means that foldl'
--   will diverge if given an infinite list.
--   
--   Also note that if you want an efficient left-fold, you probably want
--   to use foldl' instead of foldl. The reason for this is
--   that 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
--   
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 list to a single, monolithic result (e.g. length).
--   
--   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.
--   
--   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,
--   foldr can produce a terminating expression from an infinite
--   list.
--   
--   For a general Foldable structure this should be semantically
--   identical to,
--   
--   
--   foldr f z = foldr f z . toList
--   
foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b

-- | The concatenation of all the elements of a container of lists.
concat :: Foldable t => t [a] -> [a]

-- | Map a function over all the elements of a container and concatenate
--   the resulting lists.
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.
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.
or :: Foldable t => t Bool -> Bool

-- | Determines whether any element of the structure satisfies the
--   predicate.
any :: Foldable t => (a -> Bool) -> t a -> Bool

-- | Determines whether all elements of the structure satisfy the
--   predicate.
all :: Foldable t => (a -> Bool) -> t a -> Bool

-- | The sum function computes the sum of the numbers of a
--   structure.
sum :: (Foldable t, Num a) => t a -> a

-- | The product function computes the product of the numbers of a
--   structure.
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

-- | 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 :: () => (b -> a -> b) -> b -> [a] -> [b]

-- | A strictly accumulating version of scanl
scanl' :: () => (b -> a -> b) -> b -> [a] -> [b]

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

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

-- | scanr1 is a variant of scanr that has no starting value
--   argument.
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.
mapAccumL :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c)

-- | 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.
mapAccumR :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c)

-- | 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.
iterate :: () => (a -> a) -> a -> [a]

-- | repeat x is an infinite list, with x the
--   value of every element.
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 :: () => 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 :: () => [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])

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

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

-- | 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?
elem :: (Foldable t, Eq a) => a -> t a -> Bool
infix 4 `elem`

-- | notElem is the negation of elem.
notElem :: (Foldable t, Eq a) => a -> t a -> Bool
infix 4 `notElem`

-- | lookup key assocs looks up a key in an association
--   list.
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.
find :: Foldable t => (a -> Bool) -> t a -> Maybe a

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

-- | The partition function takes a predicate 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]

-- | 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 short, excess elements of the longer list are
--   discarded:
--   
--   
--   zip [1] ['a', 'b'] = [(1, 'a')]
--   zip [1, 2] ['a'] = [(1, 'a')]
--   
--   
--   zip is right-lazy:
--   
--   
--   zip [] _|_ = []
--   zip _|_ [] = _|_
--   
zip :: () => [a] -> [b] -> [(a, b)]

-- | zip3 takes three lists and returns a list of triples, analogous
--   to zip.
zip3 :: () => [a] -> [b] -> [c] -> [(a, b, c)]

-- | The zip4 function takes four lists and returns a list of
--   quadruples, analogous to zip.
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.
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.
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.
zip7 :: () => [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [(a, b, c, d, e, f, g)]

-- | 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 lists to
--   produce the list of corresponding sums.
--   
--   zipWith is right-lazy:
--   
--   
--   zipWith f [] _|_ = []
--   
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 their
--   point-wise combination, analogous to zipWith.
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.
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.
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.
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.
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 :: () => [(a, b)] -> ([a], [b])

-- | The unzip3 function takes a list of triples and returns three
--   lists, analogous to unzip.
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])

-- | lines breaks a string up into a list of strings at newline
--   characters. The resulting strings do not contain newlines.
--   
--   Note that after splitting the string at newline characters, the last
--   part of the string is considered a line even if it doesn't end with a
--   newline. For example,
--   
--   
--   >>> lines ""
--   []
--   
--   
--   
--   >>> lines "\n"
--   [""]
--   
--   
--   
--   >>> lines "one"
--   ["one"]
--   
--   
--   
--   >>> lines "one\n"
--   ["one"]
--   
--   
--   
--   >>> lines "one\n\n"
--   ["one",""]
--   
--   
--   
--   >>> lines "one\ntwo"
--   ["one","two"]
--   
--   
--   
--   >>> lines "one\ntwo\n"
--   ["one","two"]
--   
--   
--   Thus lines s contains at least as many elements as
--   newlines in s.
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]

-- | unlines is an inverse operation to lines. It joins
--   lines, after appending a terminating newline to each.
--   
--   
--   >>> unlines ["Hello", "World", "!"]
--   "Hello\nWorld\n!\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

-- | O(n^2). 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]

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

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

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

-- | The non-overloaded version of insert.
insertBy :: () => (a -> a -> Ordering) -> a -> [a] -> [a]

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

module RIO.List.Partial

-- | Extract the first element of a list, which must be non-empty.
head :: () => [a] -> a

-- | Extract the last element of a list, which must be finite and
--   non-empty.
last :: () => [a] -> a

-- | Extract the elements after the head of a list, which must be
--   non-empty.
tail :: () => [a] -> [a]

-- | Return all the elements of a list except the last one. The list must
--   be non-empty.
init :: () => [a] -> [a]

-- | A variant of foldl that has no base case, and thus may only be
--   applied to non-empty structures.
--   
--   
--   foldl1 f = foldl1 f . toList
--   
foldl1 :: Foldable t => (a -> a -> a) -> t a -> a

-- | A strict version of foldl1
foldl1' :: () => (a -> a -> a) -> [a] -> a

-- | A variant of foldr that has no base case, and thus may only be
--   applied to non-empty structures.
--   
--   
--   foldr1 f = foldr1 f . toList
--   
foldr1 :: Foldable t => (a -> a -> a) -> t a -> a

-- | The largest element of a non-empty structure.
maximum :: (Foldable t, Ord a) => t a -> a

-- | The least element of a non-empty structure.
minimum :: (Foldable t, Ord a) => t a -> a

-- | The largest element of a non-empty structure with respect to the given
--   comparison function.
maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a

-- | The least element of a non-empty structure with respect to the given
--   comparison function.
minimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a

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

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

-- | Strict Map. Import as:
--   
--   
--   import qualified RIO.Map as Map
--   
module RIO.Map

-- | A Map from keys k to values a.
data Map k a

-- | O(log n). 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 \\

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

-- | O(1). 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

-- | O(log n). 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

-- | O(log n). 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

-- | O(log n). 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

-- | O(log n). 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

-- | O(log n). 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)

-- | O(log n). 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)

-- | O(log n). 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)

-- | O(log n). 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)

-- | O(1). The empty map.
--   
--   
--   empty      == fromList []
--   size empty == 0
--   
empty :: () => Map k a

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

-- | O(log n). 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

-- | O(log n). 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

-- | O(log n). 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

-- | O(log n). 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)

-- | O(log n). 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

-- | O(log n). 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

-- | O(log n). 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

-- | O(log n). 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

-- | O(log n). 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

-- | O(log n). 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)

-- | O(log n). 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")]
--   
alter :: Ord k => (Maybe a -> Maybe a) -> k -> Map k a -> Map k a

-- | O(log n). 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 At.
alterF :: (Functor f, Ord k) => (Maybe a -> f (Maybe a)) -> k -> Map k a -> f (Map k a)

-- | O(m*log(n/m + 1)), m <= n. 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

-- | O(m*log(n/m + 1)), m <= n. 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

-- | O(m*log(n/m + 1)), m <= n. 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

-- | O(m*log(n/m + 1)), m <= n. 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

-- | O(n+m). 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

-- | O(n+m). 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

-- | O(m*log(n/m + 1)), m <= n. 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

-- | O(m*log(n/m + 1)), m <= n. 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

-- | O(m*log(n/m + 1)), m <= n. 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

-- | O(n+m). 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

-- | O(n). 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

-- | O(n). 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

-- | O(n). 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)

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

-- | O(n). 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)

-- | O(n). 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)

-- | O(n). The function mapAccumR 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)

-- | O(n*log n). 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

-- | O(n*log n). 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

-- | O(n). 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

-- | O(n). 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

-- | O(n). 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

-- | O(n). 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

-- | O(n). 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

-- | O(n). 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

-- | O(n). 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

-- | O(n). 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

-- | O(n). 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

-- | O(n). 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]

-- | O(n). 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]

-- | O(n). 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)]

-- | O(n). 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

-- | O(n). 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

-- | O(n). 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)]

-- | O(n*log n). 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

-- | O(n*log n). 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

-- | O(n*log n). Build a map from a list of key/value pairs with a
--   combining function. See also fromAscListWithKey.
--   
--   
--   let f k a1 a2 = (show k) ++ a1 ++ a2
--   fromListWithKey f [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "3ab"), (5, "5a5ba")]
--   fromListWithKey f [] == empty
--   
fromListWithKey :: Ord k => (k -> a -> a -> a) -> [(k, a)] -> Map k a

-- | O(n). 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

-- | O(n). 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

-- | O(m*log(n/m + 1)), m <= n. Restrict a Map to only
--   those keys found in a Set.
--   
--   
--   m `restrictKeys` s = filterWithKey (k _ -> k `<a>member</a>` s) m
--   m `restrictKeys` s = m `<tt>intersect</tt>` fromSet (const ()) s
--   
restrictKeys :: Ord k => Map k a -> Set k -> Map k a

-- | O(m*log(n/m + 1)), m <= n. Remove all keys in a Set
--   from a Map.
--   
--   
--   m `withoutKeys` s = filterWithKey (k _ -> k `<a>notMember</a>` s) m
--   m `withoutKeys` s = m `<a>difference</a>` fromSet (const ()) s
--   
withoutKeys :: Ord k => Map k a -> Set k -> Map k a

-- | O(n). 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)

-- | O(n). 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)

-- | O(log n). 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

-- | O(log n). 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

-- | O(log n). 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 = partition p 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)

-- | O(n). 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

-- | O(n). 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

-- | O(n). 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)

-- | O(n). 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)

-- | O(log n). 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)

-- | O(log n). 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)

-- | O(1). 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]

-- | O(m*log(n/m + 1)), m <= n. This function is defined as
--   (isSubmapOf = isSubmapOfBy (==)).
isSubmapOf :: (Ord k, Eq a) => Map k a -> Map k a -> Bool

-- | O(m*log(n/m + 1)), m <= n. 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)])
--   
isSubmapOfBy :: Ord k => (a -> b -> Bool) -> Map k a -> Map k b -> Bool

-- | O(m*log(n/m + 1)), m <= n. 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

-- | O(m*log(n/m + 1)), m <= n. Is this a proper submap? (ie. a
--   submap but not equal). The expression (isProperSubmapOfBy f
--   m1 m2) returns True when m1 and 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

-- | O(log n). 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

-- | O(log n). 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)

-- | O(log n). 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

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

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

-- | O(log n). 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)

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

-- | O(log n). 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)

-- | O(log n). 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

-- | O(log n). 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

-- | O(log n). 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

-- | O(log n). 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

-- | O(log n). 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

-- | O(log n). 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

-- | O(log n). 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)

-- | O(log n). 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)

-- | O(log n). 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)

-- | O(log n). 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

-- | O(n). 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

module RIO.Map.Partial

-- | O(log n). 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 !

-- | O(log n). 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)

-- | O(log n). 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

-- | O(log n). 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

-- | O(log n). 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

-- | O(log n). 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)
findMax :: () => Map k a -> (k, a)

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

-- | O(log n). 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.
module RIO.Map.Unchecked

-- | O(n). 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

-- | O(n). 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)]

-- | O(n). 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

-- | O(n). 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

-- | O(n). 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

-- | O(n). 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

-- | O(n). 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)]

-- | O(n). 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

-- | O(n). 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

-- | O(n). 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

-- | O(n). 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

-- | Partial functions.
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
--   
fromJust :: () => 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

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

-- | Load up an EnvOverride from the standard environment.
mkDefaultProcessContext :: MonadIO m => m ProcessContext

-- | Modify the environment variables of a ProcessContext.
--   
--   This will keep other settings unchanged, in particular 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 modifyEnvVarMap 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

-- | 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.
withProcess :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a

-- | Same as withProcess_, but generalized to MonadUnliftIO.
withProcess_ :: 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 executable.
findExecutable :: (MonadIO m, MonadReader env m, HasProcessContext env) => String -> m (Either ProcessException FilePath)

-- | Augment the PATH environment variable with the given extra paths.
augmentPath :: [FilePath] -> Maybe Text -> Either ProcessException Text

-- | Apply augmentPath on the PATH value in the given
--   EnvVars.
augmentPathMap :: [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.
data ProcessConfig stdin stdout stderr

-- | A specification for how to create one of the three standard child
--   streams. See examples below.
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.
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. This will be determined by the
--   StdStream argument.
--   
- Returns the actual stream value a, as well as a
--   cleanup
--   
- function to be run when calling stopProcess.
--   
mkStreamSpec :: () => StdStream -> (ProcessConfig () () () -> Maybe Handle -> IO (a, IO ())) -> StreamSpec streamType a

-- | A stream spec which simply inherits the stream of the parent process.
inherit :: () => 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 :: () => 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 :: () => 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 :: () => 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 :: () => Handle -> StreamSpec anyStreamType ()

-- | Launch a process based on the given ProcessConfig. You should
--   ensure that you close stopProcess on the result. It's usually
--   better to use one of the functions in this module which ensures
--   stopProcess is called, such as withProcess.
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 eiter
--   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 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

-- | 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 :: forall a. () => () => Seq a

-- | A bidirectional pattern synonym viewing the rear of a non-empty
--   sequence.
pattern (:|>) :: forall a. () => () => Seq a -> a -> Seq a

-- | A bidirectional pattern synonym viewing the front of a non-empty
--   sequence.
pattern (:<|) :: forall a. () => () => 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)

-- | O(log k). 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
--   
module RIO.Set

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

-- | O(m*log(n/m+1)), m <= n. See difference.
(\\) :: Ord a => Set a -> Set a -> Set a
infixl 9 \\

-- | O(1). Is this the empty set?
null :: () => Set a -> Bool

-- | O(1). The number of elements in the set.
size :: () => Set a -> Int

-- | O(log n). Is the element in the set?
member :: Ord a => a -> Set a -> Bool

-- | O(log n). Is the element not in the set?
notMember :: Ord a => a -> Set a -> Bool

-- | O(log n). 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

-- | O(log n). 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

-- | O(log n). 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

-- | O(log n). 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

-- | O(n+m). Is this a subset? (s1 `isSubsetOf` s2) tells
--   whether s1 is a subset of s2.
isSubsetOf :: Ord a => Set a -> Set a -> Bool

-- | O(n+m). Is this a proper subset? (ie. a subset but not equal).
isProperSubsetOf :: Ord a => Set a -> Set a -> Bool

-- | O(1). The empty set.
empty :: () => Set a

-- | O(1). Create a singleton set.
singleton :: () => a -> Set a

-- | O(log n). 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

-- | O(log n). Delete an element from a set.
delete :: Ord a => a -> Set a -> Set a

-- | O(m*log(n/m + 1)), m <= n. 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 a list of sets: (unions == foldl
--   union empty).
unions :: (Foldable f, Ord a) => f (Set a) -> Set a

-- | O(m*log(n/m + 1)), m <= n. Difference of two sets.
difference :: Ord a => Set a -> Set a -> Set a

-- | O(m*log(n/m + 1)), m <= n. 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

-- | O(n). Filter all elements that satisfy the predicate.
filter :: () => (a -> Bool) -> Set a -> Set a

-- | O(log n). 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

-- | O(log n). 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

-- | O(log n). 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)

-- | O(n). 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)

-- | O(log n). 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)

-- | O(log n). 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)

-- | O(1). 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]

-- | O(log n). 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

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

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

-- | O(log n). Split a set at a particular index.
--   
--   
--   splitAt !n !xs = (take n xs, drop n xs)
--   
splitAt :: () => Int -> Set a -> (Set a, Set a)

-- | O(n*log n). 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

-- | O(n). 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

-- | O(n). 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

-- | O(n). 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

-- | O(n). 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

-- | O(log n). The minimal element of a set.
lookupMin :: () => Set a -> Maybe a

-- | O(log n). The maximal element of a set.
lookupMax :: () => Set a -> Maybe a

-- | O(log n). Delete the minimal element. Returns an empty set if
--   the set is empty.
deleteMin :: () => Set a -> Set a

-- | O(log n). Delete the maximal element. Returns an empty set if
--   the set is empty.
deleteMax :: () => Set a -> Set a

-- | O(log n). 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)

-- | O(log n). 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)

-- | O(n). An alias of toAscList. The elements of a set in
--   ascending order. Subject to list fusion.
elems :: () => Set a -> [a]

-- | O(n). Convert the set to a list of elements. Subject to list
--   fusion.
toList :: () => Set a -> [a]

-- | O(n*log n). 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

-- | O(n). Convert the set to an ascending list of elements. Subject
--   to list fusion.
toAscList :: () => Set a -> [a]

-- | O(n). Convert the set to a descending list of elements. Subject
--   to list fusion.
toDescList :: () => Set a -> [a]

-- | O(n). Show the tree that implements the set. The tree is shown
--   in a compressed, hanging format.
showTree :: Show a => Set a -> String

-- | O(n). 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

-- | O(n). Test if the internal set structure is valid.
valid :: Ord a => Set a -> Bool

module RIO.Set.Partial

-- | O(log n). 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

-- | O(log n). 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

-- | O(log n). 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

-- | O(log n). The minimal element of a set.
findMin :: () => Set a -> a

-- | O(log n). The maximal element of a set.
findMax :: () => Set a -> a

-- | O(log n). Delete and find the minimal element.
--   
--   
--   deleteFindMin set = (findMin set, deleteMin set)
--   
deleteFindMin :: () => Set a -> (a, Set a)

-- | O(log n). 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.
module RIO.Set.Unchecked

-- | O(n). 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

-- | O(n). 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

-- | O(n). 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

-- | O(n). 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

-- | O(n). 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 ()

-- | Strict Text. Import as:
--   
--   
--   import qualified RIO.Text as Text
--   
--   
--   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. Subject to
--   fusion. Performs replacement on invalid scalar values.
pack :: String -> Text

-- | O(n) Convert a Text into a String. Subject to
--   fusion.
unpack :: Text -> String

-- | O(1) Convert a character into a Text. Subject to fusion.
--   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. Subject to fusion. 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, unless fused. Subject to fusion.
--   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. Subject to fusion.
append :: Text -> Text -> Text

-- | O(1) Returns the first character and rest of a Text, or
--   Nothing if empty. Subject to fusion.
uncons :: Text -> Maybe (Char, Text)

-- | O(1) Tests whether a Text is empty or not. Subject to
--   fusion.
null :: Text -> Bool

-- | O(n) Returns the number of characters in a Text. Subject
--   to fusion.
length :: Text -> Int

-- | O(n) Compare the count of characters in a Text to a
--   number. Subject to fusion.
--   
--   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!"
--   
--   
--   Subject to fusion. 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"
--   
--   
--   Subject to fusion. 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"
--   
--   
--   Subject to fusion.
reverse :: Text -> Text

-- | O(n) Convert a string to folded case. Subject to fusion.
--   
--   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. Subject to fusion.
--   
--   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. Subject to fusion.
--   
--   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. Subject to fusion.
--   
--   The first letter 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).
--   
--   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. Subject to fusion. 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. Subject to fusion.
foldl :: () => (a -> Char -> a) -> a -> Text -> a

-- | O(n) A strict version of foldl. Subject to fusion.
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. Subject to fusion.
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. Subject to fusion.
any :: (Char -> Bool) -> Text -> Bool

-- | O(n) all p t determines whether all
--   characters in the Text t satisfy the predicate
--   p. Subject to fusion.
all :: (Char -> Bool) -> Text -> Bool

-- | O(n) scanl is similar to foldl, but returns a
--   list of successive reduced values from the left. Subject to fusion.
--   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. Subject to fusion. 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. Subject to fusion. 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. Subject to fusion. 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. Subject to fusion. 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. Subject
--   to fusion.
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. Subject to fusion.
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. Subject to fusion.
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. Subject to fusion. Examples:
--   
--   
--   >>> takeWhileEnd (=='o') "foo"
--   "oo"
--   
takeWhileEnd :: (Char -> Bool) -> Text -> Text

-- | O(n) dropWhile p t returns the suffix
--   remaining after takeWhile p t. Subject to
--   fusion.
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. Subject to fusion.
--   
--   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.
--   Subject to fusion.
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.
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 list.
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 Chars. The resulting strings do not contain newlines.
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 iff the first is a prefix of the second. Subject
--   to fusion.
isPrefixOf :: Text -> Text -> Bool

-- | O(n) The isSuffixOf function takes two Texts and
--   returns True iff the first is a suffix of the second.
isSuffixOf :: Text -> Text -> Bool

-- | O(n+m) The isInfixOf function takes two Texts and
--   returns True iff 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 :: 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. Subject to fusion.
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 literal string into a Text. Subject to
--   fusion.
--   
--   This is exposed solely for people writing GHC rewrite rules.
unpackCString# :: Addr# -> Text

-- | Encode text using UTF-8 encoding.
encodeUtf8 :: Text -> ByteString

-- | Decode a ByteString containing UTF-8 encoded text.
--   
--   NOTE: The replacement character returned by
--   OnDecodeError MUST be within the BMP plane; surrogate code
--   points will automatically be remapped to the replacement char
--   U+FFFD (since 0.11.3.0), whereas code points beyond
--   the BMP will throw an error (since 1.2.3.1); For earlier
--   versions of text using those unsupported code points would
--   result in undefined behavior.
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

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

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

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

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

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

-- | Strip out duplicates
nubOrd :: Ord a => [a] -> [a]

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

-- | Helper function to force an action to run in IO. Especially
--   useful for overly general contexts, like hspec tests.
asIO :: IO a -> IO 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

-- | 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 ()
view :: MonadReader s m => Getting a s a -> m 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 ^.

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

-- | 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.
--   
--   @since 0.1.3.0
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.
--   
--   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 enabled
--   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

-- | 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>:2:1 in interactive:Ghci1
--   
--   
--   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

-- | 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
runRIO :: MonadIO m => env -> RIO env a -> m a
liftRIO :: (MonadIO m, MonadReader env m) => RIO env a -> m a

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

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

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

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

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

--   
- 
(<*>) = ap

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

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

-- | 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.
(<*>) :: Applicative f => f (a -> b) -> f a -> f b

-- | Lift a binary function to actions.
--   
--   Some functors support an implementation of liftA2 that is more
--   efficient than the default one. In particular, if fmap is an
--   expensive operation, it is likely better to use liftA2 than to
--   fmap over the structure and then use <*>.
liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c

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

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

-- | Lift a function to actions. This function may be used as a value for
--   fmap in a Functor instance.
liftA :: Applicative f => (a -> b) -> f a -> f b

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

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

-- | One or none.
optional :: Alternative f => f a -> f (Maybe a)

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

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

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

-- | A mirror image of first.
--   
--   The default definition may be overridden with a more efficient version
--   if desired.
second :: Arrow a => a b c -> a (d, b) (d, c)

-- | 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
(>>>) :: Category cat => cat a b -> cat b c -> cat a c
infixr 1 >>>

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

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

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

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

-- | 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 laws:
--   
--   
--   
- 
return a >>= k = k a

--   
- 
m >>= return = m

--   
- 
m >>= (\x -> k x >>= h) = (m
--   >>= k) >>= h

--   
--   
--   Furthermore, the Monad and Applicative operations should
--   relate as follows:
--   
--   
--   
- 
pure = return

--   
- 
(<*>) = ap

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

-- | Sequentially compose two actions, passing any value produced by the
--   first as an argument to the second.
(>>=) :: Monad m => m a -> (a -> m b) -> m b

-- | Sequentially compose two actions, discarding any value produced by the
--   first, like sequencing operators (such as the semicolon) in imperative
--   languages.
(>>) :: Monad m => m a -> m b -> m b

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

-- | Fail with a message. This operation is not part of the mathematical
--   definition of a monad, but is invoked on pattern-match failure in a
--   do expression.
--   
--   As part of the MonadFail proposal (MFP), this function is moved to its
--   own class MonadFail (see Control.Monad.Fail for more
--   details). The definition here will be removed in a future release.
fail :: Monad m => String -> m a
infixl 1 >>=
infixl 1 >>

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

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

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

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

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

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

-- | 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
--   
forever :: Applicative f => f a -> f b

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

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

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

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

-- | The reverse of when.
unless :: Applicative f => Bool -> f () -> 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 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 ()

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

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

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

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

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

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

-- | Lift a computation from the argument monad to the constructed monad.
lift :: (MonadTrans t, Monad m) => m a -> t m a

-- | 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 a
[runReaderT] :: ReaderT r a -> r -> 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
data Bool
False :: Bool
True :: 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

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

-- | Boolean "and"
(&&) :: Bool -> Bool -> Bool
infixr 3 &&

-- | Boolean "or"
(||) :: Bool -> Bool -> Bool
infixr 2 ||

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

-- | 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 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.
--   
--   It is suitable for use as an internal representation for code that
--   needs to keep many short strings in memory, but it should not
--   be used as an interchange type. That is, it should not generally be
--   used in public APIs. The ByteString type is usually more
--   suitable for use in interfaces; it is more flexible and it supports a
--   wide range of operations.
data ShortByteString

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

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

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

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

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

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

-- | 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, ==
--   is customarily expected to implement an equivalence relationship where
--   two values comparing equal are indistinguishable by "public"
--   functions, with a "public" function being one not allowing to see
--   implementation details. For example, for a type representing
--   non-normalised natural numbers modulo 100, a "public" function doesn't
--   make the difference between 1 and 201. It is expected to have the
--   following properties:
--   
--   
--   
- Reflexivity x == x = True
--   
- Symmetry x == y = y == x
--   
- Transitivity if x == y && y == z =
--   True, then x == z = True
--   
- Substitutivity if x == y = True and
--   f is a "public" 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
(==) :: Eq a => a -> a -> Bool
(/=) :: Eq a => a -> a -> Bool
infix 4 ==
infix 4 /=

-- | Data structures that can be folded.
--   
--   For example, given a data type
--   
--   
--   data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
--   
--   
--   a suitable instance would be
--   
--   
--   instance Foldable Tree where
--      foldMap f Empty = mempty
--      foldMap f (Leaf x) = f x
--      foldMap f (Node l k r) = foldMap f l `mappend` f k `mappend` foldMap f r
--   
--   
--   This is suitable even for abstract types, as the monoid is assumed to
--   satisfy the monoid laws. Alternatively, one could define
--   foldr:
--   
--   
--   instance Foldable Tree where
--      foldr f z Empty = z
--      foldr f z (Leaf x) = f x z
--      foldr f z (Node l k r) = foldr f (f k (foldr f z r)) l
--   
--   
--   Foldable instances are expected to satisfy the following
--   laws:
--   
--   
--   foldr f z t = appEndo (foldMap (Endo . f) t ) z
--   
--   
--   
--   foldl f z t = appEndo (getDual (foldMap (Dual . Endo . flip f) t)) z
--   
--   
--   
--   fold = foldMap id
--   
--   
--   
--   length = getSum . foldMap (Sum . const  1)
--   
--   
--   sum, product, maximum, and minimum
--   should all be essentially equivalent to foldMap forms, such
--   as
--   
--   
--   sum = getSum . foldMap Sum
--   
--   
--   but may be less defined.
--   
--   If the type is also a Functor instance, it should satisfy
--   
--   
--   foldMap f = fold . fmap f
--   
--   
--   which implies that
--   
--   
--   foldMap f . fmap g = foldMap (f . g)
--   
class Foldable (t :: Type -> Type)

-- | Determines whether all elements of the structure satisfy the
--   predicate.
all :: Foldable t => (a -> Bool) -> t a -> Bool

-- | and returns the conjunction of a container of Bools. For the
--   result to be True, the container must be finite; False,
--   however, results from a False value finitely far from the left
--   end.
and :: Foldable t => t Bool -> Bool

-- | Determines whether any element of the structure satisfies the
--   predicate.
any :: Foldable t => (a -> Bool) -> t a -> Bool

-- | The sum of a collection of actions, generalizing concat.
--   
--   asum [Just Hello, Nothing, Just World] Just Hello
asum :: (Foldable t, Alternative f) => t (f a) -> f a

-- | The concatenation of all the elements of a container of lists.
concat :: Foldable t => t [a] -> [a]

-- | Map a function over all the elements of a container and concatenate
--   the resulting lists.
concatMap :: Foldable t => (a -> [b]) -> t a -> [b]

-- | Does the element occur in the structure?
elem :: (Foldable t, Eq a) => a -> t a -> Bool
infix 4 `elem`

-- | Combine the elements of a structure using a monoid.
fold :: (Foldable t, Monoid m) => t m -> m

-- | Map each element of the structure to a monoid, and combine the
--   results.
foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m

-- | 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 list to a single, monolithic result (e.g. length).
--   
--   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.
--   
--   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,
--   foldr can produce a terminating expression from an infinite
--   list.
--   
--   For a general Foldable structure this should be semantically
--   identical to,
--   
--   
--   foldr f z = foldr f z . toList
--   
foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b

-- | forM_ is mapM_ with its arguments flipped. For a version
--   that doesn't ignore the results see forM.
--   
--   As of base 4.8.0.0, forM_ is just for_, specialized to
--   Monad.
forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m ()

-- | for_ is traverse_ with its arguments flipped. For a
--   version that doesn't ignore the results see for.
--   
--   
--   >>> for_ [1..4] print
--   1
--   2
--   3
--   4
--   
for_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f ()

-- | Returns the size/length of a finite structure as an Int. The
--   default implementation is optimized for structures that are similar to
--   cons-lists, because there is no general way to do better.
length :: Foldable t => t a -> Int

-- | 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.
--   
--   As of base 4.8.0.0, mapM_ is just traverse_, specialized
--   to Monad.
mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m ()

-- | The sum of a collection of actions, generalizing concat. As of
--   base 4.8.0.0, msum is just asum, specialized to
--   MonadPlus.
msum :: (Foldable t, MonadPlus m) => t (m a) -> m a

-- | notElem is the negation of elem.
notElem :: (Foldable t, Eq a) => a -> t a -> Bool
infix 4 `notElem`

-- | Test whether the structure is empty. The default implementation is
--   optimized for structures that are similar to cons-lists, because there
--   is no general way to do better.
null :: Foldable t => t a -> 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.
or :: Foldable t => t Bool -> Bool

-- | The product function computes the product of the numbers of a
--   structure.
product :: (Foldable t, Num a) => t a -> a

-- | 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_ :: (Foldable t, Applicative f) => t (f a) -> f ()

-- | 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.
--   
--   As of base 4.8.0.0, sequence_ is just sequenceA_,
--   specialized to Monad.
sequence_ :: (Foldable t, Monad m) => t (m a) -> m ()

-- | The sum function computes the sum of the numbers of a
--   structure.
sum :: (Foldable t, Num a) => t a -> a

-- | List of elements of a structure, from left to right.
toList :: Foldable t => t a -> [a]

-- | Map each element of a structure to an action, evaluate these actions
--   from left to right, and ignore the results. For a version that doesn't
--   ignore the results see traverse.
traverse_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f ()

-- | const x is a unary function which evaluates to x for
--   all inputs.
--   
--   
--   >>> const 42 "hello"
--   42
--   
--   
--   
--   >>> map (const 42) [0..3]
--   [42,42,42,42]
--   
const :: () => a -> b -> a

-- | 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' argument, hence the recursion is reintroduced.
fix :: () => (a -> a) -> a

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

-- | Identity function.
--   
--   
--   id x = x
--   
id :: () => 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`

-- | 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 levity-polymorphic in its result type, so
--   that foo $ True where foo :: Bool -> Int# is well-typed
($) :: () => (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 &

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

-- | The Functor class is used for types that can be mapped over.
--   Instances of Functor should satisfy the following laws:
--   
--   
--   fmap id  ==  id
--   fmap (f . g)  ==  fmap f . fmap g
--   
--   
--   The instances of Functor for lists, Maybe and IO
--   satisfy these laws.
class Functor (f :: Type -> Type)
fmap :: Functor f => (a -> b) -> f a -> f b

-- | Replace all locations in the input with the same value. The default
--   definition is fmap . const, but this may be
--   overridden with a more efficient version.
(<$) :: Functor f => a -> f b -> f a
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 <$.
--   
--   
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 $>

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

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

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

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

-- | The class of types that can be converted to a hash value.
--   
--   Minimal implementation: hashWithSalt.
class 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

-- | 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 map of integers to values a.
data IntMap a

-- | A set of integers.
data IntSet

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

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

-- | lines breaks a string up into a list of strings at newline
--   characters. The resulting strings do not contain newlines.
--   
--   Note that after splitting the string at newline characters, the last
--   part of the string is considered a line even if it doesn't end with a
--   newline. For example,
--   
--   
--   >>> lines ""
--   []
--   
--   
--   
--   >>> lines "\n"
--   [""]
--   
--   
--   
--   >>> lines "one"
--   ["one"]
--   
--   
--   
--   >>> lines "one\n"
--   ["one"]
--   
--   
--   
--   >>> lines "one\n\n"
--   ["one",""]
--   
--   
--   
--   >>> lines "one\ntwo"
--   ["one","two"]
--   
--   
--   
--   >>> lines "one\ntwo\n"
--   ["one","two"]
--   
--   
--   Thus lines s contains at least as many elements as
--   newlines in s.
lines :: String -> [String]

-- | lookup key assocs looks up a key in an association
--   list.
lookup :: Eq a => a -> [(a, b)] -> Maybe b

-- | 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 :: () => (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 :: () => Int -> a -> [a]

-- | reverse xs returns the elements of xs in
--   reverse order. xs must be finite.
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]

-- | unlines is an inverse operation to lines. It joins
--   lines, after appending a terminating newline to each.
--   
--   
--   >>> unlines ["Hello", "World", "!"]
--   "Hello\nWorld\n!\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]

-- | 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 short, excess elements of the longer list are
--   discarded:
--   
--   
--   zip [1] ['a', 'b'] = [(1, 'a')]
--   zip [1, 2] ['a'] = [(1, 'a')]
--   
--   
--   zip is right-lazy:
--   
--   
--   zip [] _|_ = []
--   zip _|_ [] = _|_
--   
zip :: () => [a] -> [b] -> [(a, b)]

-- | 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.
(++) :: () => [a] -> [a] -> [a]
infixr 5 ++

-- | A Map from keys k to values a.
data Map k a

-- | 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 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 fromMaybe function takes a default value and and
--   Maybe value. If the Maybe is Nothing, it returns
--   the default values; 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

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

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

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

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

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

-- | The maybeToList function returns an empty list when given
--   Nothing or a singleton list when not given Nothing.
--   
--   
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 class of monoids (types with an associative binary operation that
--   has an identity). Instances should satisfy the following laws:
--   
--   
--   
- 
x <> mempty = x

--   
- 
mempty <> x = x

--   
- x <> (y <> z) = (x <>
--   y) <> z (Semigroup law)
--   
- 
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

-- | Identity of mappend
mempty :: Monoid a => a

-- | An associative operation
--   
--   NOTE: This method is redundant and has the default
--   implementation mappend = '(<>)' since
--   base-4.11.0.0.
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 :: Monoid a => [a] -> 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.
--   
--   The Haskell Report defines no laws for Ord. However,
--   <= is customarily expected to implement a non-strict partial
--   order and have the following properties:
--   
--   
--   
- 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
--   
--   
--   Note that 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
--   
--   
--   Minimal complete definition: either compare or <=.
--   Using compare can be more efficient for complex types.
class Eq a => Ord a
compare :: Ord a => a -> a -> Ordering
(<) :: Ord a => a -> a -> Bool
(<=) :: Ord a => a -> a -> Bool
(>) :: Ord a => a -> a -> Bool
(>=) :: Ord a => a -> a -> Bool
max :: Ord a => a -> a -> a
min :: Ord a => a -> a -> a
infix 4 >=
infix 4 >
infix 4 <
infix 4 <=
data Ordering
LT :: Ordering
EQ :: Ordering
GT :: Ordering

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

-- | 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) :: forall k. () => k -> Type
Proxy :: Proxy

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

--   
class Semigroup a

-- | An associative operation.
(<>) :: Semigroup a => a -> a -> a

-- | Reduce a non-empty list with <>
--   
--   The default definition should be sufficient, but this can be
--   overridden for efficiency.
sconcat :: Semigroup a => NonEmpty a -> a

-- | Repeat a value n times.
--   
--   Given that this works on a Semigroup it is allowed to fail if
--   you request 0 or fewer repetitions, and the default definition will do
--   so.
--   
--   By making this a member of the class, idempotent semigroups and
--   monoids can upgrade this to execute in O(1) by picking
--   stimes = stimesIdempotent or stimes =
--   stimesIdempotentMonoid respectively.
stimes :: (Semigroup a, Integral b) => b -> a -> a
infixr 6 <>

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

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

-- | A space efficient, packed, unboxed Unicode text type.
data 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.
--   
--   NOTE: The replacement character returned by
--   OnDecodeError MUST be within the BMP plane; surrogate code
--   points will automatically be remapped to the replacement char
--   U+FFFD (since 0.11.3.0), whereas code points beyond
--   the BMP will throw an error (since 1.2.3.1); For earlier
--   versions of text using those unsupported code points would
--   result in undefined behavior.
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

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

-- | Replace an invalid input byte with the Unicode replacement character
--   U+FFFD.
lenientDecode :: OnDecodeError

-- | Functors representing data structures that can be traversed from left
--   to right.
--   
--   A definition of traverse must satisfy the following laws:
--   
--   
--   
- naturality t . traverse f =
--   traverse (t . f) for every applicative transformation
--   t
--   
- identity traverse Identity =
--   Identity
--   
- composition traverse (Compose .
--   fmap g . f) = Compose . fmap (traverse g) .
--   traverse f
--   
--   
--   A definition of sequenceA must satisfy the following laws:
--   
--   
--   
- naturality t . sequenceA =
--   sequenceA . fmap t for every applicative
--   transformation t
--   
- identity sequenceA . fmap Identity
--   = Identity
--   
- composition sequenceA . fmap
--   Compose = Compose . fmap sequenceA .
--   sequenceA
--   
--   
--   where an applicative transformation is a function
--   
--   
--   t :: (Applicative f, Applicative g) => f a -> g a
--   
--   
--   preserving the Applicative operations, i.e.
--   
--   
--   
- 
t (pure x) = pure x

--   
- 
t (x <*> y) = t x <*> t
--   y

--   
--   
--   and the identity functor Identity and composition of functors
--   Compose are defined as
--   
--   
--   newtype Identity a = Identity a
--   
--   instance Functor Identity where
--     fmap f (Identity x) = Identity (f x)
--   
--   instance Applicative Identity where
--     pure x = Identity x
--     Identity f <*> Identity x = Identity (f x)
--   
--   newtype Compose f g a = Compose (f (g a))
--   
--   instance (Functor f, Functor g) => Functor (Compose f g) where
--     fmap f (Compose x) = Compose (fmap (fmap f) x)
--   
--   instance (Applicative f, Applicative g) => Applicative (Compose f g) where
--     pure x = Compose (pure (pure x))
--     Compose f <*> Compose x = Compose ((<*>) <$> f <*> x)
--   
--   
--   (The naturality law is implied by parametricity.)
--   
--   Instances are similar to Functor, e.g. given a data type
--   
--   
--   data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
--   
--   
--   a suitable instance would be
--   
--   
--   instance Traversable Tree where
--      traverse f Empty = pure Empty
--      traverse f (Leaf x) = Leaf <$> f x
--      traverse f (Node l k r) = Node <$> traverse f l <*> f k <*> traverse f r
--   
--   
--   This is suitable even for abstract types, as the laws for
--   <*> imply a form of associativity.
--   
--   The superclass instances should satisfy the following:
--   
--   
--   
- In the Functor instance, fmap should be equivalent
--   to traversal with the identity applicative functor
--   (fmapDefault).
--   
- In the Foldable instance, foldMap should be
--   equivalent to traversal with a constant applicative functor
--   (foldMapDefault).
--   
class (Functor t, Foldable t) => Traversable (t :: Type -> Type)

-- | Map each element of a structure to an action, evaluate these actions
--   from left to right, and collect the results. For a version that
--   ignores the results see traverse_.
traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)

-- | Evaluate each action in the structure from left to right, and collect
--   the results. For a version that ignores the results see
--   sequenceA_.
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_.
mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b)

-- | Evaluate each monadic action in the structure from left to right, and
--   collect the results. For a version that ignores the results see
--   sequence_.
sequence :: (Traversable t, Monad m) => t (m a) -> m (t a)

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

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

-- | Boxed vectors, supporting efficient slicing.
data Vector a

-- | Uninhabited data type
data Void

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

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

-- | Swap bytes in Word16.
byteSwap16 :: Word16 -> Word16

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

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

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

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

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

-- | Type representing arbitrary-precision non-negative integers.
--   
--   
--   >>> 2^100 :: Natural
--   1267650600228229401496703205376
--   
--   
--   Operations whose result would be negative throw
--   (Underflow :: ArithException),
--   
--   
--   >>> -1 :: Natural
--   *** Exception: arithmetic underflow
--   
data Natural

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

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

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

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

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

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

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

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

-- | reciprocal fraction
recip :: Fractional a => a -> a

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

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

-- | Invariant: Jn# and Jp# are used iff value doesn't fit in
--   S#
--   
--   Useful properties resulting from the invariants:
--   
--   
--   
- 
abs (S# _) <= abs (Jp# _)

--   
- 
abs (S# _) < abs (Jn# _)

--   
data Integer

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

-- | integer division truncated toward zero
quot :: Integral a => a -> a -> a

-- | integer remainder, satisfying
--   
--   
--   (x `quot` y)*y + (x `rem` y) == x
--   
rem :: Integral a => a -> a -> a

-- | integer division truncated toward negative infinity
div :: Integral a => a -> a -> a

-- | integer modulus, satisfying
--   
--   
--   (x `div` y)*y + (x `mod` y) == x
--   
mod :: Integral a => a -> a -> a

-- | simultaneous quot and rem
quotRem :: Integral a => a -> a -> (a, a)

-- | simultaneous div and mod
divMod :: Integral a => a -> a -> (a, a)

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

-- | 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
(+) :: Num a => a -> a -> a
(-) :: Num a => a -> a -> a
(*) :: Num a => a -> a -> a

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

-- | A String is a list of characters. String constants in Haskell
--   are values of type String.
type String = [Char]

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

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

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

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

-- | general coercion from integral types
fromIntegral :: (Integral a, Num b) => a -> b

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

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

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

-- | general coercion to fractional types
realToFrac :: (Real a, Fractional b) => a -> b

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

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

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

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

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

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

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

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

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

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

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

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

-- | 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) :: Type;
}

-- | Execute a primitive operation
primitive :: PrimMonad m => (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
class (Vector Vector a, MVector MVector a) => Unbox a
sappend :: Semigroup s => s -> s -> s
type LByteString = ByteString
type LText = Text
type UVector = Vector
type SVector = Vector
type GVector = Vector
toStrictBytes :: LByteString -> ByteString
fromStrictBytes :: ByteString -> LByteString
decodeUtf8Lenient :: ByteString -> Text
tshow :: Show a => a -> Text

-- | 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
class (Vector Vector a, MVector MVector a) => Unbox a

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

-- | Lazy ByteString. Import as:
--   
--   
--   import qualified RIO.ByteString.Lazy as BL
--   
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(n/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. This function will fuse.
--   
--   
--   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 :: (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 :: 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 [] 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)

-- | takeWhile, applied to a predicate p and a ByteString
--   xs, returns the longest prefix (possibly empty) of
--   xs of elements that satisfy p.
takeWhile :: (Word8 -> Bool) -> ByteString -> ByteString

-- | dropWhile p xs returns the suffix remaining after
--   takeWhile p xs.
dropWhile :: (Word8 -> Bool) -> ByteString -> ByteString

-- | span p xs breaks the ByteString into two segments. It
--   is equivalent to (takeWhile p xs, dropWhile p
--   xs)
span :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)

-- | break p is equivalent to span (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 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 :: ByteString -> [ByteString]

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

-- | O(n) Return all initial segments of the given
--   ByteString, shortest first.
inits :: ByteString -> [ByteString]

-- | O(n) Return 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 '\n' "a\nb\nd\ne" == ["a","b","d","e"]
--   split 'a'  "aXaXaXa"    == ["","X","X","X",""]
--   split 'x'  "x"          == ["",""]
--   
--   
--   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 (=='a') "aabbaca" == ["","","bb","c",""]
--   splitWith (=='a') []        == []
--   
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.
index :: 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 ==
--   (-) (length xs - 1) `fmap` elemIndex c (reverse xs)
--   
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
--   
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

-- | 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) Sort a ByteString efficiently, using counting sort.
sort :: ByteString -> ByteString

-- | O(n) Return all final segments of the given ByteString,
--   longest first.
tails :: ByteString -> [ByteString]

-- | O(n) Return all initial segments of the given
--   ByteString, shortest first.
inits :: 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)

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

-- | 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
--   
--   
--   and:
--   
--   
--   findSubstring s l ==
--      if null s then Just 0
--                else case breakSubstring s l of
--                         (x,y) | null y    -> Nothing
--                               | otherwise -> Just (length x)
--   
--   
--   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 occurence 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)

-- | Check whether one string is a substring of another. isInfixOf p
--   s is equivalent to not (null (findSubstrings p s)).
isInfixOf :: ByteString -> ByteString -> Bool

-- | 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) 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 implemenation uses memcmp to compare the end of the
--   string only, with no reverse required..
isSuffixOf :: ByteString -> ByteString -> Bool

-- | 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 isPrefixOf function takes two ByteStrings and
--   returns True if the first is a prefix of the second.
isPrefixOf :: ByteString -> ByteString -> Bool

-- | 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(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) notElem is the inverse of elem
notElem :: Word8 -> ByteString -> Bool

-- | O(n) elem is the ByteString membership predicate.
elem :: Word8 -> ByteString -> Bool

-- | The findIndices function extends findIndex, by returning
--   the indices of all elements satisfying the predicate, in ascending
--   order.
findIndices :: (Word8 -> Bool) -> ByteString -> [Int]

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

-- | 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 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 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 ==
--   (-) (length xs - 1) `fmap` elemIndex c (reverse xs)
--   
elemIndexEnd :: Word8 -> ByteString -> Maybe Int

-- | 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(1) ByteString index (subscript) operator, starting
--   from 0.
index :: ByteString -> Int -> Word8

-- | 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 groupBy function is the non-overloaded version of
--   group.
groupBy :: (Word8 -> Word8 -> Bool) -> 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 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. It is about 40% faster than groupBy
--   (==)
group :: ByteString -> [ByteString]

-- | O(n) Break a ByteString into pieces separated by the
--   byte argument, consuming the delimiter. I.e.
--   
--   
--   split '\n' "a\nb\nd\ne" == ["a","b","d","e"]
--   split 'a'  "aXaXaXa"    == ["","X","X","X",""]
--   split 'x'  "x"          == ["",""]
--   
--   
--   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 (=='a') "aabbaca" == ["","","bb","c",""]
--   splitWith (=='a') []        == []
--   
splitWith :: (Word8 -> Bool) -> ByteString -> [ByteString]

-- | spanEnd behaves like span but from the end of the
--   ByteString. 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)

-- | span p xs breaks the ByteString into two segments. It
--   is equivalent to (takeWhile p xs, dropWhile p
--   xs)
span :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)

-- | breakEnd behaves like break but from the end of the
--   ByteString
--   
--   breakEnd p == spanEnd (not.p)
breakEnd :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)

-- | break p is equivalent to span (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)

-- | dropWhile p xs returns the suffix remaining after
--   takeWhile p xs.
dropWhile :: (Word8 -> Bool) -> ByteString -> ByteString

-- | takeWhile, applied to a predicate p and a ByteString
--   xs, returns the longest prefix (possibly empty) of
--   xs of elements that satisfy p.
takeWhile :: (Word8 -> Bool) -> ByteString -> ByteString

-- | O(1) splitAt n xs is equivalent to
--   (take n xs, drop n xs).
splitAt :: Int -> ByteString -> (ByteString, ByteString)

-- | O(1) drop n xs returns the suffix of
--   xs after the first n elements, or [] if
--   n > length xs.
drop :: Int -> 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(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)

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

-- | O(n) replicate n x is a ByteString of length
--   n with x the value of every element. The following
--   holds:
--   
--   
--   replicate w c = unfoldr w (\u -> Just (u,u)) c
--   
--   
--   This implemenation uses memset(3)
replicate :: Int -> Word8 -> ByteString

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

-- | scanr is the right-to-left dual of scanl.
scanr :: (Word8 -> Word8 -> Word8) -> Word8 -> ByteString -> ByteString

-- | scanl1 is a variant of scanl that has no starting value
--   argument. This function will fuse.
--   
--   
--   scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
--   
scanl1 :: (Word8 -> Word8 -> Word8) -> ByteString -> ByteString

-- | scanl is similar to foldl, but returns a list of
--   successive reduced values from the left. This function will fuse.
--   
--   
--   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 :: (Word8 -> Word8 -> Word8) -> Word8 -> ByteString -> 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 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
--   list.
mapAccumL :: () => (acc -> Word8 -> (acc, Word8)) -> acc -> ByteString -> (acc, ByteString)

-- | 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) Applied to a predicate and a ByteString, any
--   determines if any element of the ByteString satisfies the
--   predicate.
any :: (Word8 -> Bool) -> ByteString -> Bool

-- | Map a function over a ByteString and concatenate the results
concatMap :: (Word8 -> ByteString) -> ByteString -> ByteString

-- | O(n) Concatenate a list of ByteStrings.
concat :: [ByteString] -> ByteString

-- | foldr' is like foldr, but strict in the accumulator.
foldr' :: () => (Word8 -> a -> 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

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

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

-- | The transpose function transposes the rows and columns of its
--   ByteString argument.
transpose :: [ByteString] -> [ByteString]

-- | 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) reverse xs efficiently returns the
--   elements of xs in reverse order.
reverse :: ByteString -> ByteString

-- | O(n) map f xs is the ByteString obtained by
--   applying f to each element of xs.
map :: (Word8 -> Word8) -> ByteString -> ByteString

-- | O(n) Append two ByteStrings
append :: ByteString -> ByteString -> ByteString

-- | O(1) Extract the init and last of a ByteString,
--   returning Nothing if it is empty.
unsnoc :: ByteString -> Maybe (ByteString, Word8)

-- | O(1) Extract the head and tail of a ByteString, returning
--   Nothing if it is empty.
uncons :: ByteString -> Maybe (Word8, ByteString)

-- | O(n) Append a byte to the end of a ByteString
snoc :: ByteString -> Word8 -> ByteString
infixl 5 `snoc`

-- | 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(1) length returns the length of a ByteString as an
--   Int.
length :: ByteString -> Int

-- | O(1) Test whether a ByteString is empty.
null :: ByteString -> Bool

-- | O(n) Converts a ByteString to a [Word8].
unpack :: ByteString -> [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 packAddress (GHC only).
pack :: [Word8] -> ByteString

-- | O(1) Convert a Word8 into a ByteString
singleton :: Word8 -> ByteString

-- | O(1) The empty ByteString
empty :: ByteString

-- | Lifted packCString
packCString :: MonadIO m => CString -> m ByteString

-- | Lifted packCStringLen
packCStringLen :: MonadIO m => CStringLen -> m ByteString

-- | Unlifted useAsCString
useAsCString :: MonadUnliftIO m => ByteString -> (CString -> m a) -> m a

-- | Unlifted useAsCStringLen
useAsCStringLen :: MonadUnliftIO m => ByteString -> (CStringLen -> m a) -> m a

-- | Lifted getLine
getLine :: MonadIO m => m ByteString

-- | Lifted getContents
getContents :: MonadIO m => m ByteString

-- | Lifted putStr
putStr :: MonadIO m => ByteString -> m ()

-- | Lifted interact
interact :: MonadIO m => (ByteString -> ByteString) -> m ()

-- | Lifted readFile
readFile :: MonadIO m => FilePath -> m ByteString

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

-- | Lifted appendFile
appendFile :: MonadIO m => FilePath -> ByteString -> m ()

-- | Lifted hGetLine
hGetLine :: MonadIO m => Handle -> m ByteString

-- | Lifted hGetContents
hGetContents :: MonadIO m => Handle -> m ByteString

-- | Lifted hGet
hGet :: MonadIO m => Handle -> Int -> m ByteString

-- | Lifted hGetSome
hGetSome :: MonadIO m => Handle -> Int -> m ByteString

-- | Lifted hGetNonBlocking
hGetNonBlocking :: MonadIO m => Handle -> Int -> m ByteString

-- | Lifted hPut
hPut :: MonadIO m => Handle -> ByteString -> m ()

-- | Lifted hPutNonBlocking
hPutNonBlocking :: MonadIO m => Handle -> ByteString -> m ByteString

-- | Lifted hPutStr
hPutStr :: MonadIO m => Handle -> ByteString -> m ()

-- | 
Rationale
--   
--   This module offers functions to handle files that offer better
--   durability and/or atomicity.
--   
--   
When to use the functions on this module?
--   
--   Given the usage of this functions comes at a cost in performance, it
--   is important to consider what are the use cases that are ideal for
--   each of the functions.
--   
--   
Not Durable and not Atomic
--   
--   For this use case, you want to use the regular functions:
--   
--   
--   
- withBinaryFile
--   
- writeFileBinary
--   
--   
--   The regular use case for this scenario happens when your program is
--   dealing with outputs that are never going to be consumed again by your
--   program. For example, imagine you have a program that generates sales
--   reports for the last month, this is a report that can be generated
--   quickly; you don't really care if the output file gets corrupted or
--   lost at one particular execution of your program given that is cheap
--   to execute the data export program a second time. In other words, your
--   program doesn't rely on the data contained in this file in
--   order to work.
--   
--   
Atomic but not Durable
--   
--   Imagine a scenario where your program builds a temporary file that
--   serves as an intermediate step to a bigger task, like Object files
--   (.o) in a compilation process. The program will use an
--   existing .o file if it is present, or it will build one from
--   scratch if it is not. The file is not really required, but if it is
--   present, it *must* be valid and consistent. In this situation, you
--   care about atomicity, but not durability.
--   
--   There is no function exported by this module that provides only
--   atomicity.
--   
--   
Durable but not Atomic
--   
--   For this use case, you want to use the functions:
--   
--   
--   
- withBinaryFileDurable
--   
- writeBinaryFileDurable
--   
--   
--   The regular use case for this scenario happens when your program deals
--   with file modifications that must be guaranteed to be durable, but you
--   don't care that changes are consistent. If you use this function, more
--   than likely your program is ensuring consistency guarantees through
--   other means, for example, SQLite uses the Write Ahead Log (WAL)
--   algorithm to ensure changes are atomic at an application level.
--   
--   
Durable and Atomic
--   
--   For this use case, you can use the functions:
--   
--   
--   
- withBinaryFileDurableAtomic
--   
- writeBinaryFileDurableAtomic
--   
--   
--   The regular use case for this scenario happens when you want to ensure
--   that after a program is executed, the modifications done to a file are
--   guaranteed to be saved, and also that changes are rolled-back in case
--   there is a failure (e.g. hard reboot, shutdown, etc).
module RIO.File

-- | Similar to writeFileBinary, 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 writeFileBinary on Windows
--   platforms.
writeBinaryFileDurable :: MonadUnliftIO m => FilePath -> ByteString -> m ()

-- | Similar to writeFileBinary, 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 writeFileBinary on Windows
--   platforms.
writeBinaryFileDurableAtomic :: MonadUnliftIO 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

-- | 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 temporal file to the original filepath, in
--   case of catastrophic failure, the original file stays unaffected.
--   
--   
--   
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

-- | After a file is closed, it opens it again and executes fsync
--   internally on both the file and the directory that contains it. Note
--   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 File 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.
--   
--   
Cross-Platform support
--   
--   This function is a noop on Windows platforms.
ensureFileDurable :: MonadUnliftIO m => FilePath -> m ()

-- | 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.
--   
--   Subject to fusion. Performs replacement on invalid scalar values.
pack :: String -> Text

-- | O(n) Convert a Text into a String. Subject to
--   fusion.
unpack :: Text -> String

-- | O(1) Convert a character into a Text. Subject to fusion.
--   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. Subject to
--   fusion.
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, unless fused. Subject to fusion.
snoc :: Text -> Char -> Text

-- | O(n/c) Appends one Text to another. Subject to fusion.
append :: Text -> Text -> Text

-- | O(1) Returns the first character and rest of a Text, or
--   Nothing if empty. Subject to fusion.
uncons :: Text -> Maybe (Char, Text)

-- | O(1) Tests whether a Text is empty or not. Subject to
--   fusion.
null :: Text -> Bool

-- | O(n) Returns the number of characters in a Text. Subject
--   to fusion.
length :: Text -> Int64

-- | O(n) Compare the count of characters in a Text to a
--   number. Subject to fusion.
--   
--   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. Subject
--   to fusion. 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. Subject to fusion.
--   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. Subject to fusion.
--   
--   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. Subject to fusion.
--   
--   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. Subject to fusion.
--   
--   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. Subject to fusion.
--   
--   The first letter 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).
--   
--   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. Subject to fusion. 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. Subject to fusion.
foldl :: () => (a -> Char -> a) -> a -> Text -> a

-- | O(n) A strict version of foldl. Subject to fusion.
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. Subject to fusion.
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. Subject to fusion.
any :: (Char -> Bool) -> Text -> Bool

-- | O(n) all p t determines whether all
--   characters in the Text t satisfy the predicate
--   p. Subject to fusion.
all :: (Char -> Bool) -> Text -> Bool

-- | O(n) scanl is similar to foldl, but returns a
--   list of successive reduced values from the left. Subject to fusion.
--   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. Subject to fusion. 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 :: 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. Subject
--   to fusion.
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. Subject to fusion.
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. Subject to fusion.
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. Subject to
--   fusion.
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.
--   Subject to fusion.
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 list.
span :: (Char -> Bool) -> Text -> (Text, Text)

-- | O(n) break is like span, but the prefix returned
--   is over elements that fail the predicate p.
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 Chars. The resulting strings do not contain newlines.
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 iff the first is a prefix of the second. Subject
--   to fusion.
isPrefixOf :: Text -> Text -> Bool

-- | O(n) The isSuffixOf function takes two Texts and
--   returns True iff the first is a suffix of the second.
isSuffixOf :: Text -> Text -> Bool

-- | O(n+m) The isInfixOf function takes two Texts and
--   returns True iff 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 :: 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 :: 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

-- | This module exports all the partial functions from
--   Data.Text.Lazy
module RIO.Text.Lazy.Partial

-- | O(1) Returns the first character of a Text, which must
--   be non-empty. Subject to fusion.
head :: Text -> Char

-- | O(n/c) Returns the last character of a Text, which must
--   be non-empty. Subject to fusion.
last :: Text -> Char

-- | O(1) Returns all characters after the head of a Text,
--   which must be non-empty. Subject to fusion.
tail :: Text -> Text

-- | O(n/c) Returns all but the last character of a Text,
--   which must be non-empty. Subject to fusion.
init :: 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 :: 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. Subject
--   to fusion.
foldl1 :: (Char -> Char -> Char) -> Text -> Char

-- | O(n) A strict version of foldl1. Subject to fusion.
foldl1' :: (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. Subject
--   to fusion.
foldr1 :: (Char -> Char -> Char) -> Text -> Char

-- | O(n) maximum returns the maximum value from a
--   Text, which must be non-empty. Subject to fusion.
maximum :: Text -> Char

-- | O(n) minimum returns the minimum value from a
--   Text, which must be non-empty. Subject to fusion.
minimum :: 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 :: 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 :: 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 :: 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 :: Text -> Text -> [(Text, Text)]

-- | This module exports all the partial functions from Data.Text
module RIO.Text.Partial

-- | O(1) Returns the first character of a Text, which must
--   be non-empty. Subject to fusion.
head :: Text -> Char

-- | O(1) Returns the last character of a Text, which must be
--   non-empty. Subject to fusion.
last :: Text -> Char

-- | O(1) Returns all characters after the head of a Text,
--   which must be non-empty. Subject to fusion.
tail :: Text -> Text

-- | O(1) Returns all but the last character of a Text, which
--   must be non-empty. Subject to fusion.
init :: 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 :: 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. Subject
--   to fusion.
foldl1 :: (Char -> Char -> Char) -> Text -> Char

-- | O(n) A strict version of foldl1. Subject to fusion.
foldl1' :: (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. Subject
--   to fusion.
foldr1 :: (Char -> Char -> Char) -> Text -> Char

-- | O(n) maximum returns the maximum value from a
--   Text, which must be non-empty. Subject to fusion.
maximum :: Text -> Char

-- | O(n) minimum returns the minimum value from a
--   Text, which must be non-empty. Subject to fusion.
minimum :: 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 :: 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 :: 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 :: 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 :: 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 :: Text -> Text -> Int

module RIO.Time

-- | Substitute various time-related information for each %-code in the
--   string, as per formatCharacter.
--   
--   The general form is
--   %<modifier><width><specifier>, where
--   <modifier> and <width> 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
--   
--   
--   
<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.
--   
- %Z timezone name
--   
--   
--   
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.
--   
--   
--   
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)
--   
- %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
--   
- %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 day of week for Week Date format, 1 -
--   7
--   
- %a day of week, short form (snd from
--   wDays locale), Sun - Sat
--   
- %A day of week, long form (fst from
--   wDays locale), Sunday -
--   Saturday
--   
- %U week of year where weeks start on Sunday (as
--   sundayStartWeek), 0-padded to two chars, 00 -
--   53
--   
- %w day of week number, 0 (= Sunday) -
--   6 (= Saturday)
--   
- %W week of year where weeks start on Monday (as
--   mondayStartWeek), 0-padded to two chars, 00 -
--   53
--   
formatTime :: FormatTime t => TimeLocale -> String -> t -> String
type NumericPadOption = Maybe Char
class FormatTime t
formatCharacter :: FormatTime t => Char -> Maybe (TimeLocale -> Maybe NumericPadOption -> Maybe Int -> t -> String)
readsTime :: ParseTime t => TimeLocale -> String -> ReadS t
readTime :: ParseTime t => TimeLocale -> String -> String -> t
parseTime :: ParseTime t => TimeLocale -> String -> String -> Maybe t

-- | Parse a time value given a format string. See parseTimeM for
--   details.
readPTime :: ParseTime t => Bool -> TimeLocale -> String -> ReadP 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. Fails if the input could not
--   be parsed using the given format. See parseTimeM for details.
parseTimeOrError :: ParseTime t => Bool -> TimeLocale -> String -> String -> t

-- | Parses a time value given a format string. 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 accepts any of -HHMM or
--   -HH:MM.
--   
- %Z 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.
--   
parseTimeM :: (Monad m, ParseTime t) => Bool -> TimeLocale -> String -> String -> m t

-- | The class of types which can be parsed given a UNIX-style time format
--   string.
class ParseTime t

-- | Builds a time value from a parsed input string. If the input does not
--   include all the information needed to construct a complete value, any
--   missing parts should be taken from 1970-01-01 00:00:00 +0000 (which
--   was a Thursday). In the absence of %C or %Y, century
--   is 1969 - 2068.
buildTime :: ParseTime t => TimeLocale -> [(Char, String)] -> Maybe t
zonedTimeToUTC :: ZonedTime -> UTCTime
utcToZonedTime :: TimeZone -> UTCTime -> ZonedTime

-- | A local time together with a time zone.
data ZonedTime
ZonedTime :: LocalTime -> TimeZone -> ZonedTime
[zonedTimeToLocalTime] :: ZonedTime -> LocalTime
[zonedTimeZone] :: ZonedTime -> TimeZone

-- | Format string according to RFC822.
rfc822DateFormat :: String

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

-- | 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
--   single-letter military time-zones and +HHMM format.
defaultTimeLocale :: TimeLocale
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]

-- | Get the UT1 time of a local time on a particular meridian (in degrees,
--   positive is East).
localTimeToUT1 :: Rational -> LocalTime -> UniversalTime

-- | Get the local time of a UT1 time on a particular meridian (in degrees,
--   positive is East).
ut1ToLocalTime :: Rational -> UniversalTime -> LocalTime

-- | Get the UTC time of a local time in a time zone.
localTimeToUTC :: TimeZone -> LocalTime -> UTCTime

-- | Get the local time of a UTC time in a time zone.
utcToLocalTime :: TimeZone -> UTCTime -> LocalTime

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

-- | Get the fraction of a day since midnight given a time of day.
timeOfDayToDayFraction :: TimeOfDay -> Rational

-- | Get the time of day given the fraction of a day since midnight.
dayFractionToTimeOfDay :: Rational -> TimeOfDay

-- | Get the time since midnight for a given time of day.
timeOfDayToTime :: TimeOfDay -> DiffTime

-- | Get the time of day given a time since midnight. Time more than 24h
--   will be converted to leap-seconds.
timeToTimeOfDay :: DiffTime -> 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)

-- | 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)
makeTimeOfDayValid :: Int -> Int -> Pico -> Maybe TimeOfDay

-- | Hour twelve
midday :: TimeOfDay

-- | Hour zero
midnight :: TimeOfDay

-- | Time of day as represented in hour, minute and second (with
--   picoseconds), typically used to express local time of day.
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

-- | The UTC time zone.
utc :: TimeZone

-- | Text representing the offset of this timezone, such as "-0800" or
--   "+0400" (like %z in formatTime).
timeZoneOffsetString :: TimeZone -> String

-- | Text representing the offset of this timezone, such as "-0800" or
--   "+0400" (like %z in formatTime), with arbitrary padding.
timeZoneOffsetString' :: Maybe Char -> TimeZone -> String

-- | Create a nameless non-summer timezone for this number of hours.
hoursToTimeZone :: Int -> TimeZone

-- | Create a nameless non-summer timezone for this number of minutes.
minutesToTimeZone :: Int -> TimeZone

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

-- | diffUTCTime a b = a - b
diffUTCTime :: UTCTime -> UTCTime -> NominalDiffTime

-- | addUTCTime a b = a + b
addUTCTime :: NominalDiffTime -> UTCTime -> UTCTime

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

-- | 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 resolution of getSystemTime, getCurrentTime,
--   getPOSIXTime
getTime_resolution :: DiffTime

-- | One day in NominalDiffTime.
nominalDay :: NominalDiffTime

-- | This is a length of time, as measured by UTC. Conversion functions
--   will treat it as seconds. It has a precision of 10^-12 s. 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

-- | Get the number of picoseconds in a DiffTime.
diffTimeToPicoseconds :: DiffTime -> Integer

-- | Create a DiffTime from a number of picoseconds.
picosecondsToDiffTime :: Integer -> DiffTime

-- | Create a DiffTime which represents an integral number of
--   seconds.
secondsToDiffTime :: Integer -> DiffTime

-- | This is a length of time, as measured by a clock. Conversion functions
--   will treat it as seconds. It has a precision of 10^-12 s.
data DiffTime

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

-- | The number of days in a given month according to the proleptic
--   Gregorian calendar. First argument is year, second is month.
gregorianMonthLength :: Integer -> Int -> Int

-- | Show in ISO 8601 format (yyyy-mm-dd)
showGregorian :: Day -> String

-- | Convert from proleptic Gregorian calendar. First argument is year,
--   second month number (1-12), third day (1-31). Invalid values will
--   return Nothing
fromGregorianValid :: Integer -> Int -> Int -> Maybe Day

-- | Convert from proleptic Gregorian calendar. First argument is year,
--   second month number (1-12), third day (1-31). Invalid values will be
--   clipped to the correct range, month first, then day.
fromGregorian :: Integer -> Int -> Int -> Day

-- | Convert to proleptic Gregorian calendar. First element of result is
--   year, second month number (1-12), third day (1-31).
toGregorian :: Day -> (Integer, Int, Int)

-- | Is this year a leap year according to the proleptic Gregorian
--   calendar?
isLeapYear :: Integer -> Bool
diffDays :: Day -> Day -> Integer
addDays :: Integer -> Day -> Day

-- | 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
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
--   
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 :: 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) Empty vector
empty :: Vector v a => v a

-- | O(1) Vector with exactly one element
singleton :: Vector v a => a -> v a

-- | O(n) 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 function n times to value. Zeroth element is
--   original value.
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 monadic function n times to value. Zeroth element is
--   original value.
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 f <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 f <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 0.1 5 = <1,1.1,1.2,1.3,1.4>
--   
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 at all
--   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 at all
--   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 will be
--   performed in place if it is safe to do so and will modify a copy of
--   the vector otherwise.
--   
--   
--   modify (\v -> write v 0 'x') (replicate 3 'a') = <'x','a','a'>
--   
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
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)
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 elements that do not satisfy the predicate
filter :: Vector v a => (a -> Bool) -> v a -> v a

-- | O(n) Drop elements that do not satisfy the predicate which is
--   applied to values and their indices
ifilter :: Vector v a => (Int -> a -> Bool) -> v a -> v a

-- | O(n) Drop repeated adjacent elements.
uniq :: (Vector v a, Eq a) => v a -> v a

-- | O(n) Drop elements when predicate returns Nothing
mapMaybe :: (Vector v a, Vector v b) => (a -> Maybe b) -> v a -> v b

-- | O(n) Drop elements when predicate, applied to index and value,
--   returns Nothing
imapMaybe :: (Vector v a, Vector v b) => (Int -> a -> Maybe b) -> v a -> v b

-- | O(n) Drop 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 without copying.
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 occurence 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 occurences 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 (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 (function applied to
--   each element and its index)
ifoldl' :: Vector v b => (a -> Int -> b -> a) -> a -> v b -> a

-- | O(n) Right fold (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 (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.
all :: Vector v a => (a -> Bool) -> v a -> Bool

-- | O(n) Check if any element satisfies the predicate.
any :: Vector v a => (a -> Bool) -> v a -> Bool

-- | O(n) Check if all elements are True
and :: Vector v Bool => v Bool -> Bool

-- | O(n) Check if any element is True
or :: Vector v Bool => v Bool -> Bool

-- | O(n) Compute the sum of the elements
sum :: (Vector v a, Num a) => v a -> a

-- | O(n) Compute the produce of the elements
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 (action 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 (action 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 (action 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 (action 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) Prescan
--   
--   
--   prescanl f z = init . scanl f z
--   
--   
--   Example: prescanl (+) 0 <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) Prescan with strict accumulator
prescanl' :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a

-- | O(n) Scan
--   
--   
--   postscanl f z = tail . scanl f z
--   
--   
--   Example: postscanl (+) 0 <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) Scan with strict accumulator
postscanl' :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a

-- | O(n) Haskell-style scan
--   
--   
--   scanl f z <x1,...,xn> = <y1,...,y(n+1)>
--     where y1 = z
--           yi = f y(i-1) x(i-1)
--   
--   
--   Example: scanl (+) 0 <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) Haskell-style scan with strict accumulator
scanl' :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a

-- | O(n) 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) 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 scan
postscanr :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b

-- | O(n) Right-to-left scan with strict accumulator
postscanr' :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b

-- | O(n) Right-to-left Haskell-style scan
scanr :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b

-- | O(n) Right-to-left Haskell-style 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
--   
--   
--   fromListN n xs = fromList (take n xs)
--   
fromListN :: Vector v a => Int -> [a] -> v a

-- | O(n) Convert 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 the 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 :: (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 :: 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)
eqBy :: (Vector v a, Vector v b) => (a -> b -> Bool) -> v a -> v b -> Bool

-- | O(n)
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
--   
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) Empty vector
empty :: () => Vector a

-- | O(1) Vector with exactly one element
singleton :: () => a -> Vector a

-- | O(n) 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 function n times to value. Zeroth element is
--   original value.
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 monadic function n times to value. Zeroth element is
--   original value.
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 f <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 f <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 0.1 5 = <1,1.1,1.2,1.3,1.4>
--   
enumFromStepN :: Num a => a -> a -> Int -> Vector a

-- | O(n) Enumerate values from x to y.
--   
--   WARNING: This operation can be very inefficient. If at all
--   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 at all
--   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 will be
--   performed in place if it is safe to do so and will modify a copy of
--   the vector otherwise.
--   
--   
--   modify (\v -> write v 0 'x') (replicate 3 'a') = <'x','a','a'>
--   
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

-- | Elementwise pairing of array elements.
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 elements that do not satisfy the predicate
filter :: () => (a -> Bool) -> Vector a -> Vector a

-- | O(n) Drop elements that do not satisfy the predicate which is
--   applied to values and their indices
ifilter :: () => (Int -> a -> Bool) -> Vector a -> Vector a

-- | O(n) Drop repeated adjacent elements.
uniq :: Eq a => Vector a -> Vector a

-- | O(n) Drop elements when predicate returns Nothing
mapMaybe :: () => (a -> Maybe b) -> Vector a -> Vector b

-- | O(n) Drop elements when predicate, applied to index and value,
--   returns Nothing
imapMaybe :: () => (Int -> a -> Maybe b) -> Vector a -> Vector b

-- | O(n) Drop 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 without copying.
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 occurence 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 occurences 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 (function applied to each element and its index)
ifoldl :: () => (a -> Int -> b -> a) -> a -> Vector b -> a

-- | O(n) Left fold with strict accumulator (function applied to
--   each element and its index)
ifoldl' :: () => (a -> Int -> b -> a) -> a -> Vector b -> a

-- | O(n) Right fold (function applied to each element and its
--   index)
ifoldr :: () => (Int -> a -> b -> b) -> b -> Vector a -> b

-- | O(n) Right fold with strict accumulator (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.
all :: () => (a -> Bool) -> Vector a -> Bool

-- | O(n) Check if any element satisfies the predicate.
any :: () => (a -> Bool) -> Vector a -> Bool

-- | O(n) Check if all elements are True
and :: Vector Bool -> Bool

-- | O(n) Check if any element is True
or :: Vector Bool -> Bool

-- | O(n) Compute the sum of the elements
sum :: Num a => Vector a -> a

-- | O(n) Compute the produce of the elements
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 (action 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 (action 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 (action 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 (action 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) Prescan
--   
--   
--   prescanl f z = init . scanl f z
--   
--   
--   Example: prescanl (+) 0 <1,2,3,4> = <0,1,3,6>
prescanl :: () => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Prescan with strict accumulator
prescanl' :: () => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Scan
--   
--   
--   postscanl f z = tail . scanl f z
--   
--   
--   Example: postscanl (+) 0 <1,2,3,4> = <1,3,6,10>
postscanl :: () => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Scan with strict accumulator
postscanl' :: () => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Haskell-style scan
--   
--   
--   scanl f z <x1,...,xn> = <y1,...,y(n+1)>
--     where y1 = z
--           yi = f y(i-1) x(i-1)
--   
--   
--   Example: scanl (+) 0 <1,2,3,4> = <0,1,3,6,10>
scanl :: () => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Haskell-style scan with strict accumulator
scanl' :: () => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Scan over a vector with its index
iscanl :: () => (Int -> a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) 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 scan
postscanr :: () => (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left scan with strict accumulator
postscanr' :: () => (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left Haskell-style scan
scanr :: () => (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left Haskell-style 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
--   
--   
--   fromListN n xs = fromList (take n xs)
--   
fromListN :: () => Int -> [a] -> Vector a

-- | O(n) Convert 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 the 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 ()

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 elements) 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, 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.
--   
--   
--   accum (+) <5,9,2> [(2,4),(1,6),(0,3),(1,7)] = <5+3, 9+6+7, 2+4>
--   
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.
--   
--   
--   accumulate (+) <5,9,2> <(2,4),(1,6),(0,3),(1,7)> = <5+3, 9+6+7, 2+4>
--   
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.
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.
maximumBy :: () => (a -> a -> Ordering) -> Vector a -> a

-- | O(n) Yield the minimum element of the vector. The vector may
--   not be empty.
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.
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.
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.
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) Scan over a non-empty vector
--   
--   
--   scanl f <x1,...,xn> = <y1,...,yn>
--     where y1 = x1
--           yi = f y(i-1) xi
--   
scanl1 :: () => (a -> a -> a) -> Vector a -> Vector a

-- | O(n) Scan over a non-empty vector with a strict accumulator
scanl1' :: () => (a -> a -> a) -> Vector a -> Vector a

-- | O(n) Right-to-left scan over a non-empty vector
scanr1 :: () => (a -> a -> a) -> Vector a -> Vector a

-- | O(n) Right-to-left scan over a non-empty vector with a strict
--   accumulator
scanr1' :: () => (a -> a -> a) -> Vector a -> Vector a

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) Unsafe 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. The immutable vector may not be used after this
--   operation.
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 ()

module RIO.Vector.Partial

-- | O(1) Indexing
(!) :: 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 elements) is evaluated eagerly.
indexM :: (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, 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.
--   
--   
--   accum (+) <5,9,2> [(2,4),(1,6),(0,3),(1,7)] = <5+3, 9+6+7, 2+4>
--   
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.
--   
--   
--   accumulate (+) <5,9,2> <(2,4),(1,6),(0,3),(1,7)> = <5+3, 9+6+7, 2+4>
--   
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 :: (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.
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.
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.
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.
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.
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.
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) Scan over a non-empty vector
--   
--   
--   scanl f <x1,...,xn> = <y1,...,yn>
--     where y1 = x1
--           yi = f y(i-1) xi
--   
scanl1 :: Vector v a => (a -> a -> a) -> v a -> v a

-- | O(n) Scan over a non-empty vector with a strict accumulator
scanl1' :: Vector v a => (a -> a -> a) -> v a -> v a

-- | O(n) Right-to-left scan over a non-empty vector
scanr1 :: Vector v a => (a -> a -> a) -> v a -> v a

-- | O(n) Right-to-left scan over a non-empty vector with a strict
--   accumulator
scanr1' :: Vector v a => (a -> a -> a) -> v a -> v a

-- | Storable Vector. Import as:
--   
--   
--   import qualified RIO.Vector.Storable as VS
--   
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) Empty vector
empty :: Storable a => Vector a

-- | O(1) Vector with exactly one element
singleton :: Storable a => a -> Vector a

-- | O(n) 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 function n times to value. Zeroth element is
--   original value.
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 monadic function n times to value. Zeroth element is
--   original value.
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 f <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 f <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 0.1 5 = <1,1.1,1.2,1.3,1.4>
--   
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 at all
--   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 at all
--   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 will be
--   performed in place if it is safe to do so and will modify a copy of
--   the vector otherwise.
--   
--   
--   modify (\v -> write v 0 'x') (replicate 3 'a') = <'x','a','a'>
--   
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 elements that do not satisfy the predicate
filter :: Storable a => (a -> Bool) -> Vector a -> Vector a

-- | O(n) Drop elements that do not satisfy the predicate which is
--   applied to values and their indices
ifilter :: Storable a => (Int -> a -> Bool) -> Vector a -> Vector a

-- | O(n) Drop repeated adjacent elements.
uniq :: (Storable a, Eq a) => Vector a -> Vector a

-- | O(n) Drop elements when predicate returns Nothing
mapMaybe :: (Storable a, Storable b) => (a -> Maybe b) -> Vector a -> Vector b

-- | O(n) Drop elements when predicate, applied to index and value,
--   returns Nothing
imapMaybe :: (Storable a, Storable b) => (Int -> a -> Maybe b) -> Vector a -> Vector b

-- | O(n) Drop 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 without copying.
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 occurence 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 occurences 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 (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 (function applied to
--   each element and its index)
ifoldl' :: Storable b => (a -> Int -> b -> a) -> a -> Vector b -> a

-- | O(n) Right fold (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 (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.
all :: Storable a => (a -> Bool) -> Vector a -> Bool

-- | O(n) Check if any element satisfies the predicate.
any :: Storable a => (a -> Bool) -> Vector a -> Bool

-- | O(n) Check if all elements are True
and :: Vector Bool -> Bool

-- | O(n) Check if any element is True
or :: Vector Bool -> Bool

-- | O(n) Compute the sum of the elements
sum :: (Storable a, Num a) => Vector a -> a

-- | O(n) Compute the produce of the elements
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) Prescan
--   
--   
--   prescanl f z = init . scanl f z
--   
--   
--   Example: prescanl (+) 0 <1,2,3,4> = <0,1,3,6>
prescanl :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Prescan with strict accumulator
prescanl' :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Scan
--   
--   
--   postscanl f z = tail . scanl f z
--   
--   
--   Example: postscanl (+) 0 <1,2,3,4> = <1,3,6,10>
postscanl :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Scan with strict accumulator
postscanl' :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Haskell-style scan
--   
--   
--   scanl f z <x1,...,xn> = <y1,...,y(n+1)>
--     where y1 = z
--           yi = f y(i-1) x(i-1)
--   
--   
--   Example: scanl (+) 0 <1,2,3,4> = <0,1,3,6,10>
scanl :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Haskell-style 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 scan
postscanr :: (Storable a, Storable b) => (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left scan with strict accumulator
postscanr' :: (Storable a, Storable b) => (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left Haskell-style scan
scanr :: (Storable a, Storable b) => (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left Haskell-style 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
--   
--   
--   fromListN n xs = fromList (take n xs)
--   
fromListN :: Storable a => Int -> [a] -> Vector a

-- | O(n) Convert 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 the 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 ()

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 elements) 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, 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.
--   
--   
--   accum (+) <5,9,2> [(2,4),(1,6),(0,3),(1,7)] = <5+3, 9+6+7, 2+4>
--   
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.
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.
maximumBy :: Storable a => (a -> a -> Ordering) -> Vector a -> a

-- | O(n) Yield the minimum element of the vector. The vector may
--   not be empty.
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.
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.
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) Scan over a non-empty vector
--   
--   
--   scanl f <x1,...,xn> = <y1,...,yn>
--     where y1 = x1
--           yi = f y(i-1) xi
--   
scanl1 :: Storable a => (a -> a -> a) -> Vector a -> Vector a

-- | O(n) Scan over a non-empty vector with a strict accumulator
scanl1' :: Storable a => (a -> a -> a) -> Vector a -> Vector a

-- | O(n) Right-to-left scan over a non-empty vector
scanr1 :: Storable a => (a -> a -> a) -> Vector a -> Vector a

-- | O(n) Right-to-left scan over a non-empty vector with a strict
--   accumulator
scanr1' :: Storable a => (a -> a -> a) -> Vector a -> Vector a

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) Unsafe 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. The immutable vector may not be used after this
--   operation.
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 ForeignPtr 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 ForeignPtr afterwards.
unsafeFromForeignPtr0 :: Storable a => 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 :: Storable a => Vector a -> (ForeignPtr a, Int, Int)

-- | O(1) Yield the underlying ForeignPtr together with its
--   length.
--   
--   You can assume the pointer points directly to the data (no offset).
--   
--   The data may not be modified through the ForeignPtr.
unsafeToForeignPtr0 :: Storable a => 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
--   
module RIO.Vector.Unboxed
data family Vector a :: Type
data family MVector s a :: Type
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) Empty vector
empty :: Unbox a => Vector a

-- | O(1) Vector with exactly one element
singleton :: Unbox a => a -> Vector a

-- | O(n) 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 function n times to value. Zeroth element is
--   original value.
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 monadic function n times to value. Zeroth element is
--   original value.
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 f <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 f <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 0.1 5 = <1,1.1,1.2,1.3,1.4>
--   
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 at all
--   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 at all
--   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 will be
--   performed in place if it is safe to do so and will modify a copy of
--   the vector otherwise.
--   
--   
--   modify (\v -> write v 0 'x') (replicate 3 'a') = <'x','a','a'>
--   
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 elements that do not satisfy the predicate
filter :: Unbox a => (a -> Bool) -> Vector a -> Vector a

-- | O(n) Drop elements that do not satisfy the predicate which is
--   applied to values and their indices
ifilter :: Unbox a => (Int -> a -> Bool) -> Vector a -> Vector a

-- | O(n) Drop repeated adjacent elements.
uniq :: (Unbox a, Eq a) => Vector a -> Vector a

-- | O(n) Drop elements when predicate returns Nothing
mapMaybe :: (Unbox a, Unbox b) => (a -> Maybe b) -> Vector a -> Vector b

-- | O(n) Drop elements when predicate, applied to index and value,
--   returns Nothing
imapMaybe :: (Unbox a, Unbox b) => (Int -> a -> Maybe b) -> Vector a -> Vector b

-- | O(n) Drop 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 without copying.
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 occurence 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 occurences 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 (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 (function applied to
--   each element and its index)
ifoldl' :: Unbox b => (a -> Int -> b -> a) -> a -> Vector b -> a

-- | O(n) Right fold (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 (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.
all :: Unbox a => (a -> Bool) -> Vector a -> Bool

-- | O(n) Check if any element satisfies the predicate.
any :: Unbox a => (a -> Bool) -> Vector a -> Bool

-- | O(n) Check if all elements are True
and :: Vector Bool -> Bool

-- | O(n) Check if any element is True
or :: Vector Bool -> Bool

-- | O(n) Compute the sum of the elements
sum :: (Unbox a, Num a) => Vector a -> a

-- | O(n) Compute the produce of the elements
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 (action 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 (action 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 (action 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 (action applied to each element and its index)
ifoldM'_ :: (Monad m, Unbox b) => (a -> Int -> b -> m a) -> a -> Vector b -> m ()

-- | O(n) Prescan
--   
--   
--   prescanl f z = init . scanl f z
--   
--   
--   Example: prescanl (+) 0 <1,2,3,4> = <0,1,3,6>
prescanl :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Prescan with strict accumulator
prescanl' :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Scan
--   
--   
--   postscanl f z = tail . scanl f z
--   
--   
--   Example: postscanl (+) 0 <1,2,3,4> = <1,3,6,10>
postscanl :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Scan with strict accumulator
postscanl' :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Haskell-style scan
--   
--   
--   scanl f z <x1,...,xn> = <y1,...,y(n+1)>
--     where y1 = z
--           yi = f y(i-1) x(i-1)
--   
--   
--   Example: scanl (+) 0 <1,2,3,4> = <0,1,3,6,10>
scanl :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a

-- | O(n) Haskell-style 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 scan
postscanr :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left scan with strict accumulator
postscanr' :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left Haskell-style scan
scanr :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b

-- | O(n) Right-to-left Haskell-style 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
--   
--   
--   fromListN n xs = fromList (take n xs)
--   
fromListN :: Unbox a => Int -> [a] -> Vector a

-- | O(n) Convert 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 the 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 ()

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 elements) 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, 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.
--   
--   
--   accum (+) <5,9,2> [(2,4),(1,6),(0,3),(1,7)] = <5+3, 9+6+7, 2+4>
--   
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.
--   
--   
--   accumulate (+) <5,9,2> <(2,4),(1,6),(0,3),(1,7)> = <5+3, 9+6+7, 2+4>
--   
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.
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.
maximumBy :: Unbox a => (a -> a -> Ordering) -> Vector a -> a

-- | O(n) Yield the minimum element of the vector. The vector may
--   not be empty.
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.
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.
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.
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) Scan over a non-empty vector
--   
--   
--   scanl f <x1,...,xn> = <y1,...,yn>
--     where y1 = x1
--           yi = f y(i-1) xi
--   
scanl1 :: Unbox a => (a -> a -> a) -> Vector a -> Vector a

-- | O(n) Scan over a non-empty vector with a strict accumulator
scanl1' :: Unbox a => (a -> a -> a) -> Vector a -> Vector a

-- | O(n) Right-to-left scan over a non-empty vector
scanr1 :: Unbox a => (a -> a -> a) -> Vector a -> Vector a

-- | O(n) Right-to-left scan over a non-empty vector with a strict
--   accumulator
scanr1' :: Unbox a => (a -> a -> a) -> Vector a -> Vector a

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) Unsafe 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. The immutable vector may not be used after this
--   operation.
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 ()

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, PrimMonad m) => Mutable v (PrimState m) a -> m (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, PrimMonad m) => v a -> m (Mutable v (PrimState m) 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, Monad m) => v a -> Int -> m 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 basic on basicUnsafeIndexM and
--   basicUnsafeWrite.
basicUnsafeCopy :: (Vector v a, PrimMonad m) => Mutable v (PrimState m) a -> v a -> m ()

-- | 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. The 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) Unsafe 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. The immutable vector may not be used after this
--   operation.
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
