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


-- | Checked exceptions for Servant APIs.
--   
--   Please see <a>README.md</a>.
@package servant-checked-exceptions
@version 2.0.0.0

module Servant.Checked.Exceptions.Internal.Servant.API


-- | This module only exports <a>HasClient</a> instances for <a>Throws</a>
--   and <a>Throwing</a>.
module Servant.Checked.Exceptions.Internal.Servant.Client
instance (Servant.Client.Core.Internal.RunClient.RunClient m, Servant.Client.Core.Internal.HasClient.HasClient m (Servant.Checked.Exceptions.Internal.Servant.API.Throwing '[e] Servant.API.Sub.:> api)) => Servant.Client.Core.Internal.HasClient.HasClient m (Servant.Checked.Exceptions.Internal.Servant.API.Throws e Servant.API.Sub.:> api)
instance forall k1 (m :: * -> *) (method :: k1) (status :: GHC.Types.Nat) (ctypes :: [*]) (es :: [*]) a. Servant.Client.Core.Internal.HasClient.HasClient m (Servant.API.Verbs.Verb method status ctypes (Servant.Checked.Exceptions.Internal.Envelope.Envelope es a)) => Servant.Client.Core.Internal.HasClient.HasClient m (Servant.Checked.Exceptions.Internal.Servant.API.Throwing es Servant.API.Sub.:> Servant.API.Verbs.Verb method status ctypes a)
instance forall k1 (m :: * -> *) (method :: k1) (status :: GHC.Types.Nat) (ctypes :: [*]) a. (Servant.Client.Core.Internal.RunClient.RunClient m, Servant.Client.Core.Internal.HasClient.HasClient m (Servant.API.Verbs.Verb method status ctypes (Servant.Checked.Exceptions.Internal.Envelope.Envelope '[] a))) => Servant.Client.Core.Internal.HasClient.HasClient m (Servant.Checked.Exceptions.Internal.Servant.API.NoThrow Servant.API.Sub.:> Servant.API.Verbs.Verb method status ctypes a)
instance (Servant.Client.Core.Internal.RunClient.RunClient m, Servant.Client.Core.Internal.HasClient.HasClient m ((Servant.Checked.Exceptions.Internal.Servant.API.Throwing es Servant.API.Sub.:> api1) Servant.API.Alternative.:<|> (Servant.Checked.Exceptions.Internal.Servant.API.Throwing es Servant.API.Sub.:> api2))) => Servant.Client.Core.Internal.HasClient.HasClient m (Servant.Checked.Exceptions.Internal.Servant.API.Throwing es Servant.API.Sub.:> (api1 Servant.API.Alternative.:<|> api2))
instance (Servant.Client.Core.Internal.RunClient.RunClient m, Servant.Client.Core.Internal.HasClient.HasClient m ((Servant.Checked.Exceptions.Internal.Servant.API.NoThrow Servant.API.Sub.:> api1) Servant.API.Alternative.:<|> (Servant.Checked.Exceptions.Internal.Servant.API.NoThrow Servant.API.Sub.:> api2))) => Servant.Client.Core.Internal.HasClient.HasClient m (Servant.Checked.Exceptions.Internal.Servant.API.NoThrow Servant.API.Sub.:> (api1 Servant.API.Alternative.:<|> api2))
instance forall k (m :: * -> *) (es :: [*]) (api :: k) apis. (Servant.Client.Core.Internal.RunClient.RunClient m, Servant.Client.Core.Internal.HasClient.HasClient m (Servant.Checked.Exceptions.Internal.Servant.API.ThrowingNonterminal (Servant.Checked.Exceptions.Internal.Servant.API.Throwing es Servant.API.Sub.:> (api Servant.API.Sub.:> apis)))) => Servant.Client.Core.Internal.HasClient.HasClient m (Servant.Checked.Exceptions.Internal.Servant.API.Throwing es Servant.API.Sub.:> (api Servant.API.Sub.:> apis))
instance forall k (m :: * -> *) (api :: k) apis. (Servant.Client.Core.Internal.RunClient.RunClient m, Servant.Client.Core.Internal.HasClient.HasClient m (api Servant.API.Sub.:> (Servant.Checked.Exceptions.Internal.Servant.API.NoThrow Servant.API.Sub.:> apis))) => Servant.Client.Core.Internal.HasClient.HasClient m (Servant.Checked.Exceptions.Internal.Servant.API.NoThrow Servant.API.Sub.:> (api Servant.API.Sub.:> apis))


-- | This module exports <a>HasServer</a> instances for <a>Throws</a> and
--   <a>Throwing</a>.
module Servant.Checked.Exceptions.Internal.Servant.Server
methodRouter :: forall ctypes a es env. (AllCTRender ctypes (Envelope es a), AllErrStatus es) => Method -> Status -> Proxy ctypes -> Delayed env (Handler (Envelope es a)) -> Router' env (Request -> (RouteResult Response -> IO ResponseReceived) -> IO ResponseReceived)
allowedMethod :: Method -> Request -> Bool
allowedMethodHead :: Method -> Request -> Bool
methodCheck :: Method -> Request -> DelayedIO ()
acceptCheck :: AllMime list => Proxy list -> ByteString -> DelayedIO ()
getErrStatus :: AllErrStatus es => OpenUnion es -> Status
processMethodRouter :: Maybe (ByteString, ByteString) -> Status -> Method -> Maybe [(HeaderName, ByteString)] -> Request -> RouteResult Response
instance Servant.Server.Internal.HasServer (Servant.Checked.Exceptions.Internal.Servant.API.Throwing '[e] Servant.API.Sub.:> api) context => Servant.Server.Internal.HasServer (Servant.Checked.Exceptions.Internal.Servant.API.Throws e Servant.API.Sub.:> api) context
instance forall k1 (method :: k1) (status :: GHC.Types.Nat) (ctypes :: [*]) (es :: [*]) a (context :: [*]). Servant.Server.Internal.HasServer (Servant.Checked.Exceptions.Internal.Verbs.VerbWithErr method status ctypes es a) context => Servant.Server.Internal.HasServer (Servant.Checked.Exceptions.Internal.Servant.API.Throwing es Servant.API.Sub.:> Servant.API.Verbs.Verb method status ctypes a) context
instance forall k1 (method :: k1) (status :: GHC.Types.Nat) (ctypes :: [*]) a (context :: [*]). Servant.Server.Internal.HasServer (Servant.Checked.Exceptions.Internal.Verbs.VerbWithErr method status ctypes '[] a) context => Servant.Server.Internal.HasServer (Servant.Checked.Exceptions.Internal.Servant.API.NoThrow Servant.API.Sub.:> Servant.API.Verbs.Verb method status ctypes a) context
instance Servant.Server.Internal.HasServer ((Servant.Checked.Exceptions.Internal.Servant.API.Throwing es Servant.API.Sub.:> api1) Servant.API.Alternative.:<|> (Servant.Checked.Exceptions.Internal.Servant.API.Throwing es Servant.API.Sub.:> api2)) context => Servant.Server.Internal.HasServer (Servant.Checked.Exceptions.Internal.Servant.API.Throwing es Servant.API.Sub.:> (api1 Servant.API.Alternative.:<|> api2)) context
instance Servant.Server.Internal.HasServer ((Servant.Checked.Exceptions.Internal.Servant.API.NoThrow Servant.API.Sub.:> api1) Servant.API.Alternative.:<|> (Servant.Checked.Exceptions.Internal.Servant.API.NoThrow Servant.API.Sub.:> api2)) context => Servant.Server.Internal.HasServer (Servant.Checked.Exceptions.Internal.Servant.API.NoThrow Servant.API.Sub.:> (api1 Servant.API.Alternative.:<|> api2)) context
instance forall k (es :: [*]) (api :: k) apis (context :: [*]). Servant.Server.Internal.HasServer (Servant.Checked.Exceptions.Internal.Servant.API.ThrowingNonterminal (Servant.Checked.Exceptions.Internal.Servant.API.Throwing es Servant.API.Sub.:> (api Servant.API.Sub.:> apis))) context => Servant.Server.Internal.HasServer (Servant.Checked.Exceptions.Internal.Servant.API.Throwing es Servant.API.Sub.:> (api Servant.API.Sub.:> apis)) context
instance forall k (api :: k) apis (context :: [*]). Servant.Server.Internal.HasServer (api Servant.API.Sub.:> (Servant.Checked.Exceptions.Internal.Servant.API.NoThrow Servant.API.Sub.:> apis)) context => Servant.Server.Internal.HasServer (Servant.Checked.Exceptions.Internal.Servant.API.NoThrow Servant.API.Sub.:> (api Servant.API.Sub.:> apis)) context
instance forall k1 (ctypes :: [*]) (es :: [*]) a (successStatus :: GHC.Types.Nat) (method :: k1) (context :: [*]). (Servant.API.ContentTypes.AllCTRender ctypes (Servant.Checked.Exceptions.Internal.Envelope.Envelope es a), Servant.Checked.Exceptions.Internal.Servant.API.AllErrStatus es, GHC.TypeNats.KnownNat successStatus, Servant.API.Verbs.ReflectMethod method) => Servant.Server.Internal.HasServer (Servant.Checked.Exceptions.Internal.Verbs.VerbWithErr method successStatus ctypes es a) context


-- | Export all of instances for the Client, Docs, and Server.
module Servant.Checked.Exceptions.Internal.Servant


-- | Export all of the internal functions.
module Servant.Checked.Exceptions.Internal


-- | This module gives you the ability to specify which errors are thrown
--   by a Servant api. This is done with the <a>Throws</a> data type. Here
--   is an example of creating an api that uses <a>Throws</a>:
--   
--   <pre>
--   type Api =
--     "author" <a>:&gt;</a>
--     <a>Capture</a> "author-id" AuthorId <a>:&gt;</a>
--     <a>Throws</a> CouldNotConnectToDbError <a>:&gt;</a>
--     <a>Throws</a> AuthorNotFoundError <a>:&gt;</a>
--     <a>Get</a> '[<a>JSON</a>] Author
--   </pre>
--   
--   This api will return an <tt>Author</tt> for a given <tt>AuthorId</tt>.
--   <a>Throws</a> is used to indicate that this api will potentially
--   return two different errors: <tt>CouldNotConnectToDbError</tt> and
--   <tt>AuthorNotFoundError</tt>.
--   
--   These two errors might be defined like this:
--   
--   <pre>
--   data CouldNotConnectToDbError = CouldNotConnectToDbError
--     deriving (<a>Eq</a>, <a>Read</a>, <a>Show</a>)
--   
--   data AuthorNotFoundError = AuthorNotFoundError
--     deriving (<a>Eq</a>, <a>Read</a>, <a>Show</a>)
--   </pre>
--   
--   Writing the server handler for this api will look like the following.
--   Notice how the <a>Envelope</a> type is used:
--   
--   <pre>
--   getAuthorHandler
--     :: AuthorId
--     -&gt; <tt>Handler</tt> (<a>Envelope</a> '[DatabaseError, AuthorNotFoundError] Author)
--   getAuthorHandler authorId = do
--     eitherAuthor &lt;- getAuthorFromDb authorId
--     case eitherAuthor of
--       Left NoDb -&gt; pure $ <a>toErrEnvelope</a> CouldNotConnectToDbError
--       Left NoAuthor -&gt; pure $ <a>toErrEnvelope</a> AuthorNotFoundError
--       Right author -&gt; pure $ <a>toSuccEnvelope</a> author
--   
--   getAuthorFromDb :: AuthorId -&gt; Handler (Either DbErr Author)
--   getAuthorFromDb = ...
--   
--   data DbErr = NoDb | NoAuthor
--   </pre>
--   
--   <tt><a>Envelope</a> '[DatabaseError, AuthorNotFoundError] Author</tt>
--   represents a response that will contain an <tt>Author</tt> on success,
--   or contain either a <tt>DatabaseError</tt> or a
--   <tt>AuthorNotFoundError</tt> on error.
--   
--   Under the hood, <a>Envelope</a> is using an extensible sum-type
--   (<a>OpenUnion</a>) to represent possible errors. Working with an api
--   that returns two possible errors is just as easy as working with an
--   api that returns three possible errors.
--   
--   Clients will also use the <a>Envelope</a> type:
--   
--   <pre>
--   getAuthor
--     :: AuthorId
--     -&gt; <a>ClientM</a> (<a>Envelope</a> '[DatabaseError, AuthorNotFoundError] Author)
--   getAuthor = <a>client</a> (<a>Proxy</a> :: <a>Proxy</a> Api)
--   </pre>
--   
--   It is easy to do case analysis (similar to pattern matching) on the
--   <a>Envelope</a> type with the <a>catchesEnvelope</a> function.
--   
--   Checkout the <a>example</a> in the repository on Github. It includes a
--   fleshed-out example of an <a>api</a>, <a>server</a>, <a>client</a>,
--   and <a>documentation</a>. The <a>README.md</a> shows how to compile
--   and run the examples.
module Servant.Checked.Exceptions
