Skip to content

wsproxy: code removal and stylistic changes#7099

Open
contificate wants to merge 4 commits into
xapi-project:masterfrom
contificate:cbarr/modernise
Open

wsproxy: code removal and stylistic changes#7099
contificate wants to merge 4 commits into
xapi-project:masterfrom
contificate:cbarr/modernise

Conversation

@contificate
Copy link
Copy Markdown
Contributor

Removes some unused combinators from wsproxy and adds some stylistic changes (mostly preferring let-operators over infix monadic bind >>=). These are just some changes I made when learning the iteratee style used in wslib/wsproxy.


In future, we may rewrite wsproxy so as to remove the iteratee style (as it's not convenient for other websocket use cases, like a websocket server in full generality).

Comment thread ocaml/wsproxy/src/iteratees.ml Outdated
Signed-off-by: Colin James <colin.barr@vates.tech>
Signed-off-by: Colin James <colin.barr@vates.tech>
Signed-off-by: Colin James <colin.barr@vates.tech>
- Removes the enumeratee type abbreviation, as it's less terse than
  spelling out the iteratee transformer function type ('a t -> 'a t t).
- Removes unused combinators from iteratees, such as "apply". The use
  case for this is largely subsumed by writing effectful enumeratees,
  such as the extant "stream_printer" adapter.
- Removes "extract_result_from_iteratee". This is unused but, in
  general, it should have been partial, casing on the iteratee after
  sending EOF to it (as the equivalent "run" function does in the
  original iteratee resources).

Signed-off-by: Colin James <colin.barr@vates.tech>
k stream
| x ->
IO.return (x, stream)
return (x, stream)
Copy link
Copy Markdown
Member

@minglumlu minglumlu May 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to keep this in mind: in the continuation k, the return is always IO.return; while in f, it is Iteratee.return.

IE_cont (None, step n k)
| IE_cont (Some _, _) | IE_done _ ->
bind (drop n) (fun () -> return s)
function
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is neater. But to be honest, fun s -> makes me think more quickly this is a continuation. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants