servant-typed-error-0.1.2.0: Typed error wrapper for Servant
Safe HaskellSafe-Inferred
LanguageHaskell2010

Servant.Typed.Error

Synopsis

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 #

type WithError err ty = '[WithStatus200 ty, WithStatus500 err] Source #

newtype TypedHandler e a Source #

Constructors

TypedHandler 

Instances

Instances details
Applicative (TypedHandler e) Source # 
Instance details

Defined in Servant.Typed.Error

Methods

pure :: a -> TypedHandler e a #

(<*>) :: TypedHandler e (a -> b) -> TypedHandler e a -> TypedHandler e b #

liftA2 :: (a -> b -> c) -> TypedHandler e a -> TypedHandler e b -> TypedHandler e c #

(*>) :: TypedHandler e a -> TypedHandler e b -> TypedHandler e b #

(<*) :: TypedHandler e a -> TypedHandler e b -> TypedHandler e a #

Functor (TypedHandler e) Source # 
Instance details

Defined in Servant.Typed.Error

Methods

fmap :: (a -> b) -> TypedHandler e a -> TypedHandler e b #

(<$) :: a -> TypedHandler e b -> TypedHandler e a #

Monad (TypedHandler e) Source # 
Instance details

Defined in Servant.Typed.Error

Methods

(>>=) :: TypedHandler e a -> (a -> TypedHandler e b) -> TypedHandler e b #

(>>) :: TypedHandler e a -> TypedHandler e b -> TypedHandler e b #

return :: a -> TypedHandler e a #

MonadError (Either ServerError e) (TypedHandler e) Source # 
Instance details

Defined in Servant.Typed.Error

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.

typedClient :: TypedClient a b => a -> b Source #