lwt
lwt copied to clipboard
Lwt.npick and Lwt.nchoose return type
I feel since both npick and nchoose return at least one fulfilled promise, the return type must reflect this propery. Current signature:
val npick : 'a t list -> 'a list t
proposed signature:
val npick : 'a t list -> ('a * 'a list) t
Or maybe it can be separate functions not to break compatibility.
It'd probably need to be a separate function for backwards compatibility.
It'd also need to be a different function to allow for the convenience of getting the results in a conveniently typed container. Specifically, it's currently possible to do things such as npick ps >>= List.iter_p h
which wouldn't work with a tuple-ised non-empty list.
It'd also need to be a different function to allow for the convenience of getting the results in a conveniently typed container. Specifically, it's currently possible to do things such as
npick ps >>= List.iter_p h
which wouldn't work with a tuple-ised non-empty list.
Indeed, this is a drawback of using a pair. I suggest not to add this function to Lwt itself, as it adds more API noise for something that is situationally useful (even if in some sense more correct). I suggest to just recommend creating a wrapper that does this, I guess with an ugly assert false
hidden inside it.