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

-- | Content addressable Haskell package management
--   
--   Please see the README on Github at
--   https://github.com/commercialhaskell/pantry#readme
@package pantry
@version 0.4.0.2

-- | 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. DO NOT RELY ON IT.
module Pantry.Internal.AesonExtended

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

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

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

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

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

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

-- | Efficiently deserialize a JSON value from a file. If this fails due to
--   incomplete or invalid input, Nothing 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
--   json' for details.
decodeFileStrict' :: FromJSON a => FilePath -> IO (Maybe a)

-- | Efficiently deserialize a JSON value from a strict ByteString.
--   If this fails due to incomplete or invalid input, Nothing 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
--   json' for details.
decodeStrict' :: FromJSON a => ByteString -> Maybe a

-- | Efficiently deserialize a JSON value from a lazy ByteString. If
--   this fails due to incomplete or invalid input, Nothing 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
--   json' for details.
decode' :: FromJSON a => ByteString -> Maybe a

-- | Efficiently deserialize a JSON value from a file. If this fails due to
--   incomplete or invalid input, Nothing 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
--   json for details.
decodeFileStrict :: FromJSON a => FilePath -> IO (Maybe a)

-- | Efficiently deserialize a JSON value from a strict ByteString.
--   If this fails due to incomplete or invalid input, Nothing 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
--   json for details.
decodeStrict :: FromJSON a => ByteString -> Maybe a

-- | Efficiently deserialize a JSON value from a lazy ByteString. If
--   this fails due to incomplete or invalid input, Nothing 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
--   json for details.
decode :: FromJSON a => ByteString -> Maybe a

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

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

-- | Encode a Foldable as a JSON array.
foldable :: (Foldable t, ToJSON a) => t a -> Encoding
type GToJSON = GToJSON Value
type GToEncoding = GToJSON Encoding

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

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

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

-- | Lift the standard toJSON function through the type constructor.
toJSON1 :: (ToJSON1 f, ToJSON a) => f a -> Value
genericToJSONKey :: (Generic a, GToJSONKey (Rep a)) => JSONKeyOptions -> ToJSONKeyFunction a

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

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

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

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

-- | A ToArgs value either stores nothing (for ToJSON) or it
--   stores the two function arguments that encode occurrences of the type
--   parameter (for ToJSON1).
data ToArgs res arity a
[NoToArgs] :: forall res a. ToArgs res Zero a
[To1Args] :: forall a res. (a -> res) -> ([a] -> res) -> ToArgs res One a

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

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

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

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

-- | key is encoded to value, produces array
ToJSONKeyValue :: !a -> Value -> !a -> Encoding -> ToJSONKeyFunction a
class GetConName f => GToJSONKey (f :: k -> Type)

