Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

threading through Cstruct #9

Open
mor1 opened this issue Sep 21, 2013 · 1 comment
Open

threading through Cstruct #9

mor1 opened this issue Sep 21, 2013 · 1 comment

Comments

@mor1
Copy link

mor1 commented Sep 21, 2013

the Lwt_cstruct API seems incomplete now i try to start using it to write buffers out.

specifically, using this as a standard POSIX app albeit (hopefully) in a mirage compatible way, i want to write a Cstruct.t to a file.

i've used Lwt_unix to get me a file_descr Lwt.t, and i've extracted the file_descr from that so that i can Cstruct.write to it:

lwt fd = Lwt_unix.(openfile filename [O_RDWR; O_CREAT] 0o644) in
let _ = Lwt_cstruct.write fd buf in
fd

...except that i can't do that because i need to return an 'a Lwt.t, not an 'a (in this case, 'a is a file_descr).

but then how do i thread things back up so that i can pass the fd through Cstruct.fold somehow? or, as i suspect, do i need to extend Lwt_cstruct to have a fold method?

@avsm
Copy link
Member

avsm commented Sep 21, 2013

Right... the blocking versions do need a blocking fold too. That API could be abstracted a little more through a functor, but it's probably not worth it.

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

No branches or pull requests

2 participants