caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Guillaume Yziquel <guillaume.yziquel@citycable.ch>
To: "Daniel Bünzli" <daniel.buenzli@erratique.ch>
Cc: caml-list@inria.fr
Subject: Re: React.E.switch issue.
Date: Thu, 24 Sep 2009 16:14:34 +0200	[thread overview]
Message-ID: <4ABB7ECA.7080105@citycable.ch> (raw)
In-Reply-To: <91a3da520909240642p1df60421k209e7ae16e9403ef@mail.gmail.com>

Daniel Bünzli a écrit :
>> 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.
> 
> Cannot really make sense out of your snippets of code.

What I want to do is the following:

The server sends events with chunks of string that I want to parse.

I accumulate the string chunks (with React.E.fold) until I can parse 
some server message out of it.

When some message is parsed, I discard this part of the event, and I 
install another "accumulating event" (accumulating with React.E.fold).

In order to discard and renew the "accumulating event", I send an event 
to the event of event. This is why I use the React.E.switch construct.

The output of React.E.switch is an event that can hold, for example the 
following sequence of values:

My fi
My first mes
My first message. My s

(Here is where the event of event is renewed:)

My s
My secon
My second mess

etc...

> However this phi functions seems to invoke a primitive event sending function

Yes. phi is the function that parses the messages from the server. So it 
has to send an event to renew the "accumulating event".

> and that's explicitely prohibited by the documentation. Primitive event
> sending/signal setting functions cannot be invoked as side effects
> inside update cycles (see doc of E.create/S.create).

OK. So this is not a bug, nor a feature.

> Not sure what you are trying to achieve but I suspect fixed point
> combinators (E.fix/S.fix) may help you to solve your problem.

I tried to look into this, but I did not see how they could help me with 
my specific issue.

> Best,
> 
> Daniel

For now, I'm using a workaround, but I'll try to see how I can make this 
clean...

Many thanks for your answer.

-- 
      Guillaume Yziquel
http://yziquel.homelinux.org/


  reply	other threads:[~2009-09-24 14:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-24  7:40 Guillaume Yziquel
2009-09-24  8:01 ` Guillaume Yziquel
2009-09-24 13:42 ` Daniel Bünzli
2009-09-24 14:14   ` Guillaume Yziquel [this message]
2009-09-28 11:57     ` Daniel Bünzli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ABB7ECA.7080105@citycable.ch \
    --to=guillaume.yziquel@citycable.ch \
    --cc=caml-list@inria.fr \
    --cc=daniel.buenzli@erratique.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).