Servant.Swagger.Internal.TypeLevel.API

servant-swagger-1.1.3.1: Generate Swagger specification for your servant API.

Safe Haskell | None
Language | Haskell2010

Servant.Swagger.Internal.TypeLevel.API

Synopsis

- type family EndpointsList api where ...
- type family IsSubAPI sub api :: Constraint where ...
- type family AllIsElem xs api :: Constraint where ...
- type family MapSub e xs where ...
- type family AppendList xs ys where ...
- type family Or (a :: Constraint) (b :: Constraint) :: Constraint where ...
- type family IsIn sub api :: Constraint where ...
- type family Elem x xs where ...
- type family Nub xs where ...
- type family Remove x xs where ...
- type BodyTypes c api = Nub (BodyTypes' c api)
- type AddBodyType c cs a as = If (Elem c cs) (a ': as) as
- type family BodyTypes' c api :: [*] where ...

# Documentation

type family EndpointsList api where ... #

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 :: Constraint where ... #

Check whether `sub` is a sub API of `api`.

Equations

IsSubAPI sub api = AllIsElem (EndpointsList sub) api |

type family AllIsElem xs api :: Constraint where ... #

Check that every element of `xs` is an endpoint of `api`.

Equations

AllIsElem '[] api = () |
AllIsElem (x ': xs) api = (IsIn x api, AllIsElem xs api) |

type family MapSub e xs where ... #

Apply `(e :>)` to every API in `xs`.

Equations

MapSub e '[] = '[] |
MapSub e (x ': xs) = (e :> x) ': MapSub e xs |

type family AppendList xs ys where ... #

Append two type-level lists.

Equations

AppendList '[] ys = ys |
AppendList (x ': xs) ys = x ': AppendList xs ys |

type family Or (a :: Constraint) (b :: Constraint) :: Constraint where ... #

Equations

Or () b = () |
Or a () = () |

type family IsIn sub api :: Constraint where ... #

Equations

IsIn e (a :<|> b) = Or (IsIn e a) (IsIn e b) |
IsIn (e :> a) (e :> b) = IsIn a b |
IsIn e e = () |

type family Elem x xs where ... #

Check whether a type is a member of a list of types. This is a type-level analogue of ``elem``.

Equations

Elem x '[] = False |
Elem x (x ': xs) = True |
Elem x (y ': xs) = Elem x xs |

type family Nub xs where ... #

Remove duplicates from a type-level list.

Equations

Nub '[] = '[] |
Nub (x ': xs) = x ': Nub (Remove x xs) |

type family Remove x xs where ... #

Remove element from a type-level list.

Equations

Remove x '[] = '[] |
Remove x (x ': ys) = Remove x ys |
Remove x (y ': ys) = y ': Remove x ys |

type BodyTypes c api = Nub (BodyTypes' c api) #

Extract a list of unique "body" types for a specific content-type from a servant API.

type AddBodyType c cs a as = If (Elem c cs) (a ': as) as #

``AddBodyType` c cs a as` adds type `a` to the list `as` only if `c` is in `cs`.

type family BodyTypes' c api :: [*] where ... #

Extract a list of "body" types for a specific content-type from a servant API. To extract unique types see ``BodyTypes``.

Equations

BodyTypes' c (Verb verb b cs (Headers hdrs a)) = AddBodyType c cs a '[] |
BodyTypes' c (Verb verb b cs a) = AddBodyType c cs a '[] |
BodyTypes' c (ReqBody 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 = '[] |