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


-- | A web framework that integrates Servant, RIO, EKG, fast-logger, wai-cli…
--   
--   Inspired by Dropwizard, Magicbane provides a packaged framework for
--   developing web services using the best available libraries, including
--   Servant, RIO, Aeson, EKG/monad-metrics, fast-logger, wai-cli and
--   others.
@package magicbane
@version 0.3.0


-- | Extends Servant with context, based on RIO. The context should be a
--   tuple of all your moudles and configs and stuff, so that the Data.Has
--   module would let you access these items by type.
module Magicbane.App

-- | <a>asProxyTypeOf</a> is a type-restricted version of <a>const</a>. It
--   is usually used as an infix operator, and its typing forces its first
--   argument (which is usually overloaded) to have the same type as the
--   tag of the second.
--   
--   <pre>
--   &gt;&gt;&gt; import Data.Word
--   
--   &gt;&gt;&gt; :type asProxyTypeOf 123 (Proxy :: Proxy Word8)
--   asProxyTypeOf 123 (Proxy :: Proxy Word8) :: Word8
--   </pre>
--   
--   Note the lower-case <tt>proxy</tt> in the definition. This allows any
--   type constructor with just one argument to be passed to the function,
--   for example we could also write
--   
--   <pre>
--   &gt;&gt;&gt; import Data.Word
--   
--   &gt;&gt;&gt; :type asProxyTypeOf 123 (Just (undefined :: Word8))
--   asProxyTypeOf 123 (Just (undefined :: Word8)) :: Word8
--   </pre>
asProxyTypeOf :: () => a -> proxy a -> a

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

-- | A concrete, promotable proxy type, for use at the kind level There are
--   no instances for this because it is intended at the kind level only
data KProxy t
KProxy :: KProxy t

-- | Type-level <a>If</a>. <tt>If True a b</tt> ==&gt; <tt>a</tt>; <tt>If
--   False a b</tt> ==&gt; <tt>b</tt>

-- | A type class for extensible product.
--   
--   We provide instances for tuples up to 12 elements by default. You can
--   define your own instance of <a>Has</a>, but most of the time tuples
--   will do fine.
class Has a t
getter :: Has a t => t -> a
modifier :: Has a t => a -> a -> t -> t
hasLens :: Has a t => Lens t a

-- | Convert value to HTTP API data.
--   
--   <b>WARNING</b>: Do not derive this using <tt>DeriveAnyClass</tt> as
--   the generated instance will loop indefinitely.
class ToHttpApiData a

-- | Convert to URL path piece.
toUrlPiece :: ToHttpApiData a => a -> Text

-- | Convert to a URL path piece, making sure to encode any special chars.
--   The default definition uses <a>encodePathSegmentsRelative</a>, but
--   this may be overriden with a more efficient version.
toEncodedUrlPiece :: ToHttpApiData a => a -> Builder

-- | Convert to HTTP header value.
toHeader :: ToHttpApiData a => a -> ByteString

-- | Convert to query param value.
toQueryParam :: ToHttpApiData a => a -> Text

-- | Parse value from HTTP API data.
--   
--   <b>WARNING</b>: Do not derive this using <tt>DeriveAnyClass</tt> as
--   the generated instance will loop indefinitely.
class FromHttpApiData a

-- | Parse URL path piece.
parseUrlPiece :: FromHttpApiData a => Text -> Either Text a

-- | Parse HTTP header value.
parseHeader :: FromHttpApiData a => ByteString -> Either Text a

-- | Parse query param value.
parseQueryParam :: FromHttpApiData a => Text -> Either Text a

-- | Represents a general universal resource identifier using its component
--   parts.
--   
--   For example, for the URI
--   
--   <pre>
--   foo://anonymous@www.haskell.org:42/ghc?query#frag
--   </pre>
--   
--   the components are:
data URI
URI :: String -> Maybe URIAuth -> String -> String -> String -> URI

-- | <pre>
--   foo:
--   </pre>
[uriScheme] :: URI -> String

-- | <pre>
--   //anonymous@www.haskell.org:42
--   </pre>
[uriAuthority] :: URI -> Maybe URIAuth

-- | <pre>
--   /ghc
--   </pre>
[uriPath] :: URI -> String

-- | <pre>
--   ?query
--   </pre>
[uriQuery] :: URI -> String

-- | <pre>
--   #frag
--   </pre>
[uriFragment] :: URI -> String

-- | HTTP Version.
--   
--   Note that the Show instance is intended merely for debugging.
data HttpVersion
HttpVersion :: !Int -> !Int -> HttpVersion
[httpMajor] :: HttpVersion -> !Int
[httpMinor] :: HttpVersion -> !Int

-- | HTTP standard method (as defined by RFC 2616, and PATCH which is
--   defined by RFC 5789).
data StdMethod
GET :: StdMethod
POST :: StdMethod
HEAD :: StdMethod
PUT :: StdMethod
DELETE :: StdMethod
TRACE :: StdMethod
CONNECT :: StdMethod
OPTIONS :: StdMethod
PATCH :: StdMethod

-- | Is used within a monadic computation to begin exception processing.
throwError :: MonadError e m => e -> m a

-- | More general version of <a>allFieldLinks</a>.
allFieldLinks' :: (HasLink ToServantApi routes, GenericServant routes AsLink a, ToServant routes AsLink a ~ MkLink ToServantApi routes a) => Link -> a -> routes AsLink a

-- | Get all links as a record.
allFieldLinks :: (HasLink ToServantApi routes, GenericServant routes AsLink Link, ToServant routes AsLink Link ~ MkLink ToServantApi routes Link) => routes AsLink Link

-- | More general version of <a>fieldLink</a>
fieldLink' :: (IsElem endpoint ToServantApi routes, HasLink endpoint, GenericServant routes AsApi) => Link -> a -> routes AsApi -> endpoint -> MkLink endpoint a

-- | Given an API record field, create a link for that route. Only the
--   field's type is used.
--   
--   <pre>
--   data Record route = Record
--       { _get :: route :- Capture "id" Int :&gt; Get '[JSON] String
--       , _put :: route :- ReqBody '[JSON] Int :&gt; Put '[JSON] Bool
--       }
--     deriving (<a>Generic</a>)
--   
--   getLink :: Int -&gt; Link
--   getLink = <a>fieldLink</a> _get
--   </pre>
fieldLink :: (IsElem endpoint ToServantApi routes, HasLink endpoint, GenericServant routes AsApi) => routes AsApi -> endpoint -> MkLink endpoint Link

-- | More general <a>allLinks</a>. See <a>safeLink'</a>.
allLinks' :: HasLink api => Link -> a -> Proxy api -> MkLink api a

-- | Create all links in an API.
--   
--   Note that the <tt>api</tt> type must be restricted to the endpoints
--   that have valid links to them.
--   
--   <pre>
--   &gt;&gt;&gt; type API = "foo" :&gt; Capture "name" Text :&gt; Get '[JSON] Text :&lt;|&gt; "bar" :&gt; Capture "name" Int :&gt; Get '[JSON] Double
--   
--   &gt;&gt;&gt; let fooLink :&lt;|&gt; barLink = allLinks (Proxy :: Proxy API)
--   
--   &gt;&gt;&gt; :t fooLink
--   fooLink :: Text -&gt; Link
--   
--   &gt;&gt;&gt; :t barLink
--   barLink :: Int -&gt; Link
--   </pre>
--   
--   Note: nested APIs don't work well with this approach
--   
--   <pre>
--   &gt;&gt;&gt; :kind! MkLink (Capture "nest" Char :&gt; (Capture "x" Int :&gt; Get '[JSON] Int :&lt;|&gt; Capture "y" Double :&gt; Get '[JSON] Double)) Link
--   MkLink (Capture "nest" Char :&gt; (Capture "x" Int :&gt; Get '[JSON] Int :&lt;|&gt; Capture "y" Double :&gt; Get '[JSON] Double)) Link :: *
--   = Char -&gt; (Int -&gt; Link) :&lt;|&gt; (Double -&gt; Link)
--   </pre>
allLinks :: HasLink api => Proxy api -> MkLink api Link

-- | More general <a>safeLink</a>.
safeLink' :: (IsElem endpoint api, HasLink endpoint) => Link -> a -> Proxy api -> Proxy endpoint -> MkLink endpoint a

-- | Create a valid (by construction) relative URI with query params.
--   
--   This function will only typecheck if <tt>endpoint</tt> is part of the
--   API <tt>api</tt>
safeLink :: (IsElem endpoint api, HasLink endpoint) => Proxy api -> Proxy endpoint -> MkLink endpoint Link

-- | Configurable <a>linkURI</a>.
--   
--   <pre>
--   &gt;&gt;&gt; type API = "sum" :&gt; QueryParams "x" Int :&gt; Get '[JSON] Int
--   
--   &gt;&gt;&gt; linkURI' LinkArrayElementBracket $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API) [1, 2, 3]
--   sum?x[]=1&amp;x[]=2&amp;x[]=3
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; linkURI' LinkArrayElementPlain $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API) [1, 2, 3]
--   sum?x=1&amp;x=2&amp;x=3
--   </pre>
linkURI' :: LinkArrayElementStyle -> Link -> URI

-- | Transform <a>Link</a> into <a>URI</a>.
--   
--   <pre>
--   &gt;&gt;&gt; type API = "something" :&gt; Get '[JSON] Int
--   
--   &gt;&gt;&gt; linkURI $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API)
--   something
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; type API = "sum" :&gt; QueryParams "x" Int :&gt; Get '[JSON] Int
--   
--   &gt;&gt;&gt; linkURI $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API) [1, 2, 3]
--   sum?x[]=1&amp;x[]=2&amp;x[]=3
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; type API = "foo/bar" :&gt; Get '[JSON] Int
--   
--   &gt;&gt;&gt; linkURI $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API)
--   foo%2Fbar
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; type SomeRoute = "abc" :&gt; Capture "email" String :&gt; Put '[JSON] ()
--   
--   &gt;&gt;&gt; let someRoute = Proxy :: Proxy SomeRoute
--   
--   &gt;&gt;&gt; safeLink someRoute someRoute "test@example.com"
--   Link {_segments = ["abc","test%40example.com"], _queryParams = []}
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; linkURI $ safeLink someRoute someRoute "test@example.com"
--   abc/test%40example.com
--   </pre>
linkURI :: Link -> URI
linkQueryParams :: Link -> [Param]
linkSegments :: Link -> [String]

-- | A safe link datatype. The only way of constructing a <a>Link</a> is
--   using <a>safeLink</a>, which means any <a>Link</a> is guaranteed to be
--   part of the mentioned API.
data Link

-- | Query parameter.
data Param
SingleParam :: String -> Text -> Param
ArrayElemParam :: String -> Text -> Param
FlagParam :: String -> Param

-- | How to encode array query elements.
data LinkArrayElementStyle

-- | <pre>
--   foo[]=1&amp;foo[]=2
--   </pre>
LinkArrayElementBracket :: LinkArrayElementStyle

-- | <pre>
--   foo=1&amp;foo=2
--   </pre>
LinkArrayElementPlain :: LinkArrayElementStyle

-- | A type that specifies that an API record contains a set of links.
data AsLink a

-- | Construct a toLink for an endpoint.
class HasLink (endpoint :: k) where {
    type family MkLink (endpoint :: k) a :: *;
}
toLink :: HasLink endpoint => Link -> a -> Proxy endpoint -> Link -> MkLink endpoint a

-- | <a>WithNamedContext</a> names a specific tagged context to use for the
--   combinators in the API. (See also in <tt>servant-server</tt>,
--   <tt>Servant.Server.Context</tt>.) For example:
--   
--   <pre>
--   type UseNamedContextAPI = WithNamedContext "myContext" '[String] (
--       ReqBody '[JSON] Int :&gt; Get '[JSON] Int)
--   </pre>
--   
--   Both the <tt>ReqBody</tt> and <tt>Get</tt> combinators will use the
--   <a>WithNamedContext</a> with type tag "myContext" as their context.
--   
--   <tt>Context</tt>s are only relevant for <tt>servant-server</tt>.
--   
--   For more information, see the tutorial.
data WithNamedContext (name :: Symbol) (subContext :: [*]) subApi

-- | Flatten API into a list of endpoints.
--   
--   <pre>
--   &gt;&gt;&gt; Refl :: Endpoints SampleAPI :~: '["hello" :&gt; Verb 'GET 200 '[JSON] Int, "bye" :&gt; (Capture "name" String :&gt; Verb 'POST 200 '[JSON, PlainText] Bool)]
--   Refl
--   </pre>

-- | You may use this type family to tell the type checker that your custom
--   type may be skipped as part of a link. This is useful for things like
--   <tt><a>QueryParam</a></tt> that are optional in a URI and do not
--   affect them if they are omitted.
--   
--   <pre>
--   &gt;&gt;&gt; data CustomThing
--   
--   &gt;&gt;&gt; type instance IsElem' e (CustomThing :&gt; s) = IsElem e s
--   </pre>
--   
--   Note that <tt><a>IsElem</a></tt> is called, which will mutually
--   recurse back to <tt><a>IsElem'</a></tt> if it exhausts all other
--   options again.
--   
--   Once you have written a <tt>HasLink</tt> instance for
--   <tt>CustomThing</tt> you are ready to go.

