From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 9CAB4BBAF for ; Thu, 24 Sep 2009 09:44:57 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjYCAOS/ukpV2gB4nGdsb2JhbACafwEBAQEBCAsICRO7GoQbBQ X-IronPort-AV: E=Sophos;i="4.44,444,1249250400"; d="scan'208";a="47175387" Received: from emailfrontal1.citycable.ch ([85.218.0.120]) by mail4-smtp-sop.national.inria.fr with SMTP; 24 Sep 2009 09:44:56 +0200 Received: from [130.223.248.40] (wlb-248-40.unil.ch [130.223.248.40]) (Authenticated sender: guillaume.yziquel@citycable.ch) by emailfrontal1.citycable.ch (Postfix) with ESMTPA id DE9EF12C276; Thu, 24 Sep 2009 09:44:46 +0200 (CEST) Message-ID: <4ABB2264.1090409@citycable.ch> Date: Thu, 24 Sep 2009 09:40:20 +0200 From: Guillaume Yziquel Reply-To: guillaume.yziquel@citycable.ch User-Agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103) MIME-Version: 1.0 To: =?UTF-8?B?RGFuaWVsIELDvG56bGk=?= Cc: caml-list@inria.fr Subject: React.E.switch issue. Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; guillaume:01 guillaume:01 chunks:01 parsed:01 parsed:01 parsing:01 behaviour:01 accu:02 accu:02 chunk:02 chunk:02 parse:02 output:02 string:02 string:02 Hello. Here is a piece of code that I am having issue. I'm trying to use React to parse reactively a server output. I have the following event definition: > let event_starting_at str = React.E.fold begin fun accu chunk -> accu^chunk end str received_event in > let to_be_parsed_event_of_event, set_to_be_parsed_event_of_event = React.E.create () in > let to_be_parsed_event = React.E.switch (event_starting_at "") to_be_parsed_event_of_event in > let reinitialise_with unparsed_text = set_to_be_parsed_event_of_event (event_starting_at unparsed_text) in String chunks from the server are received by the 'received_event' event, on the first line. My issue is that the 'reinitialise_with' function is called in a function 'phi' which is used in the following way: let message_event = React.E.map phi to_be_parsed_event. phi is the parsing function, so I'm not reproducing it directly here. However, you would have the behaviour described further below with the following code: let phi string_chunk = let new_string_chunk = String.copy string_chunk in reinitialise_with new_string_chunk; new_string_chunk This creates hiccups in the events. For example, at different time intervals, with to_be_parsed_event, I get: q qqw qqwwe qqwweer qqwweerrt etc... where I'd like in fact to have q qw qwe qwer qwert Advice would be appreciated on how to correct this. All the best, -- Guillaume Yziquel http://yziquel.homelinux.org/