Lwt use with non-monadic XML library

Hi!
I’m using MirageOS and Xmlm to try and parse some XML data sent to the unikernel. I can receive the data but since Xmlm doesn’t accept monads and I’m having a hard time trying to get it to accept a valid function of type unit -> int.

I have a function which reads from the TCP flow and handles the option there. If there was data already in a buffer when the Xmlm library wants to extract the next int from this function then the function returns it, otherwise it calls read on the TCP flow in order to wait for the next part of the XML to be sent.

I’ve tried wrapping this up a few different ways to get the code to work but so far unsuccessfully.

Do you really need the streaming behaviour ?

Otherwise I think the simplest solution is to simply input the whole document as a string and parse the result. xmlm was designed a long time ago when I did not care about non-blocking IO. (These things will be easy to side-step with the current interface with algebraic effects, if they happen).

It will be part of an XMPP server so would be useful to have the streaming side of it, but I can always make do with just inputting strings.

Have you tried https://github.com/aantron/markup.ml for parsing XML?
It seems to support non-blocking streaming.

I ended up using this library actually. It has support for non-blocking streaming. It is error-correcting by default but you can make it strict parsing if needed (as I did).