-- | Lifting of the ToJSON class to unary type constructors.
--   
--   Instead of manually writing your ToJSON1 instance, there are
--   two options to do it automatically:
--   
--   
--   
- Data.Aeson.TH 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.
--   
- The compiler can provide a default generic implementation for
--   toJSON1.
--   
--   
--   To use the second, simply add a deriving Generic1
--   clause to your datatype and declare a ToJSON1 instance for your
--   datatype without giving definitions for liftToJSON or
--   liftToEncoding.
--   
--   For example:
--   
--   
--   {-# LANGUAGE DeriveGeneric #-}
--   
--   import GHC.Generics
--   
--   data Pair = Pair { pairFst :: a, pairSnd :: b } deriving Generic1
--   
--   instance ToJSON a => ToJSON1 (Pair a)
--   
--   
--   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 genericLiftToJSON and
--   genericLiftToEncoding with your preferred Options:
--   
--   
--   customOptions = defaultOptions
--                   { fieldLabelModifier = map toUpper
--                   }
--   
--   instance ToJSON a => ToJSON1 (Pair a) where
--       liftToJSON     = genericLiftToJSON customOptions
--       liftToEncoding = genericLiftToEncoding customOptions
--   
--   
--   See also ToJSON.
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

-- | Lifting of the ToJSON class to binary type constructors.
--   
--   Instead of manually writing your ToJSON2 instance,
--   Data.Aeson.TH provides Template Haskell functions which will
--   derive an instance at compile time.
--   
--   The compiler cannot provide a default generic implementation for
--   liftToJSON2, unlike toJSON and liftToJSON.
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

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

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

-- | Often used synonym for Encoding'.
type Encoding = Encoding' Value

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

-- | Helper for use in combination with .:? 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
--   .: instead.
--   
--   Example usage:
--   
--   
--   v1 <- o .:? "opt_field_with_dfl" .!= "default_val"
--   v2 <- o .:  "mandatory_field"
--   v3 <- o .:? "opt_field2"
--   
(.!=) :: Parser (Maybe a) -> a -> Parser a

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

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

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

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

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

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

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

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

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

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

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

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

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

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

-- | This method (applied to defaultOptions) is used as the default
--   generic implementation of parseJSON (if the arity is
--   Zero) or liftParseJSON (if the arity is
--   One).
gParseJSON :: GFromJSON arity f => Options -> FromArgs arity a -> Value -> Parser (f a)

-- | A FromArgs value either stores nothing (for FromJSON) or
--   it stores the two function arguments that decode occurrences of the
--   type parameter (for FromJSON1).
data FromArgs arity a
[NoFromArgs] :: forall a. FromArgs Zero a
[From1Args] :: forall a. (Value -> Parser a) -> (Value -> Parser [a]) -> FromArgs One a

-- | 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
--   Object could be missing a required key, an Array 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:
--   
--   
--   
- fail yields a custom error message: it is the recommended
--   way of reporting a failure;
--   
- empty (or mzero) is uninformative: use it when the
--   error is meant to be caught by some (<|>);
--   
- typeMismatch can be used to report a failure when the
--   encountered value is not of the expected JSON type; unexpected
--   is an appropriate alternative when more than one type may be expected,
--   or to keep the expected type implicit.
--   
--   
--   prependFailure (or modifyFailure) add more information
--   to a parser's error messages.
--   
--   An example type and instance using typeMismatch and
--   prependFailure:
--   
--   
--   -- Allow ourselves to write Text literals.
--   {-# LANGUAGE OverloadedStrings #-}
--   
--   data Coord = Coord { x :: Double, y :: Double }
--   
--   instance FromJSON Coord where
--       parseJSON (Object v) = Coord
--           <$> v .: "x"
--           <*> v .: "y"
--   
--       -- We do not expect a non-Object value here.
--       -- We could use empty to fail, but typeMismatch
--       -- gives a much more informative error message.
--       parseJSON invalid    =
--           prependFailure "parsing Coord failed, "
--               (typeMismatch "Object" invalid)
--   
--   
--   For this common case of only being concerned with a single type of
--   JSON value, the functions withObject, withScientific,
--   etc. are provided. Their use is to be preferred when possible, since
--   they are more terse. Using withObject, we can rewrite the above
--   instance (assuming the same language extension and data type) as:
--   
--   
--   instance FromJSON Coord where
--       parseJSON = withObject "Coord" $ \v -> Coord
--           <$> v .: "x"
--           <*> v .: "y"
--   
--   
--   Instead of manually writing your FromJSON instance, there are
--   two options to do it automatically:
--   
--   
--   
- Data.Aeson.TH 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.
--   
- The compiler can provide a default generic implementation for
--   parseJSON.
--   
--   
--   To use the second, simply add a deriving Generic
--   clause to your datatype and declare a FromJSON instance for
--   your datatype without giving a definition for parseJSON.
--   
--   For example, the previous example can be simplified to just:
--   
--   
--   {-# LANGUAGE DeriveGeneric #-}
--   
--   import GHC.Generics
--   
--   data Coord = Coord { x :: Double, y :: Double } deriving Generic
--   
--   instance FromJSON Coord
--   
--   
--   The default implementation will be equivalent to parseJSON =
--   genericParseJSON defaultOptions; if you need
--   different options, you can customize the generic decoding by defining:
--   
--   
--   customOptions = defaultOptions
--                   { fieldLabelModifier = map toUpper
--                   }
--   
--   instance FromJSON Coord where
--       parseJSON = genericParseJSON customOptions
--   
class FromJSON a
parseJSON :: FromJSON a => Value -> Parser a
parseJSONList :: FromJSON a => Value -> Parser [a]

-- | Read the docs for ToJSONKey first. This class is a conversion
--   in the opposite direction. If you have a newtype wrapper around
--   Text, the recommended way to define instances is with
--   generalized newtype deriving:
--   
--   
--   newtype SomeId = SomeId { getSomeId :: Text }
--     deriving (Eq,Ord,Hashable,FromJSONKey)
--   
--   
--   If you have a sum of nullary constructors, you may use the generic
--   implementation:
--   
--   
--   data Color = Red | Green | Blue
--     deriving Generic
--   
--   instance FromJSONKey Color where
--     fromJSONKey = genericFromJSONKey defaultJSONKeyOptions
--   
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 readList method of
--   Read. It makes it possible to give String keys special
--   treatment without using OverlappingInstances. End users
--   should always be able to use the default implementation of this
--   method.
fromJSONKeyList :: FromJSONKey a => FromJSONKeyFunction [a]

-- | This type is related to ToJSONKeyFunction. If
--   FromJSONKeyValue is used in the FromJSONKey instance,
--   then ToJSONKeyValue should be used in the ToJSONKey
--   instance. The other three data constructors for this type all
--   correspond to ToJSONKeyText. Strictly speaking,
--   FromJSONKeyTextParser is more powerful than
--   FromJSONKeyText, which is in turn more powerful than
--   FromJSONKeyCoerce. For performance reasons, these exist as
--   three options instead of one.
data FromJSONKeyFunction a

-- | uses coerce (unsafeCoerce in older GHCs)
FromJSONKeyCoerce :: !CoerceText a -> FromJSONKeyFunction a

-- | conversion from Text that always succeeds
FromJSONKeyText :: !Text -> a -> FromJSONKeyFunction a

-- | conversion from Text that may fail
FromJSONKeyTextParser :: !Text -> Parser a -> FromJSONKeyFunction a

-- | conversion for non-textual keys
FromJSONKeyValue :: !Value -> Parser a -> FromJSONKeyFunction a
class (ConstructorNames f, SumFromString f) => GFromJSONKey (f :: Type -> Type)

-- | Lifting of the FromJSON class to unary type constructors.
--   
--   Instead of manually writing your FromJSON1 instance, there are
--   two options to do it automatically:
--   
--   
--   
- Data.Aeson.TH 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.
--   
- The compiler can provide a default generic implementation for
--   liftParseJSON.
--   
--   
--   To use the second, simply add a deriving Generic1
--   clause to your datatype and declare a FromJSON1 instance for
--   your datatype without giving a definition for liftParseJSON.
--   
--   For example:
--   
--   
--   {-# LANGUAGE DeriveGeneric #-}
--   
--   import GHC.Generics
--   
--   data Pair a b = Pair { pairFst :: a, pairSnd :: b } deriving Generic1
--   
--   instance FromJSON a => FromJSON1 (Pair a)
--   
--   
--   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 genericLiftParseJSON with your preferred
--   Options:
--   
--   
--   customOptions = defaultOptions
--                   { fieldLabelModifier = map toUpper
--                   }
--   
--   instance FromJSON a => FromJSON1 (Pair a) where
--       liftParseJSON = genericLiftParseJSON customOptions
--   
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]

-- | Lifting of the FromJSON class to binary type constructors.
--   
--   Instead of manually writing your FromJSON2 instance,
--   Data.Aeson.TH 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]

-- | Parse any JSON value.
--   
--   This is a strict version of json 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 value'. In aeson 0.8 and earlier,
--   it parsed only object or array types, in conformance with the
--   now-obsolete RFC 4627.
--   
--   
Warning
--   
--   If an object contains duplicate keys, only the first one will be kept.
--   For a more flexible alternative, see jsonWith'.
json' :: Parser Value

-- | 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 value. In aeson 0.8 and earlier,
--   it parsed only object or array types, in conformance with the
--   now-obsolete RFC 4627.
--   
--   
Warning
--   
--   If an object contains duplicate keys, only the first one will be kept.
--   For a more flexible alternative, see jsonWith.
json :: Parser Value

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

-- | Default JSONKeyOptions:
--   
--   
--   defaultJSONKeyOptions = JSONKeyOptions
--                           { keyModifier = id
--                           }
--   
defaultJSONKeyOptions :: JSONKeyOptions

-- | Default TaggedObject SumEncoding options:
--   
--   
--   defaultTaggedObject = TaggedObject
--                         { tagFieldName      = "tag"
--                         , contentsFieldName = "contents"
--                         }
--   
defaultTaggedObject :: SumEncoding

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

-- | 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.
--   
--   
--   withObject "Person" $ \o ->
--     Person
--       <$> o .: "name" <?> Key "name"
--       <*> o .: "age"  <?> Key "age"
--   
--   
--   (Standard methods like (.:) 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

-- | Create a Value from a list of name/value Pairs. If
--   duplicate keys arise, earlier keys and their associated values win.
object :: [Pair] -> Value
type JSONPath = [JSONPathElement]

-- | The result of running a Parser.
data Result a
Error :: String -> Result a
Success :: a -> Result a

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

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

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

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

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

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

-- | Specifies how to encode constructors of a sum datatype.
data SumEncoding

-- | A constructor will be encoded to an object with a field
--   tagFieldName which specifies the constructor tag (modified by
--   the constructorTagModifier). 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
--   tagFieldName. 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 contentsFieldName
--   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.
--   
--   Note: Nullary constructors are encoded as strings (using
--   constructorTagModifier). Having a nullary constructor alongside
--   a single field constructor that encodes to a string leads to
--   ambiguity.
--   
--   Note: 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
--   constructorTagModifier) 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
--   constructorTagModifier) and the second element the encoded
--   contents of the constructor.
TwoElemArray :: SumEncoding

-- | Options for encoding keys with genericFromJSONKey and
--   genericToJSONKey.
data JSONKeyOptions

-- | A type-level indicator that ToJSON or FromJSON is
--   being derived generically.
data Zero

-- | A type-level indicator that ToJSON1 or FromJSON1 is
--   being derived generically.
data One

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

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

-- | Warning output from WarningParser.
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

-- | WarningParser version of withObject.
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 Traversable of sub-objects.
jsonSubWarningsT :: Traversable t => WarningParser (t (WithJSONWarnings a)) -> WarningParser (t a)

-- | Handle warnings in a Maybe Traversable 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 WarningParser to a Parser.
unWarningParser :: WarningParser a -> Parser a

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

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

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

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

-- | WarningParser version of .!=.
(..!=) :: WarningParser (Maybe a) -> a -> WarningParser a
instance GHC.Generics.Generic Pantry.Internal.AesonExtended.WarningParserMonoid
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.Classes.Eq Pantry.Internal.AesonExtended.JSONWarning
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 /DO NOT DEPEND ON
--   IT/.
module Pantry.Internal.Companion

-- | Keep running the Companion action until either the inner action
--   completes or calls the StopCompanion 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 StopCompanion is
--   triggered before the timer completes, a CompanionDone exception
--   will be thrown (which is caught internally by withCompanion).
type Delay = forall mio. MonadIO mio => Int -> mio ()

-- | Tell the Companion to stop. The next time Delay is
--   called, or if a Delay is currently blocking, the
--   Companion thread will exit with a CompanionDone
--   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 GHC.Classes.Eq Pantry.Internal.StaticBytes.StaticBytesException
instance GHC.Show.Show Pantry.Internal.StaticBytes.StaticBytesException
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 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.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.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.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 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.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 (SHA256) 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 SHA256.
--   
--   Some nomenclature:
--   
--   
--   
- Hashing calculates a new hash value from some input. from
--   takes a value that representats an existing hash.
--   
- Raw means a raw binary representation of the hash value, without
--   any hex encoding.
--   
- Text always uses lower case hex encoding
--   
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 SHA256 value by hashing the contents of a file.
hashFile :: MonadIO m => FilePath -> m SHA256

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

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

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

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

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

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

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

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

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

-- | Convert a SHA256 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 TreeEntrys.
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 System.FilePath.normalise, however:
--   
--   
--   
- Only works on relative paths, absolute paths fail
--   
- Strips trailing slashes
--   
- Only works on forward slashes, even on Windows
--   
- Normalizes parent dirs foo.. get stripped
--   
- Cannot begin with a parent directory (../)
--   
- Spelled like an American, sorry
--   
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
--   https://github.com/commercialhaskell/stack/issues/4471, 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 Pantry.Storage 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

-- | Unique keys besides the Key.
data family Unique record

-- | An EntityField is parameterised by the Haskell record it
--   belongs to and the additional type of that field.
data family EntityField record :: Type -> Type

-- | 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
data SafeFilePath
newtype ModuleNameP
ModuleNameP :: ModuleName -> ModuleNameP
[unModuleNameP] :: ModuleNameP -> ModuleName
newtype VersionP
VersionP :: Version -> VersionP
[unVersionP] :: VersionP -> Version
newtype PackageNameP
PackageNameP :: PackageName -> PackageNameP
[unPackageNameP] :: PackageNameP -> PackageName

-- | Configuration value used by the entire pantry package. Create one
--   using withPantryConfig. See also PantryApp for a
--   convenience approach to using pantry.
data PantryConfig
PantryConfig :: !HackageSecurityConfig -> !HpackExecutable -> !Path Abs Dir -> !Storage -> !MVar Bool -> !IORef (Map RawPackageLocationImmutable GenericPackageDescription) -> !IORef (Map (Path Abs Dir) (PrintWarnings -> IO GenericPackageDescription, PackageName, Path Abs File)) -> !Int -> !CasaRepoPrefix -> !Int -> PantryConfig
[pcHackageSecurity] :: PantryConfig -> !HackageSecurityConfig
[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 True.
[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 GenericPackageDescription until its
--   actually needed. Therefore, we keep the filepath and the
--   PackageName derived from that filepath. When the IO
--   GenericPackageDescription is run, it will ensure that the
--   PackageName 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

-- | The pull URL e.g. https://casa.fpcomplete.com/v1/pull
[pcCasaRepoPrefix] :: PantryConfig -> !CasaRepoPrefix

-- | Maximum blobs sent per pull request.
[pcCasaMaxPerRequest] :: PantryConfig -> !Int

-- | Represents a SQL database connection. This used to be a newtype
--   wrapper around a connection pool. However, when investigating
--   https://github.com/commercialhaskell/stack/issues/4471, 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 Pantry.Storage 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

-- | The TreeKey containing this package.
--   
--   This is a hash of the binary representation of packageTree.
packageTreeKey :: Package -> TreeKey
unSafeFilePath :: SafeFilePath -> Text
mkSafeFilePath :: Text -> Maybe SafeFilePath
type ModuleNameId = Key ModuleName
type TreeEntryId = Key TreeEntry
type TreeId = Key Tree
data Tree
Tree :: !Key Blob -> !Maybe (Key Blob) -> !FileType -> !Key PackageName -> !Key Version -> Tree
[treeKey] :: Tree -> !Key Blob
[treeCabal] :: Tree -> !Maybe (Key Blob)
[treeCabalType] :: Tree -> !FileType
[treeName] :: Tree -> !Key PackageName
[treeVersion] :: Tree -> !Key Version
type HackageCabalId = Key HackageCabal
type VersionId = Key Version
data Version
type PackageNameId = Key PackageName
data PackageName
type BlobId = Key Blob
migrateAll :: Migration
getPackageNameById :: PackageNameId -> ReaderT SqlBackend (RIO env) (Maybe PackageName)
getPackageNameId :: PackageName -> ReaderT SqlBackend (RIO env) PackageNameId
getVersionId :: Version -> ReaderT SqlBackend (RIO env) VersionId
storeBlob :: ByteString -> ReaderT SqlBackend (RIO env) (BlobId, BlobKey)
loadBlobById :: BlobId -> ReaderT SqlBackend (RIO env) ByteString
getBlobKey :: BlobId -> ReaderT SqlBackend (RIO env) BlobKey
getTreeForKey :: TreeKey -> ReaderT SqlBackend (RIO env) (Maybe (Entity Tree))

-- | Information returned by getHackageTarball
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)

-- | Same as updateHackageIndex, 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

-- | 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 withPantryConfig. See also PantryApp for a
--   convenience approach to using pantry.
data PantryConfig

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

-- | Default HackageSecurityConfig value using the official Hackage
--   server.
defaultHackageSecurityConfig :: HackageSecurityConfig

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

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

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

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

-- | Create a new PantryConfig with the given settings.
--   
--   For something easier to use in simple cases, see runPantryApp.
withPantryConfig :: HasLogFunc env => Path Abs Dir -> HackageSecurityConfig -> HpackExecutable -> Int -> CasaRepoPrefix -> Int -> (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 withPantryConfig directly. Uses basically sane
--   settings, like sharing a pantry directory with Stack.
--   
--   You can use runPantryApp to use this.
data PantryApp

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

-- | Like runPantryApp, 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 runPantryAppClean.
runPantryAppWith :: MonadIO m => Int -> CasaRepoPrefix -> Int -> RIO PantryApp a -> m a

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

-- | Things that can go wrong in pantry. Note two things:
--   
--   
--   
- Many other exception types may be thrown from underlying
--   libraries. Pantry does not attempt to wrap these underlying
--   exceptions.
--   
- 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.
--   
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
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 DownloadInvalidSize since mismatchActual
--   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 :: !Repo -> 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
InvalidTreeFromCasa :: !BlobKey -> !ByteString -> PantryException

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

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

-- | A FlagName is the name of a user-defined configuration flag
--   
--   Use mkFlagName and unFlagName to convert from/to a
--   String.
--   
--   This type is opaque since Cabal-2.0
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 resolvePaths.
data Unresolved a

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

-- | The hash of the binary representation of a Tree.
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
--   https://www.fpcomplete.com/blog/2018/07/pantry-part-2-trees-keys.
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 TreeKey containing this package.
--   
--   This is a hash of the binary representation of packageTree.
[packageTreeKey] :: Package -> !TreeKey

-- | The Tree 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
--   PackageIdentifier 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
--   Maybe on FileSize 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.
--   CFIHash 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 CFIRevision.
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

-- | Clone the repository and execute the action with the working directory
--   set to the repository root.
withRepo :: forall env a. (HasLogFunc env, HasProcessContext env) => Repo -> RIO env a -> RIO env a

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

-- | Convert PackageLocation 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 BlobKey
--   is used for reproducibility.
RSLUrl :: !Text -> !Maybe BlobKey -> RawSnapshotLocation

-- | Snapshot at a local file path.
RSLFilePath :: !ResolvedPath File -> 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 BlobKey
--   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 slFlags
[rspFlags] :: RawSnapshotPackage -> !Map FlagName Bool

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

-- | Same as slGhcOptions
[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 slFlags
[spFlags] :: SnapshotPackage -> !Map FlagName Bool

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

-- | Same as slGhcOptions
[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
--   SnapshotLocation which gives us more information (like
--   packages). Ultimately, we'll end up with a CompilerVersion.
[rslParent] :: RawSnapshotLayer -> !RawSnapshotLocation

-- | Override the compiler specified in slParent. Must be
--   Nothing if using SLCompiler.
[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
--   Map instead of just a Set 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 slPublishTime
[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
--   SnapshotLocation which gives us more information (like
--   packages). Ultimately, we'll end up with a CompilerVersion.
[slParent] :: SnapshotLayer -> !SnapshotLocation

-- | Override the compiler specified in slParent. Must be
--   Nothing if using SLCompiler.
[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
--   Map instead of just a Set 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

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

-- | Load a Package from a RawPackageLocationImmutable.
--   
--   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 Package from a PackageLocationImmutable.
loadPackage :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => PackageLocationImmutable -> RIO env Package

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

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

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

-- | Parse a Snapshot (all layers) from a SnapshotLocation
--   noting any incomplete package locations
loadAndCompleteSnapshot :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => SnapshotLocation -> Map RawSnapshotLocation SnapshotLocation -> Map RawPackageLocationImmutable PackageLocationImmutable -> RIO env (Snapshot, [CompletedSL], [CompletedPLI])

-- | Parse a Snapshot (all layers) from a RawSnapshotLocation
--   completing any incomplete package locations
loadAndCompleteSnapshotRaw :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => 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 foo is in the parent and
--   has flag bar set, and foo also appears in new
--   packages, then bar will no longer be set.
--   
--   Returns any of the AddPackagesConfig 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 addPackagesToSnapshot.
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
--   https://tech.fpcomplete.com/blog/storing-generated-cabal-files
data CompletePackageLocation
CompletePackageLocation :: !PackageLocationImmutable -> !Bool -> CompletePackageLocation
[cplComplete] :: CompletePackageLocation -> !PackageLocationImmutable
[cplHasCabalFile] :: CompletePackageLocation -> !Bool

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

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

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

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

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

-- | Parse a PackageIdentifierRevision
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 String.
parsePackageName :: String -> Maybe PackageName

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

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

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

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

-- | Location of an LTS snapshot
ltsSnapshotLocation :: Int -> Int -> RawSnapshotLocation

-- | Location of a Stackage Nightly snapshot
nightlySnapshotLocation :: Day -> RawSnapshotLocation

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

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

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

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

-- | Render a module name as a String.
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 Map with a CabalString to get a
--   ToJSON instance.
toCabalStringMap :: Map a v -> Map (CabalString a) v

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

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

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

-- | Get the Version from a GenericPackageDescription.
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 RawPackageLocationImmutable 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 PackageLocationImmutable 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 PackageName of the package at the given location.
getPackageLocationName :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawPackageLocationImmutable -> RIO env PackageName

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

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

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

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

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

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

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

-- | Load the cabal file for the given RawPackageLocationImmutable.
--   
--   This function ignores all warnings.
--   
--   Note that, for now, this will not allow support for hpack files in
--   these package locations. Instead, all
--   PackageLocationImmutables 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 PackageLocationImmutable.
--   
--   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) => Path Abs Dir -> RIO env (PrintWarnings -> IO GenericPackageDescription, PackageName, Path Abs File)

-- | Get the filename 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 throwM.
--   
--   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) => 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 PantryConfig
--   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 updateHackageIndex?
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)
