Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- type GetTypedError resp ty err = UVerb 'GET resp '[WithStatus200 ty, WithStatus500 err]
- type PostTypedError resp ty err = UVerb 'POST resp '[WithStatus200 ty, WithStatus500 err]
- type DeleteTypedError resp ty err = UVerb 'DELETE resp '[WithStatus200 ty, WithStatus500 err]
- type PutTypedError resp ty err = UVerb 'PUT resp '[WithStatus200 ty, WithStatus500 err]
- type WithError err ty = '[WithStatus200 ty, WithStatus500 err]
- newtype TypedHandler e a = TypedHandler {
- unTypedHandler :: ExceptT (Either ServerError e) IO a
- throwTypedError :: e -> TypedHandler e a
- throwServantError :: ServerError -> TypedHandler e a
- runTypedHandler :: TypedHandler e a -> Handler (Union '[WithStatus200 a, WithStatus500 e])
- liftTypedError :: Functor m => ExceptT e m a -> m (Union '[WithStatus200 a, WithStatus500 e])
- data TypedClientM e a
- typedClient :: TypedClient a b => a -> b
- runTypedClientM :: TypedClientM e a -> ClientEnv -> IO (Either (Either ClientError e) a)
Documentation
type GetTypedError resp ty err = UVerb 'GET resp '[WithStatus200 ty, WithStatus500 err] Source #
type PostTypedError resp ty err = UVerb 'POST resp '[WithStatus200 ty, WithStatus500 err] Source #
type DeleteTypedError resp ty err = UVerb 'DELETE resp '[WithStatus200 ty, WithStatus500 err] Source #
type PutTypedError resp ty err = UVerb 'PUT resp '[WithStatus200 ty, WithStatus500 err] Source #
newtype TypedHandler e a Source #
TypedHandler | |
|
Instances
throwTypedError :: e -> TypedHandler e a Source #
throwServantError :: ServerError -> TypedHandler e a Source #
runTypedHandler :: TypedHandler e a -> Handler (Union '[WithStatus200 a, WithStatus500 e]) Source #
Inside TypedHandler
we can throw two different kinds of errors:
Either a ServerError, via throwServantError
or a custom error via throwTyped
liftTypedError :: Functor m => ExceptT e m a -> m (Union '[WithStatus200 a, WithStatus500 e]) Source #
This function is subtly different to runTypedHandler
in that it can be used to
instantiate a function `f :: MonadError e m => m a` to `Handler (Union '[WithStatus200 a, WithStatus500 e])`.
Any calls to throwError
in f
will get turned to throwTyped
in `liftTypedError f`.
In case you also want to throw a ServantError
, use runTypedHandler
instead.
data TypedClientM e a Source #
typedClient :: TypedClient a b => a -> b Source #
runTypedClientM :: TypedClientM e a -> ClientEnv -> IO (Either (Either ClientError e) a) Source #