From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id B52617EEB3 for ; Wed, 23 Jan 2013 06:02:43 +0100 (CET) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of lambda.q.q@gmail.com) identity=pra; client-ip=209.85.215.50; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="lambda.q.q@gmail.com"; x-sender="lambda.q.q@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of lambda.q.q@gmail.com designates 209.85.215.50 as permitted sender) identity=mailfrom; client-ip=209.85.215.50; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="lambda.q.q@gmail.com"; x-sender="lambda.q.q@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-la0-f50.google.com) identity=helo; client-ip=209.85.215.50; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="lambda.q.q@gmail.com"; x-sender="postmaster@mail-la0-f50.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmUBAA1u/1DRVdcyjWdsb2JhbABEhX64KxYOAQEBAQkJCwkSBiOCTBMGATkDDQUmNAEkAQUBUIdsAw8Em0yCcI8vhRgnDYlPAQUMjgGDKQOIW40xjmg/gViCRA X-IronPort-AV: E=Sophos;i="4.84,520,1355094000"; d="scan'208";a="191201001" Received: from mail-la0-f50.google.com ([209.85.215.50]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 23 Jan 2013 06:02:43 +0100 Received: by mail-la0-f50.google.com with SMTP id ec20so4158897lab.9 for ; Tue, 22 Jan 2013 21:02:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:subject:date:message-id:mime-version :content-type; bh=m3juK9mu8APZfCUC2ORgwde+XW6PPYMXZ6PWjNoiF1s=; b=v0QFnCHMBVE89zx1mK03HnxgF9KCmyc0/PAn0lpHhfnppzkJAoD+3OxChNwC4IEqkN UWLxXCaLEmRI/ysV9N4yxfeN/qIg59jiua62vn5xAYoQpfZRkxNIBqmtoRQe8g+ej2E3 Y+KFWzKn6pZTqHZuoK5fGfmfhRRG+5xNIvkwV0Kd81oj0s9uVCkHdApJZK+2N1xSj24+ gV/DOSOBu+Yur6Efsyqcq5HKPmdTx43/23MRMGm8jN9UDoPV0OhfCeArY8IPz97vC+Rm vFtKf/4nGKiSaUmQ0vecqyOSe++HLvAiEwc5O/Se1SK+P33lLaYKC9O7ehi5EDDd5pCp vK4g== X-Received: by 10.152.46.12 with SMTP id r12mr52121lam.15.1358917362375; Tue, 22 Jan 2013 21:02:42 -0800 (PST) Received: from golf.niidar.ru.niidar.ru ([178.176.172.41]) by mx.google.com with ESMTPS id gu8sm1352178lab.6.2013.01.22.21.02.40 (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Tue, 22 Jan 2013 21:02:41 -0800 (PST) Sender: Ivan Gotovchits From: Ivan Gotovchits To: caml-list@inria.fr Date: Wed, 23 Jan 2013 09:02:34 +0400 Message-ID: <87pq0w4hlh.fsf@golf.niidar.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [Caml-list] Lwt idioms: iterating What is a best practice to implement a common iterative operations with Lwt? For example, I have a data structure incapsulating some collection. Interface of the structure includes some iterators, i.e. val iter (e -> unit) -> t -> unit Now, I would like to output each element of type e using one of the functions from Lwt_io module. I see two solutions and neither I like: 1. Use Buffer.t to accumulate text while iterating, then output it. 2. Use Lwt_stream.t for the same purpose. Both solutions a rather imperative and too ad-hoc (not scales to other iterators and tasks). Are there any idiomatic solutions for such common tasks in Lwt? -- (__) (oo) /------\/ / | || * /\---/\ ~~ ~~ ...."Have you mooed today?"...