Copyright | (c) Frederick Pringle 2024 |
---|---|
License | BSD-3-Clause |
Maintainer | freddyjepringle@gmail.com |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Internal module, subject to change.
Documentation
A more expressive sum-type than just a list. This can be useful in situations where a body (request or response) may have several interpretations.
For example, the UVerb
combinator lets us represent an endpoint that may return one of
several types: hence the _routeResponseType
field needs to be able to contain
several TypeRep
s as a disjunction.
On the other hand, if multiple ReqBody'
s are chained together with :>
, the resulting
type's HasServer
instance would try to parse the request body as all of the relevant types. In this
case the _routeRequestBody
field needs to be able to contain several TypeRep
s
as a conjunction.
bodyToList :: Body -> [TypeRep] Source #
Convert a Body
to a list of TypeRep
s. Inverse of listToBody
.
listToBody :: [TypeRep] -> Body Source #
Convert a list of TypeRep
s to a Body
. Inverse of listToBody
.
This maintains the invariant that the argument of ManyTypes
has to be of length > 1.
class AllTypeable (as :: [Type]) where Source #
This class does 2 things:
- It lets us get a term-level list of
TypeRep
s from a type-level list of types, all of which haveTypeable
instances. - More impressively, its instances enforce that
typeReps
will only type-check for type-level lists of length 2 or more. This is becauseAllTypeable
will only ever be used bymanyTypes
(and its aliases), which is the only way to construct aManyTypes
and thus lets us enforce the invariant thatManyTypes
will always have more than 1 argument. This lets us make sure that there's only ever one way to represent a list ofTypeRep
s usingBody
.
Of course, someone might import this Internal module and define a
instance. Don't do that.Typeable
a => AllTypeable
'[a]
Instances
(Typeable a, AllTypeable (b ': (c ': as))) => AllTypeable (a ': (b ': (c ': as))) Source # | |
Defined in Servant.API.Routes.Internal.Body | |
(Typeable a, Typeable b) => AllTypeable '[a, b] Source # | |
Defined in Servant.API.Routes.Internal.Body |