Repository navigation
Make Lwt_seq.of_list lazier, Lwt_seq.to_list tail recursive - #1019
Conversation
|
Thanks! I think there's one regression: if the first call to In practice this is probably not too big a deal because the the exception is caught if the call is on the right-on-side of a bind (or inside another closure/lambda). But for now I'd rather we keep this. Can you add a call to |
Hi, thanks for reviewing my PR! |
Ah you're right! I missed this because it's not in the same "shape" as some of the other functions where the recursive function is inlined and the first call has an extra apply. I think it's all good to go then. |
|
Thanks for the contribution! |
Thank you for your time reviewing it and for Lwt! All the best. |
This PR makes a couple of small changes to make
Lwt_seq.to_listandLwt_seq.of_listwork better with large lists.of_list: current version builds a large term eagerly and can fail with a stack overflow or segmentation fault for large lists. This lazier version defers the creation ofLwt_seq.nodeterms until they are needed.to_list: current version is not tail recursive and can fail with long sequences. This tail recursive version (using a difference list accumulator) seems able to handle longer sequences.