-- | Closed type family, check if <tt>endpoint</tt> is within <tt>api</tt>.
--   Uses <tt><a>IsElem'</a></tt> if it exhausts all other options.
--   
--   <pre>
--   &gt;&gt;&gt; ok (Proxy :: Proxy (IsElem ("hello" :&gt; Get '[JSON] Int) SampleAPI))
--   OK
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ok (Proxy :: Proxy (IsElem ("bye" :&gt; Get '[JSON] Int) SampleAPI))
--   ...
--   ... Could not deduce...
--   ...
--   </pre>
--   
--   An endpoint is considered within an api even if it is missing
--   combinators that don't affect the URL:
--   
--   <pre>
--   &gt;&gt;&gt; ok (Proxy :: Proxy (IsElem (Get '[JSON] Int) (Header "h" Bool :&gt; Get '[JSON] Int)))
--   OK
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ok (Proxy :: Proxy (IsElem (Get '[JSON] Int) (ReqBody '[JSON] Bool :&gt; Get '[JSON] Int)))
--   OK
--   </pre>
--   
--   <ul>
--   <li>N.B.:* <tt>IsElem a b</tt> can be seen as capturing the notion of
--   whether the URL represented by <tt>a</tt> would match the URL
--   represented by <tt>b</tt>, *not* whether a request represented by
--   <tt>a</tt> matches the endpoints serving <tt>b</tt> (for the latter,
--   use <a>IsIn</a>).</li>
--   </ul>

-- | Check whether <tt>sub</tt> is a sub-API of <tt>api</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; ok (Proxy :: Proxy (IsSubAPI SampleAPI (SampleAPI :&lt;|&gt; Get '[JSON] Int)))
--   OK
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ok (Proxy :: Proxy (IsSubAPI (SampleAPI :&lt;|&gt; Get '[JSON] Int) SampleAPI))
--   ...
--   ... Could not deduce...
--   ...
--   </pre>
--   
--   This uses <tt>IsElem</tt> for checking; thus the note there applies
--   here.

-- | Check that every element of <tt>xs</tt> is an endpoint of <tt>api</tt>
--   (using <tt><a>IsElem</a></tt>).

-- | Closed type family, check if <tt>endpoint</tt> is exactly within
--   <tt>api</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; ok (Proxy :: Proxy (IsIn ("hello" :&gt; Get '[JSON] Int) SampleAPI))
--   OK
--   </pre>
--   
--   Unlike <a>IsElem</a>, this requires an *exact* match.
--   
--   <pre>
--   &gt;&gt;&gt; ok (Proxy :: Proxy (IsIn (Get '[JSON] Int) (Header "h" Bool :&gt; Get '[JSON] Int)))
--   ...
--   ... Could not deduce...
--   ...
--   </pre>

-- | Check whether <tt>sub</tt> is a sub API of <tt>api</tt>.
--   
--   Like <a>IsSubAPI</a>, but uses <a>IsIn</a> rather than <a>IsElem</a>.

-- | Check that every element of <tt>xs</tt> is an endpoint of <tt>api</tt>
--   (using <tt><a>IsIn</a></tt>).
--   
--   ok (Proxy :: Proxy (AllIsIn (Endpoints SampleAPI) SampleAPI)) OK

-- | Apply <tt>(e :&gt;)</tt> to every API in <tt>xs</tt>.

-- | Append two type-level lists.

-- | Check that a value is an element of a list:
--   
--   <pre>
--   &gt;&gt;&gt; ok (Proxy :: Proxy (Elem Bool '[Int, Bool]))
--   OK
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ok (Proxy :: Proxy (Elem String '[Int, Bool]))
--   ...
--   ... [Char]...'[Int, Bool...
--   ...
--   </pre>
type Elem (e :: t) (es :: [t]) = ElemGo e es es

-- | If either a or b produce an empty constraint, produce an empty
--   constraint.

-- | <tt>Verb</tt> is a general type for representing HTTP verbs (a.k.a.
--   methods). For convenience, type synonyms for each verb with a 200
--   response code are provided, but you are free to define your own:
--   
--   <pre>
--   &gt;&gt;&gt; type Post204 contentTypes a = Verb 'POST 204 contentTypes a
--   </pre>
data Verb (method :: k1) (statusCode :: Nat) (contentTypes :: [*]) a :: forall k1. () => k1 -> Nat -> [*] -> * -> *

-- | <a>GET</a> with 200 status code.
type Get = Verb GET 200

-- | <a>POST</a> with 200 status code.
type Post = Verb POST 200

-- | <a>PUT</a> with 200 status code.
type Put = Verb PUT 200

-- | <a>DELETE</a> with 200 status code.
type Delete = Verb DELETE 200

-- | <a>PATCH</a> with 200 status code.
type Patch = Verb PATCH 200

-- | <a>POST</a> with 201 status code.
type PostCreated = Verb POST 201

-- | <a>GET</a> with 202 status code.
type GetAccepted = Verb GET 202

-- | <a>POST</a> with 202 status code.
type PostAccepted = Verb POST 202

-- | <a>DELETE</a> with 202 status code.
type DeleteAccepted = Verb DELETE 202

-- | <a>PATCH</a> with 202 status code.
type PatchAccepted = Verb PATCH 202

-- | <a>PUT</a> with 202 status code.
type PutAccepted = Verb PUT 202

-- | <a>GET</a> with 203 status code.
type GetNonAuthoritative = Verb GET 203

-- | <a>POST</a> with 203 status code.
type PostNonAuthoritative = Verb POST 203

-- | <a>DELETE</a> with 203 status code.
type DeleteNonAuthoritative = Verb DELETE 203

-- | <a>PATCH</a> with 203 status code.
type PatchNonAuthoritative = Verb PATCH 203

-- | <a>PUT</a> with 203 status code.
type PutNonAuthoritative = Verb PUT 203

-- | <a>GET</a> with 204 status code.
type GetNoContent = Verb GET 204

-- | <a>POST</a> with 204 status code.
type PostNoContent = Verb POST 204

-- | <a>DELETE</a> with 204 status code.
type DeleteNoContent = Verb DELETE 204

-- | <a>PATCH</a> with 204 status code.
type PatchNoContent = Verb PATCH 204

-- | <a>PUT</a> with 204 status code.
type PutNoContent = Verb PUT 204

-- | <a>GET</a> with 205 status code.
type GetResetContent = Verb GET 205

-- | <a>POST</a> with 205 status code.
type PostResetContent = Verb POST 205

-- | <a>GET</a> with 206 status code.
type GetPartialContent = Verb GET 206
class ReflectMethod (a :: k)
reflectMethod :: ReflectMethod a => Proxy a -> Method

-- | The contained API (second argument) can be found under <tt>("/" ++
--   path)</tt> (path being the first argument).
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; -- GET /hello/world
--   
--   &gt;&gt;&gt; -- returning a JSON encoded World value
--   
--   &gt;&gt;&gt; type MyApi = "hello" :&gt; "world" :&gt; Get '[JSON] World
--   </pre>
data (:>) (path :: k) a :: forall k. () => k -> * -> *

-- | A Stream endpoint for a given method emits a stream of encoded values
--   at a given Content-Type, delimited by a framing strategy. Stream
--   endpoints always return response code 200 on success. Type synonyms
--   are provided for standard methods.
data Stream (method :: k1) (status :: Nat) framing contentType a :: forall k1. () => k1 -> Nat -> * -> * -> * -> *
type StreamGet = Stream GET 200
type StreamPost = Stream POST 200

-- | Stream endpoints may be implemented as producing a
--   <tt>StreamGenerator</tt> -- a function that itself takes two emit
--   functions -- the first to be used on the first value the stream emits,
--   and the second to be used on all subsequent values (to allow
--   interspersed framing strategies such as comma separation).
newtype StreamGenerator a
StreamGenerator :: a -> IO () -> a -> IO () -> IO () -> StreamGenerator a
[getStreamGenerator] :: StreamGenerator a -> a -> IO () -> a -> IO () -> IO ()

-- | ToStreamGenerator is intended to be implemented for types such as
--   Conduit, Pipe, etc. By implementing this class, all such streaming
--   abstractions can be used directly as endpoints.
class ToStreamGenerator a b | a -> b
toStreamGenerator :: ToStreamGenerator a b => a -> StreamGenerator b

-- | Clients reading from streaming endpoints can be implemented as
--   producing a <tt>ResultStream</tt> that captures the setup, takedown,
--   and incremental logic for a read, being an IO continuation that takes
--   a producer of Just either values or errors that terminates with a
--   Nothing.
newtype ResultStream a
ResultStream :: forall b. () => IO Maybe Either String a -> IO b -> IO b -> ResultStream a

-- | BuildFromStream is intended to be implemented for types such as
--   Conduit, Pipe, etc. By implementing this class, all such streaming
--   abstractions can be used directly on the client side for talking to
--   streaming endpoints.
class BuildFromStream a b
buildFromStream :: BuildFromStream a b => ResultStream a -> b

-- | The FramingRender class provides the logic for emitting a framing
--   strategy. The strategy emits a header, followed by boundary-delimited
--   data, and finally a termination character. For many strategies, some
--   of these will just be empty bytestrings.
class FramingRender (strategy :: k) (a :: k1)
header :: FramingRender strategy a => Proxy strategy -> Proxy a -> ByteString
boundary :: FramingRender strategy a => Proxy strategy -> Proxy a -> BoundaryStrategy
trailer :: FramingRender strategy a => Proxy strategy -> Proxy a -> ByteString

-- | The bracketing strategy generates things to precede and follow the
--   content, as with netstrings. The intersperse strategy inserts
--   seperators between things, as with newline framing. Finally, the
--   general strategy performs an arbitrary rewrite on the content, to
--   allow escaping rules and such.
data BoundaryStrategy
BoundaryStrategyBracket :: ByteString -> (ByteString, ByteString) -> BoundaryStrategy
BoundaryStrategyIntersperse :: ByteString -> BoundaryStrategy
BoundaryStrategyGeneral :: ByteString -> ByteString -> BoundaryStrategy

-- | A type of parser that can never fail, and has different parsing
--   strategies (incremental, or EOF) depending if more input can be sent.
--   The incremental parser should return <a>Nothing</a> if it would like
--   to be sent a longer ByteString. If it returns a value, it also returns
--   the remainder following that value.
data ByteStringParser a
ByteStringParser :: ByteString -> Maybe (a, ByteString) -> ByteString -> (a, ByteString) -> ByteStringParser a
[parseIncremental] :: ByteStringParser a -> ByteString -> Maybe (a, ByteString)
[parseEOF] :: ByteStringParser a -> ByteString -> (a, ByteString)

-- | The FramingUnrender class provides the logic for parsing a framing
--   strategy. The outer <tt>ByteStringParser</tt> strips the header from a
--   stream of bytes, and yields a parser that can handle the remainder,
--   stepwise. Each frame may be a ByteString, or a String indicating the
--   error state for that frame. Such states are per-frame, so that
--   protocols that can resume after errors are able to do so. Eventually
--   this returns an empty ByteString to indicate termination.
class FramingUnrender (strategy :: k) (a :: k1)
unrenderFrames :: FramingUnrender strategy a => Proxy strategy -> Proxy a -> ByteStringParser ByteStringParser Either String ByteString

-- | A framing strategy that does not do any framing at all, it just passes
--   the input data This will be used most of the time with binary data,
--   such as files
data NoFraming

-- | A simple framing strategy that has no header or termination, and
--   inserts a newline character between each frame. This assumes that it
--   is used with a Content-Type that encodes without newlines (e.g. JSON).
data NewlineFraming

-- | The netstring framing strategy as defined by djb:
--   <a>http://cr.yp.to/proto/netstrings.txt</a>
data NetstringFraming

-- | Deliberately do not add a header to a value.
--   
--   <pre>
--   &gt;&gt;&gt; let example1 = noHeader "hi" :: Headers '[Header "someheader" Int] String
--   
--   &gt;&gt;&gt; getHeaders example1
--   []
--   </pre>
noHeader :: AddHeader h v orig new => orig -> new

-- | <tt>addHeader</tt> adds a header to a response. Note that it changes
--   the type of the value in the following ways:
--   
--   <ol>
--   <li>A simple value is wrapped in "Headers '[hdr]":</li>
--   </ol>
--   
--   <pre>
--   &gt;&gt;&gt; let example1 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] String;
--   
--   &gt;&gt;&gt; getHeaders example1
--   [("someheader","5")]
--   </pre>
--   
--   <ol>
--   <li>A value that already has a header has its new header *prepended*
--   to the existing list:</li>
--   </ol>
--   
--   <pre>
--   &gt;&gt;&gt; let example1 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] String;
--   
--   &gt;&gt;&gt; let example2 = addHeader True example1 :: Headers '[Header "1st" Bool, Header "someheader" Int] String
--   
--   &gt;&gt;&gt; getHeaders example2
--   [("1st","true"),("someheader","5")]
--   </pre>
--   
--   Note that while in your handlers type annotations are not required,
--   since the type can be inferred from the API type, in other cases you
--   may find yourself needing to add annotations.
addHeader :: AddHeader h v orig new => v -> orig -> new

-- | Response Header objects. You should never need to construct one
--   directly. Instead, use <a>addOptionalHeader</a>.
data Headers (ls :: [*]) a
Headers :: a -> HList ls -> Headers a

-- | The underlying value of a <a>Headers</a>
[getResponse] :: Headers a -> a

-- | HList of headers.
[getHeadersHList] :: Headers a -> HList ls
data ResponseHeader (sym :: Symbol) a
Header :: a -> ResponseHeader a
MissingHeader :: ResponseHeader a
UndecodableHeader :: ByteString -> ResponseHeader a
data HList (a :: [*])
[HNil] :: HList ([] :: [*])
[HCons] :: HList Header h x : xs
class BuildHeadersTo (hs :: [*])

-- | Note: if there are multiple occurences of a header in the argument,
--   the values are interspersed with commas before deserialization (see
--   <a>RFC2616 Sec 4.2</a>)
buildHeadersTo :: BuildHeadersTo hs => [Header] -> HList hs
class GetHeaders ls
getHeaders :: GetHeaders ls => ls -> [Header]
class AddHeader (h :: Symbol) v orig new | h v orig -> new, new -> h, new -> v, new -> orig

-- | Extract the request body as a value of type <tt>a</tt>.
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; -- POST /books
--   
--   &gt;&gt;&gt; type MyApi = "books" :&gt; ReqBody '[JSON] Book :&gt; Post '[JSON] Book
--   </pre>
type ReqBody = ReqBody' Required : Strict : ([] :: [*])

-- | <i>Note:</i> <a>ReqBody'</a> is always <a>Required</a>.
data ReqBody' (mods :: [*]) (contentTypes :: [*]) a

-- | Provides access to the host or IP address from which the HTTP request
--   was sent.
data RemoteHost

-- | Endpoint for plugging in your own Wai <tt>Application</tt>s.
--   
--   The given <tt>Application</tt> will get the request as received by the
--   server, potentially with a modified (stripped) <tt>pathInfo</tt> if
--   the <tt>Application</tt> is being routed with <a>:&gt;</a>.
--   
--   In addition to just letting you plug in your existing WAI
--   <tt>Application</tt>s, this can also be used with
--   <a>serveDirectory</a> to serve static files stored in a particular
--   directory on your filesystem
data Raw

-- | Lookup the value associated to the <tt>sym</tt> query string parameter
--   and try to extract it as a value of type <tt>a</tt>.
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; -- /books?author=&lt;author name&gt;
--   
--   &gt;&gt;&gt; type MyApi = "books" :&gt; QueryParam "author" Text :&gt; Get '[JSON] [Book]
--   </pre>
type QueryParam = QueryParam' Optional : Strict : ([] :: [*])

-- | <a>QueryParam</a> which can be <a>Required</a>, <a>Lenient</a>, or
--   modified otherwise.
data QueryParam' (mods :: [*]) (sym :: Symbol) a

-- | Lookup the values associated to the <tt>sym</tt> query string
--   parameter and try to extract it as a value of type <tt>[a]</tt>. This
--   is typically meant to support query string parameters of the form
--   <tt>param[]=val1&amp;param[]=val2</tt> and so on. Note that servant
--   doesn't actually require the <tt>[]</tt>s and will fetch the values
--   just fine with <tt>param=val1&amp;param=val2</tt>, too.
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; -- /books?authors[]=&lt;author1&gt;&amp;authors[]=&lt;author2&gt;&amp;...
--   
--   &gt;&gt;&gt; type MyApi = "books" :&gt; QueryParams "authors" Text :&gt; Get '[JSON] [Book]
--   </pre>
data QueryParams (sym :: Symbol) a

-- | Lookup a potentially value-less query string parameter with boolean
--   semantics. If the param <tt>sym</tt> is there without any value, or if
--   it's there with value "true" or "1", it's interpreted as <a>True</a>.
--   Otherwise, it's interpreted as <a>False</a>.
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; -- /books?published
--   
--   &gt;&gt;&gt; type MyApi = "books" :&gt; QueryFlag "published" :&gt; Get '[JSON] [Book]
--   </pre>
data QueryFlag (sym :: Symbol)

-- | Extract the given header's value as a value of type <tt>a</tt>. I.e.
--   header sent by client, parsed by server.
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; newtype Referer = Referer Text deriving (Eq, Show)
--   
--   &gt;&gt;&gt; 
--   
--   &gt;&gt;&gt; -- GET /view-my-referer
--   
--   &gt;&gt;&gt; type MyApi = "view-my-referer" :&gt; Header "from" Referer :&gt; Get '[JSON] Referer
--   </pre>
type Header = (Header' Optional : Strict : ([] :: [*]) :: Symbol -> k -> *)
data Header' (mods :: [*]) (sym :: Symbol) (a :: k) :: forall k. () => [*] -> Symbol -> k -> *

-- | Required argument. Not wrapped.
data Required

-- | Optional argument. Wrapped in <a>Maybe</a>.
data Optional

-- | Leniently parsed argument, i.e. parsing never fail. Wrapped in
--   <tt><a>Either</a> <a>Text</a></tt>.
data Lenient

-- | Strictly parsed argument. Not wrapped.
data Strict

-- | Was this request made over an SSL connection?
--   
--   Note that this value will not tell you if the client originally made
--   this request over SSL, but rather whether the current connection is
--   SSL. The distinction lies with reverse proxies. In many cases, the
--   client will connect to a load balancer over SSL, but connect to the
--   WAI handler without SSL. In such a case, the handlers would get
--   <a>NotSecure</a>, but from a user perspective, there is a secure
--   connection.
data IsSecure

-- | the connection to the server is secure (HTTPS)
Secure :: IsSecure

-- | the connection to the server is not secure (HTTP)
NotSecure :: IsSecure

-- | A generalized Authentication combinator. Use this if you have a
--   non-standard authentication technique.
--   
--   NOTE: THIS API IS EXPERIMENTAL AND SUBJECT TO CHANGE.
data AuthProtect (tag :: k) :: forall k. () => k -> *

-- | An empty API: one which serves nothing. Morally speaking, this should
--   be the unit of <tt>:&lt;|&gt;</tt>. Implementors of interpretations of
--   API types should treat <a>EmptyAPI</a> as close to the unit as
--   possible.
data EmptyAPI
EmptyAPI :: EmptyAPI

-- | Add a short summary for (part of) API.
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; type MyApi = Summary "Get book by ISBN." :&gt; "books" :&gt; Capture "isbn" Text :&gt; Get '[JSON] Book
--   </pre>
data Summary (sym :: Symbol)

-- | Add more verbose description for (part of) API.
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; :{
--   type MyApi = Description
--    "This comment is visible in multiple Servant interpretations \
--    \and can be really long if necessary. \
--    \Haskell multiline support is not perfect \
--    \but it's still very readable."
--   :&gt; Get '[JSON] Book
--   :}
--   </pre>
data Description (sym :: Symbol)
data JSON
data PlainText
data FormUrlEncoded
data OctetStream

-- | Instances of <a>Accept</a> represent mimetypes. They are used for
--   matching against the <tt>Accept</tt> HTTP header of the request, and
--   for setting the <tt>Content-Type</tt> header of the response
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; import Network.HTTP.Media ((//), (/:))
--   
--   &gt;&gt;&gt; data HTML
--   
--   &gt;&gt;&gt; :{
--   instance Accept HTML where
--      contentType _ = "text" // "html" /: ("charset", "utf-8")
--   :}
--   </pre>
class Accept (ctype :: k)
contentType :: Accept ctype => Proxy ctype -> MediaType
contentTypes :: Accept ctype => Proxy ctype -> NonEmpty MediaType

-- | Instantiate this class to register a way of serializing a type based
--   on the <tt>Accept</tt> header.
--   
--   Example:
--   
--   <pre>
--   data MyContentType
--   
--   instance Accept MyContentType where
--      contentType _ = "example" // "prs.me.mine" /: ("charset", "utf-8")
--   
--   instance Show a =&gt; MimeRender MyContentType a where
--      mimeRender _ val = pack ("This is MINE! " ++ show val)
--   
--   type MyAPI = "path" :&gt; Get '[MyContentType] Int
--   </pre>
class Accept ctype => MimeRender (ctype :: k) a
mimeRender :: MimeRender ctype a => Proxy ctype -> a -> ByteString

-- | Instantiate this class to register a way of deserializing a type based
--   on the request's <tt>Content-Type</tt> header.
--   
--   <pre>
--   &gt;&gt;&gt; import Network.HTTP.Media hiding (Accept)
--   
--   &gt;&gt;&gt; import qualified Data.ByteString.Lazy.Char8 as BSC
--   
--   &gt;&gt;&gt; data MyContentType = MyContentType String
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; :{
--   instance Accept MyContentType where
--      contentType _ = "example" // "prs.me.mine" /: ("charset", "utf-8")
--   :}
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; :{
--   instance Read a =&gt; MimeUnrender MyContentType a where
--      mimeUnrender _ bs = case BSC.take 12 bs of
--        "MyContentType" -&gt; return . read . BSC.unpack $ BSC.drop 12 bs
--        _ -&gt; Left "didn't start with the magic incantation"
--   :}
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; type MyAPI = "path" :&gt; ReqBody '[MyContentType] Int :&gt; Get '[JSON] Int
--   </pre>
class Accept ctype => MimeUnrender (ctype :: k) a
mimeUnrender :: MimeUnrender ctype a => Proxy ctype -> ByteString -> Either String a

-- | Variant which is given the actual <a>MediaType</a> provided by the
--   other party.
--   
--   In the most cases you don't want to branch based on the
--   <a>MediaType</a>. See <a>pr552</a> for a motivating example.
mimeUnrenderWithType :: MimeUnrender ctype a => Proxy ctype -> MediaType -> ByteString -> Either String a

-- | A type for responses without content-body.
data NoContent
NoContent :: NoContent

-- | Capture a value from the request path under a certain type <tt>a</tt>.
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; -- GET /books/:isbn
--   
--   &gt;&gt;&gt; type MyApi = "books" :&gt; Capture "isbn" Text :&gt; Get '[JSON] Book
--   </pre>
type Capture = Capture' ([] :: [*])

-- | <a>Capture</a> which can be modified. For example with
--   <tt>Description</tt>.
data Capture' (mods :: [*]) (sym :: Symbol) a

-- | Capture all remaining values from the request path under a certain
--   type <tt>a</tt>.
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; -- GET /src/*
--   
--   &gt;&gt;&gt; type MyAPI = "src" :&gt; CaptureAll "segments" Text :&gt; Get '[JSON] SourceFile
--   </pre>
data CaptureAll (sym :: Symbol) a

-- | Combinator for <a>Basic Access Authentication</a>.
--   
--   <ul>
--   <li>IMPORTANT*: Only use Basic Auth over HTTPS! Credentials are not
--   hashed or encrypted. Note also that because the same credentials are
--   sent on every request, Basic Auth is not as secure as some
--   alternatives. Further, the implementation in servant-server does not
--   protect against some types of timing attacks.</li>
--   </ul>
--   
--   In Basic Auth, username and password are base64-encoded and
--   transmitted via the <tt>Authorization</tt> header. Handshakes are not
--   required, making it relatively efficient.
data BasicAuth (realm :: Symbol) userData

-- | A simple datatype to hold data required to decorate a request
data BasicAuthData
BasicAuthData :: !ByteString -> !ByteString -> BasicAuthData
[basicAuthUsername] :: BasicAuthData -> !ByteString
[basicAuthPassword] :: BasicAuthData -> !ByteString

-- | Union of two APIs, first takes precedence in case of overlap.
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; :{
--   type MyApi = "books" :&gt; Get '[JSON] [Book] -- GET /books
--          :&lt;|&gt; "books" :&gt; ReqBody '[JSON] Book :&gt; Post '[JSON] () -- POST /books
--   :}
--   </pre>
data (:<|>) a b
(:<|>) :: a -> b -> (:<|>) a b

-- | A persistent store for values of arbitrary types.
--   
--   This variant is the simplest and creates keys in the <a>IO</a> monad.
--   See the module <a>Data.Vault.ST</a> if you want to use it with the
--   <a>ST</a> monad instead.
type Vault = Vault RealWorld
class SBoolI (b :: Bool)
sbool :: SBoolI b => SBool b
data SBool (b :: Bool)
[STrue] :: SBool True
[SFalse] :: SBool False

-- | Same as <a>serveDirectoryFileServer</a>. It used to be the only file
--   serving function in servant pre-0.10 and will be kept around for a few
--   versions, but is deprecated.
serveDirectory :: () => FilePath -> ServerT Raw m

-- | Alias for <a>staticApp</a>. Lets you serve a directory with arbitrary
--   <a>StaticSettings</a>. Useful when you want particular settings not
--   covered by the four other variants. This is the most flexible method.
serveDirectoryWith :: () => StaticSettings -> ServerT Raw m

-- | Uses <a>embeddedSettings</a>.
serveDirectoryEmbedded :: () => [(FilePath, ByteString)] -> ServerT Raw m

-- | Same as <a>serveDirectoryWebApp</a>, but uses
--   <a>webAppSettingsWithLookup</a>.
serveDirectoryWebAppLookup :: () => ETagLookup -> FilePath -> ServerT Raw m

-- | Same as <a>serveDirectoryWebApp</a>, but uses
--   <a>defaultFileServerSettings</a>.
serveDirectoryFileServer :: () => FilePath -> ServerT Raw m

-- | Serve anything under the specified directory as a <a>Raw</a> endpoint.
--   
--   <pre>
--   type MyApi = "static" :&gt; Raw
--   
--   server :: Server MyApi
--   server = serveDirectoryWebApp "/var/www"
--   </pre>
--   
--   would capture any request to <tt>/static/&lt;something&gt;</tt> and
--   look for <tt>&lt;something&gt;</tt> under <tt>/var/www</tt>.
--   
--   It will do its best to guess the MIME type for that file, based on the
--   extension, and send an appropriate <i>Content-Type</i> header if
--   possible.
--   
--   If your goal is to serve HTML, CSS and Javascript files that use the
--   rest of the API as a webapp backend, you will most likely not want the
--   static files to be hidden behind a <i>/static/</i> prefix. In that
--   case, remember to put the <a>serveDirectoryWebApp</a> handler in the
--   last position, because <i>servant</i> will try to match the handlers
--   in order.
--   
--   Corresponds to the <a>defaultWebAppSettings</a> <a>StaticSettings</a>
--   value.
serveDirectoryWebApp :: () => FilePath -> ServerT Raw m

-- | Variant of <a>layout</a> that takes an additional <a>Context</a>.
layoutWithContext :: HasServer api context => Proxy api -> Context context -> Text

-- | The function <a>layout</a> produces a textual description of the
--   internal router layout for debugging purposes. Note that the router
--   layout is determined just by the API, not by the handlers.
--   
--   Example:
--   
--   For the following API
--   
--   <pre>
--   type API =
--          "a" :&gt; "d" :&gt; Get '[JSON] NoContent
--     :&lt;|&gt; "b" :&gt; Capture "x" Int :&gt; Get '[JSON] Bool
--     :&lt;|&gt; "c" :&gt; Put '[JSON] Bool
--     :&lt;|&gt; "a" :&gt; "e" :&gt; Get '[JSON] Int
--     :&lt;|&gt; "b" :&gt; Capture "x" Int :&gt; Put '[JSON] Bool
--     :&lt;|&gt; Raw
--   </pre>
--   
--   we get the following output:
--   
--   <pre>
--   /
--   ├─ a/
--   │  ├─ d/
--   │  │  └─•
--   │  └─ e/
--   │     └─•
--   ├─ b/
--   │  └─ &lt;capture&gt;/
--   │     ├─•
--   │     ┆
--   │     └─•
--   ├─ c/
--   │  └─•
--   ┆
--   └─ &lt;raw&gt;
--   </pre>
--   
--   Explanation of symbols:
--   
--   <ul>
--   <li><i><tt>├</tt></i> Normal lines reflect static branching via a
--   table.</li>
--   <li><i><tt>a/</tt></i> Nodes reflect static path components.</li>
--   <li><i><tt>─•</tt></i> Leaves reflect endpoints.</li>
--   <li><i><tt>&lt;capture&gt;/</tt></i> This is a delayed capture of a
--   path component.</li>
--   <li><i><tt>&lt;raw&gt;</tt></i> This is a part of the API we do not
--   know anything about.</li>
--   <li><i><tt>┆</tt></i> Dashed lines suggest a dynamic choice between
--   the part above and below. If there is a success for fatal failure in
--   the first part, that one takes precedence. If both parts fail, the
--   "better" error code will be returned.</li>
--   </ul>
layout :: HasServer api ([] :: [*]) => Proxy api -> Text

-- | Hoist server implementation.
--   
--   Sometimes our cherished <a>Handler</a> monad isn't quite the type
--   you'd like for your handlers. Maybe you want to thread some
--   configuration in a <tt>Reader</tt> monad. Or have your types ensure
--   that your handlers don't do any IO. Use <a>hoistServer</a> (a
--   successor of now deprecated <tt>enter</tt>).
--   
--   With <a>hoistServer</a>, you can provide a function, to convert any
--   number of endpoints from one type constructor to another. For example
--   
--   <i>Note:</i> <a>Server</a> <tt>Raw</tt> can also be entered. It will
--   be retagged.
--   
--   <pre>
--   &gt;&gt;&gt; import Control.Monad.Reader
--   
--   &gt;&gt;&gt; type ReaderAPI = "ep1" :&gt; Get '[JSON] Int :&lt;|&gt; "ep2" :&gt; Get '[JSON] String :&lt;|&gt; Raw :&lt;|&gt; EmptyAPI
--   
--   &gt;&gt;&gt; let readerApi = Proxy :: Proxy ReaderAPI
--   
--   &gt;&gt;&gt; let readerServer = return 1797 :&lt;|&gt; ask :&lt;|&gt; Tagged (error "raw server") :&lt;|&gt; emptyServer :: ServerT ReaderAPI (Reader String)
--   
--   &gt;&gt;&gt; let nt x = return (runReader x "hi")
--   
--   &gt;&gt;&gt; let mainServer = hoistServer readerApi nt readerServer :: Server ReaderAPI
--   </pre>
hoistServer :: HasServer api ([] :: [*]) => Proxy api -> forall x. () => m x -> n x -> ServerT api m -> ServerT api n
serveWithContext :: HasServer api context => Proxy api -> Context context -> Server api -> Application

-- | <a>serve</a> allows you to implement an API and produce a wai
--   <a>Application</a>.
--   
--   Example:
--   
--   <pre>
--   type MyApi = "books" :&gt; Get '[JSON] [Book] -- GET /books
--           :&lt;|&gt; "books" :&gt; ReqBody Book :&gt; Post '[JSON] Book -- POST /books
--   
--   server :: Server MyApi
--   server = listAllBooks :&lt;|&gt; postBook
--     where listAllBooks = ...
--           postBook book = ...
--   
--   myApi :: Proxy MyApi
--   myApi = Proxy
--   
--   app :: Application
--   app = serve myApi server
--   
--   main :: IO ()
--   main = Network.Wai.Handler.Warp.run 8080 app
--   </pre>
serve :: HasServer api ([] :: [*]) => Proxy api -> Server api -> Application

-- | Server for <a>EmptyAPI</a>
emptyServer :: () => ServerT EmptyAPI m
class HasServer (api :: k) (context :: [*]) where {
    type family ServerT (api :: k) (m :: * -> *) :: *;
}
route :: HasServer api context => Proxy api -> Context context -> Delayed env Server api -> Router env
hoistServerWithContext :: HasServer api context => Proxy api -> Proxy context -> forall x. () => m x -> n x -> ServerT api m -> ServerT api n
type Server (api :: k) = ServerT api Handler

-- | Singleton type representing a server that serves an empty API.
data EmptyServer

-- | servant-server's current implementation of basic authentication is not
--   immune to certian kinds of timing attacks. Decoding payloads does not
--   take a fixed amount of time.
--   
--   The result of authentication/authorization
data BasicAuthResult usr
Unauthorized :: BasicAuthResult usr
BadPassword :: BasicAuthResult usr
NoSuchUser :: BasicAuthResult usr
Authorized :: usr -> BasicAuthResult usr

-- | Datatype wrapping a function used to check authentication.
newtype BasicAuthCheck usr
BasicAuthCheck :: BasicAuthData -> IO BasicAuthResult usr -> BasicAuthCheck usr
[unBasicAuthCheck] :: BasicAuthCheck usr -> BasicAuthData -> IO BasicAuthResult usr

-- | Apply a transformation to the response of a <a>Router</a>.
tweakResponse :: () => RouteResult Response -> RouteResult Response -> Router env -> Router env
toApplication :: RoutingApplication -> Application
runHandler :: () => Handler a -> IO Either ServantErr a
runHandler' :: Handler a -> ExceptT ServantErr IO a

-- | <a>err505</a> HTTP Version not supported
--   
--   Example usage:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err505 { errBody = "I support HTTP/4.0 only." }
--   </pre>
err505 :: ServantErr

-- | <a>err504</a> Gateway Time-out
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err504 { errBody = "Backend foobar did not respond in 5 seconds." }
--   </pre>
err504 :: ServantErr

-- | <a>err503</a> Service Unavailable
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err503 { errBody = "We're rewriting in PHP." }
--   </pre>
err503 :: ServantErr

-- | <a>err502</a> Bad Gateway
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err502 { errBody = "Tried gateway foo, bar, and baz.  None responded." }
--   </pre>
err502 :: ServantErr

-- | <a>err501</a> Not Implemented
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err501 { errBody = "/v1/foo is not supported with quux in the request." }
--   </pre>
err501 :: ServantErr

-- | <a>err500</a> Internal Server Error
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err500 { errBody = "Exception in module A.B.C:55.  Have a great day!" }
--   </pre>
err500 :: ServantErr

-- | <a>err422</a> Unprocessable Entity
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err422 { errBody = "I understood your request, but can't process it." }
--   </pre>
err422 :: ServantErr

-- | <a>err418</a> Expectation Failed
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err418 { errBody = "Apologies, this is not a webserver but a teapot." }
--   </pre>
err418 :: ServantErr

-- | <a>err417</a> Expectation Failed
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err417 { errBody = "I found a quux in the request.  This isn't going to work." }
--   </pre>
err417 :: ServantErr

-- | <a>err416</a> Request range not satisfiable
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err416 { errBody = "Valid range is [0, 424242]." }
--   </pre>
err416 :: ServantErr

-- | <a>err415</a> Unsupported Media Type
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err415 { errBody = "Supported media types:  gif, png" }
--   </pre>
err415 :: ServantErr

-- | <a>err414</a> Request-URI Too Large
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err414 { errBody = "Maximum length is 64." }
--   </pre>
err414 :: ServantErr

-- | <a>err413</a> Request Entity Too Large
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err413 { errBody = "Request exceeded 64k." }
--   </pre>
err413 :: ServantErr

-- | <a>err412</a> Precondition Failed
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err412 { errBody = "Precondition fail: x &lt; 42 &amp;&amp; y &gt; 57" }
--   </pre>
err412 :: ServantErr

-- | <a>err411</a> Length Required
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError err411
--   </pre>
err411 :: ServantErr

-- | <a>err410</a> Gone
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err410 { errBody = "I know it was here at some point, but.. I blame bad luck." }
--   </pre>
err410 :: ServantErr

-- | <a>err409</a> Conflict
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err409 { errBody = "Transaction conflicts with 59879cb56c7c159231eeacdd503d755f7e835f74" }
--   </pre>
err409 :: ServantErr

-- | <a>err407</a> Proxy Authentication Required
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError err407
--   </pre>
err407 :: ServantErr

-- | <a>err406</a> Not Acceptable
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError err406
--   </pre>
err406 :: ServantErr

-- | <a>err405</a> Method Not Allowed
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err405 { errBody = "Your account privileges does not allow for this.  Please pay $$$." }
--   </pre>
err405 :: ServantErr

-- | <a>err404</a> Not Found
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err404 { errBody = "(╯°□°）╯︵ ┻━┻)." }
--   </pre>
err404 :: ServantErr

-- | <a>err403</a> Forbidden
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err403 { errBody = "Please login first." }
--   </pre>
err403 :: ServantErr

-- | <a>err402</a> Payment Required
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err402 { errBody = "You have 0 credits. Please give me $$$." }
--   </pre>
err402 :: ServantErr

-- | <a>err401</a> Unauthorized
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err401 { errBody = "Your credentials are invalid." }
--   </pre>
err401 :: ServantErr

-- | <a>err400</a> Bad Request
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err400 { errBody = "Your request makes no sense to me." }
--   </pre>
err400 :: ServantErr

-- | <a>err307</a> Temporary Redirect
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError err307
--   </pre>
err307 :: ServantErr

-- | <a>err305</a> Use Proxy
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError err305
--   </pre>
err305 :: ServantErr

-- | <a>err304</a> Not Modified
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError err304
--   </pre>
err304 :: ServantErr

-- | <a>err303</a> See Other
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError err303
--   </pre>
err303 :: ServantErr

-- | <a>err302</a> Found
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError err302
--   </pre>
err302 :: ServantErr

-- | <a>err301</a> Moved Permanently
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError err301
--   </pre>
err301 :: ServantErr

-- | <a>err300</a> Multiple Choices
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err300 { errBody = "I can't choose." }
--   </pre>
err300 :: ServantErr
data ServantErr
ServantErr :: Int -> String -> ByteString -> [Header] -> ServantErr
[errHTTPCode] :: ServantErr -> Int
[errReasonPhrase] :: ServantErr -> String
[errBody] :: ServantErr -> ByteString
[errHeaders] :: ServantErr -> [Header]

-- | <a>descendIntoNamedContext</a> allows you to access
--   <a>NamedContext</a>s. Usually you won't have to use it yourself but
--   instead use a combinator like <a>WithNamedContext</a>.
--   
--   This is how <a>descendIntoNamedContext</a> works:
--   
--   <pre>
--   &gt;&gt;&gt; :set -XFlexibleContexts
--   
--   &gt;&gt;&gt; let subContext = True :. EmptyContext
--   
--   &gt;&gt;&gt; :type subContext
--   subContext :: Context '[Bool]
--   
--   &gt;&gt;&gt; let parentContext = False :. (NamedContext subContext :: NamedContext "subContext" '[Bool]) :. EmptyContext
--   
--   &gt;&gt;&gt; :type parentContext
--   parentContext :: Context '[Bool, NamedContext "subContext" '[Bool]]
--   
--   &gt;&gt;&gt; descendIntoNamedContext (Proxy :: Proxy "subContext") parentContext :: Context '[Bool]
--   True :. EmptyContext
--   </pre>
descendIntoNamedContext :: HasContextEntry context NamedContext name subContext => Proxy name -> Context context -> Context subContext

-- | <a>Context</a>s are used to pass values to combinators. (They are
--   <b>not</b> meant to be used to pass parameters to your handlers, i.e.
--   they should not replace any custom <a>ReaderT</a>-monad-stack that
--   you're using with <tt>hoistServer</tt>.) If you don't use combinators
--   that require any context entries, you can just use <a>serve</a> as
--   always.
--   
--   If you are using combinators that require a non-empty <a>Context</a>
--   you have to use <a>serveWithContext</a> and pass it a <a>Context</a>
--   that contains all the values your combinators need. A <a>Context</a>
--   is essentially a heterogenous list and accessing the elements is being
--   done by type (see <a>getContextEntry</a>). The parameter of the type
--   <a>Context</a> is a type-level list reflecting the types of the
--   contained context entries. To create a <a>Context</a> with entries,
--   use the operator <tt>(<a>:.</a>)</tt>:
--   
--   <pre>
--   &gt;&gt;&gt; :type True :. () :. EmptyContext
--   True :. () :. EmptyContext :: Context '[Bool, ()]
--   </pre>
data Context (contextTypes :: [*])
[EmptyContext] :: Context ([] :: [*])
[:.] :: Context x : xs

-- | This class is used to access context entries in <a>Context</a>s.
--   <a>getContextEntry</a> returns the first value where the type matches:
--   
--   <pre>
--   &gt;&gt;&gt; getContextEntry (True :. False :. EmptyContext) :: Bool
--   True
--   </pre>
--   
--   If the <a>Context</a> does not contain an entry of the requested type,
--   you'll get an error:
--   
--   <pre>
--   &gt;&gt;&gt; getContextEntry (True :. False :. EmptyContext) :: String
--   ...
--   ...No instance for (HasContextEntry '[] [Char])
--   ...
--   </pre>
class HasContextEntry (context :: [*]) val
getContextEntry :: HasContextEntry context val => Context context -> val

-- | Normally context entries are accessed by their types. In case you need
--   to have multiple values of the same type in your <a>Context</a> and
--   need to access them, we provide <a>NamedContext</a>. You can think of
--   it as sub-namespaces for <a>Context</a>s.
data NamedContext (name :: Symbol) (subContext :: [*])
NamedContext :: Context subContext -> NamedContext

-- | The WAI application.
--   
--   Note that, since WAI 3.0, this type is structured in continuation
--   passing style to allow for proper safe resource handling. This was
--   handled in the past via other means (e.g., <tt>ResourceT</tt>). As a
--   demonstration:
--   
--   <pre>
--   app :: Application
--   app req respond = bracket_
--       (putStrLn "Allocating scarce resource")
--       (putStrLn "Cleaning up")
--       (respond $ responseLBS status200 [] "Hello World")
--   </pre>
type Application = Request -> Response -> IO ResponseReceived -> IO ResponseReceived

-- | A <tt><a>Tagged</a> s b</tt> value is a value <tt>b</tt> with an
--   attached phantom type <tt>s</tt>. This can be used in place of the
--   more traditional but less safe idiom of passing in an undefined value
--   with the type, because unlike an <tt>(s -&gt; b)</tt>, a
--   <tt><a>Tagged</a> s b</tt> can't try to use the argument <tt>s</tt> as
--   a real value.
--   
--   Moreover, you don't have to rely on the compiler to inline away the
--   extra argument, because the newtype is "free"
--   
--   <a>Tagged</a> has kind <tt>k -&gt; * -&gt; *</tt> if the compiler
--   supports <tt>PolyKinds</tt>, therefore there is an extra <tt>k</tt>
--   showing in the instance haddocks that may cause confusion.
newtype Tagged (s :: k) b :: forall k. () => k -> * -> *
Tagged :: b -> Tagged b
[unTagged] :: Tagged b -> b
runMagicbaneHandler :: β -> RIO β α -> Handler α

-- | Constructs a WAI application from an API definition, a Servant context
--   (used for auth mainly), the app context and the actual action
--   handlers.
magicbaneApp :: forall β χ ψ. (HasServer χ ψ) => Proxy χ -> Context ψ -> β -> ServerT χ (RIO β) -> Application

-- | Gets a value of any type from the context.
askObj :: (Has β α, MonadReader α μ) => μ β

-- | Gets a thing from a value of any type from the context. (Useful for
--   configuration fields.)
askOpt :: (Has β α, MonadReader α μ) => (β -> ψ) -> μ ψ

-- | The Reader+IO monad. This is different from a <a>ReaderT</a> because:
--   
--   <ul>
--   <li>It's not a transformer, it hardcodes IO for simpler usage and
--   error messages.</li>
--   <li>Instances of typeclasses like <tt>MonadLogger</tt> are implemented
--   using classes defined on the environment, instead of using an
--   underlying monad.</li>
--   </ul>
data RIO env a


-- | Provides logging via fast-logger in a Magicbane app context.
module Magicbane.Logging
type Formatter = TimedFastLogger -> CallStack -> LogSource -> LogLevel -> Utf8Builder -> IO ()
type ModLogger = LogFunc

-- | Creates a logger module using a given formatting function. | Also
--   returns the underlying TimedFastLogger for use outside of your
--   Magicbane app (e.g. in some WAI middleware).
newLogger :: LogType -> Formatter -> IO (TimedFastLogger, ModLogger)
simpleFormatter :: Formatter

-- | Logger Type.
data LogType

-- | No logging.
LogNone :: LogType

-- | Logging to stdout. <a>BufSize</a> is a buffer size for each
--   capability.
LogStdout :: BufSize -> LogType

-- | Logging to stderr. <a>BufSize</a> is a buffer size for each
--   capability.
LogStderr :: BufSize -> LogType

-- | Logging to a file. <a>BufSize</a> is a buffer size for each
--   capability.
LogFileNoRotate :: FilePath -> BufSize -> LogType

-- | Logging to a file. <a>BufSize</a> is a buffer size for each
--   capability. File rotation is done on-demand.
LogFile :: FileLogSpec -> BufSize -> LogType

-- | Logging with a log and flush action. run flush after log each message.
LogCallback :: LogStr -> IO () -> IO () -> LogType

-- | The default buffer size (4,096 bytes).
defaultBufSize :: BufSize
instance Data.Has.Has Magicbane.Logging.ModLogger α => RIO.Prelude.Logger.HasLogFunc α


-- | Provides metrics via monad-metrics/EKG in a Magicbane app context.
--   Also reexports Wai metrics middleware.
module Magicbane.Metrics
newtype ModMetrics
ModMetrics :: Metrics -> ModMetrics
forkMetricsServer :: ByteString -> Int -> IO Server

-- | Creates a metrics module with a particular Store. The Store should
--   come from the backend you want to use for storing the metrics. For
--   development, a simple backend that shows metrics on a web page is
--   ekg-wai, reexported here.
newMetricsWith :: Store -> IO ModMetrics

-- | Register a number of metrics related to garbage collector behavior.
--   
--   To enable GC statistics collection, either run your program with
--   
--   <pre>
--   +RTS -T
--   </pre>
--   
--   or compile it with
--   
--   <pre>
--   -with-rtsopts=-T
--   </pre>
--   
--   The runtime overhead of <tt>-T</tt> is very small so it's safe to
--   always leave it enabled.
--   
--   Registered counters:
--   
--   <ul>
--   <li><i><tt>rts.gc.bytes_allocated</tt></i> Total number of bytes
--   allocated</li>
--   <li><i><tt>rts.gc.num_gcs</tt></i> Number of garbage collections
--   performed</li>
--   <li><i><tt>rts.gc.num_bytes_usage_samples</tt></i> Number of byte
--   usage samples taken</li>
--   <li><i><tt>rts.gc.cumulative_bytes_used</tt></i> Sum of all byte usage
--   samples, can be used with <tt>numByteUsageSamples</tt> to calculate
--   averages with arbitrary weighting (if you are sampling this record
--   multiple times).</li>
--   <li><i><tt>rts.gc.bytes_copied</tt></i> Number of bytes copied during
--   GC</li>
--   <li><i><tt>rts.gc.init_cpu_ms</tt></i> CPU time used by the init
--   phase, in milliseconds. GHC 8.6+ only.</li>
--   <li><i><tt>rts.gc.init_wall_ms</tt></i> Wall clock time spent running
--   the init phase, in milliseconds. GHC 8.6+ only.</li>
--   <li><i><tt>rts.gc.mutator_cpu_ms</tt></i> CPU time spent running
--   mutator threads, in milliseconds. This does not include any profiling
--   overhead or initialization.</li>
--   <li><i><tt>rts.gc.mutator_wall_ms</tt></i> Wall clock time spent
--   running mutator threads, in milliseconds. This does not include
--   initialization.</li>
--   <li><i><tt>rts.gc.gc_cpu_ms</tt></i> CPU time spent running GC, in
--   milliseconds.</li>
--   <li><i><tt>rts.gc.gc_wall_ms</tt></i> Wall clock time spent running
--   GC, in milliseconds.</li>
--   <li><i><tt>rts.gc.cpu_ms</tt></i> Total CPU time elapsed since program
--   start, in milliseconds.</li>
--   <li><i><tt>rts.gc.wall_ms</tt></i> Total wall clock time elapsed since
--   start, in milliseconds.</li>
--   </ul>
--   
--   Registered gauges:
--   
--   <ul>
--   <li><i><tt>rts.gc.max_bytes_used</tt></i> Maximum number of live bytes
--   seen so far</li>
--   <li><i><tt>rts.gc.current_bytes_used</tt></i> Current number of live
--   bytes</li>
--   <li><i><tt>rts.gc.current_bytes_slop</tt></i> Current number of bytes
--   lost to slop</li>
--   <li><i><tt>rts.gc.max_bytes_slop</tt></i> Maximum number of bytes lost
--   to slop at any one time so far</li>
--   <li><i><tt>rts.gc.peak_megabytes_allocated</tt></i> Maximum number of
--   megabytes allocated</li>
--   <li><i><tt>rts.gc.par_tot_bytes_copied</tt></i> Number of bytes copied
--   during GC, minus space held by mutable lists held by the capabilities.
--   Can be used with <tt>parMaxBytesCopied</tt> to determine how well
--   parallel GC utilized all cores.</li>
--   <li><i><tt>rts.gc.par_avg_bytes_copied</tt></i> Deprecated alias for
--   <tt>par_tot_bytes_copied</tt>.</li>
--   <li><i><tt>rts.gc.par_max_bytes_copied</tt></i> Sum of number of bytes
--   copied each GC by the most active GC thread each GC. The ratio of
--   <tt>par_tot_bytes_copied</tt> divided by <tt>par_max_bytes_copied</tt>
--   approaches 1 for a maximally sequential run and approaches the number
--   of threads (set by the RTS flag <tt>-N</tt>) for a maximally parallel
--   run.</li>
--   </ul>
registerGcMetrics :: Store -> IO ()

-- | A mutable metric store.
data Store

-- | The metric store associated with the server. If you want to add metric
--   to the default store created by <a>forkServer</a> you need to use this
--   function to retrieve it.
serverMetricStore :: Server -> Store

-- | Set the <a>Label</a> to the <a>Show</a>n value of whatever you pass
--   in.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
label' :: (MonadIO m, MonadMetrics m, Show a) => Text -> a -> m ()

-- | Set the <a>Label</a> to the given <a>Text</a> value.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
label :: (MonadIO m, MonadMetrics m) => Text -> Text -> m ()

-- | Record the time of executing the given action in seconds. Defers to
--   <a>timed'</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
timed :: (MonadIO m, MonadMetrics m, MonadMask m) => Text -> m a -> m a

-- | Record the time taken to perform the action, under several names at
--   once. The number is stored in a <a>Distribution</a> and is converted
--   to the specified <a>Resolution</a>.
--   
--   This is useful to store the same durations data sectioned by different
--   criteria, e.g.:
--   
--   <pre>
--   timedList Seconds ["request.byUser." &lt;&gt; userName, "request.byType." &lt;&gt; requestType] $ do
--       ...
--   </pre>
--   
--   So you will have <tt>"request.byUser.someuser"</tt> storing duration
--   distribution for requests of user <tt>"someuser"</tt> of any type; and
--   <tt>"request.byType.sometype"</tt> storing duration distribution for
--   requests of type <tt>"sometype"</tt> from any user.
timedList :: (MonadIO m, MonadMetrics m, MonadMask m) => Resolution -> [Text] -> m a -> m a

-- | Record the time taken to perform the named action. The number is
--   stored in a <a>Distribution</a> and is converted to the specified
--   <a>Resolution</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
timed' :: (MonadIO m, MonadMetrics m, MonadMask m) => Resolution -> Text -> m a -> m a

-- | A type specialized version of <a>gauge'</a> to avoid ambiguous types.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
gauge :: (MonadIO m, MonadMetrics m) => Text -> Int -> m ()

-- | Set the value of the named <a>Gauge</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
gauge' :: (MonadIO m, MonadMetrics m, Integral int) => Text -> int -> m ()

-- | Add the value to the named <a>Distribution</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
distribution :: (MonadIO m, MonadMetrics m) => Text -> Double -> m ()

-- | A type specialized version of <a>counter'</a> to avoid ambiguous type
--   errors.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
counter :: (MonadIO m, MonadMetrics m) => Text -> Int -> m ()

-- | Adds the value to the named <a>Counter</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
counter' :: (MonadIO m, MonadMetrics m, Integral int) => Text -> int -> m ()

-- | Increment the named counter by 1.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
increment :: (MonadIO m, MonadMetrics m) => Text -> m ()

-- | A type can be an instance of <a>MonadMetrics</a> if it can provide a
--   <a>Metrics</a> somehow. Commonly, this will be implemented as a
--   <a>ReaderT</a> where some field in the environment is the
--   <a>Metrics</a> data.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
class Monad m => MonadMetrics (m :: * -> *)
getMetrics :: MonadMetrics m => m Metrics

-- | A lens into the <a>Store</a> provided by the <a>Metrics</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
metricsStore :: Lens' Metrics Store

-- | A lens into the <a>Label</a>s provided by the <a>Metrics</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
metricsLabels :: Lens' Metrics IORef HashMap Text Label

-- | A lens into the <a>Gauge</a>s provided by the <a>Metrics</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
metricsGauges :: Lens' Metrics IORef HashMap Text Gauge

-- | A lens into the <a>Counter</a>s provided by the <a>Metrics</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
metricsCounters :: Lens' Metrics IORef HashMap Text Counter

-- | A container for metrics used by the <tt>MonadMetrics</tt> class.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
data Metrics

-- | A type representing the resolution of time to use for the
--   <tt>timed</tt> metric.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
data Resolution
Nanoseconds :: Resolution
Microseconds :: Resolution
Milliseconds :: Resolution
Seconds :: Resolution
Minutes :: Resolution
Hours :: Resolution
Days :: Resolution

-- | Create a middleware to be added to a WAI-based webserver.
metrics :: WaiMetrics -> Middleware

-- | Register in EKG a number of metrics related to web server activity
--   with a namespace.
--   
--   <ul>
--   <li><pre><a>namespace</a>.wai.request_count</pre></li>
--   <li><pre><a>namespace</a>.wai.response_status_1xx</pre></li>
--   <li><pre><a>namespace</a>.wai.response_status_2xx</pre></li>
--   <li><pre><a>namespace</a>.wai.response_status_3xx</pre></li>
--   <li><pre><a>namespace</a>.wai.response_status_4xx</pre></li>
--   <li><pre><a>namespace</a>.wai.response_status_5xx</pre></li>
--   <li><pre><a>namespace</a>.wai.latency_distribution</pre></li>
--   </ul>
registerNamedWaiMetrics :: Text -> Store -> IO WaiMetrics

-- | Register in EKG a number of metrics related to web server activity
--   using empty namespace.
--   
--   <ul>
--   <li><pre>wai.request_count</pre></li>
--   <li><pre>wai.response_status_1xx</pre></li>
--   <li><pre>wai.response_status_2xx</pre></li>
--   <li><pre>wai.response_status_3xx</pre></li>
--   <li><pre>wai.response_status_4xx</pre></li>
--   <li><pre>wai.response_status_5xx</pre></li>
--   <li><pre>wai.latency_distribution</pre></li>
--   </ul>
registerWaiMetrics :: Store -> IO WaiMetrics

-- | The metrics to feed in WAI and register in EKG.
data WaiMetrics
WaiMetrics :: Counter -> Distribution -> Counter -> Counter -> Counter -> Counter -> Counter -> WaiMetrics
[requestCounter] :: WaiMetrics -> Counter
[latencyDistribution] :: WaiMetrics -> Distribution
[statusCode100Counter] :: WaiMetrics -> Counter
[statusCode200Counter] :: WaiMetrics -> Counter
[statusCode300Counter] :: WaiMetrics -> Counter
[statusCode400Counter] :: WaiMetrics -> Counter
[statusCode500Counter] :: WaiMetrics -> Counter
instance (Data.Has.Has Magicbane.Metrics.ModMetrics α, GHC.Base.Monad μ, Control.Monad.Reader.Class.MonadReader α μ) => Control.Monad.Metrics.MonadMetrics μ


-- | Various useful functions.
module Magicbane.Util

-- | Merges two JSON objects recursively. When the values are not objects,
--   just returns the left one.
mergeVal :: Value -> Value -> Value

-- | Encodes key-value data as application/x-www-form-urlencoded.
writeForm :: (ConvertibleStrings α Text, ConvertibleStrings β Text, ConvertibleStrings ByteString γ) => [(α, β)] -> γ

-- | Decodes key-value data from application/x-www-form-urlencoded.
readForm :: (ConvertibleStrings Text α, ConvertibleStrings Text β, ConvertibleStrings γ ByteString) => γ -> Maybe [(α, β)]

-- | Reads a Servant incoming form as a list of key-value pairs (for use in
--   FromForm instances).
formList :: Form -> [(Text, Text)]

-- | Converts a flat key-value form with keys in typical nesting syntax
--   (e.g. "one[two][three]") to an Aeson Value with nesting (for use in
--   FromForm instances).
formToObject :: [(Text, Text)] -> Value
formKey :: Parser [Text]

-- | Parses any string into a URI.
parseUri :: ConvertibleStrings α String => α -> URI

-- | Prepares text for inclusion in a URL.
--   
--   <pre>
--   &gt;&gt;&gt; :set -XOverloadedStrings
--   
--   &gt;&gt;&gt; slugify "Hello &amp; World!"
--   "hello-and-world"
--   </pre>
slugify :: Text -> Text

-- | Creates a simple text/plain ServantErr.
errText :: ServantErr -> ByteString -> ServantErr

-- | Creates and throws a simple text/plain ServantErr.
throwErrText :: MonadThrow μ => ServantErr -> ByteString -> μ α


-- | Provides an HTTP(S) client via http-client(-tls) in a Magicbane app
--   context. Also provides a simple composable interface for making
--   arbitrary requests, based on http-client-conduit. That lets you plug
--   stream parsers (e.g. html-conduit: 'performWithFn (.| sinkDoc)')
--   directly into the reading of the response body.
module Magicbane.HTTPClient
type MonadHTTP ψ μ = (HasHttpManager ψ, MonadReader ψ μ, MonadUnliftIO μ)
newtype ModHttpClient
ModHttpClient :: Manager -> ModHttpClient
newHttpClient :: IO ModHttpClient
runHTTP :: ExceptT ε μ α -> μ (Either ε α)

-- | Creates a request from a URI.
reqU :: (MonadHTTP ψ μ) => URI -> ExceptT Text μ Request

-- | Creates a request from a string of any type, parsing it into a URI.
reqS :: (MonadHTTP ψ μ, ConvertibleStrings σ String) => σ -> ExceptT Text μ Request

-- | Configures the request to not throw errors on error status codes.
anyStatus :: (MonadHTTP ψ μ) => Request -> ExceptT Text μ Request

-- | Sets a x-www-form-urlencoded form as the request body (also sets the
--   content-type).
postForm :: (MonadHTTP ψ μ) => [(Text, Text)] -> Request -> ExceptT Text μ Request

-- | Performs the request, using a given function to read the body. This is
--   what all other performWith functions are based on.
performWithFn :: (MonadHTTP ψ μ, MonadCatch μ) => (ConduitM ι ByteString μ () -> ConduitT () Void μ ρ) -> Request -> ExceptT Text μ (Response ρ)

-- | Performs the request, ignoring the body.
performWithVoid :: (MonadHTTP ψ μ, MonadCatch μ) => Request -> ExceptT Text μ (Response ())

-- | Performs the request, reading the body into a lazy ByteString.
performWithBytes :: (MonadHTTP ψ μ, MonadCatch μ) => Request -> ExceptT Text μ (Response ByteString)

-- | A monad transformer that adds exceptions to other monads.
--   
--   <tt>ExceptT</tt> constructs a monad parameterized over two things:
--   
--   <ul>
--   <li>e - The exception type.</li>
--   <li>m - The inner monad.</li>
--   </ul>
--   
--   The <a>return</a> function yields a computation that produces the
--   given value, while <tt>&gt;&gt;=</tt> sequences two subcomputations,
--   exiting on the first exception.
newtype ExceptT e (m :: * -> *) a
ExceptT :: m Either e a -> ExceptT e a

-- | Monads which allow their actions to be run in <a>IO</a>.
--   
--   While <a>MonadIO</a> allows an <a>IO</a> action to be lifted into
--   another monad, this class captures the opposite concept: allowing you
--   to capture the monadic context. Note that, in order to meet the laws
--   given below, the intuition is that a monad must have no monadic state,
--   but may have monadic context. This essentially limits
--   <a>MonadUnliftIO</a> to <a>ReaderT</a> and <a>IdentityT</a>
--   transformers on top of <a>IO</a>.
--   
--   Laws. For any value <tt>u</tt> returned by <a>askUnliftIO</a>, it must
--   meet the monad transformer laws as reformulated for
--   <tt>MonadUnliftIO</tt>:
--   
--   <ul>
--   <li><pre>unliftIO u . return = return</pre></li>
--   <li><pre>unliftIO u (m &gt;&gt;= f) = unliftIO u m &gt;&gt;= unliftIO
--   u . f</pre></li>
--   </ul>
--   
--   The third is a currently nameless law which ensures that the current
--   context is preserved.
--   
--   <ul>
--   <li><pre>askUnliftIO &gt;&gt;= (u -&gt; liftIO (unliftIO u m)) =
--   m</pre></li>
--   </ul>
--   
--   If you have a name for this, please submit it in a pull request for
--   great glory.
class MonadIO m => MonadUnliftIO (m :: * -> *)

-- | The inverse of <a>ExceptT</a>.
runExceptT :: () => ExceptT e m a -> m Either e a

-- | A class for monads which allow exceptions to be caught, in particular
--   exceptions which were thrown by <a>throwM</a>.
--   
--   Instances should obey the following law:
--   
--   <pre>
--   catch (throwM e) f = f e
--   </pre>
--   
--   Note that the ability to catch an exception does <i>not</i> guarantee
--   that we can deal with all possible exit points from a computation.
--   Some monads, such as continuation-based stacks, allow for more than
--   just a success/failure strategy, and therefore <tt>catch</tt>
--   <i>cannot</i> be used by those monads to properly implement a function
--   such as <tt>finally</tt>. For more information, see <a>MonadMask</a>.
class MonadThrow m => MonadCatch (m :: * -> *)

-- | Represents a general universal resource identifier using its component
--   parts.
--   
--   For example, for the URI
--   
--   <pre>
--   foo://anonymous@www.haskell.org:42/ghc?query#frag
--   </pre>
--   
--   the components are:
data URI
URI :: String -> Maybe URIAuth -> String -> String -> String -> URI

-- | <pre>
--   foo:
--   </pre>
[uriScheme] :: URI -> String

-- | <pre>
--   //anonymous@www.haskell.org:42
--   </pre>
[uriAuthority] :: URI -> Maybe URIAuth

-- | <pre>
--   /ghc
--   </pre>
[uriPath] :: URI -> String

-- | <pre>
--   ?query
--   </pre>
[uriQuery] :: URI -> String

-- | <pre>
--   #frag
--   </pre>
[uriFragment] :: URI -> String

-- | Use the default response timeout
--   
--   When used on a <a>Request</a>, means: use the manager's timeout value
--   
--   When used on a <a>ManagerSettings</a>, means: default to 30 seconds
responseTimeoutDefault :: ResponseTimeout

-- | Do not have a response timeout
responseTimeoutNone :: ResponseTimeout

-- | Specify a response timeout in microseconds
responseTimeoutMicro :: Int -> ResponseTimeout

-- | Set the proxy override value, for both HTTP (insecure) and HTTPS
--   (insecure) connections.
--   
--   Since 0.4.7
managerSetProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings

-- | Set the proxy override value, only for HTTPS (secure) connections.
--   
--   Since 0.4.7
managerSetSecureProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings

-- | Set the proxy override value, only for HTTP (insecure) connections.
--   
--   Since 0.4.7
managerSetInsecureProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings

-- | A variant of <tt>withResponse</tt> which keeps a history of all
--   redirects performed in the interim, together with the first 1024 bytes
--   of their response bodies.
--   
--   Since 0.4.1
withResponseHistory :: () => Request -> Manager -> HistoriedResponse BodyReader -> IO a -> IO a

-- | A variant of <tt>responseOpen</tt> which keeps a history of all
--   redirects performed in the interim, together with the first 1024 bytes
--   of their response bodies.
--   
--   Since 0.4.1
responseOpenHistory :: Request -> Manager -> IO HistoriedResponse BodyReader

-- | A datatype holding information on redirected requests and the final
--   response.
--   
--   Since 0.4.1
data HistoriedResponse body

-- | Perform an action using a <tt>Connection</tt> acquired from the given
--   <tt>Manager</tt>.
--   
--   You should use this only when you have to read and write interactively
--   through the connection (e.g. connection by the WebSocket protocol).
withConnection :: () => Request -> Manager -> Connection -> IO a -> IO a

-- | Close any open resources associated with the given <tt>Response</tt>.
--   In general, this will either close an active <tt>Connection</tt> or
--   return it to the <tt>Manager</tt> to be reused.
--   
--   Since 0.1.0
responseClose :: () => Response a -> IO ()

-- | The most low-level function for initiating an HTTP request.
--   
--   The first argument to this function gives a full specification on the
--   request: the host to connect to, whether to use SSL, headers, etc.
--   Please see <a>Request</a> for full details. The second argument
--   specifies which <a>Manager</a> should be used.
--   
--   This function then returns a <a>Response</a> with a <a>BodyReader</a>.
--   The <a>Response</a> contains the status code and headers that were
--   sent back to us, and the <a>BodyReader</a> contains the body of the
--   request. Note that this <a>BodyReader</a> allows you to have fully
--   interleaved IO actions during your HTTP download, making it possible
--   to download very large responses in constant memory.
--   
--   An important note: the response body returned by this function
--   represents a live HTTP connection. As such, if you do not use the
--   response body, an open socket will be retained indefinitely. You must
--   be certain to call <a>responseClose</a> on this response to free up
--   resources.
--   
--   This function automatically performs any necessary redirects, as
--   specified by the <a>redirectCount</a> setting.
--   
--   When implementing a (reverse) proxy using this function or relating
--   functions, it's wise to remove Transfer-Encoding:, Content-Length:,
--   Content-Encoding: and Accept-Encoding: from request and response
--   headers to be relayed.
--   
--   Since 0.1.0
responseOpen :: Request -> Manager -> IO Response BodyReader

-- | A convenient wrapper around <a>withResponse</a> which ignores the
--   response body. This is useful, for example, when performing a HEAD
--   request.
--   
--   Since 0.3.2
httpNoBody :: Request -> Manager -> IO Response ()

-- | A convenience wrapper around <a>withResponse</a> which reads in the
--   entire response body and immediately closes the connection. Note that
--   this function performs fully strict I/O, and only uses a lazy
--   ByteString in its response for memory efficiency. If you are
--   anticipating a large response body, you are encouraged to use
--   <a>withResponse</a> and <a>brRead</a> instead.
--   
--   Since 0.1.0
httpLbs :: Request -> Manager -> IO Response ByteString

-- | Perform a <tt>Request</tt> using a connection acquired from the given
--   <tt>Manager</tt>, and then provide the <tt>Response</tt> to the given
--   function. This function is fully exception safe, guaranteeing that the
--   response will be closed when the inner function exits. It is defined
--   as:
--   
--   <pre>
--   withResponse req man f = bracket (responseOpen req man) responseClose f
--   </pre>
--   
--   It is recommended that you use this function in place of explicit
--   calls to <a>responseOpen</a> and <a>responseClose</a>.
--   
--   You will need to use functions such as <a>brRead</a> to consume the
--   response body.
--   
--   Since 0.1.0
withResponse :: () => Request -> Manager -> Response BodyReader -> IO a -> IO a

-- | Turn a SetCookie into a Cookie, if it is valid
generateCookie :: SetCookie -> Request -> UTCTime -> Bool -> Maybe Cookie

-- | Insert a cookie created by generateCookie into the cookie jar (or not
--   if it shouldn't be allowed in)
insertCheckedCookie :: Cookie -> CookieJar -> Bool -> CookieJar

-- | This corresponds to the algorithm described in Section 5.3 "Storage
--   Model" This function consists of calling <a>generateCookie</a>
--   followed by <a>insertCheckedCookie</a>. Use this function if you plan
--   to do both in a row. <a>generateCookie</a> and
--   <a>insertCheckedCookie</a> are only provided for more fine-grained
--   control.
receiveSetCookie :: SetCookie -> Request -> UTCTime -> Bool -> CookieJar -> CookieJar

-- | This applies <a>receiveSetCookie</a> to a given Response
updateCookieJar :: () => Response a -> Request -> UTCTime -> CookieJar -> (CookieJar, Response a)

-- | This corresponds to the algorithm described in Section 5.4 "The Cookie
--   Header"
computeCookieString :: Request -> CookieJar -> UTCTime -> Bool -> (ByteString, CookieJar)

-- | This applies the <a>computeCookieString</a> to a given Request
insertCookiesIntoRequest :: Request -> CookieJar -> UTCTime -> (Request, CookieJar)

-- | This corresponds to the eviction algorithm described in Section 5.3
--   "Storage Model"
evictExpiredCookies :: CookieJar -> UTCTime -> CookieJar
removeExistingCookieFromCookieJar :: Cookie -> CookieJar -> (Maybe Cookie, CookieJar)
destroyCookieJar :: CookieJar -> [Cookie]
createCookieJar :: [Cookie] -> CookieJar

-- | This corresponds to the subcomponent algorithm entitled "Path-Match"
--   detailed in section 5.1.4
pathMatches :: ByteString -> ByteString -> Bool

-- | This corresponds to the subcomponent algorithm entitled "Paths"
--   detailed in section 5.1.4
defaultPath :: Request -> ByteString

-- | This corresponds to the subcomponent algorithm entitled "Domain
--   Matching" detailed in section 5.1.3
domainMatches :: ByteString -> ByteString -> Bool
isIpAddress :: ByteString -> Bool

-- | The default proxy settings for a manager. In particular: if the
--   <tt>http_proxy</tt> (or <tt>https_proxy</tt>) environment variable is
--   set, use it. Otherwise, use the values in the <tt>Request</tt>.
--   
--   Since 0.4.7
defaultProxy :: ProxyOverride

-- | Same as <a>proxyEnvironment</a>, but instead of default environment
--   variable names, allows you to set your own name.
--   
--   Since 0.4.7
proxyEnvironmentNamed :: Text -> Maybe Proxy -> ProxyOverride

-- | Get the proxy settings from the default environment variable
--   (<tt>http_proxy</tt> for insecure, <tt>https_proxy</tt> for secure).
--   If no variable is set, then fall back to the given value.
--   <tt>Nothing</tt> is equivalent to <a>noProxy</a>, <tt>Just</tt> is
--   equivalent to <a>useProxy</a>.
--   
--   Since 0.4.7
proxyEnvironment :: Maybe Proxy -> ProxyOverride

-- | Use the given proxy settings, regardless of the proxy value in the
--   <tt>Request</tt>.
--   
--   Since 0.4.7
useProxy :: Proxy -> ProxyOverride

-- | Never connect using a proxy, regardless of the proxy value in the
--   <tt>Request</tt>.
--   
--   Since 0.4.7
noProxy :: ProxyOverride

-- | Get the proxy settings from the <tt>Request</tt> itself.
--   
--   Since 0.4.7
proxyFromRequest :: ProxyOverride

-- | Create, use and close a <a>Manager</a>.
--   
--   Since 0.2.1
withManager :: () => ManagerSettings -> Manager -> IO a -> IO a

-- | Close all connections in a <a>Manager</a>.
--   
--   Note that this doesn't affect currently in-flight connections, meaning
--   you can safely use it without hurting any queries you may have
--   concurrently running.
--   
--   Since 0.1.0
closeManager :: Manager -> IO ()

-- | Create a <a>Manager</a>. The <tt>Manager</tt> will be shut down
--   automatically via garbage collection.
--   
--   Creating a new <a>Manager</a> is a relatively expensive operation, you
--   are advised to share a single <a>Manager</a> between requests instead.
--   
--   The first argument to this function is often
--   <a>defaultManagerSettings</a>, though add-on libraries may provide a
--   recommended replacement.
--   
--   Since 0.1.0
newManager :: ManagerSettings -> IO Manager

-- | Default value for <tt>ManagerSettings</tt>.
--   
--   Note that this value does <i>not</i> have support for SSL/TLS. If you
--   need to make any https connections, please use the http-client-tls
--   package, which provides a <tt>tlsManagerSettings</tt> value.
--   
--   Since 0.1.0
defaultManagerSettings :: ManagerSettings

-- | Same as <tt>rawConnectionModifySocket</tt>, but also takes in a chunk
--   size.
rawConnectionModifySocketSize :: Socket -> IO () -> IO Int -> Maybe HostAddress -> String -> Int -> IO Connection

-- | A value for the <tt>managerRawConnection</tt> setting, but also allows
--   you to modify the underlying <tt>Socket</tt> to set additional
--   settings. For a motivating use case, see:
--   <a>https://github.com/snoyberg/http-client/issues/71</a>.
--   
--   Since 0.3.8
rawConnectionModifySocket :: Socket -> IO () -> IO Maybe HostAddress -> String -> Int -> IO Connection

-- | Send a file as the request body, while observing streaming progress
--   via a <tt>PopObserver</tt>. Observations are made between reading and
--   sending a chunk.
--   
--   It is expected that the file size does not change between calling
--   <a>observedStreamFile</a> and making any requests using this request
--   body.
--   
--   Since 0.4.9
observedStreamFile :: StreamFileStatus -> IO () -> FilePath -> IO RequestBody

-- | Send a file as the request body.
--   
--   It is expected that the file size does not change between calling
--   <a>streamFile</a> and making any requests using this request body.
--   
--   Since 0.4.9
streamFile :: FilePath -> IO RequestBody

-- | Set the query string to the given key/value pairs.
setQueryStringPartialEscape :: [(ByteString, [EscapeItem])] -> Request -> Request

-- | Set the query string to the given key/value pairs.
--   
--   Since 0.3.6
setQueryString :: [(ByteString, Maybe ByteString)] -> Request -> Request

-- | Modify the request so that non-2XX status codes generate a runtime
--   <a>StatusCodeException</a>, by using <a>throwErrorStatusCodes</a>
setRequestCheckStatus :: Request -> Request

-- | Modify the request so that non-2XX status codes do not generate a
--   runtime <a>StatusCodeException</a>.
setRequestIgnoreStatus :: Request -> Request

-- | Add url-encoded parameters to the <a>Request</a>.
--   
--   This sets a new <a>requestBody</a>, adds a content-type request header
--   and changes the <a>method</a> to POST.
--   
--   Since 0.1.0
urlEncodedBody :: [(ByteString, ByteString)] -> Request -> Request

-- | Add a Proxy-Authorization header (with the specified username and
--   password) to the given <a>Request</a>. Ignore error handling:
--   
--   <pre>
--   applyBasicProxyAuth "user" "pass" &lt;$&gt; parseRequest "http://example.org"
--   </pre>
--   
--   Since 0.3.4
applyBasicProxyAuth :: ByteString -> ByteString -> Request -> Request

-- | Add a Basic Auth header (with the specified user name and password) to
--   the given Request. Ignore error handling:
--   
--   <pre>
--   applyBasicAuth "user" "pass" $ parseRequest_ url
--   </pre>
--   
--   NOTE: The function <tt>applyDigestAuth</tt> is provided by the
--   <tt>http-client-tls</tt> package instead of this package due to extra
--   dependencies. Please use that package if you need to use digest
--   authentication.
--   
--   Since 0.1.0
applyBasicAuth :: ByteString -> ByteString -> Request -> Request

-- | A default request value, a GET request of localhost/:80, with an empty
--   request body.
--   
--   Note that the default <a>checkResponse</a> does nothing.
defaultRequest :: Request

-- | Extract a <a>URI</a> from the request.
--   
--   Since 0.1.0
getUri :: Request -> URI

-- | Same as <a>requestFromURI</a>, but if the conversion would fail,
--   throws an impure exception.
requestFromURI_ :: URI -> Request

-- | Convert a <a>URI</a> into a <a>Request</a>.
--   
--   This can fail if the given <a>URI</a> is not absolute, or if the
--   <a>URI</a> scheme is not <tt>"http"</tt> or <tt>"https"</tt>. In these
--   cases the function will throw an error via <a>MonadThrow</a>.
--   
--   This function defaults some of the values in <a>Request</a>, such as
--   setting <a>method</a> to <tt><a>GET</a></tt> and <a>requestHeaders</a>
--   to <tt>[]</tt>.
--   
--   A <a>Request</a> created by this function won't cause exceptions on
--   non-2XX response status codes.
requestFromURI :: MonadThrow m => URI -> m Request

-- | Same as <a>parseRequest</a>, but parse errors cause an impure
--   exception. Mostly useful for static strings which are known to be
--   correctly formatted.
parseRequest_ :: String -> Request

-- | Convert a URL into a <a>Request</a>.
--   
--   This function defaults some of the values in <a>Request</a>, such as
--   setting <a>method</a> to <tt><a>GET</a></tt> and <a>requestHeaders</a>
--   to <tt>[]</tt>.
--   
--   Since this function uses <a>MonadThrow</a>, the return monad can be
--   anything that is an instance of <a>MonadThrow</a>, such as <a>IO</a>
--   or <a>Maybe</a>.
--   
--   You can place the request method at the beginning of the URL separated
--   by a space, e.g.:
--   
--   @@<tt> parseRequest "POST <a>http://httpbin.org/post"</a> </tt>@@
--   
--   Note that the request method must be provided as all capital letters.
--   
--   A <a>Request</a> created by this function won't cause exceptions on
--   non-2XX response status codes.
--   
--   To create a request which throws on non-2XX status codes, see
--   <a>parseUrlThrow</a>
parseRequest :: MonadThrow m => String -> m Request

-- | Throws a <a>StatusCodeException</a> wrapped in
--   <a>HttpExceptionRequest</a>, if the response's status code indicates
--   an error (if it isn't 2xx). This can be used to implement
--   <a>checkResponse</a>.
throwErrorStatusCodes :: MonadIO m => Request -> Response BodyReader -> m ()

-- | Same as <a>parseRequest</a>, except will throw an <a>HttpException</a>
--   in the event of a non-2XX response. This uses
--   <a>throwErrorStatusCodes</a> to implement <a>checkResponse</a>.
parseUrlThrow :: MonadThrow m => String -> m Request

-- | Deprecated synonym for <a>parseUrlThrow</a>. You probably want
--   <a>parseRequest</a> or <a>parseRequest_</a> instead.
parseUrl :: MonadThrow m => String -> m Request

-- | Strictly consume all remaining chunks of data from the stream.
--   
--   Since 0.1.0
brConsume :: BodyReader -> IO [ByteString]

-- | Continuously call <a>brRead</a>, building up a lazy ByteString until a
--   chunk is constructed that is at least as many bytes as requested.
--   
--   Since 0.4.20
brReadSome :: BodyReader -> Int -> IO ByteString

-- | Get a single chunk of data from the response body, or an empty
--   bytestring if no more data is available.
--   
--   Note that in order to consume the entire request body, you will need
--   to repeatedly call this function until you receive an empty
--   <tt>ByteString</tt> as a result.
--   
--   Since 0.1.0
brRead :: BodyReader -> IO ByteString

-- | Create a new <a>Connection</a> from a <a>Socket</a>.
socketConnection :: Socket -> Int -> IO Connection

-- | Create a new <a>Connection</a> from a read, write, and close function.
makeConnection :: IO ByteString -> ByteString -> IO () -> IO () -> IO Connection

-- | An <tt>IO</tt> action that represents an incoming response body coming
--   from the server. Data provided by this action has already been
--   gunzipped and de-chunked, and respects any content-length headers
--   present.
--   
--   The action gets a single chunk of data from the response body, or an
--   empty bytestring if no more data is available.
--   
--   Since 0.4.0
type BodyReader = IO ByteString

-- | An exception which may be generated by this library
data HttpException

-- | Most exceptions are specific to a <a>Request</a>. Inspect the
--   <a>HttpExceptionContent</a> value for details on what occurred.
HttpExceptionRequest :: Request -> HttpExceptionContent -> HttpException

-- | A URL (first field) is invalid for a given reason (second argument).
InvalidUrlException :: String -> String -> HttpException
data HttpExceptionContent

-- | Generated by the <tt>parseUrlThrow</tt> function when the server
--   returns a non-2XX response status code.
--   
--   May include the beginning of the response body.
StatusCodeException :: Response () -> ByteString -> HttpExceptionContent

-- | The server responded with too many redirects for a request.
--   
--   Contains the list of encountered responses containing redirects in
--   reverse chronological order; including last redirect, which triggered
--   the exception and was not followed.
TooManyRedirects :: [Response ByteString] -> HttpExceptionContent

-- | Either too many headers, or too many total bytes in a single header,
--   were returned by the server, and the memory exhaustion protection in
--   this library has kicked in.
OverlongHeaders :: HttpExceptionContent

-- | The server took too long to return a response. This can be altered via
--   <a>responseTimeout</a> or <a>managerResponseTimeout</a>.
ResponseTimeout :: HttpExceptionContent

-- | Attempting to connect to the server timed out.
ConnectionTimeout :: HttpExceptionContent

-- | An exception occurred when trying to connect to the server.
ConnectionFailure :: SomeException -> HttpExceptionContent

-- | The status line returned by the server could not be parsed.
InvalidStatusLine :: ByteString -> HttpExceptionContent

-- | The given response header line could not be parsed
InvalidHeader :: ByteString -> HttpExceptionContent

-- | The given request header is not compliant (e.g. has newlines)
InvalidRequestHeader :: ByteString -> HttpExceptionContent

-- | An exception was raised by an underlying library when performing the
--   request. Most often, this is caused by a failing socket action or a
--   TLS exception.
InternalException :: SomeException -> HttpExceptionContent

-- | A non-200 status code was returned when trying to connect to the proxy
--   server on the given host and port.
ProxyConnectException :: ByteString -> Int -> Status -> HttpExceptionContent

-- | No response data was received from the server at all. This exception
--   may deserve special handling within the library, since it may indicate
--   that a pipelining has been used, and a connection thought to be open
--   was in fact closed.
NoResponseDataReceived :: HttpExceptionContent

-- | Exception thrown when using a <tt>Manager</tt> which does not have
--   support for secure connections. Typically, you will want to use
--   <tt>tlsManagerSettings</tt> from <tt>http-client-tls</tt> to overcome
--   this.
TlsNotSupported :: HttpExceptionContent

-- | The request body provided did not match the expected size.
--   
--   Provides the expected and actual size.
WrongRequestBodyStreamSize :: Word64 -> Word64 -> HttpExceptionContent

-- | The returned response body is too short. Provides the expected size
--   and actual size.
ResponseBodyTooShort :: Word64 -> Word64 -> HttpExceptionContent

-- | A chunked response body had invalid headers.
InvalidChunkHeaders :: HttpExceptionContent

-- | An incomplete set of response headers were returned.
IncompleteHeaders :: HttpExceptionContent

-- | The host we tried to connect to is invalid (e.g., an empty string).
InvalidDestinationHost :: ByteString -> HttpExceptionContent

-- | An exception was thrown when inflating a response body.
HttpZlibException :: ZlibException -> HttpExceptionContent

-- | Values in the proxy environment variable were invalid. Provides the
--   environment variable name and its value.
InvalidProxyEnvironmentVariable :: Text -> Text -> HttpExceptionContent

-- | Attempted to use a <a>Connection</a> which was already closed
ConnectionClosed :: HttpExceptionContent

-- | Proxy settings are not valid (Windows specific currently) @since 0.5.7
InvalidProxySettings :: Text -> HttpExceptionContent
data Cookie
Cookie :: ByteString -> ByteString -> UTCTime -> ByteString -> ByteString -> UTCTime -> UTCTime -> Bool -> Bool -> Bool -> Bool -> Cookie
[cookie_name] :: Cookie -> ByteString
[cookie_value] :: Cookie -> ByteString
[cookie_expiry_time] :: Cookie -> UTCTime
[cookie_domain] :: Cookie -> ByteString
[cookie_path] :: Cookie -> ByteString
[cookie_creation_time] :: Cookie -> UTCTime
[cookie_last_access_time] :: Cookie -> UTCTime
[cookie_persistent] :: Cookie -> Bool
[cookie_host_only] :: Cookie -> Bool
[cookie_secure_only] :: Cookie -> Bool
[cookie_http_only] :: Cookie -> Bool
data CookieJar

-- | The host name of the HTTP proxy.
proxyHost :: Proxy -> ByteString

-- | The port number of the HTTP proxy.
proxyPort :: Proxy -> Int

-- | When using one of the <a>RequestBodyStream</a> /
--   <a>RequestBodyStreamChunked</a> constructors, you must ensure that the
--   <a>GivesPopper</a> can be called multiple times. Usually this is not a
--   problem.
--   
--   The <a>RequestBodyStreamChunked</a> will send a chunked request body.
--   Note that not all servers support this. Only use
--   <a>RequestBodyStreamChunked</a> if you know the server you're sending
--   to supports chunked request bodies.
--   
--   Since 0.1.0
data RequestBody
RequestBodyLBS :: ByteString -> RequestBody
RequestBodyBS :: ByteString -> RequestBody
RequestBodyBuilder :: Int64 -> Builder -> RequestBody
RequestBodyStream :: Int64 -> GivesPopper () -> RequestBody
RequestBodyStreamChunked :: GivesPopper () -> RequestBody

-- | Allows creation of a <tt>RequestBody</tt> inside the <tt>IO</tt>
--   monad, which is useful for making easier APIs (like
--   <tt>setRequestBodyFile</tt>).
RequestBodyIO :: IO RequestBody -> RequestBody

-- | A function which generates successive chunks of a request body,
--   provider a single empty bytestring when no more data is available.
--   
--   Since 0.1.0
type Popper = IO ByteString

-- | A function which must be provided with a <a>Popper</a>.
--   
--   Since 0.1.0
type NeedsPopper a = Popper -> IO a

-- | A function which will provide a <a>Popper</a> to a <a>NeedsPopper</a>.
--   This seemingly convoluted structure allows for creation of request
--   bodies which allocate scarce resources in an exception safe manner.
--   
--   Since 0.1.0
type GivesPopper a = NeedsPopper a -> IO a

-- | All information on how to connect to a host and what should be sent in
--   the HTTP request.
--   
--   If you simply wish to download from a URL, see <tt>parseRequest</tt>.
--   
--   The constructor for this data type is not exposed. Instead, you should
--   use either the <tt>defaultRequest</tt> value, or <tt>parseRequest</tt>
--   to construct from a URL, and then use the records below to make
--   modifications. This approach allows http-client to add configuration
--   options without breaking backwards compatibility.
--   
--   For example, to construct a POST request, you could do something like:
--   
--   <pre>
--   initReq &lt;- parseRequest "http://www.example.com/path"
--   let req = initReq
--               { method = "POST"
--               }
--   </pre>
--   
--   For more information, please see
--   <a>http://www.yesodweb.com/book/settings-types</a>.
--   
--   Since 0.1.0
data Request

-- | How to deal with timing out a response
data ResponseTimeout

-- | A simple representation of the HTTP response.
--   
--   Since 0.1.0
data Response body

-- | Settings for a <tt>Manager</tt>. Please use the
--   <tt>defaultManagerSettings</tt> function and then modify individual
--   settings. For more information, see
--   <a>http://www.yesodweb.com/book/settings-types</a>.
--   
--   Since 0.1.0
data ManagerSettings

-- | How the HTTP proxy server settings should be discovered.
--   
--   Since 0.4.7
data ProxyOverride

-- | Keeps track of open connections for keep-alive.
--   
--   If possible, you should share a single <a>Manager</a> between multiple
--   threads and requests.
--   
--   Since 0.1.0
data Manager
class HasHttpManager a
getHttpManager :: HasHttpManager a => a -> Manager

-- | Status of streaming a request body from a file.
--   
--   Since 0.4.9
data StreamFileStatus
StreamFileStatus :: Int64 -> Int64 -> Int -> StreamFileStatus
[fileSize] :: StreamFileStatus -> Int64
[readSoFar] :: StreamFileStatus -> Int64
[thisChunkSize] :: StreamFileStatus -> Int
fragment :: URI -> String
query :: URI -> String
path :: URI -> String
authority :: URI -> String
scheme :: URI -> String
unreserved :: Char -> Bool
reserved :: Char -> Bool
escapeString :: String -> Char -> Bool -> String
parseabsoluteURI :: String -> Maybe URI

-- | Path segment normalization; cf. RFC3986 section 6.2.2.3
normalizePathSegments :: String -> String

-- | Encoding normalization; cf. RFC3986 section 6.2.2.2
normalizeEscape :: String -> String

-- | Case normalization; cf. RFC3986 section 6.2.2.1 NOTE: authority case
--   normalization is not performed
normalizeCase :: String -> String

-- | Returns a new <a>URI</a> which represents the relative location of the
--   first <a>URI</a> with respect to the second <a>URI</a>. Thus, the
--   values supplied are expected to be absolute URIs, and the result
--   returned may be a relative URI.
--   
--   Example:
--   
--   <pre>
--   "http://example.com/Root/sub1/name2#frag"
--     `relativeFrom` "http://example.com/Root/sub2/name2#frag"
--     == "../sub1/name2#frag"
--   </pre>
--   
--   There is no single correct implementation of this function, but any
--   acceptable implementation must satisfy the following:
--   
--   <pre>
--   (uabs `relativeFrom` ubase) `relativeTo` ubase == uabs
--   </pre>
--   
--   For any valid absolute URI. (cf.
--   <a>http://lists.w3.org/Archives/Public/uri/2003Jan/0008.html</a>
--   <a>http://lists.w3.org/Archives/Public/uri/2003Jan/0005.html</a>)
relativeFrom :: URI -> URI -> URI

-- | Returns the segments of the path component. E.g., pathSegments
--   <a>$</a> parseURI "<a>http://example.org/foo/bar/baz"</a> == ["foo",
--   "bar", "baz"]
pathSegments :: URI -> [String]

-- | Returns a new <a>URI</a> which represents the value of the first
--   <a>URI</a> interpreted as relative to the second <a>URI</a>.
--   
--   Algorithm from RFC3986 [3], section 5.2
relativeTo :: URI -> URI -> URI

-- | Returns a new <a>URI</a> which represents the value of the first
--   <a>URI</a> interpreted as relative to the second <a>URI</a>. For
--   example:
--   
--   <pre>
--   "foo" `relativeTo` "http://bar.org/" = "http://bar.org/foo"
--   "http:foo" `nonStrictRelativeTo` "http://bar.org/" = "http://bar.org/foo"
--   </pre>
--   
--   Algorithm from RFC3986 [3], section 5.2.2
nonStrictRelativeTo :: URI -> URI -> URI

-- | Turns all instances of escaped characters in the string back into
--   literal characters.
unEscapeString :: String -> String

-- | Can be used to make a string valid for use in a URI.
escapeURIString :: Char -> Bool -> String -> String

-- | Escape character if supplied predicate is not satisfied, otherwise
--   return character as singleton string.
escapeURIChar :: Char -> Bool -> Char -> String

-- | Returns <a>True</a> if the character is allowed unescaped in a URI
--   component.
--   
--   <pre>
--   &gt;&gt;&gt; escapeURIString isUnescapedInURIComponent "http://haskell.org:80?some_param=true&amp;other_param=їґ"
--   "http%3A%2F%2Fhaskell.org%3A80%3Fsome_param%3Dtrue%26other_param%3D%D1%97%D2%91"
--   </pre>
isUnescapedInURIComponent :: Char -> Bool

-- | Returns <a>True</a> if the character is allowed unescaped in a URI.
--   
--   <pre>
--   &gt;&gt;&gt; escapeURIString isUnescapedInURI "http://haskell.org:80?some_param=true&amp;other_param=їґ"
--   "http://haskell.org:80?some_param=true&amp;other_param=%D1%97%D2%91"
--   </pre>
isUnescapedInURI :: Char -> Bool

-- | Returns <a>True</a> if the character is allowed in a URI.
isAllowedInURI :: Char -> Bool

-- | Turn a <a>URI</a> into a string.
--   
--   Uses a supplied function to map the userinfo part of the URI.
--   
--   The Show instance for URI uses a mapping that hides any password that
--   may be present in the URI. Use this function with argument <tt>id</tt>
--   to preserve the password in the formatted output.
uriToString :: String -> String -> URI -> ShowS

-- | Returns <a>True</a> if the character is an "unreserved" character in a
--   URI. These characters do not need to be escaped in a URI. The only
--   characters allowed in a URI are either "reserved", "unreserved", or an
--   escape sequence (<tt>%</tt> followed by two hex digits).
isUnreserved :: Char -> Bool

-- | Returns <a>True</a> if the character is a "reserved" character in a
--   URI. To include a literal instance of one of these characters in a
--   component of a URI, it must be escaped.
isReserved :: Char -> Bool
uriIsRelative :: URI -> Bool
uriIsAbsolute :: URI -> Bool

-- | Test if string contains a valid IPv4 address
isIPv4address :: String -> Bool

-- | Test if string contains a valid IPv6 address
isIPv6address :: String -> Bool

-- | Test if string contains a valid absolute URI (an absolute URI without
--   a fragment identifier).
isAbsoluteURI :: String -> Bool

-- | Test if string contains a valid relative URI (a relative URI with
--   optional fragment identifier).
isRelativeReference :: String -> Bool

-- | Test if string contains a valid URI reference (an absolute or relative
--   URI with optional fragment identifier).
isURIReference :: String -> Bool

-- | Test if string contains a valid URI (an absolute URI with optional
--   fragment identifier).
isURI :: String -> Bool

-- | Parse an absolute URI to a <a>URI</a> value. Returns <a>Nothing</a> if
--   the string is not a valid absolute URI. (an absolute URI without a
--   fragment identifier).
parseAbsoluteURI :: String -> Maybe URI

-- | Parse a relative URI to a <a>URI</a> value. Returns <a>Nothing</a> if
--   the string is not a valid relative URI. (a relative URI with optional
--   fragment identifier).
parseRelativeReference :: String -> Maybe URI

-- | Parse a URI reference to a <a>URI</a> value. Returns <a>Nothing</a> if
--   the string is not a valid URI reference. (an absolute or relative URI
--   with optional fragment identifier).
parseURIReference :: String -> Maybe URI

-- | Turn a string containing a URI into a <a>URI</a>. Returns
--   <a>Nothing</a> if the string is not a valid URI; (an absolute URI with
--   optional fragment identifier).
--   
--   NOTE: this is different from the previous network.URI, whose
--   <tt>parseURI</tt> function works like <a>parseURIReference</a> in this
--   module.
parseURI :: String -> Maybe URI

-- | Blank URI
nullURI :: URI

-- | Type for authority value within a URI
data URIAuth
URIAuth :: String -> String -> String -> URIAuth

-- | <pre>
--   anonymous@
--   </pre>
[uriUserInfo] :: URIAuth -> String

-- | <pre>
--   www.haskell.org
--   </pre>
[uriRegName] :: URIAuth -> String

-- | <pre>
--   :42
--   </pre>
[uriPort] :: URIAuth -> String
instance Data.Has.Has Magicbane.HTTPClient.ModHttpClient α => Network.HTTP.Client.Types.HasHttpManager α


-- | Integrates the refinement types from the refined library with aeson.
module Magicbane.Validation
instance Data.Aeson.Types.ToJSON.ToJSON α => Data.Aeson.Types.ToJSON.ToJSON (Refined.Refined ρ α)
instance (Data.Aeson.Types.FromJSON.FromJSON α, Refined.Predicate ρ α) => Data.Aeson.Types.FromJSON.FromJSON (Refined.Refined ρ α)


-- | A Dropwizard-inspired web framework that integrates Servant,
--   monad-metrics<i>EKG, monad-logger</i>fast-logger, and other useful
--   libraries to provide a smooth web service development experience.
--   
--   This module provides all the stuff you need.
module Magicbane

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

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

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

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

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

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

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

-- | Like <a>decode</a> 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, <a>Nothing</a> is returned.
--   
--   The input file's content must consist solely of a JSON document, with
--   no trailing data except for whitespace.
--   
--   This function parses and performs conversion immediately. See
--   <a>json'</a> for details.
decodeFileStrict' :: FromJSON a => FilePath -> IO Maybe a

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

-- | Retrieve the value associated with the given key of an <a>Object</a>.
--   The result is <a>Nothing</a> if the key is not present or if its value
--   is <a>Null</a>, or <tt>empty</tt> if the value cannot be converted to
--   the desired type.
--   
--   This accessor is most useful if the key and value can be absent from
--   an object without affecting its validity. If the key and value are
--   mandatory, use <a>.:</a> instead.
(.:?) :: FromJSON a => Object -> Text -> Parser Maybe a

-- | Retrieve the value associated with the given key of an <a>Object</a>.
--   The result is <tt>empty</tt> if the key is not present or the value
--   cannot be converted to the desired type.
--   
--   This accessor is appropriate if the key and value <i>must</i> be
--   present in an object for it to be valid. If the key and value are
--   optional, use <a>.:?</a> instead.
(.:) :: FromJSON a => Object -> Text -> Parser 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

-- | <tt><a>withBool</a> expected f value</tt> applies <tt>f</tt> to the
--   <a>Bool</a> when <tt>value</tt> is a <a>Bool</a> and fails using
--   <tt><a>typeMismatch</a> expected</tt> otherwise.
withBool :: () => String -> Bool -> Parser a -> Value -> Parser a

-- | <tt><a>withScientific</a> expected f value</tt> applies <tt>f</tt> to
--   the <a>Scientific</a> number when <tt>value</tt> is a <a>Number</a>
--   and fails using <tt><a>typeMismatch</a> expected</tt> otherwise.
withScientific :: () => String -> Scientific -> Parser a -> Value -> Parser a

-- | <tt><a>withNumber</a> expected f value</tt> applies <tt>f</tt> to the
--   <a>Number</a> when <tt>value</tt> is a <a>Number</a> and fails using
--   <tt><a>typeMismatch</a> expected</tt> otherwise.
withNumber :: () => String -> Number -> Parser a -> Value -> Parser a

-- | <tt><a>withArray</a> expected f value</tt> applies <tt>f</tt> to the
--   <a>Array</a> when <tt>value</tt> is an <a>Array</a> and fails using
--   <tt><a>typeMismatch</a> expected</tt> otherwise.
withArray :: () => String -> Array -> Parser a -> Value -> Parser a

-- | <tt><a>withText</a> expected f value</tt> applies <tt>f</tt> to the
--   <a>Text</a> when <tt>value</tt> is a <a>String</a> and fails using
--   <tt><a>typeMismatch</a> expected</tt> otherwise.
withText :: () => String -> Text -> Parser a -> Value -> Parser a

-- | <tt><a>withObject</a> expected f value</tt> applies <tt>f</tt> to the
--   <a>Object</a> when <tt>value</tt> is an <a>Object</a> and fails using
--   <tt><a>typeMismatch</a> expected</tt> otherwise.
withObject :: () => String -> Object -> Parser a -> Value -> Parser a

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

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

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

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

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

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

-- | A <a>FromArgs</a> value either stores nothing (for <a>FromJSON</a>) or
--   it stores the two function arguments that decode occurrences of the
--   type parameter (for <a>FromJSON1</a>).
data FromArgs arity a
[NoFromArgs] :: FromArgs Zero a
[From1Args] :: 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
--   <a>Object</a> could be missing a required key, an <a>Array</a> could
--   be of the wrong size, or a value could be of an incompatible type.
--   
--   The basic ways to signal a failed conversion are as follows:
--   
--   <ul>
--   <li><tt>empty</tt> and <tt>mzero</tt> work, but are terse and
--   uninformative;</li>
--   <li><a>fail</a> yields a custom error message;</li>
--   <li><a>typeMismatch</a> produces an informative message for cases when
--   the value encountered is not of the expected type.</li>
--   </ul>
--   
--   An example type and instance using <a>typeMismatch</a>:
--   
--   <pre>
--   -- Allow ourselves to write <a>Text</a> literals.
--   {-# LANGUAGE OverloadedStrings #-}
--   
--   data Coord = Coord { x :: Double, y :: Double }
--   
--   instance <a>FromJSON</a> Coord where
--       <a>parseJSON</a> (<a>Object</a> v) = Coord
--           <a>&lt;$&gt;</a> v <a>.:</a> "x"
--           <a>&lt;*&gt;</a> v <a>.:</a> "y"
--   
--       -- We do not expect a non-<a>Object</a> value here.
--       -- We could use <tt>mzero</tt> to fail, but <a>typeMismatch</a>
--       -- gives a much more informative error message.
--       <a>parseJSON</a> invalid    = <a>typeMismatch</a> "Coord" invalid
--   </pre>
--   
--   For this common case of only being concerned with a single type of
--   JSON value, the functions <a>withObject</a>, <a>withNumber</a>, etc.
--   are provided. Their use is to be preferred when possible, since they
--   are more terse. Using <a>withObject</a>, we can rewrite the above
--   instance (assuming the same language extension and data type) as:
--   
--   <pre>
--   instance <a>FromJSON</a> Coord where
--       <a>parseJSON</a> = <a>withObject</a> "Coord" $ \v -&gt; Coord
--           <a>&lt;$&gt;</a> v <a>.:</a> "x"
--           <a>&lt;*&gt;</a> v <a>.:</a> "y"
--   </pre>
--   
--   Instead of manually writing your <a>FromJSON</a> instance, there are
--   two options to do it automatically:
--   
--   <ul>
--   <li><a>Data.Aeson.TH</a> provides Template Haskell functions which
--   will derive an instance at compile time. The generated instance is
--   optimized for your type so it will probably be more efficient than the
--   following option.</li>
--   <li>The compiler can provide a default generic implementation for
--   <a>parseJSON</a>.</li>
--   </ul>
--   
--   To use the second, simply add a <tt>deriving <a>Generic</a></tt>
--   clause to your datatype and declare a <a>FromJSON</a> instance for
--   your datatype without giving a definition for <a>parseJSON</a>.
--   
--   For example, the previous example can be simplified to just:
--   
--   <pre>
--   {-# LANGUAGE DeriveGeneric #-}
--   
--   import <a>GHC.Generics</a>
--   
--   data Coord = Coord { x :: Double, y :: Double } deriving <a>Generic</a>
--   
--   instance <a>FromJSON</a> Coord
--   </pre>
--   
--   The default implementation will be equivalent to <tt>parseJSON =
--   <a>genericParseJSON</a> <a>defaultOptions</a></tt>; If you need
--   different options, you can customize the generic decoding by defining:
--   
--   <pre>
--   customOptions = <a>defaultOptions</a>
--                   { <a>fieldLabelModifier</a> = <a>map</a> <a>toUpper</a>
--                   }
--   
--   instance <a>FromJSON</a> Coord where
--       <a>parseJSON</a> = <a>genericParseJSON</a> customOptions
--   </pre>
class FromJSON a
parseJSON :: FromJSON a => Value -> Parser a
parseJSONList :: FromJSON a => Value -> Parser [a]

-- | Read the docs for <tt>ToJSONKey</tt> first. This class is a conversion
--   in the opposite direction. If you have a newtype wrapper around
--   <a>Text</a>, the recommended way to define instances is with
--   generalized newtype deriving:
--   
--   <pre>
--   newtype SomeId = SomeId { getSomeId :: Text }
--     deriving (Eq,Ord,Hashable,FromJSONKey)
--   </pre>
class FromJSONKey a

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

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

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

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

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

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

-- | conversion for non-textual keys
FromJSONKeyValue :: !Value -> Parser a -> FromJSONKeyFunction a

-- | Lifting of the <a>FromJSON</a> class to unary type constructors.
--   
--   Instead of manually writing your <a>FromJSON1</a> instance, there are
--   two options to do it automatically:
--   
--   <ul>
--   <li><a>Data.Aeson.TH</a> provides Template Haskell functions which
--   will derive an instance at compile time. The generated instance is
--   optimized for your type so it will probably be more efficient than the
--   following option.</li>
--   <li>The compiler can provide a default generic implementation for
--   <a>liftParseJSON</a>.</li>
--   </ul>
--   
--   To use the second, simply add a <tt>deriving <a>Generic1</a></tt>
--   clause to your datatype and declare a <a>FromJSON1</a> instance for
--   your datatype without giving a definition for <a>liftParseJSON</a>.
--   
--   For example:
--   
--   <pre>
--   {-# LANGUAGE DeriveGeneric #-}
--   
--   import <a>GHC.Generics</a>
--   
--   data Pair a b = Pair { pairFst :: a, pairSnd :: b } deriving <a>Generic1</a>
--   
--   instance <a>FromJSON</a> a =&gt; <a>FromJSON1</a> (Pair a)
--   </pre>
--   
--   If the default implementation doesn't give exactly the results you
--   want, you can customize the generic decoding with only a tiny amount
--   of effort, using <a>genericLiftParseJSON</a> with your preferred
--   <a>Options</a>:
--   
--   <pre>
--   customOptions = <a>defaultOptions</a>
--                   { <a>fieldLabelModifier</a> = <a>map</a> <a>toUpper</a>
--                   }
--   
--   instance <a>FromJSON</a> a =&gt; <a>FromJSON1</a> (Pair a) where
--       <a>liftParseJSON</a> = <a>genericLiftParseJSON</a> customOptions
--   </pre>
class FromJSON1 (f :: * -> *)
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 <a>FromJSON</a> class to binary type constructors.
--   
--   Instead of manually writing your <a>FromJSON2</a> instance,
--   <a>Data.Aeson.TH</a> provides Template Haskell functions which will
--   derive an instance at compile time.
class FromJSON2 (f :: * -> * -> *)
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 a top-level JSON value.
--   
--   This is a strict version of <a>json</a> which avoids building up
--   thunks during parsing; it performs all conversions immediately. Prefer
--   this version if most of the JSON data needs to be accessed.
--   
--   This function is an alias for <a>value'</a>. In aeson 0.8 and earlier,
--   it parsed only object or array types, in conformance with the
--   now-obsolete RFC 4627.
json' :: Parser Value

-- | Parse a top-level JSON value.
--   
--   The conversion of a parsed value to a Haskell value is deferred until
--   the Haskell value is needed. This may improve performance if only a
--   subset of the results of conversions are needed, but at a cost in
--   thunk allocation.
--   
--   This function is an alias for <a>value</a>. In aeson 0.8 and earlier,
--   it parsed only object or array types, in conformance with the
--   now-obsolete RFC 4627.
json :: Parser Value

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

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

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

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

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

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

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

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

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

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

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

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

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

-- | A type-level indicator that <tt>ToJSON1</tt> or <tt>FromJSON1</tt> is
--   being derived generically.
data One
aesonQQ :: QuasiQuoter

-- | A <a>ThreadId</a> is an abstract type representing a handle to a
--   thread. <a>ThreadId</a> is an instance of <a>Eq</a>, <a>Ord</a> and
--   <a>Show</a>, where the <a>Ord</a> instance implements an arbitrary
--   total ordering over <a>ThreadId</a>s. The <a>Show</a> instance lets
--   you convert an arbitrary-valued <a>ThreadId</a> to string form;
--   showing a <a>ThreadId</a> value is occasionally useful when debugging
--   or diagnosing the behaviour of a concurrent program.
--   
--   <i>Note</i>: in GHC, if you have a <a>ThreadId</a>, you essentially
--   have a pointer to the thread itself. This means the thread itself
--   can't be garbage collected until you drop the <a>ThreadId</a>. This
--   misfeature will hopefully be corrected at a later date.
data ThreadId

-- | <a>True</a> if bound threads are supported. If
--   <tt>rtsSupportsBoundThreads</tt> is <a>False</a>,
--   <a>isCurrentThreadBound</a> will always return <a>False</a> and both
--   <a>forkOS</a> and <a>runInBoundThread</a> will fail.
rtsSupportsBoundThreads :: Bool

-- | <a>Chan</a> is an abstract type representing an unbounded FIFO
--   channel.
data Chan a

-- | Superclass for asynchronous exceptions.
data SomeAsyncException
[SomeAsyncException] :: SomeAsyncException

-- | Exceptions that occur in the <tt>IO</tt> monad. An
--   <tt>IOException</tt> records a more specific error type, a descriptive
--   string and maybe the handle that was used when the error was flagged.
data IOException

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

-- | Render this exception value in a human-friendly manner.
--   
--   Default implementation: <tt><a>show</a></tt>.
displayException :: Exception e => e -> String

-- | <a>asProxyTypeOf</a> is a type-restricted version of <a>const</a>. It
--   is usually used as an infix operator, and its typing forces its first
--   argument (which is usually overloaded) to have the same type as the
--   tag of the second.
--   
--   <pre>
--   &gt;&gt;&gt; import Data.Word
--   
--   &gt;&gt;&gt; :type asProxyTypeOf 123 (Proxy :: Proxy Word8)
--   asProxyTypeOf 123 (Proxy :: Proxy Word8) :: Word8
--   </pre>
--   
--   Note the lower-case <tt>proxy</tt> in the definition. This allows any
--   type constructor with just one argument to be passed to the function,
--   for example we could also write
--   
--   <pre>
--   &gt;&gt;&gt; import Data.Word
--   
--   &gt;&gt;&gt; :type asProxyTypeOf 123 (Just (undefined :: Word8))
--   asProxyTypeOf 123 (Just (undefined :: Word8)) :: Word8
--   </pre>
asProxyTypeOf :: () => a -> proxy a -> a

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

-- | A concrete, promotable proxy type, for use at the kind level There are
--   no instances for this because it is intended at the kind level only
data KProxy t
KProxy :: KProxy t

-- | Type-level <a>If</a>. <tt>If True a b</tt> ==&gt; <tt>a</tt>; <tt>If
--   False a b</tt> ==&gt; <tt>b</tt>

-- | An <a>MVar</a> (pronounced "em-var") is a synchronising variable, used
--   for communication between concurrent threads. It can be thought of as
--   a a box, which may be empty or full.
data MVar a

-- | The <tt>SomeException</tt> type is the root of the exception type
--   hierarchy. When an exception of type <tt>e</tt> is thrown, behind the
--   scenes it is encapsulated in a <tt>SomeException</tt>.
data SomeException
[SomeException] :: SomeException

-- | The parameterizable maybe monad, obtained by composing an arbitrary
--   monad with the <a>Maybe</a> monad.
--   
--   Computations are actions that may produce a value or exit.
--   
--   The <a>return</a> function yields a computation that produces that
--   value, while <tt>&gt;&gt;=</tt> sequences two subcomputations, exiting
--   if either computation does.
newtype MaybeT (m :: * -> *) a
MaybeT :: m Maybe a -> MaybeT a
[runMaybeT] :: MaybeT a -> m Maybe a

-- | A monad transformer that adds exceptions to other monads.
--   
--   <tt>ExceptT</tt> constructs a monad parameterized over two things:
--   
--   <ul>
--   <li>e - The exception type.</li>
--   <li>m - The inner monad.</li>
--   </ul>
--   
--   The <a>return</a> function yields a computation that produces the
--   given value, while <tt>&gt;&gt;=</tt> sequences two subcomputations,
--   exiting on the first exception.
newtype ExceptT e (m :: * -> *) a
ExceptT :: m Either e a -> ExceptT e a

-- | Monads which allow their actions to be run in <a>IO</a>.
--   
--   While <a>MonadIO</a> allows an <a>IO</a> action to be lifted into
--   another monad, this class captures the opposite concept: allowing you
--   to capture the monadic context. Note that, in order to meet the laws
--   given below, the intuition is that a monad must have no monadic state,
--   but may have monadic context. This essentially limits
--   <a>MonadUnliftIO</a> to <a>ReaderT</a> and <a>IdentityT</a>
--   transformers on top of <a>IO</a>.
--   
--   Laws. For any value <tt>u</tt> returned by <a>askUnliftIO</a>, it must
--   meet the monad transformer laws as reformulated for
--   <tt>MonadUnliftIO</tt>:
--   
--   <ul>
--   <li><pre>unliftIO u . return = return</pre></li>
--   <li><pre>unliftIO u (m &gt;&gt;= f) = unliftIO u m &gt;&gt;= unliftIO
--   u . f</pre></li>
--   </ul>
--   
--   The third is a currently nameless law which ensures that the current
--   context is preserved.
--   
--   <ul>
--   <li><pre>askUnliftIO &gt;&gt;= (u -&gt; liftIO (unliftIO u m)) =
--   m</pre></li>
--   </ul>
--   
--   If you have a name for this, please submit it in a pull request for
--   great glory.
class MonadIO m => MonadUnliftIO (m :: * -> *)

-- | A class for types with a default value.
class Default a

-- | The default value for this type.
def :: Default a => a

-- | A type class for extensible product.
--   
--   We provide instances for tuples up to 12 elements by default. You can
--   define your own instance of <a>Has</a>, but most of the time tuples
--   will do fine.
class Has a t
getter :: Has a t => t -> a
modifier :: Has a t => a -> a -> t -> t
hasLens :: Has a t => Lens t a

-- | Register a number of metrics related to garbage collector behavior.
--   
--   To enable GC statistics collection, either run your program with
--   
--   <pre>
--   +RTS -T
--   </pre>
--   
--   or compile it with
--   
--   <pre>
--   -with-rtsopts=-T
--   </pre>
--   
--   The runtime overhead of <tt>-T</tt> is very small so it's safe to
--   always leave it enabled.
--   
--   Registered counters:
--   
--   <ul>
--   <li><i><tt>rts.gc.bytes_allocated</tt></i> Total number of bytes
--   allocated</li>
--   <li><i><tt>rts.gc.num_gcs</tt></i> Number of garbage collections
--   performed</li>
--   <li><i><tt>rts.gc.num_bytes_usage_samples</tt></i> Number of byte
--   usage samples taken</li>
--   <li><i><tt>rts.gc.cumulative_bytes_used</tt></i> Sum of all byte usage
--   samples, can be used with <tt>numByteUsageSamples</tt> to calculate
--   averages with arbitrary weighting (if you are sampling this record
--   multiple times).</li>
--   <li><i><tt>rts.gc.bytes_copied</tt></i> Number of bytes copied during
--   GC</li>
--   <li><i><tt>rts.gc.init_cpu_ms</tt></i> CPU time used by the init
--   phase, in milliseconds. GHC 8.6+ only.</li>
--   <li><i><tt>rts.gc.init_wall_ms</tt></i> Wall clock time spent running
--   the init phase, in milliseconds. GHC 8.6+ only.</li>
--   <li><i><tt>rts.gc.mutator_cpu_ms</tt></i> CPU time spent running
--   mutator threads, in milliseconds. This does not include any profiling
--   overhead or initialization.</li>
--   <li><i><tt>rts.gc.mutator_wall_ms</tt></i> Wall clock time spent
--   running mutator threads, in milliseconds. This does not include
--   initialization.</li>
--   <li><i><tt>rts.gc.gc_cpu_ms</tt></i> CPU time spent running GC, in
--   milliseconds.</li>
--   <li><i><tt>rts.gc.gc_wall_ms</tt></i> Wall clock time spent running
--   GC, in milliseconds.</li>
--   <li><i><tt>rts.gc.cpu_ms</tt></i> Total CPU time elapsed since program
--   start, in milliseconds.</li>
--   <li><i><tt>rts.gc.wall_ms</tt></i> Total wall clock time elapsed since
--   start, in milliseconds.</li>
--   </ul>
--   
--   Registered gauges:
--   
--   <ul>
--   <li><i><tt>rts.gc.max_bytes_used</tt></i> Maximum number of live bytes
--   seen so far</li>
--   <li><i><tt>rts.gc.current_bytes_used</tt></i> Current number of live
--   bytes</li>
--   <li><i><tt>rts.gc.current_bytes_slop</tt></i> Current number of bytes
--   lost to slop</li>
--   <li><i><tt>rts.gc.max_bytes_slop</tt></i> Maximum number of bytes lost
--   to slop at any one time so far</li>
--   <li><i><tt>rts.gc.peak_megabytes_allocated</tt></i> Maximum number of
--   megabytes allocated</li>
--   <li><i><tt>rts.gc.par_tot_bytes_copied</tt></i> Number of bytes copied
--   during GC, minus space held by mutable lists held by the capabilities.
--   Can be used with <tt>parMaxBytesCopied</tt> to determine how well
--   parallel GC utilized all cores.</li>
--   <li><i><tt>rts.gc.par_avg_bytes_copied</tt></i> Deprecated alias for
--   <tt>par_tot_bytes_copied</tt>.</li>
--   <li><i><tt>rts.gc.par_max_bytes_copied</tt></i> Sum of number of bytes
--   copied each GC by the most active GC thread each GC. The ratio of
--   <tt>par_tot_bytes_copied</tt> divided by <tt>par_max_bytes_copied</tt>
--   approaches 1 for a maximally sequential run and approaches the number
--   of threads (set by the RTS flag <tt>-N</tt>) for a maximally parallel
--   run.</li>
--   </ul>
registerGcMetrics :: Store -> IO ()

-- | A mutable metric store.
data Store

-- | The metric store associated with the server. If you want to add metric
--   to the default store created by <a>forkServer</a> you need to use this
--   function to retrieve it.
serverMetricStore :: Server -> Store

-- | Display all environment variables, for convenience
showEnv :: IO ()

-- | Unset Environment using a value of class ToEnv
unsetEnvironment' :: ToEnv a => a -> IO Either String ()

-- | Unset Environment from a <a>ToEnv</a> constrained type
unsetEnvironment :: () => EnvList a -> IO Either String ()

-- | Set environment directly using a value of class ToEnv
setEnvironment' :: ToEnv a => a -> IO Either String ()

-- | Set environment via a ToEnv constrained type
setEnvironment :: () => EnvList a -> IO Either String ()

-- | Environment retrieval with failure info
decodeEnv :: FromEnv a => IO Either String a

-- | Smart constructor, environment creation helper.
makeEnv :: () => [EnvVar] -> EnvList a

-- | Meant for specifying a custom <a>Option</a> for environment retrieval
--   
--   <pre>
--   instance FromEnv PGConfig where
--     fromEnv = gFromEnvCustom Option { dropPrefixCount = 8, customPrefix = "PG" }
--   </pre>
gFromEnvCustom :: (DefConfig a, Generic a, GFromEnv Rep a) => Option -> Parser a

-- | Environment variable getter returning <a>Maybe</a>
envMaybe :: Var a => String -> Parser Maybe a

-- | Environment variable getter. Fails if the variable is not set or fails
--   to parse.
env :: Var a => String -> Parser a

-- | For use with Generics, no <a>FromEnv</a> typeclass necessary
--   
--   <pre>
--   getPgConfig :: IO (Either String ConnectInfo)
--   getPgConfig = runEnv $ gFromEnvCustom defOption
--   </pre>
runEnv :: () => Parser a -> IO Either String a

-- | Parser Monad for environment variable retrieval
newtype Parser a
Parser :: ExceptT String IO a -> Parser a
[runParser] :: Parser a -> ExceptT String IO a

-- | <a>FromEnv</a> Typeclass w/ Generic default implementation
class FromEnv a
fromEnv :: FromEnv a => Parser a

-- | Type class for objects which have a default configuration.
class DefConfig a
defConfig :: DefConfig a => a

-- | For customizing environment variable generation
data Option
Option :: Int -> String -> Option

-- | Applied first
[dropPrefixCount] :: Option -> Int

-- | Converted toUpper
[customPrefix] :: Option -> String

-- | Type class for objects which can be converted to a set of environment
--   variable settings.
class ToEnv a

-- | Convert an object into a list of environment variable settings.
toEnv :: ToEnv a => a -> EnvList a

-- | List of environment variables. Captures a "phantom type" which allows
--   the type checker to detect the proper implementation of toEnv to use.
data EnvList a

-- | Class for converting to / from an environment variable
class Typeable a => Var a

-- | Convert a value into an environment variable.
toVar :: Var a => a -> String

-- | Parse an environment variable.
fromVar :: Var a => String -> Maybe a

-- | <a>fmap</a> specialized to <a>ExceptT</a>, given a name symmetric to
--   <a>fmapLT</a>
fmapRT :: Monad m => a -> b -> ExceptT l m a -> ExceptT l m b

-- | Analogous to <a>isRight</a>, but for <a>ExceptT</a>
isRightT :: Monad m => ExceptT a m b -> m Bool

-- | Analogous to <a>isLeft</a>, but for <a>ExceptT</a>
isLeftT :: Monad m => ExceptT a m b -> m Bool

-- | <a>fmap</a> specialized to <a>Either</a>, given a name symmetric to
--   <a>fmapL</a>
fmapR :: () => a -> b -> Either l a -> Either l b

-- | Returns whether argument is a <a>Right</a>
isRight :: () => Either a b -> Bool

-- | Returns whether argument is a <a>Left</a>
isLeft :: () => Either a b -> Bool

-- | Analogous to <a>isNothing</a>, but for <a>MaybeT</a>
isNothingT :: Monad m => MaybeT m a -> m Bool

-- | Analogous to <a>isJust</a>, but for <a>MaybeT</a>
isJustT :: Monad m => MaybeT m a -> m Bool

-- | Analogous to <a>Nothing</a> and equivalent to <tt>mzero</tt>
nothing :: Monad m => MaybeT m a

-- | Analogous to <a>Just</a> and equivalent to <a>return</a>
just :: Monad m => a -> MaybeT m a

-- | Case analysis for <a>MaybeT</a>
--   
--   Use the first argument if the <a>MaybeT</a> computation fails,
--   otherwise apply the function to the successful result.
maybeT :: Monad m => m b -> a -> m b -> MaybeT m a -> m b

-- | Convert an applicative <a>Maybe</a> value into the <a>ExceptT</a>
--   monad
--   
--   Named version of (<a>!?</a>) with arguments flipped
failWithM :: Applicative m => e -> m Maybe a -> ExceptT e m a

-- | Convert a <a>Maybe</a> value into the <a>ExceptT</a> monad
--   
--   Named version of (<a>??</a>) with arguments flipped
failWith :: Applicative m => e -> Maybe a -> ExceptT e m a

-- | An infix form of <a>fromMaybe</a> with arguments flipped.
(?:) :: () => Maybe a -> a -> a
infixr 0 ?:

-- | Convert an applicative <a>Maybe</a> value into the <a>ExceptT</a>
--   monad
(!?) :: Applicative m => m Maybe a -> e -> ExceptT e m a

-- | Lift a <a>Maybe</a> to the <a>MaybeT</a> monad
hoistMaybe :: Monad m => Maybe b -> MaybeT m b

-- | Tag the <a>Nothing</a> value of a <a>MaybeT</a>
noteT :: Monad m => a -> MaybeT m b -> ExceptT a m b

-- | Tag the <a>Nothing</a> value of a <a>Maybe</a>
note :: () => a -> Maybe b -> Either a b

-- | Suppress the <a>Left</a> value of an <a>ExceptT</a>
hushT :: Monad m => ExceptT a m b -> MaybeT m b

-- | Suppress the <a>Left</a> value of an <a>Either</a>
hush :: () => Either a b -> Maybe b

-- | Upgrade an <a>Either</a> to an <a>ExceptT</a>
hoistEither :: Monad m => Either e a -> ExceptT e m a

-- | Transform the left and right value
bimapExceptT :: Functor m => e -> f -> a -> b -> ExceptT e m a -> ExceptT f m b

-- | Fold an <a>ExceptT</a> by providing one continuation for each
--   constructor
exceptT :: Monad m => a -> m c -> b -> m c -> ExceptT a m b -> m c

-- | Run multiple <a>Either</a> computations and succeed if all of them
--   succeed
--   
--   <a>mappend</a>s all successes or failures
newtype AllE e r
AllE :: Either e r -> AllE e r
[runAllE] :: AllE e r -> Either e r

-- | Run multiple <a>Either</a> computations and succeed if any of them
--   succeed
--   
--   <a>mappend</a>s all successes or failures
newtype AnyE e r
AnyE :: Either e r -> AnyE e r
[runAnyE] :: AnyE e r -> Either e r

-- | Transform the computation inside a <tt>MaybeT</tt>.
--   
--   <ul>
--   <li><pre><a>runMaybeT</a> (<a>mapMaybeT</a> f m) = f (<a>runMaybeT</a>
--   m)</pre></li>
--   </ul>
mapMaybeT :: () => m Maybe a -> n Maybe b -> MaybeT m a -> MaybeT n b

-- | Lift a <tt>catchE</tt> operation to the new monad.
liftCatch :: () => Catch e m Maybe a -> Catch e MaybeT m a

-- | The inverse of <a>ExceptT</a>.
runExceptT :: () => ExceptT e m a -> m Either e a

-- | A class for monads which allow exceptions to be caught, in particular
--   exceptions which were thrown by <a>throwM</a>.
--   
--   Instances should obey the following law:
--   
--   <pre>
--   catch (throwM e) f = f e
--   </pre>
--   
--   Note that the ability to catch an exception does <i>not</i> guarantee
--   that we can deal with all possible exit points from a computation.
--   Some monads, such as continuation-based stacks, allow for more than
--   just a success/failure strategy, and therefore <tt>catch</tt>
--   <i>cannot</i> be used by those monads to properly implement a function
--   such as <tt>finally</tt>. For more information, see <a>MonadMask</a>.
class MonadThrow m => MonadCatch (m :: * -> *)

-- | Logger Type.
data LogType

-- | No logging.
LogNone :: LogType

-- | Logging to stdout. <a>BufSize</a> is a buffer size for each
--   capability.
LogStdout :: BufSize -> LogType

-- | Logging to stderr. <a>BufSize</a> is a buffer size for each
--   capability.
LogStderr :: BufSize -> LogType

-- | Logging to a file. <a>BufSize</a> is a buffer size for each
--   capability.
LogFileNoRotate :: FilePath -> BufSize -> LogType

-- | Logging to a file. <a>BufSize</a> is a buffer size for each
--   capability. File rotation is done on-demand.
LogFile :: FileLogSpec -> BufSize -> LogType

-- | Logging with a log and flush action. run flush after log each message.
LogCallback :: LogStr -> IO () -> IO () -> LogType

-- | The default buffer size (4,096 bytes).
defaultBufSize :: BufSize

-- | Like encodePathSegments, but without the initial slash.
encodePathSegmentsRelative :: [Text] -> Builder

-- | Convert value to HTTP API data.
--   
--   <b>WARNING</b>: Do not derive this using <tt>DeriveAnyClass</tt> as
--   the generated instance will loop indefinitely.
class ToHttpApiData a

-- | Convert to URL path piece.
toUrlPiece :: ToHttpApiData a => a -> Text

-- | Convert to a URL path piece, making sure to encode any special chars.
--   The default definition uses <a>encodePathSegmentsRelative</a>, but
--   this may be overriden with a more efficient version.
toEncodedUrlPiece :: ToHttpApiData a => a -> Builder

-- | Convert to HTTP header value.
toHeader :: ToHttpApiData a => a -> ByteString

-- | Convert to query param value.
toQueryParam :: ToHttpApiData a => a -> Text

-- | Parse value from HTTP API data.
--   
--   <b>WARNING</b>: Do not derive this using <tt>DeriveAnyClass</tt> as
--   the generated instance will loop indefinitely.
class FromHttpApiData a

-- | Parse URL path piece.
parseUrlPiece :: FromHttpApiData a => Text -> Either Text a

-- | Parse HTTP header value.
parseHeader :: FromHttpApiData a => ByteString -> Either Text a

-- | Parse query param value.
parseQueryParam :: FromHttpApiData a => Text -> Either Text a

-- | Represents a general universal resource identifier using its component
--   parts.
--   
--   For example, for the URI
--   
--   <pre>
--   foo://anonymous@www.haskell.org:42/ghc?query#frag
--   </pre>
--   
--   the components are:
data URI
URI :: String -> Maybe URIAuth -> String -> String -> String -> URI

-- | <pre>
--   foo:
--   </pre>
[uriScheme] :: URI -> String

-- | <pre>
--   //anonymous@www.haskell.org:42
--   </pre>
[uriAuthority] :: URI -> Maybe URIAuth

-- | <pre>
--   /ghc
--   </pre>
[uriPath] :: URI -> String

-- | <pre>
--   ?query
--   </pre>
[uriQuery] :: URI -> String

-- | <pre>
--   #frag
--   </pre>
[uriFragment] :: URI -> String

-- | Use the default response timeout
--   
--   When used on a <a>Request</a>, means: use the manager's timeout value
--   
--   When used on a <a>ManagerSettings</a>, means: default to 30 seconds
responseTimeoutDefault :: ResponseTimeout

-- | Do not have a response timeout
responseTimeoutNone :: ResponseTimeout

-- | Specify a response timeout in microseconds
responseTimeoutMicro :: Int -> ResponseTimeout

-- | Set the proxy override value, for both HTTP (insecure) and HTTPS
--   (insecure) connections.
--   
--   Since 0.4.7
managerSetProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings

-- | Set the proxy override value, only for HTTPS (secure) connections.
--   
--   Since 0.4.7
managerSetSecureProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings

-- | Set the proxy override value, only for HTTP (insecure) connections.
--   
--   Since 0.4.7
managerSetInsecureProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings

-- | A variant of <tt>withResponse</tt> which keeps a history of all
--   redirects performed in the interim, together with the first 1024 bytes
--   of their response bodies.
--   
--   Since 0.4.1
withResponseHistory :: () => Request -> Manager -> HistoriedResponse BodyReader -> IO a -> IO a

-- | A variant of <tt>responseOpen</tt> which keeps a history of all
--   redirects performed in the interim, together with the first 1024 bytes
--   of their response bodies.
--   
--   Since 0.4.1
responseOpenHistory :: Request -> Manager -> IO HistoriedResponse BodyReader

-- | A datatype holding information on redirected requests and the final
--   response.
--   
--   Since 0.4.1
data HistoriedResponse body

-- | Perform an action using a <tt>Connection</tt> acquired from the given
--   <tt>Manager</tt>.
--   
--   You should use this only when you have to read and write interactively
--   through the connection (e.g. connection by the WebSocket protocol).
withConnection :: () => Request -> Manager -> Connection -> IO a -> IO a

-- | Close any open resources associated with the given <tt>Response</tt>.
--   In general, this will either close an active <tt>Connection</tt> or
--   return it to the <tt>Manager</tt> to be reused.
--   
--   Since 0.1.0
responseClose :: () => Response a -> IO ()

-- | The most low-level function for initiating an HTTP request.
--   
--   The first argument to this function gives a full specification on the
--   request: the host to connect to, whether to use SSL, headers, etc.
--   Please see <a>Request</a> for full details. The second argument
--   specifies which <a>Manager</a> should be used.
--   
--   This function then returns a <a>Response</a> with a <a>BodyReader</a>.
--   The <a>Response</a> contains the status code and headers that were
--   sent back to us, and the <a>BodyReader</a> contains the body of the
--   request. Note that this <a>BodyReader</a> allows you to have fully
--   interleaved IO actions during your HTTP download, making it possible
--   to download very large responses in constant memory.
--   
--   An important note: the response body returned by this function
--   represents a live HTTP connection. As such, if you do not use the
--   response body, an open socket will be retained indefinitely. You must
--   be certain to call <a>responseClose</a> on this response to free up
--   resources.
--   
--   This function automatically performs any necessary redirects, as
--   specified by the <a>redirectCount</a> setting.
--   
--   When implementing a (reverse) proxy using this function or relating
--   functions, it's wise to remove Transfer-Encoding:, Content-Length:,
--   Content-Encoding: and Accept-Encoding: from request and response
--   headers to be relayed.
--   
--   Since 0.1.0
responseOpen :: Request -> Manager -> IO Response BodyReader

-- | A convenient wrapper around <a>withResponse</a> which ignores the
--   response body. This is useful, for example, when performing a HEAD
--   request.
--   
--   Since 0.3.2
httpNoBody :: Request -> Manager -> IO Response ()

-- | A convenience wrapper around <a>withResponse</a> which reads in the
--   entire response body and immediately closes the connection. Note that
--   this function performs fully strict I/O, and only uses a lazy
--   ByteString in its response for memory efficiency. If you are
--   anticipating a large response body, you are encouraged to use
--   <a>withResponse</a> and <a>brRead</a> instead.
--   
--   Since 0.1.0
httpLbs :: Request -> Manager -> IO Response ByteString

-- | Perform a <tt>Request</tt> using a connection acquired from the given
--   <tt>Manager</tt>, and then provide the <tt>Response</tt> to the given
--   function. This function is fully exception safe, guaranteeing that the
--   response will be closed when the inner function exits. It is defined
--   as:
--   
--   <pre>
--   withResponse req man f = bracket (responseOpen req man) responseClose f
--   </pre>
--   
--   It is recommended that you use this function in place of explicit
--   calls to <a>responseOpen</a> and <a>responseClose</a>.
--   
--   You will need to use functions such as <a>brRead</a> to consume the
--   response body.
--   
--   Since 0.1.0
withResponse :: () => Request -> Manager -> Response BodyReader -> IO a -> IO a

-- | Turn a SetCookie into a Cookie, if it is valid
generateCookie :: SetCookie -> Request -> UTCTime -> Bool -> Maybe Cookie

-- | Insert a cookie created by generateCookie into the cookie jar (or not
--   if it shouldn't be allowed in)
insertCheckedCookie :: Cookie -> CookieJar -> Bool -> CookieJar

-- | This corresponds to the algorithm described in Section 5.3 "Storage
--   Model" This function consists of calling <a>generateCookie</a>
--   followed by <a>insertCheckedCookie</a>. Use this function if you plan
--   to do both in a row. <a>generateCookie</a> and
--   <a>insertCheckedCookie</a> are only provided for more fine-grained
--   control.
receiveSetCookie :: SetCookie -> Request -> UTCTime -> Bool -> CookieJar -> CookieJar

-- | This applies <a>receiveSetCookie</a> to a given Response
updateCookieJar :: () => Response a -> Request -> UTCTime -> CookieJar -> (CookieJar, Response a)

-- | This corresponds to the algorithm described in Section 5.4 "The Cookie
--   Header"
computeCookieString :: Request -> CookieJar -> UTCTime -> Bool -> (ByteString, CookieJar)

-- | This applies the <a>computeCookieString</a> to a given Request
insertCookiesIntoRequest :: Request -> CookieJar -> UTCTime -> (Request, CookieJar)

-- | This corresponds to the eviction algorithm described in Section 5.3
--   "Storage Model"
evictExpiredCookies :: CookieJar -> UTCTime -> CookieJar
removeExistingCookieFromCookieJar :: Cookie -> CookieJar -> (Maybe Cookie, CookieJar)
destroyCookieJar :: CookieJar -> [Cookie]
createCookieJar :: [Cookie] -> CookieJar

-- | This corresponds to the subcomponent algorithm entitled "Path-Match"
--   detailed in section 5.1.4
pathMatches :: ByteString -> ByteString -> Bool

-- | This corresponds to the subcomponent algorithm entitled "Paths"
--   detailed in section 5.1.4
defaultPath :: Request -> ByteString

-- | This corresponds to the subcomponent algorithm entitled "Domain
--   Matching" detailed in section 5.1.3
domainMatches :: ByteString -> ByteString -> Bool
isIpAddress :: ByteString -> Bool

-- | The default proxy settings for a manager. In particular: if the
--   <tt>http_proxy</tt> (or <tt>https_proxy</tt>) environment variable is
--   set, use it. Otherwise, use the values in the <tt>Request</tt>.
--   
--   Since 0.4.7
defaultProxy :: ProxyOverride

-- | Same as <a>proxyEnvironment</a>, but instead of default environment
--   variable names, allows you to set your own name.
--   
--   Since 0.4.7
proxyEnvironmentNamed :: Text -> Maybe Proxy -> ProxyOverride

-- | Get the proxy settings from the default environment variable
--   (<tt>http_proxy</tt> for insecure, <tt>https_proxy</tt> for secure).
--   If no variable is set, then fall back to the given value.
--   <tt>Nothing</tt> is equivalent to <a>noProxy</a>, <tt>Just</tt> is
--   equivalent to <a>useProxy</a>.
--   
--   Since 0.4.7
proxyEnvironment :: Maybe Proxy -> ProxyOverride

-- | Use the given proxy settings, regardless of the proxy value in the
--   <tt>Request</tt>.
--   
--   Since 0.4.7
useProxy :: Proxy -> ProxyOverride

-- | Never connect using a proxy, regardless of the proxy value in the
--   <tt>Request</tt>.
--   
--   Since 0.4.7
noProxy :: ProxyOverride

-- | Get the proxy settings from the <tt>Request</tt> itself.
--   
--   Since 0.4.7
proxyFromRequest :: ProxyOverride

-- | Create, use and close a <a>Manager</a>.
--   
--   Since 0.2.1
withManager :: () => ManagerSettings -> Manager -> IO a -> IO a

-- | Close all connections in a <a>Manager</a>.
--   
--   Note that this doesn't affect currently in-flight connections, meaning
--   you can safely use it without hurting any queries you may have
--   concurrently running.
--   
--   Since 0.1.0
closeManager :: Manager -> IO ()

-- | Create a <a>Manager</a>. The <tt>Manager</tt> will be shut down
--   automatically via garbage collection.
--   
--   Creating a new <a>Manager</a> is a relatively expensive operation, you
--   are advised to share a single <a>Manager</a> between requests instead.
--   
--   The first argument to this function is often
--   <a>defaultManagerSettings</a>, though add-on libraries may provide a
--   recommended replacement.
--   
--   Since 0.1.0
newManager :: ManagerSettings -> IO Manager

-- | Default value for <tt>ManagerSettings</tt>.
--   
--   Note that this value does <i>not</i> have support for SSL/TLS. If you
--   need to make any https connections, please use the http-client-tls
--   package, which provides a <tt>tlsManagerSettings</tt> value.
--   
--   Since 0.1.0
defaultManagerSettings :: ManagerSettings

-- | Same as <tt>rawConnectionModifySocket</tt>, but also takes in a chunk
--   size.
rawConnectionModifySocketSize :: Socket -> IO () -> IO Int -> Maybe HostAddress -> String -> Int -> IO Connection

-- | A value for the <tt>managerRawConnection</tt> setting, but also allows
--   you to modify the underlying <tt>Socket</tt> to set additional
--   settings. For a motivating use case, see:
--   <a>https://github.com/snoyberg/http-client/issues/71</a>.
--   
--   Since 0.3.8
rawConnectionModifySocket :: Socket -> IO () -> IO Maybe HostAddress -> String -> Int -> IO Connection

-- | Send a file as the request body, while observing streaming progress
--   via a <tt>PopObserver</tt>. Observations are made between reading and
--   sending a chunk.
--   
--   It is expected that the file size does not change between calling
--   <a>observedStreamFile</a> and making any requests using this request
--   body.
--   
--   Since 0.4.9
observedStreamFile :: StreamFileStatus -> IO () -> FilePath -> IO RequestBody

-- | Send a file as the request body.
--   
--   It is expected that the file size does not change between calling
--   <a>streamFile</a> and making any requests using this request body.
--   
--   Since 0.4.9
streamFile :: FilePath -> IO RequestBody

-- | Set the query string to the given key/value pairs.
setQueryStringPartialEscape :: [(ByteString, [EscapeItem])] -> Request -> Request

-- | Set the query string to the given key/value pairs.
--   
--   Since 0.3.6
setQueryString :: [(ByteString, Maybe ByteString)] -> Request -> Request

-- | Modify the request so that non-2XX status codes generate a runtime
--   <a>StatusCodeException</a>, by using <a>throwErrorStatusCodes</a>
setRequestCheckStatus :: Request -> Request

-- | Modify the request so that non-2XX status codes do not generate a
--   runtime <a>StatusCodeException</a>.
setRequestIgnoreStatus :: Request -> Request

-- | Add url-encoded parameters to the <a>Request</a>.
--   
--   This sets a new <a>requestBody</a>, adds a content-type request header
--   and changes the <a>method</a> to POST.
--   
--   Since 0.1.0
urlEncodedBody :: [(ByteString, ByteString)] -> Request -> Request

-- | Add a Proxy-Authorization header (with the specified username and
--   password) to the given <a>Request</a>. Ignore error handling:
--   
--   <pre>
--   applyBasicProxyAuth "user" "pass" &lt;$&gt; parseRequest "http://example.org"
--   </pre>
--   
--   Since 0.3.4
applyBasicProxyAuth :: ByteString -> ByteString -> Request -> Request

-- | Add a Basic Auth header (with the specified user name and password) to
--   the given Request. Ignore error handling:
--   
--   <pre>
--   applyBasicAuth "user" "pass" $ parseRequest_ url
--   </pre>
--   
--   NOTE: The function <tt>applyDigestAuth</tt> is provided by the
--   <tt>http-client-tls</tt> package instead of this package due to extra
--   dependencies. Please use that package if you need to use digest
--   authentication.
--   
--   Since 0.1.0
applyBasicAuth :: ByteString -> ByteString -> Request -> Request

-- | A default request value, a GET request of localhost/:80, with an empty
--   request body.
--   
--   Note that the default <a>checkResponse</a> does nothing.
defaultRequest :: Request

-- | Extract a <a>URI</a> from the request.
--   
--   Since 0.1.0
getUri :: Request -> URI

-- | Same as <a>requestFromURI</a>, but if the conversion would fail,
--   throws an impure exception.
requestFromURI_ :: URI -> Request

-- | Convert a <a>URI</a> into a <a>Request</a>.
--   
--   This can fail if the given <a>URI</a> is not absolute, or if the
--   <a>URI</a> scheme is not <tt>"http"</tt> or <tt>"https"</tt>. In these
--   cases the function will throw an error via <a>MonadThrow</a>.
--   
--   This function defaults some of the values in <a>Request</a>, such as
--   setting <a>method</a> to <tt><a>GET</a></tt> and <a>requestHeaders</a>
--   to <tt>[]</tt>.
--   
--   A <a>Request</a> created by this function won't cause exceptions on
--   non-2XX response status codes.
requestFromURI :: MonadThrow m => URI -> m Request

-- | Same as <a>parseRequest</a>, but parse errors cause an impure
--   exception. Mostly useful for static strings which are known to be
--   correctly formatted.
parseRequest_ :: String -> Request

-- | Convert a URL into a <a>Request</a>.
--   
--   This function defaults some of the values in <a>Request</a>, such as
--   setting <a>method</a> to <tt><a>GET</a></tt> and <a>requestHeaders</a>
--   to <tt>[]</tt>.
--   
--   Since this function uses <a>MonadThrow</a>, the return monad can be
--   anything that is an instance of <a>MonadThrow</a>, such as <a>IO</a>
--   or <a>Maybe</a>.
--   
--   You can place the request method at the beginning of the URL separated
--   by a space, e.g.:
--   
--   @@<tt> parseRequest "POST <a>http://httpbin.org/post"</a> </tt>@@
--   
--   Note that the request method must be provided as all capital letters.
--   
--   A <a>Request</a> created by this function won't cause exceptions on
--   non-2XX response status codes.
--   
--   To create a request which throws on non-2XX status codes, see
--   <a>parseUrlThrow</a>
parseRequest :: MonadThrow m => String -> m Request

-- | Throws a <a>StatusCodeException</a> wrapped in
--   <a>HttpExceptionRequest</a>, if the response's status code indicates
--   an error (if it isn't 2xx). This can be used to implement
--   <a>checkResponse</a>.
throwErrorStatusCodes :: MonadIO m => Request -> Response BodyReader -> m ()

-- | Same as <a>parseRequest</a>, except will throw an <a>HttpException</a>
--   in the event of a non-2XX response. This uses
--   <a>throwErrorStatusCodes</a> to implement <a>checkResponse</a>.
parseUrlThrow :: MonadThrow m => String -> m Request

-- | Deprecated synonym for <a>parseUrlThrow</a>. You probably want
--   <a>parseRequest</a> or <a>parseRequest_</a> instead.
parseUrl :: MonadThrow m => String -> m Request

-- | Strictly consume all remaining chunks of data from the stream.
--   
--   Since 0.1.0
brConsume :: BodyReader -> IO [ByteString]

-- | Continuously call <a>brRead</a>, building up a lazy ByteString until a
--   chunk is constructed that is at least as many bytes as requested.
--   
--   Since 0.4.20
brReadSome :: BodyReader -> Int -> IO ByteString

-- | Get a single chunk of data from the response body, or an empty
--   bytestring if no more data is available.
--   
--   Note that in order to consume the entire request body, you will need
--   to repeatedly call this function until you receive an empty
--   <tt>ByteString</tt> as a result.
--   
--   Since 0.1.0
brRead :: BodyReader -> IO ByteString

-- | Create a new <a>Connection</a> from a <a>Socket</a>.
socketConnection :: Socket -> Int -> IO Connection

-- | Create a new <a>Connection</a> from a read, write, and close function.
makeConnection :: IO ByteString -> ByteString -> IO () -> IO () -> IO Connection

-- | An <tt>IO</tt> action that represents an incoming response body coming
--   from the server. Data provided by this action has already been
--   gunzipped and de-chunked, and respects any content-length headers
--   present.
--   
--   The action gets a single chunk of data from the response body, or an
--   empty bytestring if no more data is available.
--   
--   Since 0.4.0
type BodyReader = IO ByteString

-- | An exception which may be generated by this library
data HttpException

-- | Most exceptions are specific to a <a>Request</a>. Inspect the
--   <a>HttpExceptionContent</a> value for details on what occurred.
HttpExceptionRequest :: Request -> HttpExceptionContent -> HttpException

-- | A URL (first field) is invalid for a given reason (second argument).
InvalidUrlException :: String -> String -> HttpException
data HttpExceptionContent

-- | Generated by the <tt>parseUrlThrow</tt> function when the server
--   returns a non-2XX response status code.
--   
--   May include the beginning of the response body.
StatusCodeException :: Response () -> ByteString -> HttpExceptionContent

-- | The server responded with too many redirects for a request.
--   
--   Contains the list of encountered responses containing redirects in
--   reverse chronological order; including last redirect, which triggered
--   the exception and was not followed.
TooManyRedirects :: [Response ByteString] -> HttpExceptionContent

-- | Either too many headers, or too many total bytes in a single header,
--   were returned by the server, and the memory exhaustion protection in
--   this library has kicked in.
OverlongHeaders :: HttpExceptionContent

-- | The server took too long to return a response. This can be altered via
--   <a>responseTimeout</a> or <a>managerResponseTimeout</a>.
ResponseTimeout :: HttpExceptionContent

-- | Attempting to connect to the server timed out.
ConnectionTimeout :: HttpExceptionContent

-- | An exception occurred when trying to connect to the server.
ConnectionFailure :: SomeException -> HttpExceptionContent

-- | The status line returned by the server could not be parsed.
InvalidStatusLine :: ByteString -> HttpExceptionContent

-- | The given response header line could not be parsed
InvalidHeader :: ByteString -> HttpExceptionContent

-- | The given request header is not compliant (e.g. has newlines)
InvalidRequestHeader :: ByteString -> HttpExceptionContent

-- | An exception was raised by an underlying library when performing the
--   request. Most often, this is caused by a failing socket action or a
--   TLS exception.
InternalException :: SomeException -> HttpExceptionContent

-- | A non-200 status code was returned when trying to connect to the proxy
--   server on the given host and port.
ProxyConnectException :: ByteString -> Int -> Status -> HttpExceptionContent

-- | No response data was received from the server at all. This exception
--   may deserve special handling within the library, since it may indicate
--   that a pipelining has been used, and a connection thought to be open
--   was in fact closed.
NoResponseDataReceived :: HttpExceptionContent

-- | Exception thrown when using a <tt>Manager</tt> which does not have
--   support for secure connections. Typically, you will want to use
--   <tt>tlsManagerSettings</tt> from <tt>http-client-tls</tt> to overcome
--   this.
TlsNotSupported :: HttpExceptionContent

-- | The request body provided did not match the expected size.
--   
--   Provides the expected and actual size.
WrongRequestBodyStreamSize :: Word64 -> Word64 -> HttpExceptionContent

-- | The returned response body is too short. Provides the expected size
--   and actual size.
ResponseBodyTooShort :: Word64 -> Word64 -> HttpExceptionContent

-- | A chunked response body had invalid headers.
InvalidChunkHeaders :: HttpExceptionContent

-- | An incomplete set of response headers were returned.
IncompleteHeaders :: HttpExceptionContent

-- | The host we tried to connect to is invalid (e.g., an empty string).
InvalidDestinationHost :: ByteString -> HttpExceptionContent

-- | An exception was thrown when inflating a response body.
HttpZlibException :: ZlibException -> HttpExceptionContent

-- | Values in the proxy environment variable were invalid. Provides the
--   environment variable name and its value.
InvalidProxyEnvironmentVariable :: Text -> Text -> HttpExceptionContent

-- | Attempted to use a <a>Connection</a> which was already closed
ConnectionClosed :: HttpExceptionContent

-- | Proxy settings are not valid (Windows specific currently) @since 0.5.7
InvalidProxySettings :: Text -> HttpExceptionContent
data Cookie
Cookie :: ByteString -> ByteString -> UTCTime -> ByteString -> ByteString -> UTCTime -> UTCTime -> Bool -> Bool -> Bool -> Bool -> Cookie
[cookie_name] :: Cookie -> ByteString
[cookie_value] :: Cookie -> ByteString
[cookie_expiry_time] :: Cookie -> UTCTime
[cookie_domain] :: Cookie -> ByteString
[cookie_path] :: Cookie -> ByteString
[cookie_creation_time] :: Cookie -> UTCTime
[cookie_last_access_time] :: Cookie -> UTCTime
[cookie_persistent] :: Cookie -> Bool
[cookie_host_only] :: Cookie -> Bool
[cookie_secure_only] :: Cookie -> Bool
[cookie_http_only] :: Cookie -> Bool
data CookieJar

-- | The host name of the HTTP proxy.
proxyHost :: Proxy -> ByteString

-- | The port number of the HTTP proxy.
proxyPort :: Proxy -> Int

-- | When using one of the <a>RequestBodyStream</a> /
--   <a>RequestBodyStreamChunked</a> constructors, you must ensure that the
--   <a>GivesPopper</a> can be called multiple times. Usually this is not a
--   problem.
--   
--   The <a>RequestBodyStreamChunked</a> will send a chunked request body.
--   Note that not all servers support this. Only use
--   <a>RequestBodyStreamChunked</a> if you know the server you're sending
--   to supports chunked request bodies.
--   
--   Since 0.1.0
data RequestBody
RequestBodyLBS :: ByteString -> RequestBody
RequestBodyBS :: ByteString -> RequestBody
RequestBodyBuilder :: Int64 -> Builder -> RequestBody
RequestBodyStream :: Int64 -> GivesPopper () -> RequestBody
RequestBodyStreamChunked :: GivesPopper () -> RequestBody

-- | Allows creation of a <tt>RequestBody</tt> inside the <tt>IO</tt>
--   monad, which is useful for making easier APIs (like
--   <tt>setRequestBodyFile</tt>).
RequestBodyIO :: IO RequestBody -> RequestBody

-- | A function which generates successive chunks of a request body,
--   provider a single empty bytestring when no more data is available.
--   
--   Since 0.1.0
type Popper = IO ByteString

-- | A function which must be provided with a <a>Popper</a>.
--   
--   Since 0.1.0
type NeedsPopper a = Popper -> IO a

-- | A function which will provide a <a>Popper</a> to a <a>NeedsPopper</a>.
--   This seemingly convoluted structure allows for creation of request
--   bodies which allocate scarce resources in an exception safe manner.
--   
--   Since 0.1.0
type GivesPopper a = NeedsPopper a -> IO a

-- | All information on how to connect to a host and what should be sent in
--   the HTTP request.
--   
--   If you simply wish to download from a URL, see <tt>parseRequest</tt>.
--   
--   The constructor for this data type is not exposed. Instead, you should
--   use either the <tt>defaultRequest</tt> value, or <tt>parseRequest</tt>
--   to construct from a URL, and then use the records below to make
--   modifications. This approach allows http-client to add configuration
--   options without breaking backwards compatibility.
--   
--   For example, to construct a POST request, you could do something like:
--   
--   <pre>
--   initReq &lt;- parseRequest "http://www.example.com/path"
--   let req = initReq
--               { method = "POST"
--               }
--   </pre>
--   
--   For more information, please see
--   <a>http://www.yesodweb.com/book/settings-types</a>.
--   
--   Since 0.1.0
data Request

-- | How to deal with timing out a response
data ResponseTimeout

-- | A simple representation of the HTTP response.
--   
--   Since 0.1.0
data Response body

-- | Settings for a <tt>Manager</tt>. Please use the
--   <tt>defaultManagerSettings</tt> function and then modify individual
--   settings. For more information, see
--   <a>http://www.yesodweb.com/book/settings-types</a>.
--   
--   Since 0.1.0
data ManagerSettings

-- | How the HTTP proxy server settings should be discovered.
--   
--   Since 0.4.7
data ProxyOverride

-- | Keeps track of open connections for keep-alive.
--   
--   If possible, you should share a single <a>Manager</a> between multiple
--   threads and requests.
--   
--   Since 0.1.0
data Manager
class HasHttpManager a
getHttpManager :: HasHttpManager a => a -> Manager

-- | Status of streaming a request body from a file.
--   
--   Since 0.4.9
data StreamFileStatus
StreamFileStatus :: Int64 -> Int64 -> Int -> StreamFileStatus
[fileSize] :: StreamFileStatus -> Int64
[readSoFar] :: StreamFileStatus -> Int64
[thisChunkSize] :: StreamFileStatus -> Int

-- | Query.
--   
--   General form: <tt>a=b&amp;c=d</tt>, but if the value is Nothing, it
--   becomes <tt>a&amp;c=d</tt>.
type Query = [QueryItem]
writeLinkHeader :: [Link] -> Text
writeLink :: Link -> Text

-- | Parses a Link header, returns a Maybe.
parseLinkHeaderBS :: ByteString -> Maybe [Link]

-- | Parses a Link header, returns an Either, where Left is the Attoparsec
--   error string (probably not a useful one).
parseLinkHeaderBS' :: ByteString -> Either String [Link]

-- | Parses a Link header, returns a Maybe.
parseLinkHeader :: Text -> Maybe [Link]

-- | Parses a Link header, returns an Either, where Left is the Attoparsec
--   error string (probably not a useful one).
parseLinkHeader' :: Text -> Either String [Link]

-- | The Attoparsec parser for the Link header.
linkHeader :: Parser [Link]
lnk :: String -> [(LinkParam, Text)] -> Maybe Link

-- | Extracts the parameters from the link.
linkParams :: Link -> [(LinkParam, Text)]

-- | Extracts the URI from the link.
href :: Link -> URI

-- | The link attribute key.
data LinkParam
Rel :: LinkParam
Anchor :: LinkParam
Rev :: LinkParam
Hreflang :: LinkParam
Media :: LinkParam
Title :: LinkParam
Title' :: LinkParam
ContentType :: LinkParam
Other :: Text -> LinkParam

-- | HTTP 2.0
http20 :: HttpVersion

-- | HTTP 1.1
http11 :: HttpVersion

-- | HTTP 1.0
http10 :: HttpVersion

-- | HTTP 0.9
http09 :: HttpVersion

-- | HTTP Version.
--   
--   Note that the Show instance is intended merely for debugging.
data HttpVersion
HttpVersion :: !Int -> !Int -> HttpVersion
[httpMajor] :: HttpVersion -> !Int
[httpMinor] :: HttpVersion -> !Int

-- | Types which can, and commonly are, converted to <a>Query</a> are in
--   this class.
--   
--   You can use lists of simple key value pairs, with <a>ByteString</a>
--   (strict, or lazy: <a>ByteString</a>), <a>Text</a>, or <a>String</a> as
--   the key/value types. You can also have the value type lifted into a
--   Maybe to support keys without values; and finally it is possible to
--   put each pair into a Maybe for key-value pairs that aren't always
--   present.
class QueryLike a

-- | Convert to <a>Query</a>.
toQuery :: QueryLike a => a -> Query

-- | Convert <a>PartialEscapeQuery</a> to a <tt>Builder</tt>.
renderQueryBuilderPartialEscape :: Bool -> PartialEscapeQuery -> Builder

-- | Convert <a>PartialEscapeQuery</a> to <tt>ByteString</tt>.
renderQueryPartialEscape :: Bool -> PartialEscapeQuery -> ByteString

-- | Decode a whole path (path segments + query).
decodePath :: ByteString -> ([Text], Query)

-- | Encode a whole path (path segments + query).
encodePath :: [Text] -> Query -> Builder

-- | Extract whole path (path segments + query) from a <a>RFC 2616
--   Request-URI</a>.
--   
--   <pre>
--   &gt;&gt;&gt; extractPath "/path"
--   "/path"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; extractPath "http://example.com:8080/path"
--   "/path"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; extractPath "http://example.com"
--   "/"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; extractPath ""
--   "/"
--   </pre>
extractPath :: ByteString -> ByteString

-- | Parse a list of path segments from a valid URL fragment.
decodePathSegments :: ByteString -> [Text]

-- | Encodes a list of path segments into a valid URL fragment.
--   
--   This function takes the following three steps:
--   
--   <ul>
--   <li>UTF-8 encodes the characters.</li>
--   <li>Performs percent encoding on all unreserved characters, as well as
--   <tt>:@=+$</tt>,</li>
--   <li>Prepends each segment with a slash.</li>
--   </ul>
--   
--   For example:
--   
--   <pre>
--   encodePathSegments [\"foo\", \"bar\", \"baz\"]
--   </pre>
--   
--   "/foo/bar/baz"
--   
--   <pre>
--   encodePathSegments [\"foo bar\", \"baz\/bin\"]
--   </pre>
--   
--   "/foo%20bar/baz%2Fbin"
--   
--   <pre>
--   encodePathSegments [\"שלום\"]
--   </pre>
--   
--   "/%D7%A9%D7%9C%D7%95%D7%9D"
--   
--   Huge thanks to Jeremy Shaw who created the original implementation of
--   this function in web-routes and did such thorough research to
--   determine all correct escaping procedures.
encodePathSegments :: [Text] -> Builder

-- | Percent-decoding.
urlDecode :: Bool -> ByteString -> ByteString

-- | Percent-encoding for URLs.
urlEncode :: Bool -> ByteString -> ByteString

-- | Percent-encoding for URLs (using <a>Builder</a>).
urlEncodeBuilder :: Bool -> ByteString -> Builder

-- | Parse <a>SimpleQuery</a> from a <tt>ByteString</tt>.
parseSimpleQuery :: ByteString -> SimpleQuery

-- | Split out the query string into a list of keys and values. A few
--   importants points:
--   
--   <ul>
--   <li>The result returned is still bytestrings, since we perform no
--   character decoding here. Most likely, you will want to use UTF-8
--   decoding, but this is left to the user of the library.</li>
--   <li>Percent decoding errors are ignored. In particular, <tt>"%Q"</tt>
--   will be output as <tt>"%Q"</tt>.</li>
--   <li>It decodes <tt>'+'</tt> characters to <tt>' '</tt></li>
--   </ul>
parseQuery :: ByteString -> Query

-- | Convert <a>SimpleQuery</a> to <tt>ByteString</tt>.
renderSimpleQuery :: Bool -> SimpleQuery -> ByteString

-- | Convert <a>Query</a> to <tt>ByteString</tt>.
renderQuery :: Bool -> Query -> ByteString

-- | Convert <a>Query</a> to a <tt>Builder</tt>.
renderQueryBuilder :: Bool -> Query -> Builder

-- | Convert <a>SimpleQuery</a> to <a>Query</a>.
simpleQueryToQuery :: SimpleQuery -> Query

-- | Parse <a>QueryText</a> from a <a>ByteString</a>. See <a>parseQuery</a>
--   for details.
parseQueryText :: ByteString -> QueryText

-- | Convert <a>Query</a> to <a>QueryText</a> (leniently decoding the
--   UTF-8).
queryToQueryText :: Query -> QueryText

-- | Convert <a>QueryText</a> to a <a>Builder</a>.
renderQueryText :: Bool -> QueryText -> Builder

-- | Convert <a>QueryText</a> to <a>Query</a>.
queryTextToQuery :: QueryText -> Query

-- | Query item
type QueryItem = (ByteString, Maybe ByteString)

-- | Like Query, but with <a>Text</a> instead of <a>ByteString</a>
--   (UTF8-encoded).
type QueryText = [(Text, Maybe Text)]

-- | Simplified Query item type without support for parameter-less items.
type SimpleQueryItem = (ByteString, ByteString)

-- | Simplified Query type without support for parameter-less items.
type SimpleQuery = [SimpleQueryItem]

-- | For some URIs characters must not be URI encoded, e.g. <tt>'+'</tt> or
--   <tt>':'</tt> in
--   <tt>q=a+language:haskell+created:2009-01-01..2009-02-01&amp;sort=stars</tt>
--   The character list unreservedPI instead of unreservedQS would solve
--   this. But we explicitly decide what part to encode. This is mandatory
--   when searching for <tt>'+'</tt>: <tt>q=%2B+language:haskell</tt>.
data EscapeItem
QE :: ByteString -> EscapeItem
QN :: ByteString -> EscapeItem

-- | Query item
type PartialEscapeQueryItem = (ByteString, [EscapeItem])

-- | Query with some chars that should not be escaped.
--   
--   General form: <tt>a=b&amp;c=d:e+f&amp;g=h</tt>
type PartialEscapeQuery = [PartialEscapeQueryItem]

-- | Server Error class
statusIsServerError :: Status -> Bool

-- | Client Error class
statusIsClientError :: Status -> Bool

-- | Redirection class
statusIsRedirection :: Status -> Bool

-- | Successful class
statusIsSuccessful :: Status -> Bool

-- | Informational class
statusIsInformational :: Status -> Bool

-- | Network Authentication Required 511 (<a>RFC 6585</a>)
networkAuthenticationRequired511 :: Status

-- | Network Authentication Required 511 (<a>RFC 6585</a>)
status511 :: Status

-- | HTTP Version Not Supported 505
httpVersionNotSupported505 :: Status

-- | HTTP Version Not Supported 505
status505 :: Status

-- | Gateway Timeout 504
gatewayTimeout504 :: Status

-- | Gateway Timeout 504
status504 :: Status

-- | Service Unavailable 503
serviceUnavailable503 :: Status

-- | Service Unavailable 503
status503 :: Status

-- | Bad Gateway 502
badGateway502 :: Status

-- | Bad Gateway 502
status502 :: Status

-- | Not Implemented 501
notImplemented501 :: Status

-- | Not Implemented 501
status501 :: Status

-- | Internal Server Error 500
internalServerError500 :: Status

-- | Internal Server Error 500
status500 :: Status

-- | Request Header Fields Too Large 431 (<a>RFC 6585</a>)
requestHeaderFieldsTooLarge431 :: Status

-- | Request Header Fields Too Large 431 (<a>RFC 6585</a>)
status431 :: Status

-- | Too Many Requests 429 (<a>RFC 6585</a>)
tooManyRequests429 :: Status

-- | Too Many Requests 429 (<a>RFC 6585</a>)
status429 :: Status

-- | Precondition Required 428 (<a>RFC 6585</a>)
preconditionRequired428 :: Status

-- | Precondition Required 428 (<a>RFC 6585</a>)
status428 :: Status

-- | Unprocessable Entity 422 (<a>RFC 4918</a>)
unprocessableEntity422 :: Status

-- | Unprocessable Entity 422 (<a>RFC 4918</a>)
status422 :: Status

-- | I'm a teapot 418
imATeapot418 :: Status

-- | I'm a teapot 418
status418 :: Status

-- | Expectation Failed 417
expectationFailed417 :: Status

-- | Expectation Failed 417
status417 :: Status

-- | Requested Range Not Satisfiable 416
requestedRangeNotSatisfiable416 :: Status

-- | Requested Range Not Satisfiable 416
status416 :: Status

-- | Unsupported Media Type 415
unsupportedMediaType415 :: Status

-- | Unsupported Media Type 415
status415 :: Status

-- | Request-URI Too Long 414
requestURITooLong414 :: Status

-- | Request-URI Too Long 414
status414 :: Status

-- | Request Entity Too Large 413
requestEntityTooLarge413 :: Status

-- | Request Entity Too Large 413
status413 :: Status

-- | Precondition Failed 412
preconditionFailed412 :: Status

-- | Precondition Failed 412
status412 :: Status

-- | Length Required 411
lengthRequired411 :: Status

-- | Length Required 411
status411 :: Status

-- | Gone 410
gone410 :: Status

-- | Gone 410
status410 :: Status

-- | Conflict 409
conflict409 :: Status

-- | Conflict 409
status409 :: Status

-- | Request Timeout 408
requestTimeout408 :: Status

-- | Request Timeout 408
status408 :: Status

-- | Proxy Authentication Required 407
proxyAuthenticationRequired407 :: Status

-- | Proxy Authentication Required 407
status407 :: Status

-- | Not Acceptable 406
notAcceptable406 :: Status

-- | Not Acceptable 406
status406 :: Status

-- | Method Not Allowed 405
methodNotAllowed405 :: Status

-- | Method Not Allowed 405
status405 :: Status

-- | Not Found 404
notFound404 :: Status

-- | Not Found 404
status404 :: Status

-- | Forbidden 403
forbidden403 :: Status

-- | Forbidden 403
status403 :: Status

-- | Payment Required 402
paymentRequired402 :: Status

-- | Payment Required 402
status402 :: Status

-- | Unauthorized 401
unauthorized401 :: Status

-- | Unauthorized 401
status401 :: Status

-- | Bad Request 400
badRequest400 :: Status

-- | Bad Request 400
status400 :: Status

-- | Permanent Redirect 308
permanentRedirect308 :: Status

-- | Permanent Redirect 308
status308 :: Status

-- | Temporary Redirect 307
temporaryRedirect307 :: Status

-- | Temporary Redirect 307
status307 :: Status

-- | Use Proxy 305
useProxy305 :: Status

-- | Use Proxy 305
status305 :: Status

-- | Not Modified 304
notModified304 :: Status

-- | Not Modified 304
status304 :: Status

-- | See Other 303
seeOther303 :: Status

-- | See Other 303
status303 :: Status

-- | Found 302
found302 :: Status

-- | Found 302
status302 :: Status

-- | Moved Permanently 301
movedPermanently301 :: Status

-- | Moved Permanently 301
status301 :: Status

-- | Multiple Choices 300
multipleChoices300 :: Status

-- | Multiple Choices 300
status300 :: Status

-- | Partial Content 206
partialContent206 :: Status

-- | Partial Content 206
status206 :: Status

-- | Reset Content 205
resetContent205 :: Status

-- | Reset Content 205
status205 :: Status

-- | No Content 204
noContent204 :: Status

-- | No Content 204
status204 :: Status

-- | Non-Authoritative Information 203
nonAuthoritative203 :: Status

-- | Non-Authoritative Information 203
status203 :: Status

-- | Accepted 202
accepted202 :: Status

-- | Accepted 202
status202 :: Status

-- | Created 201
created201 :: Status

-- | Created 201
status201 :: Status

-- | OK 200
ok200 :: Status

-- | OK 200
status200 :: Status

-- | Switching Protocols 101
switchingProtocols101 :: Status

-- | Switching Protocols 101
status101 :: Status

-- | Continue 100
continue100 :: Status

-- | Continue 100
status100 :: Status

-- | Create a Status from status code and message.
mkStatus :: Int -> ByteString -> Status

-- | HTTP Status.
--   
--   Only the <a>statusCode</a> is used for comparisons.
--   
--   Please use <a>mkStatus</a> to create status codes from code and
--   message, or the <a>Enum</a> instance or the status code constants
--   (like <a>ok200</a>). There might be additional record members in the
--   future.
--   
--   Note that the Show instance is only for debugging.
data Status
Status :: Int -> ByteString -> Status
[statusCode] :: Status -> Int
[statusMessage] :: Status -> ByteString

-- | Convert a <a>StdMethod</a> to a <tt>ByteString</tt>.
renderStdMethod :: StdMethod -> Method

-- | Convert an algebraic method to a <tt>ByteString</tt>.
renderMethod :: Either ByteString StdMethod -> Method

-- | Convert a method <tt>ByteString</tt> to a <a>StdMethod</a> if
--   possible.
parseMethod :: Method -> Either ByteString StdMethod

-- | HTTP Method constants.
methodPatch :: Method

-- | HTTP Method constants.
methodOptions :: Method

-- | HTTP Method constants.
methodConnect :: Method

-- | HTTP Method constants.
methodTrace :: Method

-- | HTTP Method constants.
methodDelete :: Method

-- | HTTP Method constants.
methodPut :: Method

-- | HTTP Method constants.
methodHead :: Method

-- | HTTP Method constants.
methodPost :: Method

-- | HTTP Method constants.
methodGet :: Method

-- | HTTP method (flat string type).
type Method = ByteString

-- | HTTP standard method (as defined by RFC 2616, and PATCH which is
--   defined by RFC 5789).
data StdMethod
GET :: StdMethod
POST :: StdMethod
HEAD :: StdMethod
PUT :: StdMethod
DELETE :: StdMethod
TRACE :: StdMethod
CONNECT :: StdMethod
OPTIONS :: StdMethod
PATCH :: StdMethod

-- | Parse the value of a Range header into a <a>ByteRanges</a>.
--   
--   <pre>
--   &gt;&gt;&gt; parseByteRanges "error"
--   Nothing
--   
--   &gt;&gt;&gt; parseByteRanges "bytes=0-499"
--   Just [ByteRangeFromTo 0 499]
--   
--   &gt;&gt;&gt; parseByteRanges "bytes=500-999"
--   Just [ByteRangeFromTo 500 999]
--   
--   &gt;&gt;&gt; parseByteRanges "bytes=-500"
--   Just [ByteRangeSuffix 500]
--   
--   &gt;&gt;&gt; parseByteRanges "bytes=9500-"
--   Just [ByteRangeFrom 9500]
--   
--   &gt;&gt;&gt; parseByteRanges "bytes=0-0,-1"
--   Just [ByteRangeFromTo 0 0,ByteRangeSuffix 1]
--   
--   &gt;&gt;&gt; parseByteRanges "bytes=500-600,601-999"
--   Just [ByteRangeFromTo 500 600,ByteRangeFromTo 601 999]
--   
--   &gt;&gt;&gt; parseByteRanges "bytes=500-700,601-999"
--   Just [ByteRangeFromTo 500 700,ByteRangeFromTo 601 999]
--   </pre>
parseByteRanges :: ByteString -> Maybe ByteRanges
renderByteRanges :: ByteRanges -> ByteString
renderByteRangesBuilder :: ByteRanges -> Builder
renderByteRange :: ByteRange -> ByteString
renderByteRangeBuilder :: ByteRange -> Builder

-- | HTTP Header names according to
--   <a>https://tools.ietf.org/html/rfc6265#section-4</a>
hCookie :: HeaderName

-- | HTTP Header names according to
--   <a>http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html</a>
hUserAgent :: HeaderName

-- | HTTP Header names according to
--   <a>http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html</a>
hServer :: HeaderName

-- | HTTP Header names according to
--   <a>http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html</a>
hReferer :: HeaderName

-- | HTTP Header names according to
--   <a>http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html</a>
hRange :: HeaderName

-- | HTTP Header names according to
--   <a>http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html</a>
hLocation :: HeaderName

-- | HTTP Header names according to
--   <a>http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html</a>
hLastModified :: HeaderName

-- | HTTP Header names according to
--   <a>http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html</a>
hIfRange :: HeaderName

-- | HTTP Header names according to
--   <a>http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html</a>
hIfModifiedSince :: HeaderName

-- | HTTP Header names according to
--   <a>http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html</a>
hDate :: HeaderName

-- | HTTP Header names according to
--   <a>http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html</a>
hContentType :: HeaderName

-- | HTTP Header names according to
--   <a>http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html</a>
hContentMD5 :: HeaderName

-- | HTTP Header names according to
--   <a>http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html</a>
hContentLength :: HeaderName

-- | HTTP Header names according to
--   <a>http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html</a>
hContentEncoding :: HeaderName

-- | HTTP Header names according to
--   <a>http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html</a>
hConnection :: HeaderName

-- | HTTP Header names according to
--   <a>http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html</a>
hCacheControl :: HeaderName

-- | HTTP Header names according to
--   <a>http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html</a>
hAuthorization :: HeaderName

-- | HTTP Header names according to
--   <a>http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html</a>
hAcceptLanguage :: HeaderName

-- | HTTP Header names according to
--   <a>http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html</a>
hAccept :: HeaderName

-- | Header name
type HeaderName = CI ByteString

-- | Request Headers
type RequestHeaders = [Header]

-- | Response Headers
type ResponseHeaders = [Header]

-- | RFC 2616 Byte range (individual).
--   
--   Negative indices are not allowed!
data ByteRange
ByteRangeFrom :: !Integer -> ByteRange
ByteRangeFromTo :: !Integer -> !Integer -> ByteRange
ByteRangeSuffix :: !Integer -> ByteRange

-- | RFC 2616 Byte ranges (set).
type ByteRanges = [ByteRange]

-- | Set the <a>Label</a> to the <a>Show</a>n value of whatever you pass
--   in.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
label' :: (MonadIO m, MonadMetrics m, Show a) => Text -> a -> m ()

-- | Set the <a>Label</a> to the given <a>Text</a> value.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
label :: (MonadIO m, MonadMetrics m) => Text -> Text -> m ()

-- | Record the time of executing the given action in seconds. Defers to
--   <a>timed'</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
timed :: (MonadIO m, MonadMetrics m, MonadMask m) => Text -> m a -> m a

-- | Record the time taken to perform the action, under several names at
--   once. The number is stored in a <a>Distribution</a> and is converted
--   to the specified <a>Resolution</a>.
--   
--   This is useful to store the same durations data sectioned by different
--   criteria, e.g.:
--   
--   <pre>
--   timedList Seconds ["request.byUser." &lt;&gt; userName, "request.byType." &lt;&gt; requestType] $ do
--       ...
--   </pre>
--   
--   So you will have <tt>"request.byUser.someuser"</tt> storing duration
--   distribution for requests of user <tt>"someuser"</tt> of any type; and
--   <tt>"request.byType.sometype"</tt> storing duration distribution for
--   requests of type <tt>"sometype"</tt> from any user.
timedList :: (MonadIO m, MonadMetrics m, MonadMask m) => Resolution -> [Text] -> m a -> m a

-- | Record the time taken to perform the named action. The number is
--   stored in a <a>Distribution</a> and is converted to the specified
--   <a>Resolution</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
timed' :: (MonadIO m, MonadMetrics m, MonadMask m) => Resolution -> Text -> m a -> m a

-- | A type specialized version of <a>gauge'</a> to avoid ambiguous types.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
gauge :: (MonadIO m, MonadMetrics m) => Text -> Int -> m ()

-- | Set the value of the named <a>Gauge</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
gauge' :: (MonadIO m, MonadMetrics m, Integral int) => Text -> int -> m ()

-- | Add the value to the named <a>Distribution</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
distribution :: (MonadIO m, MonadMetrics m) => Text -> Double -> m ()

-- | A type specialized version of <a>counter'</a> to avoid ambiguous type
--   errors.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
counter :: (MonadIO m, MonadMetrics m) => Text -> Int -> m ()

-- | Adds the value to the named <a>Counter</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
counter' :: (MonadIO m, MonadMetrics m, Integral int) => Text -> int -> m ()

-- | Increment the named counter by 1.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
increment :: (MonadIO m, MonadMetrics m) => Text -> m ()

-- | A type can be an instance of <a>MonadMetrics</a> if it can provide a
--   <a>Metrics</a> somehow. Commonly, this will be implemented as a
--   <a>ReaderT</a> where some field in the environment is the
--   <a>Metrics</a> data.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
class Monad m => MonadMetrics (m :: * -> *)
getMetrics :: MonadMetrics m => m Metrics

-- | A lens into the <a>Store</a> provided by the <a>Metrics</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
metricsStore :: Lens' Metrics Store

-- | A lens into the <a>Label</a>s provided by the <a>Metrics</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
metricsLabels :: Lens' Metrics IORef HashMap Text Label

-- | A lens into the <a>Gauge</a>s provided by the <a>Metrics</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
metricsGauges :: Lens' Metrics IORef HashMap Text Gauge

-- | A lens into the <a>Counter</a>s provided by the <a>Metrics</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
metricsCounters :: Lens' Metrics IORef HashMap Text Counter

-- | A container for metrics used by the <tt>MonadMetrics</tt> class.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
data Metrics

-- | A type representing the resolution of time to use for the
--   <tt>timed</tt> metric.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
data Resolution
Nanoseconds :: Resolution
Microseconds :: Resolution
Milliseconds :: Resolution
Seconds :: Resolution
Minutes :: Resolution
Hours :: Resolution
Days :: Resolution

-- | Is used within a monadic computation to begin exception processing.
throwError :: MonadError e m => e -> m a
fragment :: URI -> String
query :: URI -> String
path :: URI -> String
authority :: URI -> String
scheme :: URI -> String
unreserved :: Char -> Bool
reserved :: Char -> Bool
escapeString :: String -> Char -> Bool -> String
parseabsoluteURI :: String -> Maybe URI

-- | Path segment normalization; cf. RFC3986 section 6.2.2.3
normalizePathSegments :: String -> String

-- | Encoding normalization; cf. RFC3986 section 6.2.2.2
normalizeEscape :: String -> String

-- | Case normalization; cf. RFC3986 section 6.2.2.1 NOTE: authority case
--   normalization is not performed
normalizeCase :: String -> String

-- | Returns a new <a>URI</a> which represents the relative location of the
--   first <a>URI</a> with respect to the second <a>URI</a>. Thus, the
--   values supplied are expected to be absolute URIs, and the result
--   returned may be a relative URI.
--   
--   Example:
--   
--   <pre>
--   "http://example.com/Root/sub1/name2#frag"
--     `relativeFrom` "http://example.com/Root/sub2/name2#frag"
--     == "../sub1/name2#frag"
--   </pre>
--   
--   There is no single correct implementation of this function, but any
--   acceptable implementation must satisfy the following:
--   
--   <pre>
--   (uabs `relativeFrom` ubase) `relativeTo` ubase == uabs
--   </pre>
--   
--   For any valid absolute URI. (cf.
--   <a>http://lists.w3.org/Archives/Public/uri/2003Jan/0008.html</a>
--   <a>http://lists.w3.org/Archives/Public/uri/2003Jan/0005.html</a>)
relativeFrom :: URI -> URI -> URI

-- | Returns the segments of the path component. E.g., pathSegments
--   <a>$</a> parseURI "<a>http://example.org/foo/bar/baz"</a> == ["foo",
--   "bar", "baz"]
pathSegments :: URI -> [String]

-- | Returns a new <a>URI</a> which represents the value of the first
--   <a>URI</a> interpreted as relative to the second <a>URI</a>.
--   
--   Algorithm from RFC3986 [3], section 5.2
relativeTo :: URI -> URI -> URI

-- | Returns a new <a>URI</a> which represents the value of the first
--   <a>URI</a> interpreted as relative to the second <a>URI</a>. For
--   example:
--   
--   <pre>
--   "foo" `relativeTo` "http://bar.org/" = "http://bar.org/foo"
--   "http:foo" `nonStrictRelativeTo` "http://bar.org/" = "http://bar.org/foo"
--   </pre>
--   
--   Algorithm from RFC3986 [3], section 5.2.2
nonStrictRelativeTo :: URI -> URI -> URI

-- | Turns all instances of escaped characters in the string back into
--   literal characters.
unEscapeString :: String -> String

-- | Can be used to make a string valid for use in a URI.
escapeURIString :: Char -> Bool -> String -> String

-- | Escape character if supplied predicate is not satisfied, otherwise
--   return character as singleton string.
escapeURIChar :: Char -> Bool -> Char -> String

-- | Returns <a>True</a> if the character is allowed unescaped in a URI
--   component.
--   
--   <pre>
--   &gt;&gt;&gt; escapeURIString isUnescapedInURIComponent "http://haskell.org:80?some_param=true&amp;other_param=їґ"
--   "http%3A%2F%2Fhaskell.org%3A80%3Fsome_param%3Dtrue%26other_param%3D%D1%97%D2%91"
--   </pre>
isUnescapedInURIComponent :: Char -> Bool

-- | Returns <a>True</a> if the character is allowed unescaped in a URI.
--   
--   <pre>
--   &gt;&gt;&gt; escapeURIString isUnescapedInURI "http://haskell.org:80?some_param=true&amp;other_param=їґ"
--   "http://haskell.org:80?some_param=true&amp;other_param=%D1%97%D2%91"
--   </pre>
isUnescapedInURI :: Char -> Bool

-- | Returns <a>True</a> if the character is allowed in a URI.
isAllowedInURI :: Char -> Bool

-- | Turn a <a>URI</a> into a string.
--   
--   Uses a supplied function to map the userinfo part of the URI.
--   
--   The Show instance for URI uses a mapping that hides any password that
--   may be present in the URI. Use this function with argument <tt>id</tt>
--   to preserve the password in the formatted output.
uriToString :: String -> String -> URI -> ShowS

-- | Returns <a>True</a> if the character is an "unreserved" character in a
--   URI. These characters do not need to be escaped in a URI. The only
--   characters allowed in a URI are either "reserved", "unreserved", or an
--   escape sequence (<tt>%</tt> followed by two hex digits).
isUnreserved :: Char -> Bool

-- | Returns <a>True</a> if the character is a "reserved" character in a
--   URI. To include a literal instance of one of these characters in a
--   component of a URI, it must be escaped.
isReserved :: Char -> Bool
uriIsRelative :: URI -> Bool
uriIsAbsolute :: URI -> Bool

-- | Test if string contains a valid IPv4 address
isIPv4address :: String -> Bool

-- | Test if string contains a valid IPv6 address
isIPv6address :: String -> Bool

-- | Test if string contains a valid absolute URI (an absolute URI without
--   a fragment identifier).
isAbsoluteURI :: String -> Bool

-- | Test if string contains a valid relative URI (a relative URI with
--   optional fragment identifier).
isRelativeReference :: String -> Bool

-- | Test if string contains a valid URI reference (an absolute or relative
--   URI with optional fragment identifier).
isURIReference :: String -> Bool

-- | Test if string contains a valid URI (an absolute URI with optional
--   fragment identifier).
isURI :: String -> Bool

-- | Parse an absolute URI to a <a>URI</a> value. Returns <a>Nothing</a> if
--   the string is not a valid absolute URI. (an absolute URI without a
--   fragment identifier).
parseAbsoluteURI :: String -> Maybe URI

-- | Parse a relative URI to a <a>URI</a> value. Returns <a>Nothing</a> if
--   the string is not a valid relative URI. (a relative URI with optional
--   fragment identifier).
parseRelativeReference :: String -> Maybe URI

-- | Parse a URI reference to a <a>URI</a> value. Returns <a>Nothing</a> if
--   the string is not a valid URI reference. (an absolute or relative URI
--   with optional fragment identifier).
parseURIReference :: String -> Maybe URI

-- | Turn a string containing a URI into a <a>URI</a>. Returns
--   <a>Nothing</a> if the string is not a valid URI; (an absolute URI with
--   optional fragment identifier).
--   
--   NOTE: this is different from the previous network.URI, whose
--   <tt>parseURI</tt> function works like <a>parseURIReference</a> in this
--   module.
parseURI :: String -> Maybe URI

-- | Blank URI
nullURI :: URI

-- | Type for authority value within a URI
data URIAuth
URIAuth :: String -> String -> String -> URIAuth

-- | <pre>
--   anonymous@
--   </pre>
[uriUserInfo] :: URIAuth -> String

-- | <pre>
--   www.haskell.org
--   </pre>
[uriRegName] :: URIAuth -> String

-- | <pre>
--   :42
--   </pre>
[uriPort] :: URIAuth -> String

-- | A variant of <a>r</a> that interprets the <tt>"|~]"</tt> sequence as
--   <tt>"|]"</tt>, <tt>"|~~]"</tt> as <tt>"|~]"</tt> and, in general,
--   <tt>"|~^n]"</tt> as <tt>"|~^(n-1)]"</tt> for n &gt;= 1.
--   
--   Usage:
--   
--   <pre>
--   ghci&gt; [rQ||~]|~]|]
--   "|]|]"
--   ghci&gt; [rQ||~~]|]
--   "|~]"
--   ghci&gt; [rQ||~~~~]|]
--   "|~~~]"
--   </pre>
rQ :: QuasiQuoter

-- | A quasiquoter for raw string literals - that is, string literals that
--   don't recognise the standard escape sequences (such as <tt>'\n'</tt>).
--   Basically, they make your code more readable by freeing you from the
--   responsibility to escape backslashes. They are useful when working
--   with regular expressions, DOS/Windows paths and markup languages (such
--   as XML).
--   
--   Don't forget the <tt>LANGUAGE QuasiQuotes</tt> pragma if you're using
--   this module in your code.
--   
--   Usage:
--   
--   <pre>
--   ghci&gt; :set -XQuasiQuotes
--   ghci&gt; import Text.RawString.QQ
--   ghci&gt; let s = [r|\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}|]
--   ghci&gt; s
--   "\\w+@[a-zA-Z_]+?\\.[a-zA-Z]{2,3}"
--   ghci&gt; [r|C:\Windows\SYSTEM|] ++ [r|\user32.dll|]
--   "C:\\Windows\\SYSTEM\\user32.dll"
--   </pre>
--   
--   Multiline raw string literals are also supported:
--   
--   <pre>
--   multiline :: String
--   multiline = [r|&lt;HTML&gt;
--   &lt;HEAD&gt;
--   &lt;TITLE&gt;Auto-generated html formated source&lt;/TITLE&gt;
--   &lt;META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252"&gt;
--   &lt;/HEAD&gt;
--   &lt;BODY LINK="800080" BGCOLOR="#ffffff"&gt;
--   &lt;P&gt; &lt;/P&gt;
--   &lt;PRE&gt;|]
--   </pre>
--   
--   Caveat: since the <tt>"|]"</tt> character sequence is used to
--   terminate the quasiquotation, you can't use it inside the raw string
--   literal. Use <a>rQ</a> if you want to embed that character sequence
--   inside the raw string.
--   
--   For more on raw strings, see e.g.
--   <a>http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2053.html</a>
--   
--   For more on quasiquotation, see
--   <a>http://www.haskell.org/haskellwiki/Quasiquotation</a>
r :: QuasiQuoter

-- | A handler for a <tt><a>RefineException</a></tt>.
--   
--   <a>throwRefineOtherException</a> is useful for defining what behaviour
--   <a>validate</a> should have in the event of a predicate failure.
throwRefineOtherException :: Monad m => TypeRep -> Doc Void -> RefineT m a

-- | A handler function to handle previous <tt><a>RefineException</a></tt>s
--   and return to normal execution. A common idiom is:
--   
--   <pre>
--   do { action1; action2; action3 } `<tt>catchRefine'</tt> handler
--   </pre>
--   
--   where the action functions can call <tt><a>throwRefine</a></tt>. Note
--   that handler and the do-block must have the same return type.
catchRefine :: Monad m => RefineT m a -> RefineException -> RefineT m a -> RefineT m a

-- | One can use <tt><a>throwRefine</a></tt> inside of a monadic context to
--   begin processing a <tt><a>RefineException</a></tt>.
throwRefine :: Monad m => RefineException -> RefineT m a

-- | Run a monadic action of type <tt><a>RefineM</a> a</tt>, yielding an
--   <tt><a>Either</a> <a>RefineException</a> a</tt>.
--   
--   This is just defined as <tt><a>runIdentity</a> <tt>.</tt>
--   <a>runRefineT</a></tt>.
runRefineM :: () => RefineM a -> Either RefineException a

-- | Constructs a computation in the <a>RefineM</a> monad. (The inverse of
--   <tt><a>runRefineM</a></tt>).
refineM :: () => Either RefineException a -> RefineM a

-- | Map the unwrapped computation using the given function.
--   
--   <pre>
--   <a>runRefineT</a> (<a>mapRefineT</a> f m) = f (<a>runRefineT</a> m)
--   </pre>
mapRefineT :: () => m Either RefineException a -> n Either RefineException b -> RefineT m a -> RefineT n b

-- | The inverse of <tt><a>RefineT</a></tt>.
runRefineT :: () => RefineT m a -> m Either RefineException a

-- | Display a <a>RefineException</a> as a <tt><a>Doc</a> ann</tt>
displayRefineException :: () => RefineException -> Doc ann

-- | This function helps type inference. It is equivalent to the following:
--   
--   <pre>
--   instance Weaken r (Or l r)
--   </pre>
rightOr :: () => Refined r x -> Refined Or l r x

-- | This function helps type inference. It is equivalent to the following:
--   
--   <pre>
--   instance Weaken l (Or l r)
--   </pre>
leftOr :: () => Refined l x -> Refined Or l r x

-- | This function helps type inference. It is equivalent to the following:
--   
--   <pre>
--   instance Weaken (And l r) r
--   </pre>
andRight :: () => Refined And l r x -> Refined r x

-- | This function helps type inference. It is equivalent to the following:
--   
--   <pre>
--   instance Weaken (And l r) l
--   </pre>
andLeft :: () => Refined And l r x -> Refined l x

-- | Extracts the refined value.
unrefine :: () => Refined p x -> x

-- | Constructs a <a>Refined</a> value at compile-time using
--   <tt>-XTemplateHaskell</tt>.
--   
--   For example:
--   
--   <pre>
--   &gt;&gt;&gt; $$(refineTH 23) :: Refined Positive Int
--   Refined 23
--   </pre>
--   
--   Here's an example of an invalid value:
--   
--   <pre>
--   &gt;&gt;&gt; $$(refineTH 0) :: Refined Positive Int
--   &lt;interactive&gt;:6:4:
--       Value is not greater than 0
--       In the Template Haskell splice $$(refineTH 0)
--       In the expression: $$(refineTH 0) :: Refined Positive Int
--       In an equation for ‘it’:
--           it = $$(refineTH 0) :: Refined Positive Int
--   </pre>
--   
--   If it's not evident, the example above indicates a compile-time
--   failure, which means that the checking was done at compile-time, thus
--   introducing a zero runtime overhead compared to a plain value
--   construction.
refineTH :: (Predicate p x, Lift x) => x -> Q TExp Refined p x

-- | Constructs a <a>Refined</a> value at run-time, calling <a>error</a> if
--   the value does not satisfy the predicate.
--   
--   WARNING: this function is not total!
unsafeRefine :: Predicate p x => x -> Refined p x

-- | Constructs a <a>Refined</a> value at run-time, calling
--   <a>throwError</a> if the value does not satisfy the predicate.
refineError :: (Predicate p x, MonadError RefineException m) => x -> m Refined p x

-- | Constructs a <a>Refined</a> value at run-time, calling <a>fail</a> if
--   the value does not satisfy the predicate.
refineFail :: (Predicate p x, MonadFail m) => x -> m Refined p x

-- | Constructs a <a>Refined</a> value at run-time, calling <a>throwM</a>
--   if the value does not satisfy the predicate.
refineThrow :: (Predicate p x, MonadThrow m) => x -> m Refined p x

-- | A smart constructor of a <a>Refined</a> value. Checks the input value
--   at runtime.
refine :: Predicate p x => x -> Either RefineException Refined p x

-- | A refinement type, which wraps a value of type <tt>x</tt>, ensuring
--   that it satisfies a type-level predicate <tt>p</tt>.
--   
--   The only ways that this library provides to construct a value of type
--   <a>Refined</a> are with the 'refine-' family of functions, because the
--   use of the newtype constructor gets around the checking of the
--   predicate. This restriction on the user makes <a>unrefine</a> safe.
--   
--   If you would <i>really</i> like to construct a <a>Refined</a> value
--   without checking the predicate, use <a>unsafeCoerce</a>.
data Refined p x

-- | A typeclass which defines a runtime interpretation of a type-level
--   predicate <tt>p</tt> for type <tt>x</tt>.
class Typeable p => Predicate p x

-- | Check the value <tt>x</tt> according to the predicate <tt>p</tt>,
--   producing an error string if the value does not satisfy.
validate :: (Predicate p x, Monad m) => p -> x -> RefineT m ()

-- | The negation of a predicate.
data Not p

-- | The conjunction of two predicates.
data And l r

-- | The conjunction of two predicates.
type && = And

-- | The disjunction of two predicates.
data Or l r

-- | The disjunction of two predicates.
type || = Or

-- | A <a>Predicate</a> ensuring that the <a>Foldable</a> has a length
--   which is less than the specified type-level number.
data SizeLessThan (n :: Nat)

-- | A <a>Predicate</a> ensuring that the <a>Foldable</a> has a length
--   which is greater than the specified type-level number.
data SizeGreaterThan (n :: Nat)

-- | A <a>Predicate</a> ensuring that the <a>Foldable</a> has a length
--   which is equal to the specified type-level number.
data SizeEqualTo (n :: Nat)

-- | A <a>Predicate</a> ensuring that the <a>IsList</a> contains elements
--   in a strictly ascending order.
data Ascending

-- | A <a>Predicate</a> ensuring that the <a>IsList</a> contains elements
--   in a strictly descending order.
data Descending

-- | A <a>Predicate</a> ensuring that the value is less than the specified
--   type-level number.
data LessThan (n :: Nat)

-- | A <a>Predicate</a> ensuring that the value is greater than the
--   specified type-level number.
data GreaterThan (n :: Nat)

-- | A <a>Predicate</a> ensuring that the value is greater than or equal to
--   the specified type-level number.
data From (n :: Nat)

-- | A <a>Predicate</a> ensuring that the value is less than or equal to
--   the specified type-level number.
data To (n :: Nat)

-- | A <a>Predicate</a> ensuring that the value is within an inclusive
--   range.
data FromTo (mn :: Nat) (mx :: Nat)

-- | A <a>Predicate</a> ensuring that the value is equal to the specified
--   type-level number <tt>n</tt>.
data EqualTo (n :: Nat)

-- | A <a>Predicate</a> ensuring that the value is not equal to the
--   specified type-level number <tt>n</tt>.
data NotEqualTo (n :: Nat)

-- | A <a>Predicate</a> ensuring that the value is greater than zero.
type Positive = GreaterThan 0

-- | A <a>Predicate</a> ensuring that the value is less than or equal to
--   zero.
type NonPositive = To 0

-- | A <a>Predicate</a> ensuring that the value is less than zero.
type Negative = LessThan 0

-- | A <a>Predicate</a> ensuring that the value is greater than or equal to
--   zero.
type NonNegative = From 0

-- | An inclusive range of values from zero to one.
type ZeroToOne = FromTo 0 1

-- | A <a>Predicate</a> ensuring that the value is not equal to zero.
type NonZero = NotEqualTo 0

-- | A <a>Predicate</a> ensuring that the <a>Foldable</a> is non-empty.
type NonEmpty = SizeGreaterThan 0

-- | A typeclass containing "safe" conversions between refined predicates
--   where the target is <i>weaker</i> than the source: that is, all values
--   that satisfy the first predicate will be guarunteed to satisy the
--   second.
--   
--   Take care: writing an instance declaration for your custom predicates
--   is the same as an assertion that <a>weaken</a> is safe to use:
--   
--   <pre>
--   instance <a>Weaken</a> Pred1 Pred2
--   </pre>
--   
--   For most of the instances, explicit type annotations for the result
--   value's type might be required.
class Weaken from to
weaken :: Weaken from to => Refined from x -> Refined to x

-- | An exception encoding the way in which a <a>Predicate</a> failed.
data RefineException

-- | A <a>RefineException</a> for failures involving the <a>Not</a>
--   predicate.
RefineNotException :: !TypeRep -> RefineException

-- | A <a>RefineException</a> for failures involving the <a>And</a>
--   predicate.
RefineAndException :: !TypeRep -> !These RefineException RefineException -> RefineException

-- | A <a>RefineException</a> for failures involving the <a>Or</a>
--   predicate.
RefineOrException :: !TypeRep -> !RefineException -> !RefineException -> RefineException

-- | A <a>RefineException</a> for failures involving all other predicates.
RefineOtherException :: !TypeRep -> !Doc Void -> RefineException

-- | A monad transformer that adds <tt><a>RefineException</a></tt>s to
--   other monads.
--   
--   The <tt><a>pure</a></tt> and <tt><a>return</a></tt> functions yield
--   computations that produce the given value, while
--   <tt><tt>&gt;&gt;=</tt></tt> sequences two subcomputations, exiting on
--   the first <tt><a>RefineException</a></tt>.
data RefineT (m :: * -> *) a

-- | <tt><a>RefineM</a> a</tt> is equivalent to <tt><a>RefineT</a>
--   <a>Identity</a> a</tt> for any type <tt>a</tt>.
type RefineM a = RefineT Identity a

-- | Lifted <a>newChan</a>.
newChan :: MonadIO m => m Chan a

-- | Lifted <a>writeChan</a>.
writeChan :: MonadIO m => Chan a -> a -> m ()

-- | Lifted <a>readChan</a>.
readChan :: MonadIO m => Chan a -> m a

-- | Lifted <a>dupChan</a>.
dupChan :: MonadIO m => Chan a -> m Chan a

-- | Lifted <a>getChanContents</a>.
getChanContents :: MonadIO m => Chan a -> m [a]

-- | Lifted <a>writeList2Chan</a>.
writeList2Chan :: MonadIO m => Chan a -> [a] -> m ()

-- | Exception type thrown by <a>throwString</a>.
--   
--   Note that the second field of the data constructor depends on GHC/base
--   version. For base 4.9 and GHC 8.0 and later, the second field is a
--   call stack. Previous versions of GHC and base do not support call
--   stacks, and the field is simply unit (provided to make pattern
--   matching across GHC versions easier).
data StringException
StringException :: String -> CallStack -> StringException

-- | Wrap up a synchronous exception to be treated as an asynchronous
--   exception.
--   
--   This is intended to be created via <a>toAsyncException</a>.
data AsyncExceptionWrapper
[AsyncExceptionWrapper] :: AsyncExceptionWrapper

-- | Wrap up an asynchronous exception to be treated as a synchronous
--   exception.
--   
--   This is intended to be created via <a>toSyncException</a>.
data SyncExceptionWrapper
[SyncExceptionWrapper] :: SyncExceptionWrapper

-- | Unlifted <a>catch</a>, but will not catch asynchronous exceptions.
catch :: (MonadUnliftIO m, Exception e) => m a -> e -> m a -> m a

-- | <a>catch</a> specialized to only catching <a>IOException</a>s.
catchIO :: MonadUnliftIO m => m a -> IOException -> m a -> m a

-- | <a>catch</a> specialized to catch all synchronous exception.
catchAny :: MonadUnliftIO m => m a -> SomeException -> m a -> m a

-- | Same as <a>catch</a>, but fully force evaluation of the result value
--   to find all impure exceptions.
catchDeep :: (MonadUnliftIO m, Exception e, NFData a) => m a -> e -> m a -> m a

-- | <a>catchDeep</a> specialized to catch all synchronous exception.
catchAnyDeep :: (NFData a, MonadUnliftIO m) => m a -> SomeException -> m a -> m a

-- | <a>catchJust</a> is like <a>catch</a> but it takes an extra argument
--   which is an exception predicate, a function which selects which type
--   of exceptions we're interested in.
catchJust :: (MonadUnliftIO m, Exception e) => e -> Maybe b -> m a -> b -> m a -> m a

-- | Flipped version of <a>catch</a>.
handle :: (MonadUnliftIO m, Exception e) => e -> m a -> m a -> m a

-- | <a>handle</a> specialized to only catching <a>IOException</a>s.
handleIO :: MonadUnliftIO m => IOException -> m a -> m a -> m a

-- | Flipped version of <a>catchAny</a>.
handleAny :: MonadUnliftIO m => SomeException -> m a -> m a -> m a

-- | Flipped version of <a>catchDeep</a>.
handleDeep :: (MonadUnliftIO m, Exception e, NFData a) => e -> m a -> m a -> m a

-- | Flipped version of <a>catchAnyDeep</a>.
handleAnyDeep :: (MonadUnliftIO m, NFData a) => SomeException -> m a -> m a -> m a

-- | Flipped <a>catchJust</a>.
handleJust :: (MonadUnliftIO m, Exception e) => e -> Maybe b -> b -> m a -> m a -> m a

-- | Unlifted <a>try</a>, but will not catch asynchronous exceptions.
try :: (MonadUnliftIO m, Exception e) => m a -> m Either e a

-- | <a>try</a> specialized to only catching <a>IOException</a>s.
tryIO :: MonadUnliftIO m => m a -> m Either IOException a

-- | <a>try</a> specialized to catch all synchronous exceptions.
tryAny :: MonadUnliftIO m => m a -> m Either SomeException a

-- | Same as <a>try</a>, but fully force evaluation of the result value to
--   find all impure exceptions.
tryDeep :: (MonadUnliftIO m, Exception e, NFData a) => m a -> m Either e a

-- | <a>tryDeep</a> specialized to catch all synchronous exceptions.
tryAnyDeep :: (MonadUnliftIO m, NFData a) => m a -> m Either SomeException a

-- | A variant of <a>try</a> that takes an exception predicate to select
--   which exceptions are caught.
tryJust :: (MonadUnliftIO m, Exception e) => e -> Maybe b -> m a -> m Either b a

-- | Evaluate the value to WHNF and catch any synchronous exceptions.
--   
--   The expression may still have bottom values within it; you may instead
--   want to use <a>pureTryDeep</a>.
pureTry :: () => a -> Either SomeException a

-- | Evaluate the value to NF and catch any synchronous exceptions.
pureTryDeep :: NFData a => a -> Either SomeException a

-- | Same as upstream <a>catches</a>, but will not catch asynchronous
--   exceptions.
catches :: MonadUnliftIO m => m a -> [Handler m a] -> m a

-- | Same as <a>catches</a>, but fully force evaluation of the result value
--   to find all impure exceptions.
catchesDeep :: (MonadUnliftIO m, NFData a) => m a -> [Handler m a] -> m a

-- | Lifted version of <a>evaluate</a>.
evaluate :: MonadIO m => a -> m a

-- | Deeply evaluate a value using <a>evaluate</a> and <a>NFData</a>.
evaluateDeep :: (MonadIO m, NFData a) => a -> m a

-- | Async safe version of <a>bracket</a>.
bracket :: MonadUnliftIO m => m a -> a -> m b -> a -> m c -> m c

-- | Async safe version of <a>bracket_</a>.
bracket_ :: MonadUnliftIO m => m a -> m b -> m c -> m c

-- | Async safe version of <a>bracketOnError</a>.
bracketOnError :: MonadUnliftIO m => m a -> a -> m b -> a -> m c -> m c

-- | A variant of <a>bracketOnError</a> where the return value from the
--   first computation is not required.
bracketOnError_ :: MonadUnliftIO m => m a -> m b -> m c -> m c

-- | Async safe version of <a>finally</a>.
finally :: MonadUnliftIO m => m a -> m b -> m a

-- | Like <a>onException</a>, but provides the handler the thrown
--   exception.
withException :: (MonadUnliftIO m, Exception e) => m a -> e -> m b -> m a

-- | Async safe version of <a>onException</a>.
onException :: MonadUnliftIO m => m a -> m b -> m a

-- | Synchronously throw the given exception.
throwIO :: (MonadIO m, Exception e) => e -> m a

-- | Convert an exception into a synchronous exception.
--   
--   For synchronous exceptions, this is the same as <a>toException</a>.
--   For asynchronous exceptions, this will wrap up the exception with
--   <a>SyncExceptionWrapper</a>.
toSyncException :: Exception e => e -> SomeException

-- | Convert an exception into an asynchronous exception.
--   
--   For asynchronous exceptions, this is the same as <a>toException</a>.
--   For synchronous exceptions, this will wrap up the exception with
--   <a>AsyncExceptionWrapper</a>.
toAsyncException :: Exception e => e -> SomeException

-- | Check if the given exception is synchronous.
isSyncException :: Exception e => e -> Bool

-- | Check if the given exception is asynchronous.
isAsyncException :: Exception e => e -> Bool

-- | Unlifted version of <a>mask</a>.
mask :: MonadUnliftIO m => forall a. () => m a -> m a -> m b -> m b

-- | Unlifted version of <a>uninterruptibleMask</a>.
uninterruptibleMask :: MonadUnliftIO m => forall a. () => m a -> m a -> m b -> m b

-- | Unlifted version of <a>mask_</a>.
mask_ :: MonadUnliftIO m => m a -> m a

-- | Unlifted version of <a>uninterruptibleMask_</a>.
uninterruptibleMask_ :: MonadUnliftIO m => m a -> m a

-- | A convenience function for throwing a user error. This is useful for
--   cases where it would be too high a burden to define your own exception
--   type.
--   
--   This throws an exception of type <a>StringException</a>. When GHC
--   supports it (base 4.9 and GHC 8.0 and onward), it includes a call
--   stack.
throwString :: (MonadIO m, HasCallStack) => String -> m a

-- | Smart constructor for a <a>StringException</a> that deals with the
--   call stack.
stringException :: HasCallStack -> String -> StringException

-- | Throw an asynchronous exception to another thread.
--   
--   Synchronously typed exceptions will be wrapped into an
--   <a>AsyncExceptionWrapper</a>, see
--   <a>https://github.com/fpco/safe-exceptions#determining-sync-vs-async</a>.
--   
--   It's usually a better idea to use the <a>UnliftIO.Async</a> module,
--   see <a>https://github.com/fpco/safe-exceptions#quickstart</a>.
throwTo :: (Exception e, MonadIO m) => ThreadId -> e -> m ()

-- | Generate a pure value which, when forced, will synchronously throw the
--   given exception.
--   
--   Generally it's better to avoid using this function and instead use
--   <a>throwIO</a>, see
--   <a>https://github.com/fpco/safe-exceptions#quickstart</a>.
impureThrow :: Exception e => e -> a

-- | Unwrap an <a>Either</a> value, throwing its <a>Left</a> value as a
--   runtime exception via <a>throwIO</a> if present.
fromEither :: (Exception e, MonadIO m) => Either e a -> m a

-- | Same as <a>fromEither</a>, but works on an <a>IO</a>-wrapped
--   <a>Either</a>.
fromEitherIO :: (Exception e, MonadIO m) => IO Either e a -> m a

-- | Same as <a>fromEither</a>, but works on an <tt>m</tt>-wrapped
--   <a>Either</a>.
fromEitherM :: (Exception e, MonadIO m) => m Either e a -> m a

-- | Lifted <a>newEmptyMVar</a>.
newEmptyMVar :: MonadIO m => m MVar a

-- | Lifted <a>newMVar</a>.
newMVar :: MonadIO m => a -> m MVar a

-- | Lifted <a>takeMVar</a>.
takeMVar :: MonadIO m => MVar a -> m a

-- | Lifted <a>putMVar</a>.
putMVar :: MonadIO m => MVar a -> a -> m ()

-- | Lifted <a>readMVar</a>.
readMVar :: MonadIO m => MVar a -> m a

-- | Lifted <a>swapMVar</a>.
swapMVar :: MonadIO m => MVar a -> a -> m a

-- | Lifted <a>tryTakeMVar</a>.
tryTakeMVar :: MonadIO m => MVar a -> m Maybe a

-- | Lifted <a>tryPutMVar</a>.
tryPutMVar :: MonadIO m => MVar a -> a -> m Bool

-- | Lifted <a>isEmptyMVar</a>.
isEmptyMVar :: MonadIO m => MVar a -> m Bool

-- | Lifted <a>tryReadMVar</a>.
tryReadMVar :: MonadIO m => MVar a -> m Maybe a

-- | Unlifted <a>withMVar</a>.
withMVar :: MonadUnliftIO m => MVar a -> a -> m b -> m b

-- | Unlifted <a>withMVarMasked</a>.
withMVarMasked :: MonadUnliftIO m => MVar a -> a -> m b -> m b

-- | Unlifted <a>modifyMVar_</a>.
modifyMVar_ :: MonadUnliftIO m => MVar a -> a -> m a -> m ()

-- | Unlifted <a>modifyMVar</a>.
modifyMVar :: MonadUnliftIO m => MVar a -> a -> m (a, b) -> m b

-- | Unlifted <a>modifyMVarMasked_</a>.
modifyMVarMasked_ :: MonadUnliftIO m => MVar a -> a -> m a -> m ()

-- | Unlifted <a>modifyMVarMasked</a>.
modifyMVarMasked :: MonadUnliftIO m => MVar a -> a -> m (a, b) -> m b

-- | Unlifted <a>mkWeakMVar</a>.
mkWeakMVar :: MonadUnliftIO m => MVar a -> m () -> m Weak MVar a

-- | The Reader+IO monad. This is different from a <a>ReaderT</a> because:
--   
--   <ul>
--   <li>It's not a transformer, it hardcodes IO for simpler usage and
--   error messages.</li>
--   <li>Instances of typeclasses like <tt>MonadLogger</tt> are implemented
--   using classes defined on the environment, instead of using an
--   underlying monad.</li>
--   </ul>
data RIO env a

-- | Lifted version of <a>myThreadId</a>.
myThreadId :: MonadIO m => m ThreadId

-- | Lifted version of <a>threadDelay</a>.
threadDelay :: MonadIO m => Int -> m ()

-- | Lifted version of <a>threadWaitRead</a>.
threadWaitRead :: MonadIO m => Fd -> m ()

-- | Lifted version of <a>threadWaitWrite</a>.
threadWaitWrite :: MonadIO m => Fd -> m ()

-- | Lifted version of <a>isCurrentThreadBound</a>.
isCurrentThreadBound :: MonadIO m => m Bool

-- | More general version of <a>allFieldLinks</a>.
allFieldLinks' :: (HasLink ToServantApi routes, GenericServant routes AsLink a, ToServant routes AsLink a ~ MkLink ToServantApi routes a) => Link -> a -> routes AsLink a

-- | Get all links as a record.
allFieldLinks :: (HasLink ToServantApi routes, GenericServant routes AsLink Link, ToServant routes AsLink Link ~ MkLink ToServantApi routes Link) => routes AsLink Link

-- | More general version of <a>fieldLink</a>
fieldLink' :: (IsElem endpoint ToServantApi routes, HasLink endpoint, GenericServant routes AsApi) => Link -> a -> routes AsApi -> endpoint -> MkLink endpoint a

-- | Given an API record field, create a link for that route. Only the
--   field's type is used.
--   
--   <pre>
--   data Record route = Record
--       { _get :: route :- Capture "id" Int :&gt; Get '[JSON] String
--       , _put :: route :- ReqBody '[JSON] Int :&gt; Put '[JSON] Bool
--       }
--     deriving (<a>Generic</a>)
--   
--   getLink :: Int -&gt; Link
--   getLink = <a>fieldLink</a> _get
--   </pre>
fieldLink :: (IsElem endpoint ToServantApi routes, HasLink endpoint, GenericServant routes AsApi) => routes AsApi -> endpoint -> MkLink endpoint Link

-- | More general <a>allLinks</a>. See <a>safeLink'</a>.
allLinks' :: HasLink api => Link -> a -> Proxy api -> MkLink api a

-- | Create all links in an API.
--   
--   Note that the <tt>api</tt> type must be restricted to the endpoints
--   that have valid links to them.
--   
--   <pre>
--   &gt;&gt;&gt; type API = "foo" :&gt; Capture "name" Text :&gt; Get '[JSON] Text :&lt;|&gt; "bar" :&gt; Capture "name" Int :&gt; Get '[JSON] Double
--   
--   &gt;&gt;&gt; let fooLink :&lt;|&gt; barLink = allLinks (Proxy :: Proxy API)
--   
--   &gt;&gt;&gt; :t fooLink
--   fooLink :: Text -&gt; Link
--   
--   &gt;&gt;&gt; :t barLink
--   barLink :: Int -&gt; Link
--   </pre>
--   
--   Note: nested APIs don't work well with this approach
--   
--   <pre>
--   &gt;&gt;&gt; :kind! MkLink (Capture "nest" Char :&gt; (Capture "x" Int :&gt; Get '[JSON] Int :&lt;|&gt; Capture "y" Double :&gt; Get '[JSON] Double)) Link
--   MkLink (Capture "nest" Char :&gt; (Capture "x" Int :&gt; Get '[JSON] Int :&lt;|&gt; Capture "y" Double :&gt; Get '[JSON] Double)) Link :: *
--   = Char -&gt; (Int -&gt; Link) :&lt;|&gt; (Double -&gt; Link)
--   </pre>
allLinks :: HasLink api => Proxy api -> MkLink api Link

-- | More general <a>safeLink</a>.
safeLink' :: (IsElem endpoint api, HasLink endpoint) => Link -> a -> Proxy api -> Proxy endpoint -> MkLink endpoint a

-- | Create a valid (by construction) relative URI with query params.
--   
--   This function will only typecheck if <tt>endpoint</tt> is part of the
--   API <tt>api</tt>
safeLink :: (IsElem endpoint api, HasLink endpoint) => Proxy api -> Proxy endpoint -> MkLink endpoint Link

-- | Configurable <a>linkURI</a>.
--   
--   <pre>
--   &gt;&gt;&gt; type API = "sum" :&gt; QueryParams "x" Int :&gt; Get '[JSON] Int
--   
--   &gt;&gt;&gt; linkURI' LinkArrayElementBracket $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API) [1, 2, 3]
--   sum?x[]=1&amp;x[]=2&amp;x[]=3
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; linkURI' LinkArrayElementPlain $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API) [1, 2, 3]
--   sum?x=1&amp;x=2&amp;x=3
--   </pre>
linkURI' :: LinkArrayElementStyle -> Link -> URI

-- | Transform <a>Link</a> into <a>URI</a>.
--   
--   <pre>
--   &gt;&gt;&gt; type API = "something" :&gt; Get '[JSON] Int
--   
--   &gt;&gt;&gt; linkURI $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API)
--   something
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; type API = "sum" :&gt; QueryParams "x" Int :&gt; Get '[JSON] Int
--   
--   &gt;&gt;&gt; linkURI $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API) [1, 2, 3]
--   sum?x[]=1&amp;x[]=2&amp;x[]=3
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; type API = "foo/bar" :&gt; Get '[JSON] Int
--   
--   &gt;&gt;&gt; linkURI $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API)
--   foo%2Fbar
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; type SomeRoute = "abc" :&gt; Capture "email" String :&gt; Put '[JSON] ()
--   
--   &gt;&gt;&gt; let someRoute = Proxy :: Proxy SomeRoute
--   
--   &gt;&gt;&gt; safeLink someRoute someRoute "test@example.com"
--   Link {_segments = ["abc","test%40example.com"], _queryParams = []}
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; linkURI $ safeLink someRoute someRoute "test@example.com"
--   abc/test%40example.com
--   </pre>
linkURI :: Link -> URI
linkQueryParams :: Link -> [Param]
linkSegments :: Link -> [String]

-- | A safe link datatype. The only way of constructing a <a>Link</a> is
--   using <a>safeLink</a>, which means any <a>Link</a> is guaranteed to be
--   part of the mentioned API.
data Link

-- | Query parameter.
data Param
SingleParam :: String -> Text -> Param
ArrayElemParam :: String -> Text -> Param
FlagParam :: String -> Param

-- | How to encode array query elements.
data LinkArrayElementStyle

-- | <pre>
--   foo[]=1&amp;foo[]=2
--   </pre>
LinkArrayElementBracket :: LinkArrayElementStyle

-- | <pre>
--   foo=1&amp;foo=2
--   </pre>
LinkArrayElementPlain :: LinkArrayElementStyle

-- | A type that specifies that an API record contains a set of links.
data AsLink a

-- | Construct a toLink for an endpoint.
class HasLink (endpoint :: k) where {
    type family MkLink (endpoint :: k) a :: *;
}
toLink :: HasLink endpoint => Link -> a -> Proxy endpoint -> Link -> MkLink endpoint a

-- | <a>WithNamedContext</a> names a specific tagged context to use for the
--   combinators in the API. (See also in <tt>servant-server</tt>,
--   <tt>Servant.Server.Context</tt>.) For example:
--   
--   <pre>
--   type UseNamedContextAPI = WithNamedContext "myContext" '[String] (
--       ReqBody '[JSON] Int :&gt; Get '[JSON] Int)
--   </pre>
--   
--   Both the <tt>ReqBody</tt> and <tt>Get</tt> combinators will use the
--   <a>WithNamedContext</a> with type tag "myContext" as their context.
--   
--   <tt>Context</tt>s are only relevant for <tt>servant-server</tt>.
--   
--   For more information, see the tutorial.
data WithNamedContext (name :: Symbol) (subContext :: [*]) subApi

-- | Flatten API into a list of endpoints.
--   
--   <pre>
--   &gt;&gt;&gt; Refl :: Endpoints SampleAPI :~: '["hello" :&gt; Verb 'GET 200 '[JSON] Int, "bye" :&gt; (Capture "name" String :&gt; Verb 'POST 200 '[JSON, PlainText] Bool)]
--   Refl
--   </pre>

-- | You may use this type family to tell the type checker that your custom
--   type may be skipped as part of a link. This is useful for things like
--   <tt><a>QueryParam</a></tt> that are optional in a URI and do not
--   affect them if they are omitted.
--   
--   <pre>
--   &gt;&gt;&gt; data CustomThing
--   
--   &gt;&gt;&gt; type instance IsElem' e (CustomThing :&gt; s) = IsElem e s
--   </pre>
--   
--   Note that <tt><a>IsElem</a></tt> is called, which will mutually
--   recurse back to <tt><a>IsElem'</a></tt> if it exhausts all other
--   options again.
--   
--   Once you have written a <tt>HasLink</tt> instance for
--   <tt>CustomThing</tt> you are ready to go.

-- | Closed type family, check if <tt>endpoint</tt> is within <tt>api</tt>.
--   Uses <tt><a>IsElem'</a></tt> if it exhausts all other options.
--   
--   <pre>
--   &gt;&gt;&gt; ok (Proxy :: Proxy (IsElem ("hello" :&gt; Get '[JSON] Int) SampleAPI))
--   OK
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ok (Proxy :: Proxy (IsElem ("bye" :&gt; Get '[JSON] Int) SampleAPI))
--   ...
--   ... Could not deduce...
--   ...
--   </pre>
--   
--   An endpoint is considered within an api even if it is missing
--   combinators that don't affect the URL:
--   
--   <pre>
--   &gt;&gt;&gt; ok (Proxy :: Proxy (IsElem (Get '[JSON] Int) (Header "h" Bool :&gt; Get '[JSON] Int)))
--   OK
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ok (Proxy :: Proxy (IsElem (Get '[JSON] Int) (ReqBody '[JSON] Bool :&gt; Get '[JSON] Int)))
--   OK
--   </pre>
--   
--   <ul>
--   <li>N.B.:* <tt>IsElem a b</tt> can be seen as capturing the notion of
--   whether the URL represented by <tt>a</tt> would match the URL
--   represented by <tt>b</tt>, *not* whether a request represented by
--   <tt>a</tt> matches the endpoints serving <tt>b</tt> (for the latter,
--   use <a>IsIn</a>).</li>
--   </ul>

-- | Check whether <tt>sub</tt> is a sub-API of <tt>api</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; ok (Proxy :: Proxy (IsSubAPI SampleAPI (SampleAPI :&lt;|&gt; Get '[JSON] Int)))
--   OK
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ok (Proxy :: Proxy (IsSubAPI (SampleAPI :&lt;|&gt; Get '[JSON] Int) SampleAPI))
--   ...
--   ... Could not deduce...
--   ...
--   </pre>
--   
--   This uses <tt>IsElem</tt> for checking; thus the note there applies
--   here.

-- | Check that every element of <tt>xs</tt> is an endpoint of <tt>api</tt>
--   (using <tt><a>IsElem</a></tt>).

-- | Closed type family, check if <tt>endpoint</tt> is exactly within
--   <tt>api</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; ok (Proxy :: Proxy (IsIn ("hello" :&gt; Get '[JSON] Int) SampleAPI))
--   OK
--   </pre>
--   
--   Unlike <a>IsElem</a>, this requires an *exact* match.
--   
--   <pre>
--   &gt;&gt;&gt; ok (Proxy :: Proxy (IsIn (Get '[JSON] Int) (Header "h" Bool :&gt; Get '[JSON] Int)))
--   ...
--   ... Could not deduce...
--   ...
--   </pre>

-- | Check whether <tt>sub</tt> is a sub API of <tt>api</tt>.
--   
--   Like <a>IsSubAPI</a>, but uses <a>IsIn</a> rather than <a>IsElem</a>.

-- | Check that every element of <tt>xs</tt> is an endpoint of <tt>api</tt>
--   (using <tt><a>IsIn</a></tt>).
--   
--   ok (Proxy :: Proxy (AllIsIn (Endpoints SampleAPI) SampleAPI)) OK

-- | Apply <tt>(e :&gt;)</tt> to every API in <tt>xs</tt>.

-- | Append two type-level lists.

-- | Check that a value is an element of a list:
--   
--   <pre>
--   &gt;&gt;&gt; ok (Proxy :: Proxy (Elem Bool '[Int, Bool]))
--   OK
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ok (Proxy :: Proxy (Elem String '[Int, Bool]))
--   ...
--   ... [Char]...'[Int, Bool...
--   ...
--   </pre>
type Elem (e :: t) (es :: [t]) = ElemGo e es es

-- | <tt>Verb</tt> is a general type for representing HTTP verbs (a.k.a.
--   methods). For convenience, type synonyms for each verb with a 200
--   response code are provided, but you are free to define your own:
--   
--   <pre>
--   &gt;&gt;&gt; type Post204 contentTypes a = Verb 'POST 204 contentTypes a
--   </pre>
data Verb (method :: k1) (statusCode :: Nat) (contentTypes :: [*]) a :: forall k1. () => k1 -> Nat -> [*] -> * -> *

-- | <a>GET</a> with 200 status code.
type Get = Verb GET 200

-- | <a>POST</a> with 200 status code.
type Post = Verb POST 200

-- | <a>PUT</a> with 200 status code.
type Put = Verb PUT 200

-- | <a>DELETE</a> with 200 status code.
type Delete = Verb DELETE 200

-- | <a>PATCH</a> with 200 status code.
type Patch = Verb PATCH 200

-- | <a>POST</a> with 201 status code.
type PostCreated = Verb POST 201

-- | <a>GET</a> with 202 status code.
type GetAccepted = Verb GET 202

-- | <a>POST</a> with 202 status code.
type PostAccepted = Verb POST 202

-- | <a>DELETE</a> with 202 status code.
type DeleteAccepted = Verb DELETE 202

-- | <a>PATCH</a> with 202 status code.
type PatchAccepted = Verb PATCH 202

-- | <a>PUT</a> with 202 status code.
type PutAccepted = Verb PUT 202

-- | <a>GET</a> with 203 status code.
type GetNonAuthoritative = Verb GET 203

-- | <a>POST</a> with 203 status code.
type PostNonAuthoritative = Verb POST 203

-- | <a>DELETE</a> with 203 status code.
type DeleteNonAuthoritative = Verb DELETE 203

-- | <a>PATCH</a> with 203 status code.
type PatchNonAuthoritative = Verb PATCH 203

-- | <a>PUT</a> with 203 status code.
type PutNonAuthoritative = Verb PUT 203

-- | <a>GET</a> with 204 status code.
type GetNoContent = Verb GET 204

-- | <a>POST</a> with 204 status code.
type PostNoContent = Verb POST 204

-- | <a>DELETE</a> with 204 status code.
type DeleteNoContent = Verb DELETE 204

-- | <a>PATCH</a> with 204 status code.
type PatchNoContent = Verb PATCH 204

-- | <a>PUT</a> with 204 status code.
type PutNoContent = Verb PUT 204

-- | <a>GET</a> with 205 status code.
type GetResetContent = Verb GET 205

-- | <a>POST</a> with 205 status code.
type PostResetContent = Verb POST 205

-- | <a>GET</a> with 206 status code.
type GetPartialContent = Verb GET 206
class ReflectMethod (a :: k)
reflectMethod :: ReflectMethod a => Proxy a -> Method

-- | The contained API (second argument) can be found under <tt>("/" ++
--   path)</tt> (path being the first argument).
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; -- GET /hello/world
--   
--   &gt;&gt;&gt; -- returning a JSON encoded World value
--   
--   &gt;&gt;&gt; type MyApi = "hello" :&gt; "world" :&gt; Get '[JSON] World
--   </pre>
data (:>) (path :: k) a :: forall k. () => k -> * -> *

-- | A Stream endpoint for a given method emits a stream of encoded values
--   at a given Content-Type, delimited by a framing strategy. Stream
--   endpoints always return response code 200 on success. Type synonyms
--   are provided for standard methods.
data Stream (method :: k1) (status :: Nat) framing contentType a :: forall k1. () => k1 -> Nat -> * -> * -> * -> *
type StreamGet = Stream GET 200
type StreamPost = Stream POST 200

-- | Stream endpoints may be implemented as producing a
--   <tt>StreamGenerator</tt> -- a function that itself takes two emit
--   functions -- the first to be used on the first value the stream emits,
--   and the second to be used on all subsequent values (to allow
--   interspersed framing strategies such as comma separation).
newtype StreamGenerator a
StreamGenerator :: a -> IO () -> a -> IO () -> IO () -> StreamGenerator a
[getStreamGenerator] :: StreamGenerator a -> a -> IO () -> a -> IO () -> IO ()

-- | ToStreamGenerator is intended to be implemented for types such as
--   Conduit, Pipe, etc. By implementing this class, all such streaming
--   abstractions can be used directly as endpoints.
class ToStreamGenerator a b | a -> b
toStreamGenerator :: ToStreamGenerator a b => a -> StreamGenerator b

-- | Clients reading from streaming endpoints can be implemented as
--   producing a <tt>ResultStream</tt> that captures the setup, takedown,
--   and incremental logic for a read, being an IO continuation that takes
--   a producer of Just either values or errors that terminates with a
--   Nothing.
newtype ResultStream a
ResultStream :: forall b. () => IO Maybe Either String a -> IO b -> IO b -> ResultStream a

-- | BuildFromStream is intended to be implemented for types such as
--   Conduit, Pipe, etc. By implementing this class, all such streaming
--   abstractions can be used directly on the client side for talking to
--   streaming endpoints.
class BuildFromStream a b
buildFromStream :: BuildFromStream a b => ResultStream a -> b

-- | The FramingRender class provides the logic for emitting a framing
--   strategy. The strategy emits a header, followed by boundary-delimited
--   data, and finally a termination character. For many strategies, some
--   of these will just be empty bytestrings.
class FramingRender (strategy :: k) (a :: k1)
header :: FramingRender strategy a => Proxy strategy -> Proxy a -> ByteString
boundary :: FramingRender strategy a => Proxy strategy -> Proxy a -> BoundaryStrategy
trailer :: FramingRender strategy a => Proxy strategy -> Proxy a -> ByteString

-- | The bracketing strategy generates things to precede and follow the
--   content, as with netstrings. The intersperse strategy inserts
--   seperators between things, as with newline framing. Finally, the
--   general strategy performs an arbitrary rewrite on the content, to
--   allow escaping rules and such.
data BoundaryStrategy
BoundaryStrategyBracket :: ByteString -> (ByteString, ByteString) -> BoundaryStrategy
BoundaryStrategyIntersperse :: ByteString -> BoundaryStrategy
BoundaryStrategyGeneral :: ByteString -> ByteString -> BoundaryStrategy

-- | A type of parser that can never fail, and has different parsing
--   strategies (incremental, or EOF) depending if more input can be sent.
--   The incremental parser should return <a>Nothing</a> if it would like
--   to be sent a longer ByteString. If it returns a value, it also returns
--   the remainder following that value.
data ByteStringParser a
ByteStringParser :: ByteString -> Maybe (a, ByteString) -> ByteString -> (a, ByteString) -> ByteStringParser a
[parseIncremental] :: ByteStringParser a -> ByteString -> Maybe (a, ByteString)
[parseEOF] :: ByteStringParser a -> ByteString -> (a, ByteString)

-- | The FramingUnrender class provides the logic for parsing a framing
--   strategy. The outer <tt>ByteStringParser</tt> strips the header from a
--   stream of bytes, and yields a parser that can handle the remainder,
--   stepwise. Each frame may be a ByteString, or a String indicating the
--   error state for that frame. Such states are per-frame, so that
--   protocols that can resume after errors are able to do so. Eventually
--   this returns an empty ByteString to indicate termination.
class FramingUnrender (strategy :: k) (a :: k1)
unrenderFrames :: FramingUnrender strategy a => Proxy strategy -> Proxy a -> ByteStringParser ByteStringParser Either String ByteString

-- | A framing strategy that does not do any framing at all, it just passes
--   the input data This will be used most of the time with binary data,
--   such as files
data NoFraming

-- | A simple framing strategy that has no header or termination, and
--   inserts a newline character between each frame. This assumes that it
--   is used with a Content-Type that encodes without newlines (e.g. JSON).
data NewlineFraming

-- | The netstring framing strategy as defined by djb:
--   <a>http://cr.yp.to/proto/netstrings.txt</a>
data NetstringFraming

-- | Deliberately do not add a header to a value.
--   
--   <pre>
--   &gt;&gt;&gt; let example1 = noHeader "hi" :: Headers '[Header "someheader" Int] String
--   
--   &gt;&gt;&gt; getHeaders example1
--   []
--   </pre>
noHeader :: AddHeader h v orig new => orig -> new

-- | <tt>addHeader</tt> adds a header to a response. Note that it changes
--   the type of the value in the following ways:
--   
--   <ol>
--   <li>A simple value is wrapped in "Headers '[hdr]":</li>
--   </ol>
--   
--   <pre>
--   &gt;&gt;&gt; let example1 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] String;
--   
--   &gt;&gt;&gt; getHeaders example1
--   [("someheader","5")]
--   </pre>
--   
--   <ol>
--   <li>A value that already has a header has its new header *prepended*
--   to the existing list:</li>
--   </ol>
--   
--   <pre>
--   &gt;&gt;&gt; let example1 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] String;
--   
--   &gt;&gt;&gt; let example2 = addHeader True example1 :: Headers '[Header "1st" Bool, Header "someheader" Int] String
--   
--   &gt;&gt;&gt; getHeaders example2
--   [("1st","true"),("someheader","5")]
--   </pre>
--   
--   Note that while in your handlers type annotations are not required,
--   since the type can be inferred from the API type, in other cases you
--   may find yourself needing to add annotations.
addHeader :: AddHeader h v orig new => v -> orig -> new

-- | Response Header objects. You should never need to construct one
--   directly. Instead, use <a>addOptionalHeader</a>.
data Headers (ls :: [*]) a
Headers :: a -> HList ls -> Headers a

-- | The underlying value of a <a>Headers</a>
[getResponse] :: Headers a -> a

-- | HList of headers.
[getHeadersHList] :: Headers a -> HList ls
data ResponseHeader (sym :: Symbol) a
Header :: a -> ResponseHeader a
MissingHeader :: ResponseHeader a
UndecodableHeader :: ByteString -> ResponseHeader a
data HList (a :: [*])
[HNil] :: HList ([] :: [*])
[HCons] :: HList Header h x : xs
class BuildHeadersTo (hs :: [*])

-- | Note: if there are multiple occurences of a header in the argument,
--   the values are interspersed with commas before deserialization (see
--   <a>RFC2616 Sec 4.2</a>)
buildHeadersTo :: BuildHeadersTo hs => [Header] -> HList hs
class GetHeaders ls
getHeaders :: GetHeaders ls => ls -> [Header]
class AddHeader (h :: Symbol) v orig new | h v orig -> new, new -> h, new -> v, new -> orig

-- | Extract the request body as a value of type <tt>a</tt>.
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; -- POST /books
--   
--   &gt;&gt;&gt; type MyApi = "books" :&gt; ReqBody '[JSON] Book :&gt; Post '[JSON] Book
--   </pre>
type ReqBody = ReqBody' Required : Strict : ([] :: [*])

-- | <i>Note:</i> <a>ReqBody'</a> is always <a>Required</a>.
data ReqBody' (mods :: [*]) (contentTypes :: [*]) a

-- | Provides access to the host or IP address from which the HTTP request
--   was sent.
data RemoteHost

-- | Endpoint for plugging in your own Wai <tt>Application</tt>s.
--   
--   The given <tt>Application</tt> will get the request as received by the
--   server, potentially with a modified (stripped) <tt>pathInfo</tt> if
--   the <tt>Application</tt> is being routed with <a>:&gt;</a>.
--   
--   In addition to just letting you plug in your existing WAI
--   <tt>Application</tt>s, this can also be used with
--   <a>serveDirectory</a> to serve static files stored in a particular
--   directory on your filesystem
data Raw

-- | Lookup the value associated to the <tt>sym</tt> query string parameter
--   and try to extract it as a value of type <tt>a</tt>.
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; -- /books?author=&lt;author name&gt;
--   
--   &gt;&gt;&gt; type MyApi = "books" :&gt; QueryParam "author" Text :&gt; Get '[JSON] [Book]
--   </pre>
type QueryParam = QueryParam' Optional : Strict : ([] :: [*])

-- | <a>QueryParam</a> which can be <a>Required</a>, <a>Lenient</a>, or
--   modified otherwise.
data QueryParam' (mods :: [*]) (sym :: Symbol) a

-- | Lookup the values associated to the <tt>sym</tt> query string
--   parameter and try to extract it as a value of type <tt>[a]</tt>. This
--   is typically meant to support query string parameters of the form
--   <tt>param[]=val1&amp;param[]=val2</tt> and so on. Note that servant
--   doesn't actually require the <tt>[]</tt>s and will fetch the values
--   just fine with <tt>param=val1&amp;param=val2</tt>, too.
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; -- /books?authors[]=&lt;author1&gt;&amp;authors[]=&lt;author2&gt;&amp;...
--   
--   &gt;&gt;&gt; type MyApi = "books" :&gt; QueryParams "authors" Text :&gt; Get '[JSON] [Book]
--   </pre>
data QueryParams (sym :: Symbol) a

-- | Lookup a potentially value-less query string parameter with boolean
--   semantics. If the param <tt>sym</tt> is there without any value, or if
--   it's there with value "true" or "1", it's interpreted as <a>True</a>.
--   Otherwise, it's interpreted as <a>False</a>.
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; -- /books?published
--   
--   &gt;&gt;&gt; type MyApi = "books" :&gt; QueryFlag "published" :&gt; Get '[JSON] [Book]
--   </pre>
data QueryFlag (sym :: Symbol)

-- | Extract the given header's value as a value of type <tt>a</tt>. I.e.
--   header sent by client, parsed by server.
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; newtype Referer = Referer Text deriving (Eq, Show)
--   
--   &gt;&gt;&gt; 
--   
--   &gt;&gt;&gt; -- GET /view-my-referer
--   
--   &gt;&gt;&gt; type MyApi = "view-my-referer" :&gt; Header "from" Referer :&gt; Get '[JSON] Referer
--   </pre>
type Header = (Header' Optional : Strict : ([] :: [*]) :: Symbol -> k -> *)
data Header' (mods :: [*]) (sym :: Symbol) (a :: k) :: forall k. () => [*] -> Symbol -> k -> *

-- | Required argument. Not wrapped.
data Required

-- | Optional argument. Wrapped in <a>Maybe</a>.
data Optional

-- | Leniently parsed argument, i.e. parsing never fail. Wrapped in
--   <tt><a>Either</a> <a>Text</a></tt>.
data Lenient

-- | Strictly parsed argument. Not wrapped.
data Strict

-- | Was this request made over an SSL connection?
--   
--   Note that this value will not tell you if the client originally made
--   this request over SSL, but rather whether the current connection is
--   SSL. The distinction lies with reverse proxies. In many cases, the
--   client will connect to a load balancer over SSL, but connect to the
--   WAI handler without SSL. In such a case, the handlers would get
--   <a>NotSecure</a>, but from a user perspective, there is a secure
--   connection.
data IsSecure

-- | the connection to the server is secure (HTTPS)
Secure :: IsSecure

-- | the connection to the server is not secure (HTTP)
NotSecure :: IsSecure

-- | A generalized Authentication combinator. Use this if you have a
--   non-standard authentication technique.
--   
--   NOTE: THIS API IS EXPERIMENTAL AND SUBJECT TO CHANGE.
data AuthProtect (tag :: k) :: forall k. () => k -> *

-- | An empty API: one which serves nothing. Morally speaking, this should
--   be the unit of <tt>:&lt;|&gt;</tt>. Implementors of interpretations of
--   API types should treat <a>EmptyAPI</a> as close to the unit as
--   possible.
data EmptyAPI
EmptyAPI :: EmptyAPI

-- | Add a short summary for (part of) API.
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; type MyApi = Summary "Get book by ISBN." :&gt; "books" :&gt; Capture "isbn" Text :&gt; Get '[JSON] Book
--   </pre>
data Summary (sym :: Symbol)

-- | Add more verbose description for (part of) API.
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; :{
--   type MyApi = Description
--    "This comment is visible in multiple Servant interpretations \
--    \and can be really long if necessary. \
--    \Haskell multiline support is not perfect \
--    \but it's still very readable."
--   :&gt; Get '[JSON] Book
--   :}
--   </pre>
data Description (sym :: Symbol)
data JSON
data PlainText
data FormUrlEncoded
data OctetStream

-- | Instances of <a>Accept</a> represent mimetypes. They are used for
--   matching against the <tt>Accept</tt> HTTP header of the request, and
--   for setting the <tt>Content-Type</tt> header of the response
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; import Network.HTTP.Media ((//), (/:))
--   
--   &gt;&gt;&gt; data HTML
--   
--   &gt;&gt;&gt; :{
--   instance Accept HTML where
--      contentType _ = "text" // "html" /: ("charset", "utf-8")
--   :}
--   </pre>
class Accept (ctype :: k)
contentType :: Accept ctype => Proxy ctype -> MediaType
contentTypes :: Accept ctype => Proxy ctype -> NonEmpty MediaType

-- | Instantiate this class to register a way of serializing a type based
--   on the <tt>Accept</tt> header.
--   
--   Example:
--   
--   <pre>
--   data MyContentType
--   
--   instance Accept MyContentType where
--      contentType _ = "example" // "prs.me.mine" /: ("charset", "utf-8")
--   
--   instance Show a =&gt; MimeRender MyContentType a where
--      mimeRender _ val = pack ("This is MINE! " ++ show val)
--   
--   type MyAPI = "path" :&gt; Get '[MyContentType] Int
--   </pre>
class Accept ctype => MimeRender (ctype :: k) a
mimeRender :: MimeRender ctype a => Proxy ctype -> a -> ByteString

-- | Instantiate this class to register a way of deserializing a type based
--   on the request's <tt>Content-Type</tt> header.
--   
--   <pre>
--   &gt;&gt;&gt; import Network.HTTP.Media hiding (Accept)
--   
--   &gt;&gt;&gt; import qualified Data.ByteString.Lazy.Char8 as BSC
--   
--   &gt;&gt;&gt; data MyContentType = MyContentType String
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; :{
--   instance Accept MyContentType where
--      contentType _ = "example" // "prs.me.mine" /: ("charset", "utf-8")
--   :}
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; :{
--   instance Read a =&gt; MimeUnrender MyContentType a where
--      mimeUnrender _ bs = case BSC.take 12 bs of
--        "MyContentType" -&gt; return . read . BSC.unpack $ BSC.drop 12 bs
--        _ -&gt; Left "didn't start with the magic incantation"
--   :}
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; type MyAPI = "path" :&gt; ReqBody '[MyContentType] Int :&gt; Get '[JSON] Int
--   </pre>
class Accept ctype => MimeUnrender (ctype :: k) a
mimeUnrender :: MimeUnrender ctype a => Proxy ctype -> ByteString -> Either String a

-- | Variant which is given the actual <a>MediaType</a> provided by the
--   other party.
--   
--   In the most cases you don't want to branch based on the
--   <a>MediaType</a>. See <a>pr552</a> for a motivating example.
mimeUnrenderWithType :: MimeUnrender ctype a => Proxy ctype -> MediaType -> ByteString -> Either String a

-- | A type for responses without content-body.
data NoContent
NoContent :: NoContent

-- | Capture a value from the request path under a certain type <tt>a</tt>.
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; -- GET /books/:isbn
--   
--   &gt;&gt;&gt; type MyApi = "books" :&gt; Capture "isbn" Text :&gt; Get '[JSON] Book
--   </pre>
type Capture = Capture' ([] :: [*])

-- | <a>Capture</a> which can be modified. For example with
--   <tt>Description</tt>.
data Capture' (mods :: [*]) (sym :: Symbol) a

-- | Capture all remaining values from the request path under a certain
--   type <tt>a</tt>.
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; -- GET /src/*
--   
--   &gt;&gt;&gt; type MyAPI = "src" :&gt; CaptureAll "segments" Text :&gt; Get '[JSON] SourceFile
--   </pre>
data CaptureAll (sym :: Symbol) a

-- | Combinator for <a>Basic Access Authentication</a>.
--   
--   <ul>
--   <li>IMPORTANT*: Only use Basic Auth over HTTPS! Credentials are not
--   hashed or encrypted. Note also that because the same credentials are
--   sent on every request, Basic Auth is not as secure as some
--   alternatives. Further, the implementation in servant-server does not
--   protect against some types of timing attacks.</li>
--   </ul>
--   
--   In Basic Auth, username and password are base64-encoded and
--   transmitted via the <tt>Authorization</tt> header. Handshakes are not
--   required, making it relatively efficient.
data BasicAuth (realm :: Symbol) userData

-- | A simple datatype to hold data required to decorate a request
data BasicAuthData
BasicAuthData :: !ByteString -> !ByteString -> BasicAuthData
[basicAuthUsername] :: BasicAuthData -> !ByteString
[basicAuthPassword] :: BasicAuthData -> !ByteString

-- | Union of two APIs, first takes precedence in case of overlap.
--   
--   Example:
--   
--   <pre>
--   &gt;&gt;&gt; :{
--   type MyApi = "books" :&gt; Get '[JSON] [Book] -- GET /books
--          :&lt;|&gt; "books" :&gt; ReqBody '[JSON] Book :&gt; Post '[JSON] () -- POST /books
--   :}
--   </pre>
data (:<|>) a b
(:<|>) :: a -> b -> (:<|>) a b

-- | A persistent store for values of arbitrary types.
--   
--   This variant is the simplest and creates keys in the <a>IO</a> monad.
--   See the module <a>Data.Vault.ST</a> if you want to use it with the
--   <a>ST</a> monad instead.
type Vault = Vault RealWorld
class SBoolI (b :: Bool)
sbool :: SBoolI b => SBool b
data SBool (b :: Bool)
[STrue] :: SBool True
[SFalse] :: SBool False

-- | Same as <a>serveDirectoryFileServer</a>. It used to be the only file
--   serving function in servant pre-0.10 and will be kept around for a few
--   versions, but is deprecated.
serveDirectory :: () => FilePath -> ServerT Raw m

-- | Alias for <a>staticApp</a>. Lets you serve a directory with arbitrary
--   <a>StaticSettings</a>. Useful when you want particular settings not
--   covered by the four other variants. This is the most flexible method.
serveDirectoryWith :: () => StaticSettings -> ServerT Raw m

-- | Uses <a>embeddedSettings</a>.
serveDirectoryEmbedded :: () => [(FilePath, ByteString)] -> ServerT Raw m

-- | Same as <a>serveDirectoryWebApp</a>, but uses
--   <a>webAppSettingsWithLookup</a>.
serveDirectoryWebAppLookup :: () => ETagLookup -> FilePath -> ServerT Raw m

-- | Same as <a>serveDirectoryWebApp</a>, but uses
--   <a>defaultFileServerSettings</a>.
serveDirectoryFileServer :: () => FilePath -> ServerT Raw m

-- | Serve anything under the specified directory as a <a>Raw</a> endpoint.
--   
--   <pre>
--   type MyApi = "static" :&gt; Raw
--   
--   server :: Server MyApi
--   server = serveDirectoryWebApp "/var/www"
--   </pre>
--   
--   would capture any request to <tt>/static/&lt;something&gt;</tt> and
--   look for <tt>&lt;something&gt;</tt> under <tt>/var/www</tt>.
--   
--   It will do its best to guess the MIME type for that file, based on the
--   extension, and send an appropriate <i>Content-Type</i> header if
--   possible.
--   
--   If your goal is to serve HTML, CSS and Javascript files that use the
--   rest of the API as a webapp backend, you will most likely not want the
--   static files to be hidden behind a <i>/static/</i> prefix. In that
--   case, remember to put the <a>serveDirectoryWebApp</a> handler in the
--   last position, because <i>servant</i> will try to match the handlers
--   in order.
--   
--   Corresponds to the <a>defaultWebAppSettings</a> <a>StaticSettings</a>
--   value.
serveDirectoryWebApp :: () => FilePath -> ServerT Raw m

-- | Variant of <a>layout</a> that takes an additional <a>Context</a>.
layoutWithContext :: HasServer api context => Proxy api -> Context context -> Text

-- | The function <a>layout</a> produces a textual description of the
--   internal router layout for debugging purposes. Note that the router
--   layout is determined just by the API, not by the handlers.
--   
--   Example:
--   
--   For the following API
--   
--   <pre>
--   type API =
--          "a" :&gt; "d" :&gt; Get '[JSON] NoContent
--     :&lt;|&gt; "b" :&gt; Capture "x" Int :&gt; Get '[JSON] Bool
--     :&lt;|&gt; "c" :&gt; Put '[JSON] Bool
--     :&lt;|&gt; "a" :&gt; "e" :&gt; Get '[JSON] Int
--     :&lt;|&gt; "b" :&gt; Capture "x" Int :&gt; Put '[JSON] Bool
--     :&lt;|&gt; Raw
--   </pre>
--   
--   we get the following output:
--   
--   <pre>
--   /
--   ├─ a/
--   │  ├─ d/
--   │  │  └─•
--   │  └─ e/
--   │     └─•
--   ├─ b/
--   │  └─ &lt;capture&gt;/
--   │     ├─•
--   │     ┆
--   │     └─•
--   ├─ c/
--   │  └─•
--   ┆
--   └─ &lt;raw&gt;
--   </pre>
--   
--   Explanation of symbols:
--   
--   <ul>
--   <li><i><tt>├</tt></i> Normal lines reflect static branching via a
--   table.</li>
--   <li><i><tt>a/</tt></i> Nodes reflect static path components.</li>
--   <li><i><tt>─•</tt></i> Leaves reflect endpoints.</li>
--   <li><i><tt>&lt;capture&gt;/</tt></i> This is a delayed capture of a
--   path component.</li>
--   <li><i><tt>&lt;raw&gt;</tt></i> This is a part of the API we do not
--   know anything about.</li>
--   <li><i><tt>┆</tt></i> Dashed lines suggest a dynamic choice between
--   the part above and below. If there is a success for fatal failure in
--   the first part, that one takes precedence. If both parts fail, the
--   "better" error code will be returned.</li>
--   </ul>
layout :: HasServer api ([] :: [*]) => Proxy api -> Text

-- | Hoist server implementation.
--   
--   Sometimes our cherished <a>Handler</a> monad isn't quite the type
--   you'd like for your handlers. Maybe you want to thread some
--   configuration in a <tt>Reader</tt> monad. Or have your types ensure
--   that your handlers don't do any IO. Use <a>hoistServer</a> (a
--   successor of now deprecated <tt>enter</tt>).
--   
--   With <a>hoistServer</a>, you can provide a function, to convert any
--   number of endpoints from one type constructor to another. For example
--   
--   <i>Note:</i> <a>Server</a> <tt>Raw</tt> can also be entered. It will
--   be retagged.
--   
--   <pre>
--   &gt;&gt;&gt; import Control.Monad.Reader
--   
--   &gt;&gt;&gt; type ReaderAPI = "ep1" :&gt; Get '[JSON] Int :&lt;|&gt; "ep2" :&gt; Get '[JSON] String :&lt;|&gt; Raw :&lt;|&gt; EmptyAPI
--   
--   &gt;&gt;&gt; let readerApi = Proxy :: Proxy ReaderAPI
--   
--   &gt;&gt;&gt; let readerServer = return 1797 :&lt;|&gt; ask :&lt;|&gt; Tagged (error "raw server") :&lt;|&gt; emptyServer :: ServerT ReaderAPI (Reader String)
--   
--   &gt;&gt;&gt; let nt x = return (runReader x "hi")
--   
--   &gt;&gt;&gt; let mainServer = hoistServer readerApi nt readerServer :: Server ReaderAPI
--   </pre>
hoistServer :: HasServer api ([] :: [*]) => Proxy api -> forall x. () => m x -> n x -> ServerT api m -> ServerT api n
serveWithContext :: HasServer api context => Proxy api -> Context context -> Server api -> Application

-- | <a>serve</a> allows you to implement an API and produce a wai
--   <a>Application</a>.
--   
--   Example:
--   
--   <pre>
--   type MyApi = "books" :&gt; Get '[JSON] [Book] -- GET /books
--           :&lt;|&gt; "books" :&gt; ReqBody Book :&gt; Post '[JSON] Book -- POST /books
--   
--   server :: Server MyApi
--   server = listAllBooks :&lt;|&gt; postBook
--     where listAllBooks = ...
--           postBook book = ...
--   
--   myApi :: Proxy MyApi
--   myApi = Proxy
--   
--   app :: Application
--   app = serve myApi server
--   
--   main :: IO ()
--   main = Network.Wai.Handler.Warp.run 8080 app
--   </pre>
serve :: HasServer api ([] :: [*]) => Proxy api -> Server api -> Application

-- | Server for <a>EmptyAPI</a>
emptyServer :: () => ServerT EmptyAPI m
class HasServer (api :: k) (context :: [*]) where {
    type family ServerT (api :: k) (m :: * -> *) :: *;
}
route :: HasServer api context => Proxy api -> Context context -> Delayed env Server api -> Router env
hoistServerWithContext :: HasServer api context => Proxy api -> Proxy context -> forall x. () => m x -> n x -> ServerT api m -> ServerT api n
type Server (api :: k) = ServerT api Handler

-- | Singleton type representing a server that serves an empty API.
data EmptyServer

-- | servant-server's current implementation of basic authentication is not
--   immune to certian kinds of timing attacks. Decoding payloads does not
--   take a fixed amount of time.
--   
--   The result of authentication/authorization
data BasicAuthResult usr
Unauthorized :: BasicAuthResult usr
BadPassword :: BasicAuthResult usr
NoSuchUser :: BasicAuthResult usr
Authorized :: usr -> BasicAuthResult usr

-- | Datatype wrapping a function used to check authentication.
newtype BasicAuthCheck usr
BasicAuthCheck :: BasicAuthData -> IO BasicAuthResult usr -> BasicAuthCheck usr
[unBasicAuthCheck] :: BasicAuthCheck usr -> BasicAuthData -> IO BasicAuthResult usr

-- | Apply a transformation to the response of a <a>Router</a>.
tweakResponse :: () => RouteResult Response -> RouteResult Response -> Router env -> Router env
toApplication :: RoutingApplication -> Application
runHandler :: () => Handler a -> IO Either ServantErr a
runHandler' :: Handler a -> ExceptT ServantErr IO a

-- | <a>err505</a> HTTP Version not supported
--   
--   Example usage:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err505 { errBody = "I support HTTP/4.0 only." }
--   </pre>
err505 :: ServantErr

-- | <a>err504</a> Gateway Time-out
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err504 { errBody = "Backend foobar did not respond in 5 seconds." }
--   </pre>
err504 :: ServantErr

-- | <a>err503</a> Service Unavailable
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err503 { errBody = "We're rewriting in PHP." }
--   </pre>
err503 :: ServantErr

-- | <a>err502</a> Bad Gateway
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err502 { errBody = "Tried gateway foo, bar, and baz.  None responded." }
--   </pre>
err502 :: ServantErr

-- | <a>err501</a> Not Implemented
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err501 { errBody = "/v1/foo is not supported with quux in the request." }
--   </pre>
err501 :: ServantErr

-- | <a>err500</a> Internal Server Error
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err500 { errBody = "Exception in module A.B.C:55.  Have a great day!" }
--   </pre>
err500 :: ServantErr

-- | <a>err422</a> Unprocessable Entity
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err422 { errBody = "I understood your request, but can't process it." }
--   </pre>
err422 :: ServantErr

-- | <a>err418</a> Expectation Failed
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err418 { errBody = "Apologies, this is not a webserver but a teapot." }
--   </pre>
err418 :: ServantErr

-- | <a>err417</a> Expectation Failed
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err417 { errBody = "I found a quux in the request.  This isn't going to work." }
--   </pre>
err417 :: ServantErr

-- | <a>err416</a> Request range not satisfiable
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err416 { errBody = "Valid range is [0, 424242]." }
--   </pre>
err416 :: ServantErr

-- | <a>err415</a> Unsupported Media Type
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err415 { errBody = "Supported media types:  gif, png" }
--   </pre>
err415 :: ServantErr

-- | <a>err414</a> Request-URI Too Large
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err414 { errBody = "Maximum length is 64." }
--   </pre>
err414 :: ServantErr

-- | <a>err413</a> Request Entity Too Large
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err413 { errBody = "Request exceeded 64k." }
--   </pre>
err413 :: ServantErr

-- | <a>err412</a> Precondition Failed
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err412 { errBody = "Precondition fail: x &lt; 42 &amp;&amp; y &gt; 57" }
--   </pre>
err412 :: ServantErr

-- | <a>err411</a> Length Required
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError err411
--   </pre>
err411 :: ServantErr

-- | <a>err410</a> Gone
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err410 { errBody = "I know it was here at some point, but.. I blame bad luck." }
--   </pre>
err410 :: ServantErr

-- | <a>err409</a> Conflict
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err409 { errBody = "Transaction conflicts with 59879cb56c7c159231eeacdd503d755f7e835f74" }
--   </pre>
err409 :: ServantErr

-- | <a>err407</a> Proxy Authentication Required
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError err407
--   </pre>
err407 :: ServantErr

-- | <a>err406</a> Not Acceptable
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError err406
--   </pre>
err406 :: ServantErr

-- | <a>err405</a> Method Not Allowed
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err405 { errBody = "Your account privileges does not allow for this.  Please pay $$$." }
--   </pre>
err405 :: ServantErr

-- | <a>err404</a> Not Found
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err404 { errBody = "(╯°□°）╯︵ ┻━┻)." }
--   </pre>
err404 :: ServantErr

-- | <a>err403</a> Forbidden
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err403 { errBody = "Please login first." }
--   </pre>
err403 :: ServantErr

-- | <a>err402</a> Payment Required
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err402 { errBody = "You have 0 credits. Please give me $$$." }
--   </pre>
err402 :: ServantErr

-- | <a>err401</a> Unauthorized
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err401 { errBody = "Your credentials are invalid." }
--   </pre>
err401 :: ServantErr

-- | <a>err400</a> Bad Request
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err400 { errBody = "Your request makes no sense to me." }
--   </pre>
err400 :: ServantErr

-- | <a>err307</a> Temporary Redirect
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError err307
--   </pre>
err307 :: ServantErr

-- | <a>err305</a> Use Proxy
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError err305
--   </pre>
err305 :: ServantErr

-- | <a>err304</a> Not Modified
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError err304
--   </pre>
err304 :: ServantErr

-- | <a>err303</a> See Other
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError err303
--   </pre>
err303 :: ServantErr

-- | <a>err302</a> Found
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError err302
--   </pre>
err302 :: ServantErr

-- | <a>err301</a> Moved Permanently
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError err301
--   </pre>
err301 :: ServantErr

-- | <a>err300</a> Multiple Choices
--   
--   Example:
--   
--   <pre>
--   failingHandler :: Handler ()
--   failingHandler = throwError $ err300 { errBody = "I can't choose." }
--   </pre>
err300 :: ServantErr
data ServantErr
ServantErr :: Int -> String -> ByteString -> [Header] -> ServantErr
[errHTTPCode] :: ServantErr -> Int
[errReasonPhrase] :: ServantErr -> String
[errBody] :: ServantErr -> ByteString
[errHeaders] :: ServantErr -> [Header]

-- | <a>descendIntoNamedContext</a> allows you to access
--   <a>NamedContext</a>s. Usually you won't have to use it yourself but
--   instead use a combinator like <a>WithNamedContext</a>.
--   
--   This is how <a>descendIntoNamedContext</a> works:
--   
--   <pre>
--   &gt;&gt;&gt; :set -XFlexibleContexts
--   
--   &gt;&gt;&gt; let subContext = True :. EmptyContext
--   
--   &gt;&gt;&gt; :type subContext
--   subContext :: Context '[Bool]
--   
--   &gt;&gt;&gt; let parentContext = False :. (NamedContext subContext :: NamedContext "subContext" '[Bool]) :. EmptyContext
--   
--   &gt;&gt;&gt; :type parentContext
--   parentContext :: Context '[Bool, NamedContext "subContext" '[Bool]]
--   
--   &gt;&gt;&gt; descendIntoNamedContext (Proxy :: Proxy "subContext") parentContext :: Context '[Bool]
--   True :. EmptyContext
--   </pre>
descendIntoNamedContext :: HasContextEntry context NamedContext name subContext => Proxy name -> Context context -> Context subContext

-- | <a>Context</a>s are used to pass values to combinators. (They are
--   <b>not</b> meant to be used to pass parameters to your handlers, i.e.
--   they should not replace any custom <a>ReaderT</a>-monad-stack that
--   you're using with <tt>hoistServer</tt>.) If you don't use combinators
--   that require any context entries, you can just use <a>serve</a> as
--   always.
--   
--   If you are using combinators that require a non-empty <a>Context</a>
--   you have to use <a>serveWithContext</a> and pass it a <a>Context</a>
--   that contains all the values your combinators need. A <a>Context</a>
--   is essentially a heterogenous list and accessing the elements is being
--   done by type (see <a>getContextEntry</a>). The parameter of the type
--   <a>Context</a> is a type-level list reflecting the types of the
--   contained context entries. To create a <a>Context</a> with entries,
--   use the operator <tt>(<a>:.</a>)</tt>:
--   
--   <pre>
--   &gt;&gt;&gt; :type True :. () :. EmptyContext
--   True :. () :. EmptyContext :: Context '[Bool, ()]
--   </pre>
data Context (contextTypes :: [*])
[EmptyContext] :: Context ([] :: [*])
[:.] :: Context x : xs

-- | This class is used to access context entries in <a>Context</a>s.
--   <a>getContextEntry</a> returns the first value where the type matches:
--   
--   <pre>
--   &gt;&gt;&gt; getContextEntry (True :. False :. EmptyContext) :: Bool
--   True
--   </pre>
--   
--   If the <a>Context</a> does not contain an entry of the requested type,
--   you'll get an error:
--   
--   <pre>
--   &gt;&gt;&gt; getContextEntry (True :. False :. EmptyContext) :: String
--   ...
--   ...No instance for (HasContextEntry '[] [Char])
--   ...
--   </pre>
class HasContextEntry (context :: [*]) val
getContextEntry :: HasContextEntry context val => Context context -> val

-- | Normally context entries are accessed by their types. In case you need
--   to have multiple values of the same type in your <a>Context</a> and
--   need to access them, we provide <a>NamedContext</a>. You can think of
--   it as sub-namespaces for <a>Context</a>s.
data NamedContext (name :: Symbol) (subContext :: [*])
NamedContext :: Context subContext -> NamedContext

-- | The WAI application.
--   
--   Note that, since WAI 3.0, this type is structured in continuation
--   passing style to allow for proper safe resource handling. This was
--   handled in the past via other means (e.g., <tt>ResourceT</tt>). As a
--   demonstration:
--   
--   <pre>
--   app :: Application
--   app req respond = bracket_
--       (putStrLn "Allocating scarce resource")
--       (putStrLn "Cleaning up")
--       (respond $ responseLBS status200 [] "Hello World")
--   </pre>
type Application = Request -> Response -> IO ResponseReceived -> IO ResponseReceived

-- | A <tt><a>Tagged</a> s b</tt> value is a value <tt>b</tt> with an
--   attached phantom type <tt>s</tt>. This can be used in place of the
--   more traditional but less safe idiom of passing in an undefined value
--   with the type, because unlike an <tt>(s -&gt; b)</tt>, a
--   <tt><a>Tagged</a> s b</tt> can't try to use the argument <tt>s</tt> as
--   a real value.
--   
--   Moreover, you don't have to rely on the compiler to inline away the
--   extra argument, because the newtype is "free"
--   
--   <a>Tagged</a> has kind <tt>k -&gt; * -&gt; *</tt> if the compiler
--   supports <tt>PolyKinds</tt>, therefore there is an extra <tt>k</tt>
--   showing in the instance haddocks that may cause confusion.
newtype Tagged (s :: k) b :: forall k. () => k -> * -> *
Tagged :: b -> Tagged b
[unTagged] :: Tagged b -> b

-- | Split on the given sublist. Equivalent to <tt><a>split</a> .
--   <a>dropDelims</a> . <a>onSublist</a></tt>. For example:
--   
--   <pre>
--   splitOn ".." "a..b...c....d.." == ["a","b",".c","","d",""]
--   </pre>
--   
--   In some parsing combinator frameworks this is also known as
--   <tt>sepBy</tt>.
--   
--   Note that this is the right inverse of the <a>intercalate</a> function
--   from <a>Data.List</a>, that is,
--   
--   <pre>
--   intercalate x . splitOn x === id
--   </pre>
--   
--   <tt><a>splitOn</a> x . <a>intercalate</a> x</tt> is the identity on
--   certain lists, but it is tricky to state the precise conditions under
--   which this holds. (For example, it is not enough to say that
--   <tt>x</tt> does not occur in any elements of the input list. Working
--   out why is left as an exercise for the reader.)
splitOn :: Eq a => [a] -> [a] -> [[a]]
fromLT :: ConvertibleStrings LT a => LT -> a
fromLazyText :: ConvertibleStrings LazyText a => LazyText -> a
fromST :: ConvertibleStrings ST a => ST -> a
fromStrictText :: ConvertibleStrings StrictText a => StrictText -> a
fromLBS :: ConvertibleStrings LBS a => LBS -> a
fromLazyByteString :: ConvertibleStrings LazyByteString a => LazyByteString -> a
fromSBS :: ConvertibleStrings SBS a => SBS -> a
fromStrictByteString :: ConvertibleStrings StrictByteString a => StrictByteString -> a
fromString :: ConvertibleStrings String a => String -> a
toLT :: ConvertibleStrings a LT => a -> LT
toLazyText :: ConvertibleStrings a LazyText => a -> LazyText
toST :: ConvertibleStrings a ST => a -> ST
toStrictText :: ConvertibleStrings a StrictText => a -> StrictText
toLBS :: ConvertibleStrings a LBS => a -> LBS
toLazyByteString :: ConvertibleStrings a LazyByteString => a -> LazyByteString
toSBS :: ConvertibleStrings a SBS => a -> SBS
toStrictByteString :: ConvertibleStrings a StrictByteString => a -> StrictByteString
toString :: ConvertibleStrings a String => a -> String
cs :: ConvertibleStrings a b => a -> b
class ConvertibleStrings a b
convertString :: ConvertibleStrings a b => a -> b
type StrictByteString = ByteString
type SBS = ByteString
type LazyByteString = ByteString
type LBS = ByteString
type StrictText = Text
type ST = Text
type LazyText = Text
type LT = Text

-- | Convert a <a>ExceptT</a> computation to <a>MaybeT</a>, discarding the
--   value of any exception.
exceptToMaybeT :: Functor m => ExceptT e m a -> MaybeT m a

-- | Convert a <a>MaybeT</a> computation to <a>ExceptT</a>, with a default
--   exception value.
maybeToExceptT :: Functor m => e -> MaybeT m a -> ExceptT e m a

-- | Lifted version of <a>mkWeakThreadId</a>.
mkWeakThreadId :: MonadIO m => ThreadId -> m Weak ThreadId

-- | Unlifted version of <a>runInUnboundThread</a>.
runInUnboundThread :: MonadUnliftIO m => m a -> m a

-- | Unlifted version of <a>runInBoundThread</a>.
runInBoundThread :: MonadUnliftIO m => m a -> m a

-- | Unflifted version of <a>forkOS</a>.
forkOS :: MonadUnliftIO m => m () -> m ThreadId

-- | Lifted version of <a>yield</a>.
yield :: MonadIO m => m ()

-- | Lifted version of <a>threadCapability</a>.
threadCapability :: MonadIO m => ThreadId -> m (Int, Bool)

-- | Lifted version of <a>setNumCapabilities</a>.
setNumCapabilities :: MonadIO m => Int -> m ()

-- | Lifted version of <a>getNumCapabilities</a>.
getNumCapabilities :: MonadIO m => m Int

-- | Unlifted version of <a>forkOnWithUnmask</a>.
forkOnWithUnmask :: MonadUnliftIO m => Int -> forall a. () => m a -> m a -> m () -> m ThreadId

-- | Unlifted version of <a>forkOn</a>.
forkOn :: MonadUnliftIO m => Int -> m () -> m ThreadId

-- | Lifted version of <a>killThread</a>.
killThread :: MonadIO m => ThreadId -> m ()

-- | Unlifted version of <a>forkFinally</a>.
forkFinally :: MonadUnliftIO m => m a -> Either SomeException a -> m () -> m ThreadId

-- | Unlifted version of <a>forkIOWithUnmask</a>.
forkWithUnmask :: MonadUnliftIO m => forall a. () => m a -> m a -> m () -> m ThreadId

-- | Unlifted version of <a>forkIO</a>.
forkIO :: MonadUnliftIO m => m () -> m ThreadId

-- | Middleware is a component that sits between the server and
--   application. It can do such tasks as GZIP encoding or response
--   caching. What follows is the general definition of middleware, though
--   a middleware author should feel free to modify this.
--   
--   As an example of an alternate type for middleware, suppose you write a
--   function to load up session information. The session information is
--   simply a string map &lt;math&gt;. A logical type signature for this
--   middleware might be:
--   
--   <pre>
--   loadSession :: ([(String, String)] -&gt; Application) -&gt; Application
--   </pre>
--   
--   Here, instead of taking a standard <a>Application</a> as its first
--   argument, the middleware takes a function which consumes the session
--   information as well.
type Middleware = Application -> Application
defWaiMain :: Application -> IO ()
defPutListening :: WaiOptions -> IO ()
waiMain :: WaiOptions -> IO () -> WaiOptions -> IO () -> Application -> IO ()
runGraceful :: GracefulMode -> Settings -> Application -> IO () -> Settings -> Application -> IO ()
runActivated :: Settings -> Socket -> Application -> IO () -> Settings -> Application -> IO ()
data GracefulMode
ServeNormally :: GracefulMode
Serve503 :: GracefulMode
data WaiOptions
WaiOptions :: Int -> String -> String -> String -> String -> String -> Maybe Bool -> WaiOptions

-- | Create a middleware to be added to a WAI-based webserver.
metrics :: WaiMetrics -> Middleware

-- | Register in EKG a number of metrics related to web server activity
--   with a namespace.
--   
--   <ul>
--   <li><pre><a>namespace</a>.wai.request_count</pre></li>
--   <li><pre><a>namespace</a>.wai.response_status_1xx</pre></li>
--   <li><pre><a>namespace</a>.wai.response_status_2xx</pre></li>
--   <li><pre><a>namespace</a>.wai.response_status_3xx</pre></li>
--   <li><pre><a>namespace</a>.wai.response_status_4xx</pre></li>
--   <li><pre><a>namespace</a>.wai.response_status_5xx</pre></li>
--   <li><pre><a>namespace</a>.wai.latency_distribution</pre></li>
--   </ul>
registerNamedWaiMetrics :: Text -> Store -> IO WaiMetrics

-- | Register in EKG a number of metrics related to web server activity
--   using empty namespace.
--   
--   <ul>
--   <li><pre>wai.request_count</pre></li>
--   <li><pre>wai.response_status_1xx</pre></li>
--   <li><pre>wai.response_status_2xx</pre></li>
--   <li><pre>wai.response_status_3xx</pre></li>
--   <li><pre>wai.response_status_4xx</pre></li>
--   <li><pre>wai.response_status_5xx</pre></li>
--   <li><pre>wai.latency_distribution</pre></li>
--   </ul>
registerWaiMetrics :: Store -> IO WaiMetrics

-- | The metrics to feed in WAI and register in EKG.
data WaiMetrics
WaiMetrics :: Counter -> Distribution -> Counter -> Counter -> Counter -> Counter -> Counter -> WaiMetrics
[requestCounter] :: WaiMetrics -> Counter
[latencyDistribution] :: WaiMetrics -> Distribution
[statusCode100Counter] :: WaiMetrics -> Counter
[statusCode200Counter] :: WaiMetrics -> Counter
[statusCode300Counter] :: WaiMetrics -> Counter
[statusCode400Counter] :: WaiMetrics -> Counter
[statusCode500Counter] :: WaiMetrics -> Counter
runMagicbaneHandler :: β -> RIO β α -> Handler α

-- | Constructs a WAI application from an API definition, a Servant context
--   (used for auth mainly), the app context and the actual action
--   handlers.
magicbaneApp :: forall β χ ψ. (HasServer χ ψ) => Proxy χ -> Context ψ -> β -> ServerT χ (RIO β) -> Application

-- | Gets a value of any type from the context.
askObj :: (Has β α, MonadReader α μ) => μ β

-- | Gets a thing from a value of any type from the context. (Useful for
--   configuration fields.)
askOpt :: (Has β α, MonadReader α μ) => (β -> ψ) -> μ ψ
type Formatter = TimedFastLogger -> CallStack -> LogSource -> LogLevel -> Utf8Builder -> IO ()
type ModLogger = LogFunc

-- | Creates a logger module using a given formatting function. | Also
--   returns the underlying TimedFastLogger for use outside of your
--   Magicbane app (e.g. in some WAI middleware).
newLogger :: LogType -> Formatter -> IO (TimedFastLogger, ModLogger)
simpleFormatter :: Formatter
newtype ModMetrics
ModMetrics :: Metrics -> ModMetrics
forkMetricsServer :: ByteString -> Int -> IO Server

-- | Creates a metrics module with a particular Store. The Store should
--   come from the backend you want to use for storing the metrics. For
--   development, a simple backend that shows metrics on a web page is
--   ekg-wai, reexported here.
newMetricsWith :: Store -> IO ModMetrics

-- | Merges two JSON objects recursively. When the values are not objects,
--   just returns the left one.
mergeVal :: Value -> Value -> Value

-- | Encodes key-value data as application/x-www-form-urlencoded.
writeForm :: (ConvertibleStrings α Text, ConvertibleStrings β Text, ConvertibleStrings ByteString γ) => [(α, β)] -> γ

-- | Decodes key-value data from application/x-www-form-urlencoded.
readForm :: (ConvertibleStrings Text α, ConvertibleStrings Text β, ConvertibleStrings γ ByteString) => γ -> Maybe [(α, β)]

-- | Reads a Servant incoming form as a list of key-value pairs (for use in
--   FromForm instances).
formList :: Form -> [(Text, Text)]

-- | Converts a flat key-value form with keys in typical nesting syntax
--   (e.g. "one[two][three]") to an Aeson Value with nesting (for use in
--   FromForm instances).
formToObject :: [(Text, Text)] -> Value
formKey :: Parser [Text]

-- | Parses any string into a URI.
parseUri :: ConvertibleStrings α String => α -> URI

-- | Prepares text for inclusion in a URL.
--   
--   <pre>
--   &gt;&gt;&gt; :set -XOverloadedStrings
--   
--   &gt;&gt;&gt; slugify "Hello &amp; World!"
--   "hello-and-world"
--   </pre>
slugify :: Text -> Text

-- | Creates a simple text/plain ServantErr.
errText :: ServantErr -> ByteString -> ServantErr

-- | Creates and throws a simple text/plain ServantErr.
throwErrText :: MonadThrow μ => ServantErr -> ByteString -> μ α
type MonadHTTP ψ μ = (HasHttpManager ψ, MonadReader ψ μ, MonadUnliftIO μ)
newtype ModHttpClient
ModHttpClient :: Manager -> ModHttpClient
newHttpClient :: IO ModHttpClient
runHTTP :: ExceptT ε μ α -> μ (Either ε α)

-- | Creates a request from a URI.
reqU :: (MonadHTTP ψ μ) => URI -> ExceptT Text μ Request

-- | Creates a request from a string of any type, parsing it into a URI.
reqS :: (MonadHTTP ψ μ, ConvertibleStrings σ String) => σ -> ExceptT Text μ Request

-- | Configures the request to not throw errors on error status codes.
anyStatus :: (MonadHTTP ψ μ) => Request -> ExceptT Text μ Request

-- | Sets a x-www-form-urlencoded form as the request body (also sets the
--   content-type).
postForm :: (MonadHTTP ψ μ) => [(Text, Text)] -> Request -> ExceptT Text μ Request

-- | Performs the request, using a given function to read the body. This is
--   what all other performWith functions are based on.
performWithFn :: (MonadHTTP ψ μ, MonadCatch μ) => (ConduitM ι ByteString μ () -> ConduitT () Void μ ρ) -> Request -> ExceptT Text μ (Response ρ)

-- | Performs the request, ignoring the body.
performWithVoid :: (MonadHTTP ψ μ, MonadCatch μ) => Request -> ExceptT Text μ (Response ())

-- | Performs the request, reading the body into a lazy ByteString.
performWithBytes :: (MonadHTTP ψ μ, MonadCatch μ) => Request -> ExceptT Text μ (Response ByteString)
type BasicApp α = RIO BasicContext α
type BasicContext = (ModHttpClient, ModLogger)
type WithLink α = (Headers '[Header "Link" [HTTPLink]] α)
type HTTPLink = Link
type Form = ReqBody '[FormUrlEncoded] [(Text, Text)]
type Host = Header "Host" Text
decodeEnvy :: FromEnv a => IO Maybe a

-- | Reads an Envy configuration from the env variables and launches the
--   given action if successful. (Does environment variable reading ever
--   fail in practice? Probably not.)
withEnvConfig :: FromEnv α => (α -> IO ()) -> IO ()
hPutStrLn :: MonadIO m => Handle -> String -> m ()
newBasicContext :: IO BasicContext
instance Data.Default.Class.Default α => System.Envy.DefConfig α
