Safe Haskell | None |
---|---|
Language | Haskell2010 |
Servant.Swagger.Internal.TypeLevel.API
Synopsis
- type family EndpointsList api :: [Type] where ...
- type family IsSubAPI sub api where ...
- type family AllIsElem (xs :: [Type]) api where ...
- type family MapSub (e :: k) (xs :: [Type]) :: [Type] where ...
- type family AppendList (xs :: [a]) (ys :: [a]) :: [a] where ...
- type family Or a b where ...
- type family IsIn sub api where ...
- type family Elem (x :: a) (xs :: [a]) :: Bool where ...
- type family Nub (xs :: [a]) :: [a] where ...
- type family Remove (x :: a) (xs :: [a]) :: [a] where ...
- type BodyTypes c api = Nub (BodyTypes' c api)
- type AddBodyType (c :: a1) (cs :: [a1]) (a2 :: a) (as :: [a]) = If (Elem c cs) (a2 ': as) as
- type family BodyTypes' c api :: [Type] where ...
Documentation
type family EndpointsList api :: [Type] where ... Source #
Build a list of endpoints from an API.
Equations
EndpointsList (a :<|> b) = AppendList (EndpointsList a) (EndpointsList b) | |
EndpointsList (e :> a) = MapSub e (EndpointsList a) | |
EndpointsList a = '[a] |
type family IsSubAPI sub api where ... Source #
Check whether sub
is a sub API of api
.
Equations
IsSubAPI sub api = AllIsElem (EndpointsList sub) api |
type family AllIsElem (xs :: [Type]) api where ... Source #
Check that every element of xs
is an endpoint of api
.
type family MapSub (e :: k) (xs :: [Type]) :: [Type] where ... Source #
Apply (e :>)
to every API in xs
.
type family AppendList (xs :: [a]) (ys :: [a]) :: [a] where ... Source #
Append two type-level lists.
Equations
AppendList ('[] :: [a]) (ys :: [a]) = ys | |
AppendList (x ': xs :: [a]) (ys :: [a]) = x ': AppendList xs ys |
type family Elem (x :: a) (xs :: [a]) :: Bool where ... Source #
Check whether a type is a member of a list of types.
This is a type-level analogue of
.elem
type family Remove (x :: a) (xs :: [a]) :: [a] where ... Source #
Remove element from a type-level list.
type BodyTypes c api = Nub (BodyTypes' c api) Source #
Extract a list of unique "body" types for a specific content-type from a servant API.
type AddBodyType (c :: a1) (cs :: [a1]) (a2 :: a) (as :: [a]) = If (Elem c cs) (a2 ': as) as Source #
adds type AddBodyType
c cs a asa
to the list as
only if c
is in cs
.
type family BodyTypes' c api :: [Type] where ... Source #
Extract a list of "body" types for a specific content-type from a servant API.
To extract unique types see
.BodyTypes
is removed from the list and not tested. (This allows for leaving the body
completely empty on responses to requests that only accept 'application/json', while
setting the content-type in the response accordingly.)NoContent
Equations
BodyTypes' c (Verb verb b cs (Headers hdrs a)) = AddBodyType c cs a ('[] :: [Type]) | |
BodyTypes' c (Verb verb b cs NoContent) = '[] :: [Type] | |
BodyTypes' c (Verb verb b cs a) = AddBodyType c cs a ('[] :: [Type]) | |
BodyTypes' c (ReqBody' mods cs a :> api) = AddBodyType c cs a (BodyTypes' c api) | |
BodyTypes' c (e :> api) = BodyTypes' c api | |
BodyTypes' c (a :<|> b) = AppendList (BodyTypes' c a) (BodyTypes' c b) | |
BodyTypes' c api = '[] :: [Type] |