servant-checked-exceptions-0.3.0.2: Checked exceptions for Servant APIs.

CopyrightDennis Gosnell 2017
LicenseBSD3
MaintainerDennis Gosnell (cdep.illabout@gmail.com)
Stabilityexperimental
Portabilityunknown
Safe HaskellNone
LanguageHaskell2010

Servant.Checked.Exceptions.Internal.Servant.API

Description

This module defines the Throws and Throwing types.

Synopsis

Documentation

data Throws e Source #

Throws is used in Servant API definitions and signifies that an API will throw the given error.

Here is an example of how to create an API that potentially returns a String as an error, or an Int on success:

>>> import Servant.API (Get, JSON, (:>))
>>> type API = Throws String :> Get '[JSON] Int

Instances

type Client * ((:>) k * (Throws e) api) # 
type Client * ((:>) k * (Throws e) api) = Client * ((:>) k * (Throwing ((:) * e ([] *))) api)
type ServerT * ((:>) k * (Throws e) api) m # 
type ServerT * ((:>) k * (Throws e) api) m = ServerT * ((:>) k * (Throwing ((:) * e ([] *))) api) m

data Throwing e Source #

This is used internally and should not be used by end-users.

Instances

type Client * ((:>) * * (Throwing es) ((:>) k k1 api apis)) # 
type Client * ((:>) * * (Throwing es) ((:>) k k1 api apis)) = Client * (ThrowingNonterminal ((:>) * * (Throwing es) ((:>) k k1 api apis)))
type Client * ((:>) * * (Throwing es) ((:<|>) api1 api2)) # 
type Client * ((:>) * * (Throwing es) ((:<|>) api1 api2)) = Client * ((:<|>) ((:>) * * (Throwing es) api1) ((:>) * * (Throwing es) api2))
type Client * ((:>) * * (Throwing es) (Verb * k1 method status ctypes a)) # 
type Client * ((:>) * * (Throwing es) (Verb * k1 method status ctypes a)) = Client * (Verb * k1 method status ctypes (Envelope es a))
type ServerT * ((:>) * * (Throwing es) ((:>) k k1 api apis)) m # 
type ServerT * ((:>) * * (Throwing es) ((:>) k k1 api apis)) m = ServerT * (ThrowingNonterminal ((:>) * * (Throwing es) ((:>) k k1 api apis))) m
type ServerT * ((:>) * * (Throwing es) ((:<|>) api1 api2)) m # 
type ServerT * ((:>) * * (Throwing es) ((:<|>) api1 api2)) m = ServerT * ((:<|>) ((:>) * * (Throwing es) api1) ((:>) * * (Throwing es) api2)) m
type ServerT * ((:>) * * (Throwing es) (Verb * k1 method status ctypes a)) m # 
type ServerT * ((:>) * * (Throwing es) (Verb * k1 method status ctypes a)) m = ServerT * (Verb * k1 method status ctypes (Envelope es a)) m

type family ThrowingNonterminal api where ... Source #

Used by the HasServer and HasClient instances for Throwing es :> api :> apis to detect Throwing es followed immediately by Throws e.

Equations

ThrowingNonterminal (Throwing es :> (Throws e :> api)) = Throwing (Snoc es e) :> api 
ThrowingNonterminal (Throwing es :> (c :> api)) = c :> (Throwing es :> api)