Safe Haskell | None |
---|---|
Language | Haskell2010 |
Type level functions over ReqContent
and ResContent
Synopsis
- type family ApiToReq (a :: api) :: [ReqContent Type] where ...
- type family GetVerb (a :: api) :: Type where ...
- type family HttpReq (ts :: [ReqContent Type]) :: [Type] where ...
- type family HttpRes (res :: [ResContent Type]) :: [Type] where ...
- type family HttpResConstraints (res :: [ResContent Type]) :: Constraint where ...
- type family HttpReqConstraints (req :: [ReqContent Type]) :: Constraint where ...
- type family HttpSymbolTypePair (ts :: [(Symbol, Type)]) :: Constraint where ...
- type family UniqMembers (ts :: [k]) (label :: Symbol) :: Constraint where ...
- type family UniqMember (a :: k) (ts :: [k]) (label :: Symbol) :: Constraint where ...
- type family All (a :: k -> Constraint) (ts :: [k]) :: Constraint where ...
- type family AllFsts (a :: [(k1, k2)]) :: [k1] where ...
- type family AllSnds (a :: [(k1, k2)]) :: [k2] where ...
Documentation
type family ApiToReq (a :: api) :: [ReqContent Type] where ... Source #
ApiToReq
transforms an API type into a type level list of
Request component content types.
The resulting list is used by the HasRequest
class.
type family GetVerb (a :: api) :: Type where ... Source #
Given an API type, GetVerb
retrieves the Verb type component which
is used by the HasResponse
class.
type family HttpReq (ts :: [ReqContent Type]) :: [Type] where ... Source #
HttpReq
interprets a ReqContent
list as a Type
level list
used in the HasRequest
class for representing
request component inputs
HttpReq '[] = '[] | |
HttpReq (Path _ _ ': ts) = HttpReq ts | |
HttpReq (ReqBody ctyp a ': ts) = a ': HttpReq ts | |
HttpReq (StreamBody ctyp a ': ts) = a ': HttpReq ts | |
HttpReq (BasicAuth _ _ ': ts) = BasicAuthData ': HttpReq ts | |
HttpReq (QueryFlags _ _ ': ts) = HttpReq ts | |
HttpReq (Params ('(s, a) ': ps) ': ts) = a ': HttpReq (Params ps ': ts) | |
HttpReq (Params '[] ': ts) = HttpReq ts | |
HttpReq (CaptureAll a ': ts) = [a] ': HttpReq ts | |
HttpReq (Captures (a ': cs) ': ts) = a ': HttpReq (Captures cs ': ts) | |
HttpReq (Captures '[] ': ts) = HttpReq ts | |
HttpReq (ReqHeaders ('(s, a) ': hs) ': ts) = a ': HttpReq (ReqHeaders hs ': ts) | |
HttpReq (ReqHeaders '[] ': ts) = HttpReq ts |
type family HttpRes (res :: [ResContent Type]) :: [Type] where ... Source #
HttpRes
interprets a ResContent
list as a Type level list for
used HasResponse
class to represent responses
type family HttpResConstraints (res :: [ResContent Type]) :: Constraint where ... Source #
Response content types Constraints.
HttpResConstraints '[] = () | |
HttpResConstraints (ResBody ctyp a ': ts) = (HasMediaType ctyp, MediaDecode ctyp a, HttpResConstraints ts) | |
HttpResConstraints (ResStream ctyp a ': ts) = (HasMediaType ctyp, HttpResConstraints ts) | |
HttpResConstraints (ResHeaders hs ': ts) = (HttpSymbolTypePair hs, HttpResConstraints ts) | |
HttpResConstraints (Raw a ': ts) = HttpResConstraints ts |
type family HttpReqConstraints (req :: [ReqContent Type]) :: Constraint where ... Source #
Request content types Constraints.
type family HttpSymbolTypePair (ts :: [(Symbol, Type)]) :: Constraint where ... Source #
HttpSymbolTypePair ts = (All KnownSymbol (AllFsts ts), All ToHttpApiData (AllSnds ts)) |
type family UniqMembers (ts :: [k]) (label :: Symbol) :: Constraint where ... Source #
Cross check that there are no repeated instance of an item
with in a type level list. For instance we want to have only
one ResBody
with in a Response type level list
UniqMembers '[] label = () | |
UniqMembers (a ': ts) label = (UniqMember a ts label, UniqMembers ts label) |
type family UniqMember (a :: k) (ts :: [k]) (label :: Symbol) :: Constraint where ... Source #
UniqMember a '[] label = () | |
UniqMember a (a ': ts) label = TypeError ((((Text "Type " :<>: ShowType a) :<>: Text "Should be unique with in the ") :<>: Text label) :<>: Text " type level list") | |
UniqMember a (b ': ts) label = UniqMember b ts label |
type family All (a :: k -> Constraint) (ts :: [k]) :: Constraint where ... Source #