0 | module HTTP.API.Client.Interface
2 | import public HTTP.API
3 | import public HTTP.API.Client.Request
8 | interface Receive (0 a : Type) where
11 | 0 RecConstraint : a -> Type
15 | 0 RecTypes : a -> List Type
20 | recs : (v : a) -> TList (RecTypes v)
24 | -> {auto con : RecConstraint v}
25 | -> HList (RecTypes v)
30 | Receive ReqEnv where
31 | RecConstraint _ = ()
34 | adjRequest _ _ r = r
37 | interface GetResponse (0 a : Type) where
38 | 0 RespEncodings : a -> List Type
39 | 0 RespTypes : a -> List Type
46 | 0 AllRespTypes : All GetResponse ts => (endpoint : HList ts) -> List Type
47 | AllRespTypes @{[]} [] = []
48 | AllRespTypes @{_::_} (v::vs) = RespTypes v ++ AllRespTypes vs
51 | 0 AllRespEncodings : All GetResponse ts => (endpoint : HList ts) -> List Type
52 | AllRespEncodings @{[]} [] = []
53 | AllRespEncodings @{_::_} (v::vs) = RespEncodings v ++ AllRespEncodings vs
58 | 0 AllRecTypes : All Receive ts => (endpoint : HList ts) -> List Type
59 | AllRecTypes @{[]} [] = []
60 | AllRecTypes @{_::_} (v::vs) = RecTypes v ++ AllRecTypes vs
65 | 0 AllRecConstraints : All Receive ts => (endpoint : HList ts) -> List Type
66 | AllRecConstraints @{[]} [] = []
67 | AllRecConstraints @{_::_} (v::vs) = RecConstraint v :: AllRecConstraints vs
71 | (endpoint : HList ts)
72 | -> {auto all : All Receive ts}
73 | -> {auto cons : HList (AllRecConstraints endpoint)}
74 | -> HList (AllRecTypes endpoint)
77 | endpointRequest [] _ r = r
78 | endpointRequest (v::vs) @{_::_} @{_::_} hl r =
79 | let (ts,rem) := splitHList (recs v) hl
80 | in endpointRequest vs rem (adjRequest v ts r)