-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Checked exceptions for Servant APIs. -- -- Please see README.md. @package servant-checked-exceptions @version 2.2.0.0 module Servant.Checked.Exceptions.Internal.Servant.API -- | This module only exports HasClient instances for Throws -- and Throwing. module Servant.Checked.Exceptions.Internal.Servant.Client instance (Servant.Client.Core.RunClient.RunClient m, Servant.Client.Core.HasClient.HasClient m (Servant.Checked.Exceptions.Internal.Servant.API.Throwing '[e] Servant.API.Sub.:> api)) => Servant.Client.Core.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.HasClient.HasClient m (Servant.API.Verbs.Verb method status ctypes (Servant.Checked.Exceptions.Internal.Envelope.Envelope es a)) => Servant.Client.Core.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.RunClient.RunClient m, Servant.Client.Core.HasClient.HasClient m (Servant.API.Verbs.Verb method status ctypes (Servant.Checked.Exceptions.Internal.Envelope.Envelope '[] a))) => Servant.Client.Core.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.RunClient.RunClient m, Servant.Client.Core.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.HasClient.HasClient m (Servant.Checked.Exceptions.Internal.Servant.API.Throwing es Servant.API.Sub.:> (api1 Servant.API.Alternative.:<|> api2)) instance (Servant.Client.Core.RunClient.RunClient m, Servant.Client.Core.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.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.RunClient.RunClient m, Servant.Client.Core.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.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.RunClient.RunClient m, Servant.Client.Core.HasClient.HasClient m (api Servant.API.Sub.:> (Servant.Checked.Exceptions.Internal.Servant.API.NoThrow Servant.API.Sub.:> apis))) => Servant.Client.Core.HasClient.HasClient m (Servant.Checked.Exceptions.Internal.Servant.API.NoThrow Servant.API.Sub.:> (api Servant.API.Sub.:> apis)) -- | This module exports HasServer instances for Throws and -- Throwing. 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 Throws data type. Here -- is an example of creating an api that uses Throws: -- --
--   type Api =
--     "author" :>
--     Capture "author-id" AuthorId :>
--     Throws CouldNotConnectToDbError :>
--     Throws AuthorNotFoundError :>
--     Get '[JSON] Author
--   
-- -- This api will return an Author for a given AuthorId. -- Throws is used to indicate that this api will potentially -- return two different errors: CouldNotConnectToDbError and -- AuthorNotFoundError. -- -- These two errors might be defined like this: -- --
--   data CouldNotConnectToDbError = CouldNotConnectToDbError
--     deriving (Eq, Read, Show)
--   
--   data AuthorNotFoundError = AuthorNotFoundError
--     deriving (Eq, Read, Show)
--   
-- -- Writing the server handler for this api will look like the following. -- Notice how the Envelope type is used: -- --
--   getAuthorHandler
--     :: AuthorId
--     -> Handler (Envelope '[DatabaseError, AuthorNotFoundError] Author)
--   getAuthorHandler authorId = do
--     eitherAuthor <- getAuthorFromDb authorId
--     case eitherAuthor of
--       Left NoDb -> pure $ toErrEnvelope CouldNotConnectToDbError
--       Left NoAuthor -> pure $ toErrEnvelope AuthorNotFoundError
--       Right author -> pure $ toSuccEnvelope author
--   
--   getAuthorFromDb :: AuthorId -> Handler (Either DbErr Author)
--   getAuthorFromDb = ...
--   
--   data DbErr = NoDb | NoAuthor
--   
-- -- Envelope '[DatabaseError, AuthorNotFoundError] Author -- represents a response that will contain an Author on success, -- or contain either a DatabaseError or a -- AuthorNotFoundError on error. -- -- Under the hood, Envelope is using an extensible sum-type -- (OpenUnion) 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 Envelope type: -- --
--   getAuthor
--     :: AuthorId
--     -> ClientM (Envelope '[DatabaseError, AuthorNotFoundError] Author)
--   getAuthor = client (Proxy :: Proxy Api)
--   
-- -- It is easy to do case analysis (similar to pattern matching) on the -- Envelope type with the catchesEnvelope function. -- -- Checkout the example in the repository on Github. It includes a -- fleshed-out example of an api, server, client, -- and documentation. The README.md shows how to compile -- and run the examples. module Servant.Checked.Exceptions