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


-- | Content addressable Haskell package management
--   
--   Please see the README on GitHub at
--   <a>https://github.com/commercialhaskell/pantry#readme</a>
@package pantry
@version 0.8.3


-- | Extensions to Aeson parsing of objects. This module is intended for
--   internal use by Pantry and Stack only. The intention is to fully
--   remove this module in the future. <i>DO NOT RELY ON IT</i>.
module Pantry.Internal.AesonExtended

-- | The result of running a <a>Parser</a>.
data () => Result a
Error :: String -> Result a
Success :: a -> Result a

-- | Options that specify how to encode/decode your datatype to/from JSON.
--   
--   Options can be set using record syntax on <a>defaultOptions</a> with
--   the fields below.
data () => Options

-- | A type-level indicator that <tt>ToJSON1</tt> or <tt>FromJSON1</tt> is
--   being derived generically.
data () => One
data () => Key

-- | A type that can be converted from JSON, with the possibility of
--   failure.
--   
--   In many cases, you can get the compiler to generate parsing code for
--   you (see below). To begin, let's cover writing an instance by hand.
--   
--   There are various reasons a conversion could fail. For example, an
--   <a>Object</a> could be missing a required key, an <a>Array</a> could
--   be of the wrong size, or a value could be of an incompatible type.
--   
--   The basic ways to signal a failed conversion are as follows:
--   
--   <ul>
--   <li><a>fail</a> yields a custom error message: it is the recommended
--   way of reporting a failure;</li>
--   <li><a>empty</a> (or <a>mzero</a>) is uninformative: use it when the
--   error is meant to be caught by some <tt>(<a>&lt;|&gt;</a>)</tt>;</li>
--   <li><a>typeMismatch</a> can be used to report a failure when the
--   encountered value is not of the expected JSON type; <a>unexpected</a>
--   is an appropriate alternative when more than one type may be expected,
--   or to keep the expected type implicit.</li>
--   </ul>
--   
--   <a>prependFailure</a> (or <a>modifyFailure</a>) add more information
--   to a parser's error messages.
--   
--   An example type and instance using <a>typeMismatch</a> and
--   <a>prependFailure</a>:
--   
--   <pre>
--   -- Allow ourselves to write <a>Text</a> literals.
--   {-# LANGUAGE OverloadedStrings #-}
--   
--   data Coord = Coord { x :: Double, y :: Double }
--   
--   instance <a>FromJSON</a> Coord where
--       <a>parseJSON</a> (<a>Object</a> v) = Coord
--           <a>&lt;$&gt;</a> v <a>.:</a> "x"
--           <a>&lt;*&gt;</a> v <a>.:</a> "y"
--   
--       -- We do not expect a non-<a>Object</a> value here.
--       -- We could use <a>empty</a> to fail, but <a>typeMismatch</a>
--       -- gives a much more informative error message.
--       <a>parseJSON</a> invalid    =
--           <a>prependFailure</a> "parsing Coord failed, "
--               (<a>typeMismatch</a> "Object" invalid)
--   </pre>
--   
--   For this common case of only being concerned with a single type of
--   JSON value, the functions <a>withObject</a>, <a>withScientific</a>,
--   etc. are provided. Their use is to be preferred when possible, since
--   they are more terse. Using <a>withObject</a>, we can rewrite the above
--   instance (assuming the same language extension and data type) as:
--   
--   <pre>
--   instance <a>FromJSON</a> Coord where
--       <a>parseJSON</a> = <a>withObject</a> "Coord" $ \v -&gt; Coord
--           <a>&lt;$&gt;</a> v <a>.:</a> "x"
--           <a>&lt;*&gt;</a> v <a>.:</a> "y"
--   </pre>
--   
--   Instead of manually writing your <a>FromJSON</a> instance, there are
--   two options to do it automatically:
--   
--   <ul>
--   <li><a>Data.Aeson.TH</a> provides Template Haskell functions which
--   will derive an instance at compile time. The generated instance is
--   optimized for your type so it will probably be more efficient than the
--   following option.</li>
--   <li>The compiler can provide a default generic implementation for
--   <a>parseJSON</a>.</li>
--   </ul>
--   
--   To use the second, simply add a <tt>deriving <a>Generic</a></tt>
--   clause to your datatype and declare a <a>FromJSON</a> instance for
--   your datatype without giving a definition for <a>parseJSON</a>.
--   
--   For example, the previous example can be simplified to just:
--   
--   <pre>
--   {-# LANGUAGE DeriveGeneric #-}
--   
--   import <a>GHC.Generics</a>
--   
--   data Coord = Coord { x :: Double, y :: Double } deriving <a>Generic</a>
--   
--   instance <a>FromJSON</a> Coord
--   </pre>
--   
--   or using the <a>DerivingVia extension</a>
--   
--   <pre>
--   deriving via <a>Generically</a> Coord instance <a>FromJSON</a> Coord
--   </pre>
--   
--   The default implementation will be equivalent to <tt>parseJSON =
--   <a>genericParseJSON</a> <a>defaultOptions</a></tt>; if you need
--   different options, you can customize the generic decoding by defining:
--   
--   <pre>
--   customOptions = <a>defaultOptions</a>
--                   { <a>fieldLabelModifier</a> = <a>map</a> <a>toUpper</a>
--                   }
--   
--   instance <a>FromJSON</a> Coord where
--       <a>parseJSON</a> = <a>genericParseJSON</a> customOptions
--   </pre>
class () => FromJSON a
parseJSON :: FromJSON a => Value -> Parser a
parseJSONList :: FromJSON a => Value -> Parser [a]

-- | A type that can be converted to JSON.
--   
--   Instances in general <i>must</i> specify <a>toJSON</a> and
--   <i>should</i> (but don't need to) specify <a>toEncoding</a>.
--   
--   An example type and instance:
--   
--   <pre>
--   -- Allow ourselves to write <a>Text</a> literals.
--   {-# LANGUAGE OverloadedStrings #-}
--   
--   data Coord = Coord { x :: Double, y :: Double }
--   
--   instance <a>ToJSON</a> Coord where
--     <a>toJSON</a> (Coord x y) = <a>object</a> ["x" <a>.=</a> x, "y" <a>.=</a> y]
--   
--     <a>toEncoding</a> (Coord x y) = <tt>pairs</tt> ("x" <a>.=</a> x <a>&lt;&gt;</a> "y" <a>.=</a> y)
--   </pre>
--   
--   Instead of manually writing your <a>ToJSON</a> instance, there are two
--   options to do it automatically:
--   
--   <ul>
--   <li><a>Data.Aeson.TH</a> provides Template Haskell functions which
--   will derive an instance at compile time. The generated instance is
--   optimized for your type so it will probably be more efficient than the
--   following option.</li>
--   <li>The compiler can provide a default generic implementation for
--   <a>toJSON</a>.</li>
--   </ul>
--   
--   To use the second, simply add a <tt>deriving <a>Generic</a></tt>
--   clause to your datatype and declare a <a>ToJSON</a> instance. If you
--   require nothing other than <a>defaultOptions</a>, it is sufficient to
--   write (and this is the only alternative where the default
--   <a>toJSON</a> implementation is sufficient):
--   
--   <pre>
--   {-# LANGUAGE DeriveGeneric #-}
--   
--   import <a>GHC.Generics</a>
--   
--   data Coord = Coord { x :: Double, y :: Double } deriving <a>Generic</a>
--   
--   instance <a>ToJSON</a> Coord where
--       <a>toEncoding</a> = <a>genericToEncoding</a> <a>defaultOptions</a>
--   </pre>
--   
--   or more conveniently using the <a>DerivingVia extension</a>
--   
--   <pre>
--   deriving via <a>Generically</a> Coord instance <a>ToJSON</a> Coord
--   </pre>
--   
--   If on the other hand you wish to customize the generic decoding, you
--   have to implement both methods:
--   
--   <pre>
--   customOptions = <a>defaultOptions</a>
--                   { <a>fieldLabelModifier</a> = <a>map</a> <a>toUpper</a>
--                   }
--   
--   instance <a>ToJSON</a> Coord where
--       <a>toJSON</a>     = <a>genericToJSON</a> customOptions
--       <a>toEncoding</a> = <a>genericToEncoding</a> customOptions
--   </pre>
--   
--   Previous versions of this library only had the <a>toJSON</a> method.
--   Adding <a>toEncoding</a> had two reasons:
--   
--   <ol>
--   <li><a>toEncoding</a> is more efficient for the common case that the
--   output of <a>toJSON</a> is directly serialized to a
--   <tt>ByteString</tt>. Further, expressing either method in terms of the
--   other would be non-optimal.</li>
--   <li>The choice of defaults allows a smooth transition for existing
--   users: Existing instances that do not define <a>toEncoding</a> still
--   compile and have the correct semantics. This is ensured by making the
--   default implementation of <a>toEncoding</a> use <a>toJSON</a>. This
--   produces correct results, but since it performs an intermediate
--   conversion to a <a>Value</a>, it will be less efficient than directly
--   emitting an <a>Encoding</a>. (this also means that specifying nothing
--   more than <tt>instance ToJSON Coord</tt> would be sufficient as a
--   generically decoding instance, but there probably exists no good
--   reason to not specify <a>toEncoding</a> in new instances.)</li>
--   </ol>
class () => ToJSON a

-- | Convert a Haskell value to a JSON-friendly intermediate type.
toJSON :: ToJSON a => a -> Value

-- | Encode a Haskell value as JSON.
--   
--   The default implementation of this method creates an intermediate
--   <a>Value</a> using <a>toJSON</a>. This provides source-level
--   compatibility for people upgrading from older versions of this
--   library, but obviously offers no performance advantage.
--   
--   To benefit from direct encoding, you <i>must</i> provide an
--   implementation for this method. The easiest way to do so is by having
--   your types implement <a>Generic</a> using the <tt>DeriveGeneric</tt>
--   extension, and then have GHC generate a method body as follows.
--   
--   <pre>
--   instance <a>ToJSON</a> Coord where
--       <a>toEncoding</a> = <a>genericToEncoding</a> <a>defaultOptions</a>
--   </pre>
toEncoding :: ToJSON a => a -> Encoding
toJSONList :: ToJSON a => [a] -> Value
toEncodingList :: ToJSON a => [a] -> Encoding

-- | A JSON "object" (key/value map).
type Object = KeyMap Value

-- | A JSON "array" (sequence).
type Array = Vector Value

-- | Lifting of the <a>FromJSON</a> class to unary type constructors.
--   
--   Instead of manually writing your <a>FromJSON1</a> instance, there are
--   two options to do it automatically:
--   
--   <ul>
--   <li><a>Data.Aeson.TH</a> provides Template Haskell functions which
--   will derive an instance at compile time. The generated instance is
--   optimized for your type so it will probably be more efficient than the
--   following option.</li>
--   <li>The compiler can provide a default generic implementation for
--   <a>liftParseJSON</a>.</li>
--   </ul>
--   
--   To use the second, simply add a <tt>deriving <a>Generic1</a></tt>
--   clause to your datatype and declare a <a>FromJSON1</a> instance for
--   your datatype without giving a definition for <a>liftParseJSON</a>.
--   
--   For example:
--   
--   <pre>
--   {-# LANGUAGE DeriveGeneric #-}
--   
--   import <a>GHC.Generics</a>
--   
--   data Pair a b = Pair { pairFst :: a, pairSnd :: b } deriving <a>Generic1</a>
--   
--   instance <a>FromJSON</a> a =&gt; <a>FromJSON1</a> (Pair a)
--   </pre>
--   
--   or
--   
--   <pre>
--   deriving via <a>Generically1</a> (Pair a) instance <a>FromJSON1</a> (Pair a)
--   </pre>
--   
--   If the default implementation doesn't give exactly the results you
--   want, you can customize the generic decoding with only a tiny amount
--   of effort, using <a>genericLiftParseJSON</a> with your preferred
--   <a>Options</a>:
--   
--   <pre>
--   customOptions = <a>defaultOptions</a>
--                   { <a>fieldLabelModifier</a> = <a>map</a> <a>toUpper</a>
--                   }
--   
--   instance <a>FromJSON</a> a =&gt; <a>FromJSON1</a> (Pair a) where
--       <a>liftParseJSON</a> = <a>genericLiftParseJSON</a> customOptions
--   </pre>
class () => FromJSON1 (f :: Type -> Type)
liftParseJSON :: FromJSON1 f => (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (f a)
liftParseJSONList :: FromJSON1 f => (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [f a]

-- | A type-level indicator that <tt>ToJSON</tt> or <tt>FromJSON</tt> is
--   being derived generically.
data () => Zero

-- | Options for encoding keys with <a>genericFromJSONKey</a> and
--   <a>genericToJSONKey</a>.
data () => JSONKeyOptions

-- | Specifies how to encode constructors of a sum datatype.
data () => SumEncoding

-- | A constructor will be encoded to an object with a field
--   <a>tagFieldName</a> which specifies the constructor tag (modified by
--   the <a>constructorTagModifier</a>). If the constructor is a record the
--   encoded record fields will be unpacked into this object. So make sure
--   that your record doesn't have a field with the same label as the
--   <a>tagFieldName</a>. Otherwise the tag gets overwritten by the encoded
--   value of that field! If the constructor is not a record the encoded
--   constructor contents will be stored under the <a>contentsFieldName</a>
--   field.
TaggedObject :: String -> String -> SumEncoding
[tagFieldName] :: SumEncoding -> String
[contentsFieldName] :: SumEncoding -> String

-- | Constructor names won't be encoded. Instead only the contents of the
--   constructor will be encoded as if the type had a single constructor.
--   JSON encodings have to be disjoint for decoding to work properly.
--   
--   When decoding, constructors are tried in the order of definition. If
--   some encodings overlap, the first one defined will succeed.
--   
--   <i>Note:</i> Nullary constructors are encoded as strings (using
--   <a>constructorTagModifier</a>). Having a nullary constructor alongside
--   a single field constructor that encodes to a string leads to
--   ambiguity.
--   
--   <i>Note:</i> Only the last error is kept when decoding, so in the case
--   of malformed JSON, only an error for the last constructor will be
--   reported.
UntaggedValue :: SumEncoding

-- | A constructor will be encoded to an object with a single field named
--   after the constructor tag (modified by the
--   <a>constructorTagModifier</a>) which maps to the encoded contents of
--   the constructor.
ObjectWithSingleField :: SumEncoding

-- | A constructor will be encoded to a 2-element array where the first
--   element is the tag of the constructor (modified by the
--   <a>constructorTagModifier</a>) and the second element the encoded
--   contents of the constructor.
TwoElemArray :: SumEncoding

-- | A newtype wrapper for <a>UTCTime</a> that uses the same non-standard
--   serialization format as Microsoft .NET, whose <a>System.DateTime</a>
--   type is by default serialized to JSON as in the following example:
--   
--   <pre>
--   /Date(1302547608878)/
--   </pre>
--   
--   The number represents milliseconds since the Unix epoch.
newtype () => DotNetTime
DotNetTime :: UTCTime -> DotNetTime

-- | Acquire the underlying value.
[fromDotNetTime] :: DotNetTime -> UTCTime

-- | A JSON value represented as a Haskell value.
data () => Value
Object :: !Object -> Value
Array :: !Array -> Value
String :: !Text -> Value
Number :: !Scientific -> Value
Bool :: !Bool -> Value
Null :: Value
type JSONPath = [JSONPathElement]

-- | Lifting of the <a>FromJSON</a> class to binary type constructors.
--   
--   Instead of manually writing your <a>FromJSON2</a> instance,
--   <a>Data.Aeson.TH</a> provides Template Haskell functions which will
--   derive an instance at compile time.
class () => FromJSON2 (f :: Type -> Type -> Type)
liftParseJSON2 :: FromJSON2 f => (Value -> Parser a) -> (Value -> Parser [a]) -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser (f a b)
liftParseJSONList2 :: FromJSON2 f => (Value -> Parser a) -> (Value -> Parser [a]) -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser [f a b]
class (ConstructorNames f, SumFromString f) => GFromJSONKey (f :: Type -> Type)

-- | This type is related to <tt>ToJSONKeyFunction</tt>. If
--   <a>FromJSONKeyValue</a> is used in the <a>FromJSONKey</a> instance,
--   then <tt>ToJSONKeyValue</tt> should be used in the <tt>ToJSONKey</tt>
--   instance. The other three data constructors for this type all
--   correspond to <tt>ToJSONKeyText</tt>. Strictly speaking,
--   <a>FromJSONKeyTextParser</a> is more powerful than
--   <a>FromJSONKeyText</a>, which is in turn more powerful than
--   <a>FromJSONKeyCoerce</a>. For performance reasons, these exist as
--   three options instead of one.
data () => FromJSONKeyFunction a
[FromJSONKeyCoerce] :: forall a. Coercible Text a => FromJSONKeyFunction a
[FromJSONKeyText] :: forall a. !Text -> a -> FromJSONKeyFunction a
[FromJSONKeyTextParser] :: forall a. !Text -> Parser a -> FromJSONKeyFunction a
[FromJSONKeyValue] :: forall a. !Value -> Parser a -> FromJSONKeyFunction a

-- | Read the docs for <tt>ToJSONKey</tt> first. This class is a conversion
--   in the opposite direction. If you have a newtype wrapper around
--   <a>Text</a>, the recommended way to define instances is with
--   generalized newtype deriving:
--   
--   <pre>
--   newtype SomeId = SomeId { getSomeId :: Text }
--     deriving (Eq,Ord,Hashable,FromJSONKey)
--   </pre>
--   
--   If you have a sum of nullary constructors, you may use the generic
--   implementation:
--   
--   <pre>
--   data Color = Red | Green | Blue
--     deriving Generic
--   
--   instance <a>FromJSONKey</a> Color where
--     <a>fromJSONKey</a> = <a>genericFromJSONKey</a> <a>defaultJSONKeyOptions</a>
--   </pre>
class () => FromJSONKey a

-- | Strategy for parsing the key of a map-like container.
fromJSONKey :: FromJSONKey a => FromJSONKeyFunction a

-- | This is similar in spirit to the <a>readList</a> method of
--   <a>Read</a>. It makes it possible to give <a>Value</a> keys special
--   treatment without using <tt>OverlappingInstances</tt>. End users
--   should always be able to use the default implementation of this
--   method.
fromJSONKeyList :: FromJSONKey a => FromJSONKeyFunction [a]

-- | A <a>FromArgs</a> value either stores nothing (for <a>FromJSON</a>) or
--   it stores the two function arguments that decode occurrences of the
--   type parameter (for <a>FromJSON1</a>).
data () => FromArgs arity a

-- | Class of generic representation types that can be converted from JSON.
class () => GFromJSON arity (f :: Type -> Type)

-- | A series of values that, when encoded, should be separated by commas.
--   Since 0.11.0.0, the <tt>.=</tt> operator is overloaded to create
--   either <tt>(Text, Value)</tt> or <a>Series</a>. You can use Series
--   when encoding directly to a bytestring builder as in the following
--   example:
--   
--   <pre>
--   toEncoding (Person name age) = pairs ("name" .= name &lt;&gt; "age" .= age)
--   </pre>
data () => Series

-- | Often used synonym for <a>Encoding'</a>.
type Encoding = Encoding' Value

-- | Lifting of the <a>ToJSON</a> class to binary type constructors.
--   
--   Instead of manually writing your <a>ToJSON2</a> instance,
--   <a>Data.Aeson.TH</a> provides Template Haskell functions which will
--   derive an instance at compile time.
--   
--   The compiler cannot provide a default generic implementation for
--   <a>liftToJSON2</a>, unlike <a>toJSON</a> and <a>liftToJSON</a>.
class () => ToJSON2 (f :: Type -> Type -> Type)
liftToJSON2 :: ToJSON2 f => (a -> Value) -> ([a] -> Value) -> (b -> Value) -> ([b] -> Value) -> f a b -> Value
liftToJSONList2 :: ToJSON2 f => (a -> Value) -> ([a] -> Value) -> (b -> Value) -> ([b] -> Value) -> [f a b] -> Value
liftToEncoding2 :: ToJSON2 f => (a -> Encoding) -> ([a] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> f a b -> Encoding
liftToEncodingList2 :: ToJSON2 f => (a -> Encoding) -> ([a] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> [f a b] -> Encoding

-- | Lifting of the <a>ToJSON</a> class to unary type constructors.
--   
--   Instead of manually writing your <a>ToJSON1</a> instance, there are
--   two options to do it automatically:
--   
--   <ul>
--   <li><a>Data.Aeson.TH</a> provides Template Haskell functions which
--   will derive an instance at compile time. The generated instance is
--   optimized for your type so it will probably be more efficient than the
--   following option.</li>
--   <li>The compiler can provide a default generic implementation for
--   <a>toJSON1</a>.</li>
--   </ul>
--   
--   To use the second, simply add a <tt>deriving <a>Generic1</a></tt>
--   clause to your datatype and declare a <a>ToJSON1</a> instance for your
--   datatype without giving definitions for <a>liftToJSON</a> or
--   <a>liftToEncoding</a>.
--   
--   For example:
--   
--   <pre>
--   {-# LANGUAGE DeriveGeneric #-}
--   
--   import <a>GHC.Generics</a>
--   
--   data Pair a b = Pair { pairFst :: a, pairSnd :: b } deriving <a>Generic1</a>
--   
--   instance <a>ToJSON</a> a =&gt; <a>ToJSON1</a> (Pair a)
--   </pre>
--   
--   If the default implementation doesn't give exactly the results you
--   want, you can customize the generic encoding with only a tiny amount
--   of effort, using <a>genericLiftToJSON</a> and
--   <a>genericLiftToEncoding</a> with your preferred <a>Options</a>:
--   
--   <pre>
--   customOptions = <a>defaultOptions</a>
--                   { <a>fieldLabelModifier</a> = <a>map</a> <a>toUpper</a>
--                   }
--   
--   instance <a>ToJSON</a> a =&gt; <a>ToJSON1</a> (Pair a) where
--       <a>liftToJSON</a>     = <a>genericLiftToJSON</a> customOptions
--       <a>liftToEncoding</a> = <a>genericLiftToEncoding</a> customOptions
--   </pre>
--   
--   See also <a>ToJSON</a>.
class () => ToJSON1 (f :: Type -> Type)
liftToJSON :: ToJSON1 f => (a -> Value) -> ([a] -> Value) -> f a -> Value
liftToJSONList :: ToJSON1 f => (a -> Value) -> ([a] -> Value) -> [f a] -> Value
liftToEncoding :: ToJSON1 f => (a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
liftToEncodingList :: ToJSON1 f => (a -> Encoding) -> ([a] -> Encoding) -> [f a] -> Encoding
class GetConName f => GToJSONKey (f :: k -> Type)
data () => ToJSONKeyFunction a

-- | key is encoded to string, produces object
ToJSONKeyText :: !a -> Key -> !a -> Encoding' Key -> ToJSONKeyFunction a

-- | key is encoded to value, produces array
ToJSONKeyValue :: !a -> Value -> !a -> Encoding -> ToJSONKeyFunction a

-- | Typeclass for types that can be used as the key of a map-like
--   container (like <tt>Map</tt> or <tt>HashMap</tt>). For example, since
--   <a>Text</a> has a <a>ToJSONKey</a> instance and <a>Char</a> has a
--   <a>ToJSON</a> instance, we can encode a value of type <tt>Map</tt>
--   <a>Text</a> <a>Char</a>:
--   
--   <pre>
--   &gt;&gt;&gt; LBC8.putStrLn $ encode $ Map.fromList [("foo" :: Text, 'a')]
--   {"foo":"a"}
--   </pre>
--   
--   Since <a>Int</a> also has a <a>ToJSONKey</a> instance, we can
--   similarly write:
--   
--   <pre>
--   &gt;&gt;&gt; LBC8.putStrLn $ encode $ Map.fromList [(5 :: Int, 'a')]
--   {"5":"a"}
--   </pre>
--   
--   JSON documents only accept strings as object keys. For any type from
--   <tt>base</tt> that has a natural textual representation, it can be
--   expected that its <a>ToJSONKey</a> instance will choose that
--   representation.
--   
--   For data types that lack a natural textual representation, an
--   alternative is provided. The map-like container is represented as a
--   JSON array instead of a JSON object. Each value in the array is an
--   array with exactly two values. The first is the key and the second is
--   the value.
--   
--   For example, values of type '[Text]' cannot be encoded to a string, so
--   a <tt>Map</tt> with keys of type '[Text]' is encoded as follows:
--   
--   <pre>
--   &gt;&gt;&gt; LBC8.putStrLn $ encode $ Map.fromList [(["foo","bar","baz" :: Text], 'a')]
--   [[["foo","bar","baz"],"a"]]
--   </pre>
--   
--   The default implementation of <a>ToJSONKey</a> chooses this method of
--   encoding a key, using the <a>ToJSON</a> instance of the type.
--   
--   To use your own data type as the key in a map, all that is needed is
--   to write a <a>ToJSONKey</a> (and possibly a <tt>FromJSONKey</tt>)
--   instance for it. If the type cannot be trivially converted to and from
--   <a>Text</a>, it is recommended that <a>ToJSONKeyValue</a> is used.
--   Since the default implementations of the typeclass methods can build
--   this from a <a>ToJSON</a> instance, there is nothing that needs to be
--   written:
--   
--   <pre>
--   data Foo = Foo { fooAge :: Int, fooName :: Text }
--     deriving (Eq,Ord,Generic)
--   instance ToJSON Foo
--   instance ToJSONKey Foo
--   </pre>
--   
--   That's it. We can now write:
--   
--   <pre>
--   &gt;&gt;&gt; let m = Map.fromList [(Foo 4 "bar",'a'),(Foo 6 "arg",'b')]
--   
--   &gt;&gt;&gt; LBC8.putStrLn $ encode m
--   [[{"fooName":"bar","fooAge":4},"a"],[{"fooName":"arg","fooAge":6},"b"]]
--   </pre>
--   
--   The next case to consider is if we have a type that is a newtype
--   wrapper around <a>Text</a>. The recommended approach is to use
--   generalized newtype deriving:
--   
--   <pre>
--   newtype RecordId = RecordId { getRecordId :: Text }
--     deriving (Eq,Ord,ToJSONKey)
--   </pre>
--   
--   Then we may write:
--   
--   <pre>
--   &gt;&gt;&gt; LBC8.putStrLn $ encode $ Map.fromList [(RecordId "abc",'a')]
--   {"abc":"a"}
--   </pre>
--   
--   Simple sum types are a final case worth considering. Suppose we have:
--   
--   <pre>
--   data Color = Red | Green | Blue
--     deriving (Show,Read,Eq,Ord)
--   </pre>
--   
--   It is possible to get the <a>ToJSONKey</a> instance for free as we did
--   with <tt>Foo</tt>. However, in this case, we have a natural way to go
--   to and from <a>Text</a> that does not require any escape sequences. So
--   <a>ToJSONKeyText</a> can be used instead of <a>ToJSONKeyValue</a> to
--   encode maps as objects instead of arrays of pairs. This instance may
--   be implemented using generics as follows:
--   
--   <pre>
--   instance <a>ToJSONKey</a> Color where
--     <a>toJSONKey</a> = <a>genericToJSONKey</a> <a>defaultJSONKeyOptions</a>
--   </pre>
--   
--   <h3><b>Low-level implementations</b></h3>
--   
--   The <a>Show</a> instance can be used to help write <a>ToJSONKey</a>:
--   
--   <pre>
--   instance ToJSONKey Color where
--     toJSONKey = ToJSONKeyText f g
--       where f = Text.pack . show
--             g = text . Text.pack . show
--             -- text function is from Data.Aeson.Encoding
--   </pre>
--   
--   The situation of needing to turning function <tt>a -&gt; Text</tt>
--   into a <a>ToJSONKeyFunction</a> is common enough that a special
--   combinator is provided for it. The above instance can be rewritten as:
--   
--   <pre>
--   instance ToJSONKey Color where
--     toJSONKey = toJSONKeyText (Text.pack . show)
--   </pre>
--   
--   The performance of the above instance can be improved by not using
--   <a>Value</a> as an intermediate step when converting to <a>Text</a>.
--   One option for improving performance would be to use template haskell
--   machinery from the <tt>text-show</tt> package. However, even with the
--   approach, the <a>Encoding</a> (a wrapper around a bytestring builder)
--   is generated by encoding the <a>Text</a> to a <tt>ByteString</tt>, an
--   intermediate step that could be avoided. The fastest possible
--   implementation would be:
--   
--   <pre>
--   -- Assuming that OverloadedStrings is enabled
--   instance ToJSONKey Color where
--     toJSONKey = ToJSONKeyText f g
--       where f x = case x of {Red -&gt; "Red";Green -&gt;"Green";Blue -&gt; "Blue"}
--             g x = case x of {Red -&gt; text "Red";Green -&gt; text "Green";Blue -&gt; text "Blue"}
--             -- text function is from Data.Aeson.Encoding
--   </pre>
--   
--   This works because GHC can lift the encoded values out of the case
--   statements, which means that they are only evaluated once. This
--   approach should only be used when there is a serious need to maximize
--   performance.
class () => ToJSONKey a

-- | Strategy for rendering the key for a map-like container.
toJSONKey :: ToJSONKey a => ToJSONKeyFunction a

-- | This is similar in spirit to the <tt>showsList</tt> method of
--   <a>Show</a>. It makes it possible to give <a>Value</a> keys special
--   treatment without using <tt>OverlappingInstances</tt>. End users
--   should always be able to use the default implementation of this
--   method.
toJSONKeyList :: ToJSONKey a => ToJSONKeyFunction [a]

-- | A key-value pair for encoding a JSON object.
class () => KeyValue kv
(.=) :: (KeyValue kv, ToJSON v) => Key -> v -> kv
infixr 8 .=

-- | A <a>ToArgs</a> value either stores nothing (for <a>ToJSON</a>) or it
--   stores the two function arguments that encode occurrences of the type
--   parameter (for <a>ToJSON1</a>).
data () => ToArgs res arity a

-- | Class of generic representation types that can be converted to JSON.
class () => GToJSON' enc arity (f :: Type -> Type)
type GToEncoding = GToJSON' Encoding
type GToJSON = GToJSON' Value

-- | Exception thrown by <a>throwDecode</a> and variants.
newtype () => AesonException
AesonException :: String -> AesonException

-- | Add JSON Path context to a parser
--   
--   When parsing a complex structure, it helps to annotate (sub)parsers
--   with context, so that if an error occurs, you can find its location.
--   
--   <pre>
--   withObject "Person" $ \o -&gt;
--     Person
--       &lt;$&gt; o .: "name" &lt;?&gt; Key "name"
--       &lt;*&gt; o .: "age"  &lt;?&gt; Key "age"
--   </pre>
--   
--   (Standard methods like <tt>(.:)</tt> already do this.)
--   
--   With such annotations, if an error occurs, you will get a JSON Path
--   location of that error.
--   
--   Since 0.10
(<?>) :: Parser a -> JSONPathElement -> Parser a

-- | Efficiently serialize a JSON value as a lazy <a>ByteString</a>.
--   
--   This is implemented in terms of the <a>ToJSON</a> class's
--   <a>toEncoding</a> method.
encode :: ToJSON a => a -> ByteString

-- | Efficiently deserialize a JSON value from a lazy <a>ByteString</a>. If
--   this fails due to incomplete or invalid input, <a>Nothing</a> is
--   returned.
--   
--   The input must consist solely of a JSON document, with no trailing
--   data except for whitespace.
--   
--   This function parses immediately, but defers conversion. See
--   <a>json</a> for details.
decode :: FromJSON a => ByteString -> Maybe a

-- | Efficiently serialize a JSON value as a lazy <a>ByteString</a> and
--   write it to a file.
encodeFile :: ToJSON a => FilePath -> a -> IO ()

-- | <a>fromJSONKey</a> for <a>Generic</a> types. These types must be sums
--   of nullary constructors, whose names will be used as keys for JSON
--   objects.
--   
--   See also <tt>genericToJSONKey</tt>.
--   
--   <h3><b>Example</b></h3>
--   
--   <pre>
--   data Color = Red | Green | Blue
--     deriving <a>Generic</a>
--   
--   instance <a>FromJSONKey</a> Color where
--     <a>fromJSONKey</a> = <a>genericFromJSONKey</a> <a>defaultJSONKeyOptions</a>
--   </pre>
genericFromJSONKey :: (Generic a, GFromJSONKey (Rep a)) => JSONKeyOptions -> FromJSONKeyFunction a
genericToJSONKey :: (Generic a, GToJSONKey (Rep a)) => JSONKeyOptions -> ToJSONKeyFunction a

-- | Convert a value from JSON, failing if the types do not match.
fromJSON :: FromJSON a => Value -> Result a

-- | A configurable generic JSON creator. This function applied to
--   <a>defaultOptions</a> is used as the default for <a>toJSON</a> when
--   the type is an instance of <a>Generic</a>.
genericToJSON :: (Generic a, GToJSON' Value Zero (Rep a)) => Options -> a -> Value

-- | Create a <a>Value</a> from a list of name/value <a>Pair</a>s. If
--   duplicate keys arise, later keys and their associated values win.
object :: [Pair] -> Value

-- | Default encoding <a>Options</a>:
--   
--   <pre>
--   <a>Options</a>
--   { <a>fieldLabelModifier</a>      = id
--   , <a>constructorTagModifier</a>  = id
--   , <a>allNullaryToStringTag</a>   = True
--   , <a>omitNothingFields</a>       = False
--   , <a>sumEncoding</a>             = <a>defaultTaggedObject</a>
--   , <a>unwrapUnaryRecords</a>      = False
--   , <a>tagSingleConstructors</a>   = False
--   , <a>rejectUnknownFields</a>     = False
--   }
--   </pre>
defaultOptions :: Options

-- | Default <a>TaggedObject</a> <a>SumEncoding</a> options:
--   
--   <pre>
--   defaultTaggedObject = <a>TaggedObject</a>
--                         { <a>tagFieldName</a>      = "tag"
--                         , <a>contentsFieldName</a> = "contents"
--                         }
--   </pre>
defaultTaggedObject :: SumEncoding

-- | Default <a>JSONKeyOptions</a>:
--   
--   <pre>
--   defaultJSONKeyOptions = <a>JSONKeyOptions</a>
--                           { <a>keyModifier</a> = <a>id</a>
--                           }
--   </pre>
defaultJSONKeyOptions :: JSONKeyOptions

-- | Better version of <a>camelTo</a>. Example where it works better:
--   
--   <pre>
--   camelTo '_' "CamelAPICase" == "camel_apicase"
--   camelTo2 '_' "CamelAPICase" == "camel_api_case"
--   </pre>
camelTo2 :: Char -> String -> String

-- | Parse any JSON value.
--   
--   The conversion of a parsed value to a Haskell value is deferred until
--   the Haskell value is needed. This may improve performance if only a
--   subset of the results of conversions are needed, but at a cost in
--   thunk allocation.
--   
--   This function is an alias for <a>value</a>. In aeson 0.8 and earlier,
--   it parsed only object or array types, in conformance with the
--   now-obsolete RFC 4627.
--   
--   <h4>Warning</h4>
--   
--   If an object contains duplicate keys, only the first one will be kept.
--   For a more flexible alternative, see <a>jsonWith</a>.
json :: Parser Value

-- | Parse any JSON value.
--   
--   This is a strict version of <a>json</a> which avoids building up
--   thunks during parsing; it performs all conversions immediately. Prefer
--   this version if most of the JSON data needs to be accessed.
--   
--   This function is an alias for <a>value'</a>. In aeson 0.8 and earlier,
--   it parsed only object or array types, in conformance with the
--   now-obsolete RFC 4627.
--   
--   <h4>Warning</h4>
--   
--   If an object contains duplicate keys, only the first one will be kept.
--   For a more flexible alternative, see <a>jsonWith'</a>.
json' :: Parser Value
parseIndexedJSON :: (Value -> Parser a) -> Int -> Value -> Parser a

-- | A configurable generic JSON decoder. This function applied to
--   <a>defaultOptions</a> is used as the default for <a>parseJSON</a> when
--   the type is an instance of <a>Generic</a>.
genericParseJSON :: (Generic a, GFromJSON Zero (Rep a)) => Options -> Value -> Parser a

-- | A configurable generic JSON decoder. This function applied to
--   <a>defaultOptions</a> is used as the default for <a>liftParseJSON</a>
--   when the type is an instance of <a>Generic1</a>.
genericLiftParseJSON :: (Generic1 f, GFromJSON One (Rep1 f)) => Options -> (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (f a)

-- | Lift the standard <a>parseJSON</a> function through the type
--   constructor.
parseJSON1 :: (FromJSON1 f, FromJSON a) => Value -> Parser (f a)

-- | Lift the standard <a>parseJSON</a> function through the type
--   constructor.
parseJSON2 :: (FromJSON2 f, FromJSON a, FromJSON b) => Value -> Parser (f a b)

-- | <tt><a>withObject</a> name f value</tt> applies <tt>f</tt> to the
--   <a>Object</a> when <tt>value</tt> is an <a>Object</a> and fails
--   otherwise.
--   
--   <h4>Error message example</h4>
--   
--   <pre>
--   withObject "MyType" f (String "oops")
--   -- Error: "parsing MyType failed, expected Object, but encountered String"
--   </pre>
withObject :: String -> (Object -> Parser a) -> Value -> Parser a

-- | <tt><a>withText</a> name f value</tt> applies <tt>f</tt> to the
--   <a>Text</a> when <tt>value</tt> is a <a>String</a> and fails
--   otherwise.
--   
--   <h4>Error message example</h4>
--   
--   <pre>
--   withText "MyType" f Null
--   -- Error: "parsing MyType failed, expected String, but encountered Null"
--   </pre>
withText :: String -> (Text -> Parser a) -> Value -> Parser a

-- | <tt><a>withArray</a> expected f value</tt> applies <tt>f</tt> to the
--   <a>Array</a> when <tt>value</tt> is an <a>Array</a> and fails
--   otherwise.
--   
--   <h4>Error message example</h4>
--   
--   <pre>
--   withArray "MyType" f (String "oops")
--   -- Error: "parsing MyType failed, expected Array, but encountered String"
--   </pre>
withArray :: String -> (Array -> Parser a) -> Value -> Parser a

-- | <tt><a>withScientific</a> name f value</tt> applies <tt>f</tt> to the
--   <a>Scientific</a> number when <tt>value</tt> is a <a>Number</a> and
--   fails using <a>typeMismatch</a> otherwise.
--   
--   <i>Warning</i>: If you are converting from a scientific to an
--   unbounded type such as <a>Integer</a> you may want to add a
--   restriction on the size of the exponent (see
--   <a>withBoundedScientific</a>) to prevent malicious input from filling
--   up the memory of the target system.
--   
--   <h4>Error message example</h4>
--   
--   <pre>
--   withScientific "MyType" f (String "oops")
--   -- Error: "parsing MyType failed, expected Number, but encountered String"
--   </pre>
withScientific :: String -> (Scientific -> Parser a) -> Value -> Parser a

-- | <tt><a>withBool</a> expected f value</tt> applies <tt>f</tt> to the
--   <a>Value</a> when <tt>value</tt> is a <tt>Boolean</tt> and fails
--   otherwise.
--   
--   <h4>Error message example</h4>
--   
--   <pre>
--   withBool "MyType" f (String "oops")
--   -- Error: "parsing MyType failed, expected Boolean, but encountered String"
--   </pre>
withBool :: String -> (Bool -> Parser a) -> Value -> Parser a

-- | Decode a nested JSON-encoded string.
withEmbeddedJSON :: String -> (Value -> Parser a) -> Value -> Parser a

-- | Retrieve the value associated with the given key of an <a>Object</a>.
--   The result is <a>Nothing</a> if the key is not present or
--   <tt>empty</tt> if the value cannot be converted to the desired type.
--   
--   This differs from <a>.:?</a> by attempting to parse <a>Null</a> the
--   same as any other JSON value, instead of interpreting it as
--   <a>Nothing</a>.
(.:!) :: FromJSON a => Object -> Key -> Parser (Maybe a)

-- | Helper for use in combination with <a>.:?</a> to provide default
--   values for optional JSON object fields.
--   
--   This combinator is most useful if the key and value can be absent from
--   an object without affecting its validity and we know a default value
--   to assign in that case. If the key and value are mandatory, use
--   <a>.:</a> instead.
--   
--   Example usage:
--   
--   <pre>
--   v1 &lt;- o <a>.:?</a> "opt_field_with_dfl" .!= "default_val"
--   v2 &lt;- o <a>.:</a>  "mandatory_field"
--   v3 &lt;- o <a>.:?</a> "opt_field2"
--   </pre>
(.!=) :: Parser (Maybe a) -> a -> Parser a

-- | Acquire the underlying bytestring builder.
fromEncoding :: Encoding' tag -> Builder

-- | Encode a series of key/value pairs, separated by commas.
pairs :: Series -> Encoding

-- | A configurable generic JSON creator. This function applied to
--   <a>defaultOptions</a> is used as the default for <a>liftToJSON</a>
--   when the type is an instance of <a>Generic1</a>.
genericLiftToJSON :: (Generic1 f, GToJSON' Value One (Rep1 f)) => Options -> (a -> Value) -> ([a] -> Value) -> f a -> Value

-- | A configurable generic JSON encoder. This function applied to
--   <a>defaultOptions</a> is used as the default for <a>toEncoding</a>
--   when the type is an instance of <a>Generic</a>.
genericToEncoding :: (Generic a, GToJSON' Encoding Zero (Rep a)) => Options -> a -> Encoding

-- | A configurable generic JSON encoder. This function applied to
--   <a>defaultOptions</a> is used as the default for <a>liftToEncoding</a>
--   when the type is an instance of <a>Generic1</a>.
genericLiftToEncoding :: (Generic1 f, GToJSON' Encoding One (Rep1 f)) => Options -> (a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding

-- | Lift the standard <a>toJSON</a> function through the type constructor.
toJSON1 :: (ToJSON1 f, ToJSON a) => f a -> Value

-- | Lift the standard <a>toEncoding</a> function through the type
--   constructor.
toEncoding1 :: (ToJSON1 f, ToJSON a) => f a -> Encoding

-- | Lift the standard <a>toJSON</a> function through the type constructor.
toJSON2 :: (ToJSON2 f, ToJSON a, ToJSON b) => f a b -> Value

-- | Lift the standard <a>toEncoding</a> function through the type
--   constructor.
toEncoding2 :: (ToJSON2 f, ToJSON a, ToJSON b) => f a b -> Encoding

-- | Encode a <a>Foldable</a> as a JSON array.
foldable :: (Foldable t, ToJSON a) => t a -> Encoding

-- | Efficiently deserialize a JSON value from a strict <a>ByteString</a>.
--   If this fails due to incomplete or invalid input, <a>Nothing</a> is
--   returned.
--   
--   The input must consist solely of a JSON document, with no trailing
--   data except for whitespace.
--   
--   This function parses immediately, but defers conversion. See
--   <a>json</a> for details.
decodeStrict :: FromJSON a => ByteString -> Maybe a

-- | Efficiently deserialize a JSON value from a file. If this fails due to
--   incomplete or invalid input, <a>Nothing</a> is returned.
--   
--   The input file's content must consist solely of a JSON document, with
--   no trailing data except for whitespace.
--   
--   This function parses immediately, but defers conversion. See
--   <a>json</a> for details.
decodeFileStrict :: FromJSON a => FilePath -> IO (Maybe a)

-- | Efficiently deserialize a JSON value from a lazy <a>ByteString</a>. If
--   this fails due to incomplete or invalid input, <a>Nothing</a> is
--   returned.
--   
--   The input must consist solely of a JSON document, with no trailing
--   data except for whitespace.
--   
--   This function parses and performs conversion immediately. See
--   <a>json'</a> for details.
decode' :: FromJSON a => ByteString -> Maybe a

-- | Efficiently deserialize a JSON value from a strict <a>ByteString</a>.
--   If this fails due to incomplete or invalid input, <a>Nothing</a> is
--   returned.
--   
--   The input must consist solely of a JSON document, with no trailing
--   data except for whitespace.
--   
--   This function parses and performs conversion immediately. See
--   <a>json'</a> for details.
decodeStrict' :: FromJSON a => ByteString -> Maybe a

-- | Efficiently deserialize a JSON value from a file. If this fails due to
--   incomplete or invalid input, <a>Nothing</a> is returned.
--   
--   The input file's content must consist solely of a JSON document, with
--   no trailing data except for whitespace.
--   
--   This function parses and performs conversion immediately. See
--   <a>json'</a> for details.
decodeFileStrict' :: FromJSON a => FilePath -> IO (Maybe a)

-- | Like <a>decode</a> but returns an error message when decoding fails.
eitherDecode :: FromJSON a => ByteString -> Either String a

-- | Like <a>decodeStrict</a> but returns an error message when decoding
--   fails.
eitherDecodeStrict :: FromJSON a => ByteString -> Either String a

-- | Like <a>decodeFileStrict</a> but returns an error message when
--   decoding fails.
eitherDecodeFileStrict :: FromJSON a => FilePath -> IO (Either String a)

-- | Like <a>decode'</a> but returns an error message when decoding fails.
eitherDecode' :: FromJSON a => ByteString -> Either String a

-- | Like <a>decodeStrict'</a> but returns an error message when decoding
--   fails.
eitherDecodeStrict' :: FromJSON a => ByteString -> Either String a

-- | Like <a>decodeFileStrict'</a> but returns an error message when
--   decoding fails.
eitherDecodeFileStrict' :: FromJSON a => FilePath -> IO (Either String a)

-- | Like <a>decode</a> but throws an <a>AesonException</a> when decoding
--   fails.
--   
--   <pre>
--   &gt;&gt;&gt; throwDecode "42" :: Maybe Int
--   Just 42
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; throwDecode "42" :: IO Int
--   42
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; throwDecode "true" :: IO Int
--   ...Exception: AesonException...
--   </pre>
throwDecode :: (FromJSON a, MonadThrow m) => ByteString -> m a

-- | Like <a>decodeStrict</a> but throws an <a>AesonException</a> when
--   decoding fails.
throwDecodeStrict :: (FromJSON a, MonadThrow m) => ByteString -> m a

-- | Like <a>decode'</a> but throws an <a>AesonException</a> when decoding
--   fails.
throwDecode' :: (FromJSON a, MonadThrow m) => ByteString -> m a

-- | Like <a>decodeStrict'</a> but throws an <a>AesonException</a> when
--   decoding fails.
throwDecodeStrict' :: (FromJSON a, MonadThrow m) => ByteString -> m a

-- | Extends <tt>.:</tt> warning to include field name.
(.:) :: FromJSON a => Object -> Text -> Parser a

-- | Extends <tt>.:?</tt> warning to include field name.
(.:?) :: FromJSON a => Object -> Text -> Parser (Maybe a)

-- | Warning output from <a>WarningParser</a>.
data JSONWarning
JSONUnrecognizedFields :: String -> [Text] -> JSONWarning
JSONGeneralWarning :: !Text -> JSONWarning

-- | JSON parser that warns about unexpected fields in objects.
type WarningParser a = WriterT WarningParserMonoid Parser a
data WithJSONWarnings a
WithJSONWarnings :: a -> [JSONWarning] -> WithJSONWarnings a

-- | <a>WarningParser</a> version of <a>withObject</a>.
withObjectWarnings :: String -> (Object -> WarningParser a) -> Value -> Parser (WithJSONWarnings a)

-- | Handle warnings in a sub-object.
jsonSubWarnings :: WarningParser (WithJSONWarnings a) -> WarningParser a

-- | Handle warnings in a <tt>Traversable</tt> of sub-objects.
jsonSubWarningsT :: Traversable t => WarningParser (t (WithJSONWarnings a)) -> WarningParser (t a)

-- | Handle warnings in a <tt>Maybe Traversable</tt> of sub-objects.
jsonSubWarningsTT :: (Traversable t, Traversable u) => WarningParser (u (t (WithJSONWarnings a))) -> WarningParser (u (t a))

-- | Log JSON warnings.
logJSONWarnings :: (MonadReader env m, HasLogFunc env, HasCallStack, MonadIO m) => FilePath -> [JSONWarning] -> m ()
noJSONWarnings :: a -> WithJSONWarnings a

-- | Tell warning parser about an expected field, so it doesn't warn about
--   it.
tellJSONField :: Text -> WarningParser ()

-- | Convert a <a>WarningParser</a> to a <a>Parser</a>.
unWarningParser :: WarningParser a -> Parser a

-- | <a>WarningParser</a> version of <tt>.:</tt>.
(..:) :: FromJSON a => Object -> Text -> WarningParser a

-- | Synonym version of <tt>..:</tt>.
(...:) :: FromJSON a => Object -> [Text] -> WarningParser a

-- | <a>WarningParser</a> version of <tt>.:?</tt>.
(..:?) :: FromJSON a => Object -> Text -> WarningParser (Maybe a)

-- | Synonym version of <tt>..:?</tt>.
(...:?) :: FromJSON a => Object -> [Text] -> WarningParser (Maybe a)

-- | <a>WarningParser</a> version of <tt>.!=</tt>.
(..!=) :: WarningParser (Maybe a) -> a -> WarningParser a
instance GHC.Classes.Eq Pantry.Internal.AesonExtended.JSONWarning
instance GHC.Show.Show a => GHC.Show.Show (Pantry.Internal.AesonExtended.WithJSONWarnings a)
instance GHC.Generics.Generic (Pantry.Internal.AesonExtended.WithJSONWarnings a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Pantry.Internal.AesonExtended.WithJSONWarnings a)
instance GHC.Generics.Generic Pantry.Internal.AesonExtended.WarningParserMonoid
instance GHC.Base.Semigroup Pantry.Internal.AesonExtended.WarningParserMonoid
instance GHC.Base.Monoid Pantry.Internal.AesonExtended.WarningParserMonoid
instance Data.String.IsString Pantry.Internal.AesonExtended.WarningParserMonoid
instance GHC.Base.Functor Pantry.Internal.AesonExtended.WithJSONWarnings
instance GHC.Base.Monoid a => GHC.Base.Semigroup (Pantry.Internal.AesonExtended.WithJSONWarnings a)
instance GHC.Base.Monoid a => GHC.Base.Monoid (Pantry.Internal.AesonExtended.WithJSONWarnings a)
instance Data.Aeson.Types.FromJSON.FromJSON (Pantry.Internal.AesonExtended.WithJSONWarnings RIO.PrettyPrint.StylesUpdate.StylesUpdate)
instance GHC.Show.Show Pantry.Internal.AesonExtended.JSONWarning
instance RIO.Prelude.Display.Display Pantry.Internal.AesonExtended.JSONWarning
instance Data.String.IsString Pantry.Internal.AesonExtended.JSONWarning


-- | Companion threads, such as for printing messages saying we're still
--   busy. Ultimately this could be put into its own package. This is a
--   non-standard API for use by Pantry and Stack, please <i>DO NOT DEPEND
--   ON IT</i>.
module Pantry.Internal.Companion

-- | Keep running the <a>Companion</a> action until either the inner action
--   completes or calls the <a>StopCompanion</a> action. This can be used
--   to give the user status information while running a long running
--   operations.
withCompanion :: forall m a. MonadUnliftIO m => Companion m -> (StopCompanion m -> m a) -> m a

-- | When a delay was interrupted because we're told to stop, perform this
--   action.
onCompanionDone :: MonadUnliftIO m => m () -> m () -> m ()

-- | A companion thread which can perform arbitrary actions as well as
--   delay
type Companion m = Delay -> m ()

-- | Delay the given number of microseconds. If <a>StopCompanion</a> is
--   triggered before the timer completes, a <a>CompanionDone</a> exception
--   will be thrown (which is caught internally by <a>withCompanion</a>).
type Delay = forall mio. MonadIO mio => Int -> mio ()

-- | Tell the <a>Companion</a> to stop. The next time <a>Delay</a> is
--   called, or if a <a>Delay</a> is currently blocking, the
--   <a>Companion</a> thread will exit with a <a>CompanionDone</a>
--   exception.
type StopCompanion m = m ()
instance GHC.Show.Show Pantry.Internal.Companion.CompanionDone
instance GHC.Exception.Type.Exception Pantry.Internal.Companion.CompanionDone


-- | This is an unstable API, exposed only for testing. Relying on this may
--   break your code! Caveat emptor.
--   
--   This module can (and perhaps should) be separate into its own package,
--   it's generally useful.
module Pantry.Internal.StaticBytes
data Bytes8
data Bytes16
data Bytes32
data Bytes64
data Bytes128
class DynamicBytes dbytes
class StaticBytes sbytes
data StaticBytesException
NotEnoughBytes :: StaticBytesException
TooManyBytes :: StaticBytesException
toStaticExact :: forall dbytes sbytes. (DynamicBytes dbytes, StaticBytes sbytes) => dbytes -> Either StaticBytesException sbytes
toStaticPad :: forall dbytes sbytes. (DynamicBytes dbytes, StaticBytes sbytes) => dbytes -> Either StaticBytesException sbytes
toStaticTruncate :: forall dbytes sbytes. (DynamicBytes dbytes, StaticBytes sbytes) => dbytes -> Either StaticBytesException sbytes
toStaticPadTruncate :: (DynamicBytes dbytes, StaticBytes sbytes) => dbytes -> sbytes
fromStatic :: forall dbytes sbytes. (DynamicBytes dbytes, StaticBytes sbytes) => sbytes -> dbytes
instance Data.Data.Data Pantry.Internal.StaticBytes.Bytes8
instance Data.Hashable.Class.Hashable Pantry.Internal.StaticBytes.Bytes8
instance Control.DeepSeq.NFData Pantry.Internal.StaticBytes.Bytes8
instance GHC.Generics.Generic Pantry.Internal.StaticBytes.Bytes8
instance GHC.Classes.Ord Pantry.Internal.StaticBytes.Bytes8
instance GHC.Classes.Eq Pantry.Internal.StaticBytes.Bytes8
instance Data.Data.Data Pantry.Internal.StaticBytes.Bytes16
instance Data.Hashable.Class.Hashable Pantry.Internal.StaticBytes.Bytes16
instance Control.DeepSeq.NFData Pantry.Internal.StaticBytes.Bytes16
instance GHC.Generics.Generic Pantry.Internal.StaticBytes.Bytes16
instance GHC.Classes.Ord Pantry.Internal.StaticBytes.Bytes16
instance GHC.Classes.Eq Pantry.Internal.StaticBytes.Bytes16
instance GHC.Show.Show Pantry.Internal.StaticBytes.Bytes16
instance Data.Data.Data Pantry.Internal.StaticBytes.Bytes32
instance Data.Hashable.Class.Hashable Pantry.Internal.StaticBytes.Bytes32
instance Control.DeepSeq.NFData Pantry.Internal.StaticBytes.Bytes32
instance GHC.Generics.Generic Pantry.Internal.StaticBytes.Bytes32
instance GHC.Classes.Ord Pantry.Internal.StaticBytes.Bytes32
instance GHC.Classes.Eq Pantry.Internal.StaticBytes.Bytes32
instance GHC.Show.Show Pantry.Internal.StaticBytes.Bytes32
instance Data.Data.Data Pantry.Internal.StaticBytes.Bytes64
instance Data.Hashable.Class.Hashable Pantry.Internal.StaticBytes.Bytes64
instance Control.DeepSeq.NFData Pantry.Internal.StaticBytes.Bytes64
instance GHC.Generics.Generic Pantry.Internal.StaticBytes.Bytes64
instance GHC.Classes.Ord Pantry.Internal.StaticBytes.Bytes64
instance GHC.Classes.Eq Pantry.Internal.StaticBytes.Bytes64
instance GHC.Show.Show Pantry.Internal.StaticBytes.Bytes64
instance Data.Data.Data Pantry.Internal.StaticBytes.Bytes128
instance Data.Hashable.Class.Hashable Pantry.Internal.StaticBytes.Bytes128
instance Control.DeepSeq.NFData Pantry.Internal.StaticBytes.Bytes128
instance GHC.Generics.Generic Pantry.Internal.StaticBytes.Bytes128
instance GHC.Classes.Ord Pantry.Internal.StaticBytes.Bytes128
instance GHC.Classes.Eq Pantry.Internal.StaticBytes.Bytes128
instance GHC.Show.Show Pantry.Internal.StaticBytes.Bytes128
instance GHC.Classes.Eq Pantry.Internal.StaticBytes.StaticBytesException
instance GHC.Show.Show Pantry.Internal.StaticBytes.StaticBytesException
instance Pantry.Internal.StaticBytes.StaticBytes Pantry.Internal.StaticBytes.Bytes8
instance Pantry.Internal.StaticBytes.StaticBytes Pantry.Internal.StaticBytes.Bytes16
instance Pantry.Internal.StaticBytes.StaticBytes Pantry.Internal.StaticBytes.Bytes32
instance Pantry.Internal.StaticBytes.StaticBytes Pantry.Internal.StaticBytes.Bytes64
instance Pantry.Internal.StaticBytes.StaticBytes Pantry.Internal.StaticBytes.Bytes128
instance GHC.Show.Show Pantry.Internal.StaticBytes.Bytes8
instance Pantry.Internal.StaticBytes.DynamicBytes Data.ByteString.Internal.Type.ByteString
instance (word8 GHC.Types.~ GHC.Word.Word8) => Pantry.Internal.StaticBytes.DynamicBytes (Data.Vector.Storable.Vector word8)
instance (word8 GHC.Types.~ GHC.Word.Word8) => Pantry.Internal.StaticBytes.DynamicBytes (Data.Vector.Primitive.Vector word8)
instance (word8 GHC.Types.~ GHC.Word.Word8) => Pantry.Internal.StaticBytes.DynamicBytes (Data.Vector.Unboxed.Base.Vector word8)
instance GHC.Exception.Type.Exception Pantry.Internal.StaticBytes.StaticBytesException
instance Data.ByteArray.Types.ByteArrayAccess Pantry.Internal.StaticBytes.Bytes128
instance Data.ByteArray.Types.ByteArrayAccess Pantry.Internal.StaticBytes.Bytes64
instance Data.ByteArray.Types.ByteArrayAccess Pantry.Internal.StaticBytes.Bytes32
instance Data.ByteArray.Types.ByteArrayAccess Pantry.Internal.StaticBytes.Bytes16
instance Data.ByteArray.Types.ByteArrayAccess Pantry.Internal.StaticBytes.Bytes8


-- | Provides a data type (<a>SHA256</a>) for efficient memory
--   representation of a sha-256 hash value, together with helper functions
--   for converting to and from that value. This module is intended to be
--   imported qualified as <tt>SHA256</tt>.
--   
--   Some nomenclature:
--   
--   <ul>
--   <li>Hashing calculates a new hash value from some input. <tt>from</tt>
--   takes a value that represents an existing hash.</li>
--   <li>Raw means a raw binary representation of the hash value, without
--   any hex encoding.</li>
--   <li>Text always uses lower case hex encoding</li>
--   </ul>
module Pantry.SHA256

-- | A SHA256 hash, stored in a static size for more efficient memory
--   representation.
data SHA256

-- | Exceptions which can occur in this module
data SHA256Exception
InvalidByteCount :: !ByteString -> !StaticBytesException -> SHA256Exception
InvalidHexBytes :: !ByteString -> !Text -> SHA256Exception

-- | Generate a <a>SHA256</a> value by hashing the contents of a file.
hashFile :: MonadIO m => FilePath -> m SHA256

-- | Generate a <a>SHA256</a> value by hashing a <tt>ByteString</tt>.
hashBytes :: ByteString -> SHA256

-- | Generate a <a>SHA256</a> value by hashing a lazy <tt>ByteString</tt>.
hashLazyBytes :: LByteString -> SHA256

-- | Generate a <a>SHA256</a> value by hashing the contents of a stream.
sinkHash :: Monad m => ConduitT ByteString o m SHA256

-- | Convert a base16-encoded <a>Text</a> value containing a hash into a
--   <a>SHA256</a>.
fromHexText :: Text -> Either SHA256Exception SHA256

-- | Convert a base16-encoded <a>ByteString</a> value containing a hash
--   into a <a>SHA256</a>.
fromHexBytes :: ByteString -> Either SHA256Exception SHA256

-- | Convert a <a>Digest</a> into a <a>SHA256</a>
fromDigest :: Digest SHA256 -> SHA256

-- | Convert a raw representation of a hash into a <a>SHA256</a>.
fromRaw :: ByteString -> Either SHA256Exception SHA256

-- | Convert a <a>SHA256</a> into a base16-encoded SHA256 hash.
toHexText :: SHA256 -> Text

-- | Convert a <a>SHA256</a> into a base16-encoded SHA256 hash.
toHexBytes :: SHA256 -> ByteString

-- | Convert a <a>SHA256</a> into a raw binary representation.
toRaw :: SHA256 -> ByteString
instance Data.Hashable.Class.Hashable Pantry.SHA256.SHA256
instance GHC.Classes.Ord Pantry.SHA256.SHA256
instance Data.Data.Data Pantry.SHA256.SHA256
instance Control.DeepSeq.NFData Pantry.SHA256.SHA256
instance GHC.Classes.Eq Pantry.SHA256.SHA256
instance GHC.Generics.Generic Pantry.SHA256.SHA256
instance GHC.Exception.Type.Exception Pantry.SHA256.SHA256Exception
instance GHC.Show.Show Pantry.SHA256.SHA256Exception
instance RIO.Prelude.Display.Display Pantry.SHA256.SHA256Exception
instance GHC.Show.Show Pantry.SHA256.SHA256
instance Database.Persist.Class.PersistField.PersistField Pantry.SHA256.SHA256
instance Database.Persist.Sql.Class.PersistFieldSql Pantry.SHA256.SHA256
instance RIO.Prelude.Display.Display Pantry.SHA256.SHA256
instance Data.Aeson.Types.ToJSON.ToJSON Pantry.SHA256.SHA256
instance Data.Aeson.Types.FromJSON.FromJSON Pantry.SHA256.SHA256


-- | Exposed for testing, do not use!
module Pantry.Internal
parseTree :: ByteString -> Maybe Tree
renderTree :: Tree -> ByteString

-- | Represents the contents of a tree, which is a mapping from relative
--   file paths to <a>TreeEntry</a>s.
newtype Tree
TreeMap :: Map SafeFilePath TreeEntry -> Tree
data TreeEntry
TreeEntry :: !BlobKey -> !FileType -> TreeEntry
[teBlob] :: TreeEntry -> !BlobKey
[teType] :: TreeEntry -> !FileType
data FileType
FTNormal :: FileType
FTExecutable :: FileType
mkSafeFilePath :: Text -> Maybe SafeFilePath
pcHpackExecutable :: PantryConfig -> HpackExecutable

-- | Like <tt>System.FilePath.normalise</tt>, however:
--   
--   <ul>
--   <li>Only works on relative paths, absolute paths fail</li>
--   <li>Strips trailing slashes</li>
--   <li>Only works on forward slashes, even on Windows</li>
--   <li>Normalizes parent dirs <tt>foo<i>..</i></tt> get stripped</li>
--   <li>Cannot begin with a parent directory (<tt>../</tt>)</li>
--   <li>Spelled like an American, sorry</li>
--   </ul>
normalizeParents :: FilePath -> Either String FilePath

-- | Following tar file rules (Unix file paths only), make the second file
--   relative to the first file.
makeTarRelative :: FilePath -> FilePath -> Either String FilePath

-- | Get the path to the global hints cache file
getGlobalHintsFile :: HasPantryConfig env => RIO env (Path Abs File)
hpackVersion :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RIO env Version

-- | Represents a SQL database connection. This used to be a newtype
--   wrapper around a connection pool. However, when investigating
--   <a>https://github.com/commercialhaskell/stack/issues/4471</a>, it
--   appeared that holding a pool resulted in overly long write locks being
--   held on the database. As a result, we now abstract away whether a pool
--   is used, and the default implementation in <a>Pantry.Storage</a> does
--   not use a pool.
data Storage
initStorage :: HasLogFunc env => Text -> Migration -> Path Abs File -> (Storage -> RIO env a) -> RIO env a
withStorage_ :: Storage -> forall env a. HasLogFunc env => ReaderT SqlBackend (RIO env) a -> RIO env a


-- | All types and functions exported from this module are for advanced
--   usage only. They are needed for stackage-server integration with
--   pantry.
module Pantry.Internal.Stackage
data Version
data PackageName

-- | By default, a backend will automatically generate the key Instead you
--   can specify a Primary key made up of unique values.
data family Key record

-- | Unique keys besides the <a>Key</a>.
data family Unique record
data Tree
Tree :: !BlobId -> !Maybe BlobId -> !FileType -> !PackageNameId -> !VersionId -> Tree
[treeKey] :: Tree -> !BlobId
[treeCabal] :: Tree -> !Maybe BlobId
[treeCabalType] :: Tree -> !FileType
[treeName] :: Tree -> !PackageNameId
[treeVersion] :: Tree -> !VersionId

-- | An <a>EntityField</a> is parameterised by the Haskell record it
--   belongs to and the additional type of that field.
--   
--   As of <tt>persistent-2.11.0.0</tt>, it's possible to use the
--   <tt>OverloadedLabels</tt> language extension to refer to
--   <a>EntityField</a> values polymorphically. See the documentation on
--   <a>SymbolToField</a> for more information.
data family EntityField record :: Type -> Type

-- | Configuration value used by the entire pantry package. Create one
--   using <tt>withPantryConfig</tt> or <tt>withPantryConfig'</tt>. See
--   also <tt>PantryApp</tt> for a convenience approach to using pantry.
data PantryConfig
PantryConfig :: !PackageIndexConfig -> !HpackExecutable -> !Path Abs Dir -> !Storage -> !MVar Bool -> !IORef (Map RawPackageLocationImmutable GenericPackageDescription) -> !IORef (Map (Path Abs Dir) (PrintWarnings -> IO GenericPackageDescription, PackageName, Path Abs File)) -> !Int -> !Maybe (CasaRepoPrefix, Int) -> (SnapName -> RawSnapshotLocation) -> PantryConfig
[pcPackageIndex] :: PantryConfig -> !PackageIndexConfig
[pcHpackExecutable] :: PantryConfig -> !HpackExecutable
[pcRootDir] :: PantryConfig -> !Path Abs Dir
[pcStorage] :: PantryConfig -> !Storage

-- | Want to try updating the index once during a single run for missing
--   package identifiers. We also want to ensure we only update once at a
--   time. Start at <tt>True</tt>.
[pcUpdateRef] :: PantryConfig -> !MVar Bool

-- | Cache of previously parsed cabal files, to save on slow parsing time.
[pcParsedCabalFilesRawImmutable] :: PantryConfig -> !IORef (Map RawPackageLocationImmutable GenericPackageDescription)

-- | Cache for mutable packages. We want to allow for an optimization:
--   deferring parsing of the <a>GenericPackageDescription</a> until its
--   actually needed. Therefore, we keep the filepath and the
--   <a>PackageName</a> derived from that filepath. When the <tt>IO
--   GenericPackageDescription</tt> is run, it will ensure that the
--   <tt>PackageName</tt> matches the value inside the cabal file, and
--   print out any warnings that still need to be printed.
[pcParsedCabalFilesMutable] :: PantryConfig -> !IORef (Map (Path Abs Dir) (PrintWarnings -> IO GenericPackageDescription, PackageName, Path Abs File))

-- | concurrently open downloads
[pcConnectionCount] :: PantryConfig -> !Int

-- | Optionally, the Casa pull URL e.g.
--   <tt><a>https://casa.fpcomplete.com</a></tt> and the maximum number of
--   Casa keys to pull per request.
[pcCasaConfig] :: PantryConfig -> !Maybe (CasaRepoPrefix, Int)

-- | The location of snapshot synonyms
[pcSnapshotLocation] :: PantryConfig -> SnapName -> RawSnapshotLocation
data SafeFilePath

-- | Represents a SQL database connection. This used to be a newtype
--   wrapper around a connection pool. However, when investigating
--   <a>https://github.com/commercialhaskell/stack/issues/4471</a>, it
--   appeared that holding a pool resulted in overly long write locks being
--   held on the database. As a result, we now abstract away whether a pool
--   is used, and the default implementation in <a>Pantry.Storage</a> does
--   not use a pool.
data Storage
Storage :: (forall env a. HasLogFunc env => ReaderT SqlBackend (RIO env) a -> RIO env a) -> (forall env a. HasLogFunc env => RIO env a -> RIO env a) -> Storage
[withStorage_] :: Storage -> forall env a. HasLogFunc env => ReaderT SqlBackend (RIO env) a -> RIO env a
[withWriteLock_] :: Storage -> forall env a. HasLogFunc env => RIO env a -> RIO env a

-- | Information returned by <a>getHackageTarball</a>
data HackageTarballResult
HackageTarballResult :: !Package -> !Maybe (GenericPackageDescription, TreeId) -> HackageTarballResult

-- | Package that was loaded from Hackage tarball
[htrPackage] :: HackageTarballResult -> !Package

-- | This information is only available whenever package was just loaded
--   into pantry.
[htrFreshPackageInfo] :: HackageTarballResult -> !Maybe (GenericPackageDescription, TreeId)
type BlobId = Key Blob
type HackageCabalId = Key HackageCabal
type ModuleNameId = Key ModuleName
type PackageNameId = Key PackageName
type TreeEntryId = Key TreeEntry
type TreeId = Key Tree
type VersionId = Key Version
newtype ModuleNameP
ModuleNameP :: ModuleName -> ModuleNameP
[unModuleNameP] :: ModuleNameP -> ModuleName
newtype PackageNameP
PackageNameP :: PackageName -> PackageNameP
[unPackageNameP] :: PackageNameP -> PackageName
newtype VersionP
VersionP :: Version -> VersionP
[unVersionP] :: VersionP -> Version
mkSafeFilePath :: Text -> Maybe SafeFilePath

-- | Same as <a>updateHackageIndex</a>, but force the database update even
--   if hackage security tells that there is no change. This can be useful
--   in order to make sure the database is in sync with the locally
--   downloaded tarball
forceUpdateHackageIndex :: (HasPantryConfig env, HasLogFunc env) => Maybe Utf8Builder -> RIO env DidUpdateOccur
getHackageTarball :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => PackageIdentifierRevision -> Maybe TreeKey -> RIO env HackageTarballResult
allBlobsCount :: Maybe BlobId -> ReaderT SqlBackend (RIO env) Int
allBlobsSource :: HasResourceMap env => Maybe BlobId -> ConduitT () (BlobId, ByteString) (ReaderT SqlBackend (RIO env)) ()
allHackageCabalCount :: Maybe HackageCabalId -> ReaderT SqlBackend (RIO env) Int

-- | Pull all hackage cabal entries from the database as
--   <tt>RawPackageLocationImmutable</tt>. We do a manual join rather than
--   dropping to raw SQL, and Esqueleto would add more deps.
allHackageCabalRawPackageLocations :: HasResourceMap env => Maybe HackageCabalId -> ReaderT SqlBackend (RIO env) (Map HackageCabalId RawPackageLocationImmutable)
getBlobKey :: BlobId -> ReaderT SqlBackend (RIO env) BlobKey
getPackageNameById :: PackageNameId -> ReaderT SqlBackend (RIO env) (Maybe PackageName)
getPackageNameId :: PackageName -> ReaderT SqlBackend (RIO env) PackageNameId
getTreeForKey :: TreeKey -> ReaderT SqlBackend (RIO env) (Maybe (Entity Tree))
getVersionId :: Version -> ReaderT SqlBackend (RIO env) VersionId
loadBlobById :: BlobId -> ReaderT SqlBackend (RIO env) ByteString
migrateAll :: Migration
storeBlob :: ByteString -> ReaderT SqlBackend (RIO env) (BlobId, BlobKey)

-- | The <a>TreeKey</a> containing this package.
--   
--   This is a hash of the binary representation of <a>packageTree</a>.
packageTreeKey :: Package -> TreeKey
unSafeFilePath :: SafeFilePath -> Text


-- | Content addressable Haskell package management, providing for secure,
--   reproducible acquisition of Haskell package contents and metadata.
module Pantry

-- | Configuration value used by the entire pantry package. Create one
--   using <tt>withPantryConfig</tt> or <tt>withPantryConfig'</tt>. See
--   also <tt>PantryApp</tt> for a convenience approach to using pantry.
data PantryConfig

-- | Configuration to securely download package metadata and contents. For
--   most purposes, you'll want to use the default Hackage settings via
--   <tt>defaultPackageIndexConfig</tt>.
--   
--   <i>NOTE</i> It's highly recommended to only use the official Hackage
--   server or a mirror. See
--   <a>https://github.com/commercialhaskell/stack/issues/4137</a>.
data PackageIndexConfig
PackageIndexConfig :: !Text -> !HackageSecurityConfig -> PackageIndexConfig
[picDownloadPrefix] :: PackageIndexConfig -> !Text
[picHackageSecurityConfig] :: PackageIndexConfig -> !HackageSecurityConfig

-- | Configuration for Hackage Security to securely download package
--   metadata and contents. For most purposes, you'll want to use the
--   default Hackage settings via <tt>defaultHackageSecurityConfig</tt>.
--   
--   <i>NOTE</i> It's highly recommended to only use the official Hackage
--   server or a mirror. See
--   <a>https://github.com/commercialhaskell/stack/issues/4137</a>.
data HackageSecurityConfig
HackageSecurityConfig :: ![Text] -> !Int -> !Bool -> HackageSecurityConfig
[hscKeyIds] :: HackageSecurityConfig -> ![Text]
[hscKeyThreshold] :: HackageSecurityConfig -> !Int
[hscIgnoreExpiry] :: HackageSecurityConfig -> !Bool

-- | Default <a>PackageIndexConfig</a> value using the official Hackage
--   server.
defaultPackageIndexConfig :: PackageIndexConfig

-- | The download prefix for the official Hackage server.
defaultDownloadPrefix :: Text

-- | Default <a>HackageSecurityConfig</a> value using the official Hackage
--   server. The value of the <a>hscIgnoreExpiry</a> field is <a>True</a>.
defaultHackageSecurityConfig :: HackageSecurityConfig

-- | Default pull URL for Casa.
defaultCasaRepoPrefix :: CasaRepoPrefix

-- | Default max keys to pull per request.
defaultCasaMaxPerRequest :: Int

-- | Default location of snapshot synonyms, i.e. commercialhaskell's GitHub
--   repository.
defaultSnapshotLocation :: SnapName -> RawSnapshotLocation

-- | An environment which contains a <a>PantryConfig</a>.
class HasPantryConfig env

-- | Lens to get or set the <a>PantryConfig</a>
pantryConfigL :: HasPantryConfig env => Lens' env PantryConfig

-- | Create a new <a>PantryConfig</a> with the given settings. For a
--   version where the use of Casa (content-addressable storage archive) is
--   optional, see <a>withPantryConfig'</a>.
--   
--   For something easier to use in simple cases, see <a>runPantryApp</a>.
withPantryConfig :: HasLogFunc env => Path Abs Dir -> PackageIndexConfig -> HpackExecutable -> Int -> CasaRepoPrefix -> Int -> (SnapName -> RawSnapshotLocation) -> (PantryConfig -> RIO env a) -> RIO env a

-- | Create a new <a>PantryConfig</a> with the given settings.
--   
--   For something easier to use in simple cases, see <a>runPantryApp</a>.
withPantryConfig' :: HasLogFunc env => Path Abs Dir -> PackageIndexConfig -> HpackExecutable -> Int -> Maybe (CasaRepoPrefix, Int) -> (SnapName -> RawSnapshotLocation) -> (PantryConfig -> RIO env a) -> RIO env a

-- | What to use for running hpack
data HpackExecutable

-- | Compiled in library
HpackBundled :: HpackExecutable

-- | Executable at the provided path
HpackCommand :: !FilePath -> HpackExecutable

-- | Convenient data type that allows you to work with pantry more easily
--   than using <a>withPantryConfig</a> or <a>withPantryConfig'</a>
--   directly. Uses basically sane settings, like sharing a pantry
--   directory with Stack.
--   
--   You can use <a>runPantryApp</a> to use this.
data PantryApp

-- | Run some code against pantry using basic sane settings.
--   
--   For testing, see <a>runPantryAppClean</a>.
runPantryApp :: MonadIO m => RIO PantryApp a -> m a

-- | Like <a>runPantryApp</a>, but uses an empty pantry directory instead
--   of sharing with Stack. Useful for testing.
runPantryAppClean :: MonadIO m => RIO PantryApp a -> m a

-- | Run some code against pantry using basic sane settings.
--   
--   For testing, see <a>runPantryAppClean</a>.
runPantryAppWith :: MonadIO m => Int -> CasaRepoPrefix -> Int -> RIO PantryApp a -> m a

-- | Lens to view or modify the <a>HpackExecutable</a> of a
--   <a>PantryConfig</a>
hpackExecutableL :: Lens' PantryConfig HpackExecutable

-- | Things that can go wrong in pantry. Note two things:
--   
--   <ul>
--   <li>Many other exception types may be thrown from underlying
--   libraries. Pantry does not attempt to wrap these underlying
--   exceptions.</li>
--   <li>We may add more constructors to this data type in minor version
--   bumps of pantry. This technically breaks the PVP. You should not be
--   writing pattern matches against this type that expect total
--   matching.</li>
--   </ul>
data PantryException
PackageIdentifierRevisionParseFail :: !Text -> PantryException
InvalidCabalFile :: !Either RawPackageLocationImmutable (Path Abs File) -> !Maybe Version -> ![PError] -> ![PWarning] -> PantryException
TreeWithoutCabalFile :: !RawPackageLocationImmutable -> PantryException
TreeWithMultipleCabalFiles :: !RawPackageLocationImmutable -> ![SafeFilePath] -> PantryException
MismatchedCabalName :: !Path Abs File -> !PackageName -> PantryException
NoLocalPackageDirFound :: !Path Abs Dir -> PantryException
NoCabalFileFound :: !Path Abs Dir -> PantryException
MultipleCabalFilesFound :: !Path Abs Dir -> ![Path Abs File] -> PantryException
InvalidWantedCompiler :: !Text -> PantryException
InvalidSnapshotLocation :: !Path Abs Dir -> !Text -> PantryException
InvalidOverrideCompiler :: !WantedCompiler -> !WantedCompiler -> PantryException
InvalidFilePathSnapshot :: !Text -> PantryException
InvalidSnapshot :: !RawSnapshotLocation -> !SomeException -> PantryException
MismatchedPackageMetadata :: !RawPackageLocationImmutable -> !RawPackageMetadata -> !Maybe TreeKey -> !PackageIdentifier -> PantryException
Non200ResponseStatus :: !Status -> PantryException
InvalidBlobKey :: !Mismatch BlobKey -> PantryException
Couldn'tParseSnapshot :: !RawSnapshotLocation -> !String -> PantryException
WrongCabalFileName :: !RawPackageLocationImmutable -> !SafeFilePath -> !PackageName -> PantryException
DownloadInvalidSHA256 :: !Text -> !Mismatch SHA256 -> PantryException
DownloadInvalidSize :: !Text -> !Mismatch FileSize -> PantryException

-- | Different from <a>DownloadInvalidSize</a> since <a>mismatchActual</a>
--   is a lower bound on the size from the server.
DownloadTooLarge :: !Text -> !Mismatch FileSize -> PantryException
LocalInvalidSHA256 :: !Path Abs File -> !Mismatch SHA256 -> PantryException
LocalInvalidSize :: !Path Abs File -> !Mismatch FileSize -> PantryException
UnknownArchiveType :: !ArchiveLocation -> PantryException
InvalidTarFileType :: !ArchiveLocation -> !FilePath -> !FileType -> PantryException
UnsupportedTarball :: !ArchiveLocation -> !Text -> PantryException
NoHackageCryptographicHash :: !PackageIdentifier -> PantryException
FailedToCloneRepo :: !SimpleRepo -> PantryException
TreeReferencesMissingBlob :: !RawPackageLocationImmutable -> !SafeFilePath -> !BlobKey -> PantryException
CompletePackageMetadataMismatch :: !RawPackageLocationImmutable -> !PackageMetadata -> PantryException
CRC32Mismatch :: !ArchiveLocation -> !FilePath -> !Mismatch Word32 -> PantryException
UnknownHackagePackage :: !PackageIdentifierRevision -> !FuzzyResults -> PantryException
CannotCompleteRepoNonSHA1 :: !Repo -> PantryException
MutablePackageLocationFromUrl :: !Text -> PantryException
MismatchedCabalFileForHackage :: !PackageIdentifierRevision -> !Mismatch PackageIdentifier -> PantryException
PackageNameParseFail :: !Text -> PantryException
PackageVersionParseFail :: !Text -> PantryException
InvalidCabalFilePath :: !Path Abs File -> PantryException
DuplicatePackageNames :: !Utf8Builder -> ![(PackageName, [RawPackageLocationImmutable])] -> PantryException
MigrationFailure :: !Text -> !Path Abs File -> !SomeException -> PantryException
NoCasaConfig :: PantryException
InvalidTreeFromCasa :: !BlobKey -> !ByteString -> PantryException
ParseSnapNameException :: !Text -> PantryException
HpackLibraryException :: !Path Abs File -> !String -> PantryException
HpackExeException :: !FilePath -> !Path Abs Dir -> !SomeException -> PantryException
data Mismatch a
Mismatch :: !a -> !a -> Mismatch a
[mismatchExpected] :: Mismatch a -> !a
[mismatchActual] :: Mismatch a -> !a
data FuzzyResults
FRNameNotFound :: ![PackageName] -> FuzzyResults
FRVersionNotFound :: !NonEmpty PackageIdentifierRevision -> FuzzyResults
FRRevisionNotFound :: !NonEmpty PackageIdentifierRevision -> FuzzyResults

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

-- | A <a>Version</a> represents the version of a software entity.
--   
--   Instances of <a>Eq</a> and <a>Ord</a> are provided, which gives exact
--   equality and lexicographic ordering of the version number components
--   (i.e. 2.1 &gt; 2.0, 1.2.3 &gt; 1.2.2, etc.).
--   
--   This type is opaque and distinct from the <a>Version</a> type in
--   <a>Data.Version</a> since <tt>Cabal-2.0</tt>. The difference extends
--   to the <a>Binary</a> instance using a different (and more compact)
--   encoding.
data () => Version

-- | A <a>FlagName</a> is the name of a user-defined configuration flag
--   
--   Use <a>mkFlagName</a> and <a>unFlagName</a> to convert from/to a
--   <a>String</a>.
--   
--   This type is opaque since <tt>Cabal-2.0</tt>
data () => FlagName

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

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

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

-- | File size in bytes
newtype FileSize
FileSize :: Word -> FileSize

-- | File path relative to the configuration file it was parsed from
newtype RelFilePath
RelFilePath :: Text -> RelFilePath

-- | A combination of the relative path provided in a config file, together
--   with the resolved absolute path.
data ResolvedPath t
ResolvedPath :: !RelFilePath -> !Path Abs t -> ResolvedPath t

-- | Original value parsed from a config file.
[resolvedRelative] :: ResolvedPath t -> !RelFilePath

-- | Absolute path resolved against base directory loaded from.
[resolvedAbsolute] :: ResolvedPath t -> !Path Abs t

-- | Wraps a value which potentially contains relative paths. Needs to be
--   provided with a base directory to resolve these paths.
--   
--   Unwrap this using <a>resolvePaths</a>.
data Unresolved a
data SafeFilePath
mkSafeFilePath :: Text -> Maybe SafeFilePath

-- | A SHA256 hash, stored in a static size for more efficient memory
--   representation.
data SHA256

-- | The hash of the binary representation of a <a>Tree</a>.
newtype TreeKey
TreeKey :: BlobKey -> TreeKey

-- | A key for looking up a blob, which combines the SHA256 hash of the
--   contents and the file size.
--   
--   The file size may seem redundant with the hash. However, it is
--   necessary for safely downloading blobs from an untrusted source. See
--   <a>https://www.fpcomplete.com/blog/2018/07/pantry-part-2-trees-keys</a>.
data BlobKey
BlobKey :: !SHA256 -> !FileSize -> BlobKey

-- | Metadata provided by a config file for archives and repos. This
--   information can be used for optimized lookups of information like
--   package identifiers, or for validating that the user configuration has
--   the expected information.
data RawPackageMetadata
RawPackageMetadata :: !Maybe PackageName -> !Maybe Version -> !Maybe TreeKey -> RawPackageMetadata

-- | Package name in the cabal file
[rpmName] :: RawPackageMetadata -> !Maybe PackageName

-- | Package version in the cabal file
[rpmVersion] :: RawPackageMetadata -> !Maybe Version

-- | Tree key of the loaded up package
[rpmTreeKey] :: RawPackageMetadata -> !Maybe TreeKey

-- | Exact metadata specifying concrete package
data PackageMetadata
PackageMetadata :: !PackageIdentifier -> !TreeKey -> PackageMetadata

-- | Package identifier in the cabal file
[pmIdent] :: PackageMetadata -> !PackageIdentifier

-- | Tree key of the loaded up package
[pmTreeKey] :: PackageMetadata -> !TreeKey

-- | Parsed tree with more information on the Haskell package it contains.
data Package
Package :: !TreeKey -> !Tree -> !PackageCabal -> !PackageIdentifier -> Package

-- | The <a>TreeKey</a> containing this package.
--   
--   This is a hash of the binary representation of <a>packageTree</a>.
[packageTreeKey] :: Package -> !TreeKey

-- | The <a>Tree</a> containing this package.
[packageTree] :: Package -> !Tree

-- | Information on the cabal file inside this package.
[packageCabalEntry] :: Package -> !PackageCabal

-- | The package name and version in this package.
[packageIdent] :: Package -> !PackageIdentifier

-- | How to choose a cabal file for a package from Hackage. This is to work
--   with Hackage cabal file revisions, which makes
--   <tt>PackageIdentifier</tt> insufficient for specifying a package from
--   Hackage.
data CabalFileInfo

-- | Take the latest revision of the cabal file available. This isn't
--   reproducible at all, but the running assumption (not necessarily true)
--   is that cabal file revisions do not change semantics of the build.
CFILatest :: CabalFileInfo

-- | Identify by contents of the cabal file itself. Only reason for
--   <tt>Maybe</tt> on <tt>FileSize</tt> is for compatibility with input
--   that doesn't include the file size.
CFIHash :: !SHA256 -> !Maybe FileSize -> CabalFileInfo

-- | Identify by revision number, with 0 being the original and counting
--   upward. This relies on Hackage providing consistent versioning.
--   <tt>CFIHash</tt> should be preferred wherever possible for
--   reproducibility.
CFIRevision :: !Revision -> CabalFileInfo

-- | The revision number of a package from Hackage, counting upwards from 0
--   (the original cabal file).
--   
--   See caveats on <a>CFIRevision</a>.
newtype Revision
Revision :: Word -> Revision

-- | A full specification for a package from Hackage, including the package
--   name, version, and how to load up the correct cabal file revision.
data PackageIdentifierRevision
PackageIdentifierRevision :: !PackageName -> !Version -> !CabalFileInfo -> PackageIdentifierRevision

-- | Should we pay attention to Hackage's preferred versions?
data UsePreferredVersions
UsePreferredVersions :: UsePreferredVersions
IgnorePreferredVersions :: UsePreferredVersions

-- | A raw package archive, specified by a user, could have no hash and
--   file size information.
data RawArchive
RawArchive :: !ArchiveLocation -> !Maybe SHA256 -> !Maybe FileSize -> !Text -> RawArchive

-- | Location of the archive
[raLocation] :: RawArchive -> !ArchiveLocation

-- | Cryptographic hash of the archive file
[raHash] :: RawArchive -> !Maybe SHA256

-- | Size of the archive file
[raSize] :: RawArchive -> !Maybe FileSize

-- | Subdirectory within the archive to get the package from.
[raSubdir] :: RawArchive -> !Text

-- | A package archive, could be from a URL or a local file path. Local
--   file path archives are assumed to be unchanging over time, and so are
--   allowed in custom snapshots.
data Archive
Archive :: !ArchiveLocation -> !SHA256 -> !FileSize -> !Text -> Archive

-- | Location of the archive
[archiveLocation] :: Archive -> !ArchiveLocation

-- | Cryptographic hash of the archive file
[archiveHash] :: Archive -> !SHA256

-- | Size of the archive file
[archiveSize] :: Archive -> !FileSize

-- | Subdirectory within the archive to get the package from.
[archiveSubdir] :: Archive -> !Text

-- | Location that an archive is stored at
data ArchiveLocation

-- | Archive stored at an HTTP(S) URL
ALUrl :: !Text -> ArchiveLocation

-- | Archive stored at a local file path
ALFilePath :: !ResolvedPath File -> ArchiveLocation

-- | Information on packages stored in a source control repository.
data Repo
Repo :: !Text -> !Text -> !RepoType -> !Text -> Repo

-- | Location of the repo
[repoUrl] :: Repo -> !Text

-- | Commit to use from the repo. It's strongly recommended to use a hash
--   instead of a tag or branch name.
[repoCommit] :: Repo -> !Text

-- | The type of the repo
[repoType] :: Repo -> !RepoType

-- | Subdirectory within the archive to get the package from.
[repoSubdir] :: Repo -> !Text

-- | The type of a source control repository.
data RepoType
RepoGit :: RepoType
RepoHg :: RepoType

-- | Repository without subdirectory information.
data SimpleRepo
SimpleRepo :: !Text -> !Text -> !RepoType -> SimpleRepo
[sRepoUrl] :: SimpleRepo -> !Text
[sRepoCommit] :: SimpleRepo -> !Text
[sRepoType] :: SimpleRepo -> !RepoType

-- | Clone the repository (and, in the case of Git and if necessary, fetch
--   the specific commit) and execute the action with the working directory
--   set to the repository root.
withRepo :: forall env a. (HasLogFunc env, HasProcessContext env) => SimpleRepo -> RIO env a -> RIO env a

-- | Fetch the given repositories at once and populate the pantry database.
fetchRepos :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => [(Repo, PackageMetadata)] -> RIO env ()

-- | Like <a>fetchRepos</a>, except with <a>RawPackageMetadata</a> instead
--   of <a>PackageMetadata</a>.
fetchReposRaw :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => [(Repo, RawPackageMetadata)] -> RIO env ()

-- | Location to load a package from. Can either be immutable (see
--   <a>PackageLocationImmutable</a>) or a local directory which is
--   expected to change over time. Raw version doesn't include exact
--   package version (e.g. could refer to the latest revision on Hackage)
data RawPackageLocation
RPLImmutable :: !RawPackageLocationImmutable -> RawPackageLocation
RPLMutable :: !ResolvedPath Dir -> RawPackageLocation

-- | Location to load a package from. Can either be immutable (see
--   <a>PackageLocationImmutable</a>) or a local directory which is
--   expected to change over time.
data PackageLocation
PLImmutable :: !PackageLocationImmutable -> PackageLocation
PLMutable :: !ResolvedPath Dir -> PackageLocation

-- | Convert <a>PackageLocation</a> to its "raw" equivalent
toRawPL :: PackageLocation -> RawPackageLocation

-- | Location for remote packages or archives assumed to be immutable. as
--   user specifies it i.e. not an exact location
data RawPackageLocationImmutable
RPLIHackage :: !PackageIdentifierRevision -> !Maybe TreeKey -> RawPackageLocationImmutable
RPLIArchive :: !RawArchive -> !RawPackageMetadata -> RawPackageLocationImmutable
RPLIRepo :: !Repo -> !RawPackageMetadata -> RawPackageLocationImmutable

-- | Location for remote packages or archives assumed to be immutable.
data PackageLocationImmutable
PLIHackage :: !PackageIdentifier -> !BlobKey -> !TreeKey -> PackageLocationImmutable
PLIArchive :: !Archive -> !PackageMetadata -> PackageLocationImmutable
PLIRepo :: !Repo -> !PackageMetadata -> PackageLocationImmutable

-- | Where to load a snapshot from in raw form (RSUrl could have a missing
--   BlobKey)
data RawSnapshotLocation

-- | Don't use an actual snapshot, just a version of the compiler with its
--   shipped packages.
RSLCompiler :: !WantedCompiler -> RawSnapshotLocation

-- | Download the snapshot from the given URL. The optional <a>BlobKey</a>
--   is used for reproducibility.
RSLUrl :: !Text -> !Maybe BlobKey -> RawSnapshotLocation

-- | Snapshot at a local file path.
RSLFilePath :: !ResolvedPath File -> RawSnapshotLocation

-- | Snapshot synonym (LTS/Nightly).
RSLSynonym :: !SnapName -> RawSnapshotLocation

-- | Where to load a snapshot from.
data SnapshotLocation

-- | Don't use an actual snapshot, just a version of the compiler with its
--   shipped packages.
SLCompiler :: !WantedCompiler -> SnapshotLocation

-- | Download the snapshot from the given URL. The optional <a>BlobKey</a>
--   is used for reproducibility.
SLUrl :: !Text -> !BlobKey -> SnapshotLocation

-- | Snapshot at a local file path.
SLFilePath :: !ResolvedPath File -> SnapshotLocation

-- | Convert snapshot location to its "raw" equivalent.
toRawSL :: SnapshotLocation -> RawSnapshotLocation

-- | A flattened representation of all the layers in a snapshot.
data RawSnapshot
RawSnapshot :: !WantedCompiler -> !Map PackageName RawSnapshotPackage -> !Set PackageName -> RawSnapshot

-- | The compiler wanted for this snapshot.
[rsCompiler] :: RawSnapshot -> !WantedCompiler

-- | Packages available in this snapshot for installation. This will be
--   applied on top of any globally available packages.
[rsPackages] :: RawSnapshot -> !Map PackageName RawSnapshotPackage

-- | Global packages that should be dropped/ignored.
[rsDrop] :: RawSnapshot -> !Set PackageName

-- | A flattened representation of all the layers in a snapshot.
data Snapshot
Snapshot :: !WantedCompiler -> !Map PackageName SnapshotPackage -> !Set PackageName -> Snapshot

-- | The compiler wanted for this snapshot.
[snapshotCompiler] :: Snapshot -> !WantedCompiler

-- | Packages available in this snapshot for installation. This will be
--   applied on top of any globally available packages.
[snapshotPackages] :: Snapshot -> !Map PackageName SnapshotPackage

-- | Global packages that should be dropped/ignored.
[snapshotDrop] :: Snapshot -> !Set PackageName

-- | Settings for a package found in a snapshot.
data RawSnapshotPackage
RawSnapshotPackage :: !RawPackageLocationImmutable -> !Map FlagName Bool -> !Bool -> ![Text] -> RawSnapshotPackage

-- | Where to get the package from
[rspLocation] :: RawSnapshotPackage -> !RawPackageLocationImmutable

-- | Same as <a>slFlags</a>
[rspFlags] :: RawSnapshotPackage -> !Map FlagName Bool

-- | Same as <a>slHidden</a>
[rspHidden] :: RawSnapshotPackage -> !Bool

-- | Same as <a>slGhcOptions</a>
[rspGhcOptions] :: RawSnapshotPackage -> ![Text]

-- | Settings for a package found in a snapshot.
data SnapshotPackage
SnapshotPackage :: !PackageLocationImmutable -> !Map FlagName Bool -> !Bool -> ![Text] -> SnapshotPackage

-- | Where to get the package from
[spLocation] :: SnapshotPackage -> !PackageLocationImmutable

-- | Same as <a>slFlags</a>
[spFlags] :: SnapshotPackage -> !Map FlagName Bool

-- | Same as <a>slHidden</a>
[spHidden] :: SnapshotPackage -> !Bool

-- | Same as <a>slGhcOptions</a>
[spGhcOptions] :: SnapshotPackage -> ![Text]

-- | A single layer of a snapshot, i.e. a specific YAML configuration file.
data RawSnapshotLayer
RawSnapshotLayer :: !RawSnapshotLocation -> !Maybe WantedCompiler -> ![RawPackageLocationImmutable] -> !Set PackageName -> !Map PackageName (Map FlagName Bool) -> !Map PackageName Bool -> !Map PackageName [Text] -> !Maybe UTCTime -> RawSnapshotLayer

-- | The sl to extend from. This is either a specific compiler, or a
--   <tt>SnapshotLocation</tt> which gives us more information (like
--   packages). Ultimately, we'll end up with a <tt>CompilerVersion</tt>.
[rslParent] :: RawSnapshotLayer -> !RawSnapshotLocation

-- | Override the compiler specified in <a>slParent</a>. Must be
--   <a>Nothing</a> if using <a>SLCompiler</a>.
[rslCompiler] :: RawSnapshotLayer -> !Maybe WantedCompiler

-- | Where to grab all of the packages from.
[rslLocations] :: RawSnapshotLayer -> ![RawPackageLocationImmutable]

-- | Packages present in the parent which should not be included here.
[rslDropPackages] :: RawSnapshotLayer -> !Set PackageName

-- | Flag values to override from the defaults
[rslFlags] :: RawSnapshotLayer -> !Map PackageName (Map FlagName Bool)

-- | Packages which should be hidden when registering. This will affect,
--   for example, the import parser in the script command. We use a
--   <a>Map</a> instead of just a <a>Set</a> to allow overriding the hidden
--   settings in a parent sl.
[rslHidden] :: RawSnapshotLayer -> !Map PackageName Bool

-- | GHC options per package
[rslGhcOptions] :: RawSnapshotLayer -> !Map PackageName [Text]

-- | See <a>slPublishTime</a>
[rslPublishTime] :: RawSnapshotLayer -> !Maybe UTCTime

-- | A single layer of a snapshot, i.e. a specific YAML configuration file.
data SnapshotLayer
SnapshotLayer :: !SnapshotLocation -> !Maybe WantedCompiler -> ![PackageLocationImmutable] -> !Set PackageName -> !Map PackageName (Map FlagName Bool) -> !Map PackageName Bool -> !Map PackageName [Text] -> !Maybe UTCTime -> SnapshotLayer

-- | The sl to extend from. This is either a specific compiler, or a
--   <tt>SnapshotLocation</tt> which gives us more information (like
--   packages). Ultimately, we'll end up with a <tt>CompilerVersion</tt>.
[slParent] :: SnapshotLayer -> !SnapshotLocation

-- | Override the compiler specified in <a>slParent</a>. Must be
--   <a>Nothing</a> if using <a>SLCompiler</a>.
[slCompiler] :: SnapshotLayer -> !Maybe WantedCompiler

-- | Where to grab all of the packages from.
[slLocations] :: SnapshotLayer -> ![PackageLocationImmutable]

-- | Packages present in the parent which should not be included here.
[slDropPackages] :: SnapshotLayer -> !Set PackageName

-- | Flag values to override from the defaults
[slFlags] :: SnapshotLayer -> !Map PackageName (Map FlagName Bool)

-- | Packages which should be hidden when registering. This will affect,
--   for example, the import parser in the script command. We use a
--   <a>Map</a> instead of just a <a>Set</a> to allow overriding the hidden
--   settings in a parent sl.
[slHidden] :: SnapshotLayer -> !Map PackageName Bool

-- | GHC options per package
[slGhcOptions] :: SnapshotLayer -> !Map PackageName [Text]

-- | Publication timestamp for this snapshot. This field is optional, and
--   is for informational purposes only.
[slPublishTime] :: SnapshotLayer -> !Maybe UTCTime

-- | Convert snapshot layer into its "raw" equivalent.
toRawSnapshotLayer :: SnapshotLayer -> RawSnapshotLayer

-- | Which compiler a snapshot wants to use. The build tool may elect to do
--   some fuzzy matching of versions (e.g., allowing different patch
--   versions).
data WantedCompiler
WCGhc :: !Version -> WantedCompiler
WCGhcGit :: !Text -> !Text -> WantedCompiler

-- | GHCJS version followed by GHC version
WCGhcjs :: !Version -> !Version -> WantedCompiler

-- | A snapshot synonym. It is expanded according to the field
--   <a>snapshotLocation</a> of a <a>PantryConfig</a>.
--   
--   @ since 0.5.0.0
data SnapName
LTS :: !Int -> !Int -> SnapName

-- | Stackage Nightly snapshot, displayed as <tt>"nighly-YYYY-MM-DD"</tt>.
Nightly :: !Day -> SnapName

-- | Get the location of a snapshot synonym from the <a>PantryConfig</a>.
snapshotLocation :: HasPantryConfig env => SnapName -> RIO env RawSnapshotLocation

-- | Resolve all of the file paths in an <a>Unresolved</a> relative to the
--   given directory.
resolvePaths :: MonadIO m => Maybe (Path Abs Dir) -> Unresolved a -> m a

-- | Load a <a>Package</a> from a <a>RawPackageLocationImmutable</a>.
--   
--   Load the package either from the local DB, Casa, or as a last resort,
--   the third party (hackage, archive or repo).
loadPackageRaw :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawPackageLocationImmutable -> RIO env Package

-- | Maybe load the package from Casa.
tryLoadPackageRawViaCasa :: (HasLogFunc env, HasPantryConfig env, HasProcessContext env) => RawPackageLocationImmutable -> TreeKey -> RIO env (Maybe Package)

-- | Load a <a>Package</a> from a <a>PackageLocationImmutable</a>.
loadPackage :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => PackageLocationImmutable -> RIO env Package

-- | Parse a <a>SnapshotLayer</a> value from a <a>SnapshotLocation</a>.
--   
--   Returns a <a>Left</a> value if provided an <a>SLCompiler</a>
--   constructor. Otherwise, returns a <a>Right</a> value providing both
--   the <a>Snapshot</a> and a hash of the input configuration file.
loadRawSnapshotLayer :: (HasPantryConfig env, HasLogFunc env) => RawSnapshotLocation -> RIO env (Either WantedCompiler (RawSnapshotLayer, CompletedSL))

-- | Parse a <a>SnapshotLayer</a> value from a <a>SnapshotLocation</a>.
--   
--   Returns a <a>Left</a> value if provided an <a>SLCompiler</a>
--   constructor. Otherwise, returns a <a>Right</a> value providing both
--   the <a>Snapshot</a> and a hash of the input configuration file.
loadSnapshotLayer :: (HasPantryConfig env, HasLogFunc env) => SnapshotLocation -> RIO env (Either WantedCompiler RawSnapshotLayer)

-- | Parse a <a>RawSnapshot</a> (all layers) from a
--   <a>SnapshotLocation</a>.
loadSnapshot :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => SnapshotLocation -> RIO env RawSnapshot

-- | Parse a <a>Snapshot</a> (all layers) from a <a>SnapshotLocation</a>
--   noting any incomplete package locations. Debug output will include the
--   raw snapshot layer.
loadAndCompleteSnapshot :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => SnapshotLocation -> Map RawSnapshotLocation SnapshotLocation -> Map RawPackageLocationImmutable PackageLocationImmutable -> RIO env (Snapshot, [CompletedSL], [CompletedPLI])

-- | As for <a>loadAndCompleteSnapshot</a> but allows toggling of the debug
--   output of the raw snapshot layer.
loadAndCompleteSnapshot' :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Bool -> SnapshotLocation -> Map RawSnapshotLocation SnapshotLocation -> Map RawPackageLocationImmutable PackageLocationImmutable -> RIO env (Snapshot, [CompletedSL], [CompletedPLI])

-- | Parse a <a>Snapshot</a> (all layers) from a <a>RawSnapshotLocation</a>
--   completing any incomplete package locations. Debug output will include
--   the raw snapshot layer.
loadAndCompleteSnapshotRaw :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawSnapshotLocation -> Map RawSnapshotLocation SnapshotLocation -> Map RawPackageLocationImmutable PackageLocationImmutable -> RIO env (Snapshot, [CompletedSL], [CompletedPLI])

-- | As for <a>loadAndCompleteSnapshotRaw</a> but allows toggling of the
--   debug output of the raw snapshot layer.
loadAndCompleteSnapshotRaw' :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Bool -> RawSnapshotLocation -> Map RawSnapshotLocation SnapshotLocation -> Map RawPackageLocationImmutable PackageLocationImmutable -> RIO env (Snapshot, [CompletedSL], [CompletedPLI])

-- | A completed snapshot location, including the original raw and
--   completed information.
data CompletedSL
CompletedSL :: !RawSnapshotLocation -> !SnapshotLocation -> CompletedSL

-- | A completed package location, including the original raw and completed
--   information.
data CompletedPLI
CompletedPLI :: !RawPackageLocationImmutable -> !PackageLocationImmutable -> CompletedPLI

-- | Add more packages to a snapshot
--   
--   Note that any settings on a parent flag which is being replaced will
--   be ignored. For example, if package <tt>foo</tt> is in the parent and
--   has flag <tt>bar</tt> set, and <tt>foo</tt> also appears in new
--   packages, then <tt>bar</tt> will no longer be set.
--   
--   Returns any of the <a>AddPackagesConfig</a> values not used.
addPackagesToSnapshot :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Utf8Builder -> [RawPackageLocationImmutable] -> AddPackagesConfig -> Map PackageName RawSnapshotPackage -> RIO env (Map PackageName RawSnapshotPackage, AddPackagesConfig)

-- | Package settings to be passed to <a>addPackagesToSnapshot</a>.
data AddPackagesConfig
AddPackagesConfig :: !Set PackageName -> !Map PackageName (Map FlagName Bool) -> !Map PackageName Bool -> !Map PackageName [Text] -> AddPackagesConfig
[apcDrop] :: AddPackagesConfig -> !Set PackageName
[apcFlags] :: AddPackagesConfig -> !Map PackageName (Map FlagName Bool)
[apcHiddens] :: AddPackagesConfig -> !Map PackageName Bool
[apcGhcOptions] :: AddPackagesConfig -> !Map PackageName [Text]

-- | Complete package location, plus whether the package has a cabal file.
--   This is relevant to reproducibility, see
--   <a>https://tech.fpcomplete.com/blog/storing-generated-cabal-files</a>
data CompletePackageLocation
CompletePackageLocation :: !PackageLocationImmutable -> !Bool -> CompletePackageLocation
[cplComplete] :: CompletePackageLocation -> !PackageLocationImmutable
[cplHasCabalFile] :: CompletePackageLocation -> !Bool

-- | Fill in optional fields in a <a>PackageLocationImmutable</a> for more
--   reproducible builds.
completePackageLocation :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawPackageLocationImmutable -> RIO env CompletePackageLocation

-- | Add in hashes to make a <a>SnapshotLocation</a> reproducible.
completeSnapshotLocation :: (HasPantryConfig env, HasLogFunc env) => RawSnapshotLocation -> RIO env SnapshotLocation

-- | Warn if the package uses <a>PCHpack</a>.
warnMissingCabalFile :: HasLogFunc env => RawPackageLocationImmutable -> RIO env ()

-- | Parse a <a>Text</a> into a <a>WantedCompiler</a> value.
parseWantedCompiler :: Text -> Either PantryException WantedCompiler

-- | Parse the short representation of a <a>SnapName</a>.
parseSnapName :: MonadThrow m => Text -> m SnapName

-- | Parse a <a>Text</a> into an <a>Unresolved</a>
--   <a>RawSnapshotLocation</a>.
parseRawSnapshotLocation :: Text -> Unresolved RawSnapshotLocation

-- | Parse a <a>PackageIdentifierRevision</a>
parsePackageIdentifierRevision :: Text -> Either PantryException PackageIdentifierRevision

-- | Parse a hackage text.
parseHackageText :: Text -> Either PantryException (PackageIdentifier, BlobKey)

-- | This is almost a copy of Cabal's parser for package identifiers, the
--   main difference is in the fact that Stack requires version to be
--   present while Cabal uses "null version" as a default value
parsePackageIdentifier :: String -> Maybe PackageIdentifier

-- | Parse a package name from a <a>Value</a>.
parsePackageName :: String -> Maybe PackageName

-- | Parse a package name from a <a>Value</a> throwing on failure
parsePackageNameThrowing :: MonadThrow m => String -> m PackageName

-- | Parse a flag name from a <a>Value</a>.
parseFlagName :: String -> Maybe FlagName

-- | Parse a version from a <a>Value</a>.
parseVersion :: String -> Maybe Version

-- | Parse a package version from a <a>Value</a> throwing on failure
parseVersionThrowing :: MonadThrow m => String -> m Version

-- | Render a package identifier as a <a>Value</a>.
packageIdentifierString :: PackageIdentifier -> String

-- | Render a package name as a <a>Value</a>.
packageNameString :: PackageName -> String

-- | Render a flag name as a <a>Value</a>.
flagNameString :: FlagName -> String

-- | Render a version as a <a>Value</a>.
versionString :: Version -> String

-- | Render a module name as a <a>Value</a>.
moduleNameString :: ModuleName -> String

-- | Newtype wrapper for easier JSON integration with Cabal types.
newtype CabalString a
CabalString :: a -> CabalString a
[unCabalString] :: CabalString a -> a

-- | Wrap the keys in a <a>Map</a> with a <a>CabalString</a> to get a
--   <a>ToJSON</a> instance.
toCabalStringMap :: Map a v -> Map (CabalString a) v

-- | Unwrap the <a>CabalString</a> from the keys in a <a>Map</a> to use a
--   <a>FromJSON</a> instance.
unCabalStringMap :: Map (CabalString a) v -> Map a v

-- | Get the <a>PackageIdentifier</a> from a
--   <a>GenericPackageDescription</a>.
gpdPackageIdentifier :: GenericPackageDescription -> PackageIdentifier

-- | Get the <a>PackageName</a> from a <a>GenericPackageDescription</a>.
gpdPackageName :: GenericPackageDescription -> PackageName

-- | Get the <a>Version</a> from a <a>GenericPackageDescription</a>.
gpdVersion :: GenericPackageDescription -> Version

-- | Download all of the packages provided into the local cache without
--   performing any unpacking. Can be useful for build tools wanting to
--   prefetch or provide an offline mode.
fetchPackages :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env, Foldable f) => f PackageLocationImmutable -> RIO env ()

-- | Unpack a given <a>RawPackageLocationImmutable</a> into the given
--   directory. Does not generate any extra subdirectories.
unpackPackageLocationRaw :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Path Abs Dir -> RawPackageLocationImmutable -> RIO env ()

-- | Unpack a given <a>PackageLocationImmutable</a> into the given
--   directory. Does not generate any extra subdirectories.
unpackPackageLocation :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Path Abs Dir -> PackageLocationImmutable -> RIO env ()

-- | Get the <a>PackageName</a> of the package at the given location.
getPackageLocationName :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawPackageLocationImmutable -> RIO env PackageName

-- | Get the <a>PackageIdentifier</a> of the package at the given location.
getRawPackageLocationIdent :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawPackageLocationImmutable -> RIO env PackageIdentifier

-- | Get the <a>PackageIdentifier</a> of the package at the given location.
packageLocationIdent :: PackageLocationImmutable -> PackageIdentifier

-- | Get version of the package at the given location.
packageLocationVersion :: PackageLocationImmutable -> Version

-- | Get the <a>TreeKey</a> of the package at the given location.
getRawPackageLocationTreeKey :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawPackageLocationImmutable -> RIO env TreeKey

-- | Get the <a>TreeKey</a> of the package at the given location.
getPackageLocationTreeKey :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => PackageLocationImmutable -> RIO env TreeKey

-- | Same as <a>loadCabalFileRawImmutable</a>, but takes a
--   <a>RawPackageLocation</a>. Never prints warnings, see
--   <a>loadCabalFilePath</a> for that.
loadCabalFileRaw :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Maybe Text -> RawPackageLocation -> RIO env GenericPackageDescription

-- | Same as <a>loadCabalFileImmutable</a>, but takes a
--   <a>PackageLocation</a>. Never prints warnings, see
--   <a>loadCabalFilePath</a> for that.
loadCabalFile :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Maybe Text -> PackageLocation -> RIO env GenericPackageDescription

-- | Load the cabal file for the given <a>RawPackageLocationImmutable</a>.
--   
--   This function ignores all warnings.
--   
--   Note that, for now, this will not allow support for hpack files in
--   these package locations. Instead, all
--   <tt>PackageLocationImmutable</tt>s will require a .cabal file. This
--   may be relaxed in the future.
loadCabalFileRawImmutable :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawPackageLocationImmutable -> RIO env GenericPackageDescription

-- | Load the cabal file for the given <a>PackageLocationImmutable</a>.
--   
--   This function ignores all warnings.
loadCabalFileImmutable :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => PackageLocationImmutable -> RIO env GenericPackageDescription

-- | Parse the Cabal file for the package inside the given directory.
--   Performs various sanity checks, such as the file name being correct
--   and having only a single Cabal file.
loadCabalFilePath :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Maybe Text -> Path Abs Dir -> RIO env (PrintWarnings -> IO GenericPackageDescription, PackageName, Path Abs File)

-- | Get the file name for the Cabal file in the given directory.
--   
--   If no Cabal file is present, or more than one is present, an exception
--   is thrown via <a>throwM</a>.
--   
--   If the directory contains a file named package.yaml, Hpack is used to
--   generate a Cabal file from it.
findOrGenerateCabalFile :: forall env. (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Maybe Text -> Path Abs Dir -> RIO env (PackageName, Path Abs File)

-- | Should we print warnings when loading a cabal file?
data PrintWarnings
YesPrintWarnings :: PrintWarnings
NoPrintWarnings :: PrintWarnings

-- | Download the most recent 01-index.tar file from Hackage and update the
--   database tables.
--   
--   This function will only perform an update once per <a>PantryConfig</a>
--   for user sanity. See the return value to find out if it happened.
updateHackageIndex :: (HasPantryConfig env, HasLogFunc env) => Maybe Utf8Builder -> RIO env DidUpdateOccur

-- | Did an update occur when running <a>updateHackageIndex</a>?
data DidUpdateOccur
UpdateOccurred :: DidUpdateOccur
NoUpdateOccurred :: DidUpdateOccur

-- | Require that the Hackage index is populated.
data RequireHackageIndex

-- | If there is nothing in the Hackage index, then perform an update
YesRequireHackageIndex :: RequireHackageIndex

-- | Do not perform an update
NoRequireHackageIndex :: RequireHackageIndex

-- | Where does pantry download its 01-index.tar file from Hackage?
hackageIndexTarballL :: HasPantryConfig env => SimpleGetter env (Path Abs File)

-- | Returns the versions of the package available on Hackage.
getHackagePackageVersions :: (HasPantryConfig env, HasLogFunc env) => RequireHackageIndex -> UsePreferredVersions -> PackageName -> RIO env (Map Version (Map Revision BlobKey))

-- | Returns the latest version of the given package available from
--   Hackage.
getLatestHackageVersion :: (HasPantryConfig env, HasLogFunc env) => RequireHackageIndex -> PackageName -> UsePreferredVersions -> RIO env (Maybe PackageIdentifierRevision)

-- | Returns location of the latest version of the given package available
--   from Hackage.
getLatestHackageLocation :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RequireHackageIndex -> PackageName -> UsePreferredVersions -> RIO env (Maybe PackageLocationImmutable)

-- | Returns the latest revision of the given package version available
--   from Hackage.
getLatestHackageRevision :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RequireHackageIndex -> PackageName -> Version -> RIO env (Maybe (Revision, BlobKey, TreeKey))

-- | Try to come up with typo corrections for given package identifier
--   using Hackage package names. This can provide more user-friendly
--   information in error messages.
getHackageTypoCorrections :: (HasPantryConfig env, HasLogFunc env) => PackageName -> RIO env [PackageName]

-- | Load the global hints from GitHub.
loadGlobalHints :: (HasTerm env, HasPantryConfig env) => WantedCompiler -> RIO env (Maybe (Map PackageName Version))

-- | Partition a map of global packages with its versions into a Set of
--   replaced packages and its dependencies and a map of remaining
--   (untouched) packages.
partitionReplacedDependencies :: Ord id => Map PackageName a -> (a -> PackageName) -> (a -> id) -> (a -> [id]) -> Set PackageName -> (Map PackageName [PackageName], Map PackageName a)

-- | An arbitrary hash for a snapshot, used for finding module names in a
--   snapshot. Mostly intended for Stack's usage.
newtype SnapshotCacheHash
SnapshotCacheHash :: SHA256 -> SnapshotCacheHash
[unSnapshotCacheHash] :: SnapshotCacheHash -> SHA256

-- | Use a snapshot cache, which caches which modules are in which packages
--   in a given snapshot. This is mostly intended for usage by Stack.
withSnapshotCache :: (HasPantryConfig env, HasLogFunc env) => SnapshotCacheHash -> RIO env (Map PackageName (Set ModuleName)) -> ((ModuleName -> RIO env [PackageName]) -> RIO env a) -> RIO env a
instance RIO.Prelude.Logger.HasLogFunc Pantry.PantryApp
instance Pantry.Types.HasPantryConfig Pantry.PantryApp
instance RIO.Process.HasProcessContext Pantry.PantryApp
instance RIO.PrettyPrint.StylesUpdate.HasStylesUpdate Pantry.PantryApp
instance RIO.PrettyPrint.HasTerm Pantry.PantryApp
instance GHC.Base.Semigroup (Pantry.SingleOrNot a)
