You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The res type in Conn is implicitly Type -> Type despite its declaration not showing that.
moduleHyper.Connwhere--| A `Conn` models the entirety of an HTTP connection, containing the fields--| `request`, `response`, and the extensibility point `components`.typeConnreqrescomponents={request::req
, response::res-- (res :: Type -> Type)
, components::components}
This isn't immediately clear to the end-reader (unless one reads through the source code or potentially the docs). Moreover, the lack of using a kind here also allows one to use other non-ResponseState types here (e.g. res Int rather than res StatusLineOpen).
I propose we instead define a kind and more clearly indicate that. When I worked on implementing this, I found that the code is easier if the Conn type also has a type parameter for the responseState that it applies to res in its definition. In other words...
moduleHyper.Connwhere--| Defines the states of an HTTP request stream. It tracks whether or not--| some content has already been written to an HTTP request stream.--|--| Proper order of computations. Items marked with an asterisk indicate that--| transitioning back to the same state is valid:--| StatusLineOpen -> HeadersOpen* -> BodyOpen* -> ResponseEndedforeignimportkindResponseState--| Type indicating that the status-line is ready to be--| sent.foreignimportdataStatusLineOpen:: ResponseState
--| Type indicating that headers are ready to be--| sent, i.e. the body streaming has not been started.foreignimportdataHeadersOpen:: ResponseState
--| Type indicating that headers have already been--| sent, and that the body is currently streaming.foreignimportdataBodyOpen:: ResponseState
--| Type indicating that headers have already been--| sent, and that the body stream, and thus the response,--| is finished.foreignimportdataResponseEnded:: ResponseState
--| A `Conn` models the entirety of an HTTP connection, containing the fields--| `request`, `response`, and the extensibility point `components`.typeConnrequestresponsecomponents (responseState :: ResponseState) ={request::request
, response::responseresponseState
, components::components}-- now the `ResponseTransition` type alias is defined like so:--| A middleware transitioning from one `Response` state to another.typeResponseStateTransitionm (res :: ResponseState->Type) (from :: ResponseState) (to :: ResponseState) =forallreqcomp.
Middlewarem
(Connreqrescompfrom)
(Connreqrescompto)
Unit
The text was updated successfully, but these errors were encountered:
The
res
type inConn
is implicitlyType -> Type
despite its declaration not showing that.This isn't immediately clear to the end-reader (unless one reads through the source code or potentially the docs). Moreover, the lack of using a kind here also allows one to use other non-ResponseState types here (e.g.
res Int
rather thanres StatusLineOpen
).I propose we instead define a kind and more clearly indicate that. When I worked on implementing this, I found that the code is easier if the
Conn
type also has a type parameter for theresponseState
that it applies tores
in its definition. In other words...The text was updated successfully, but these errors were encountered: