caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Hugo Ferreira <hmf@inescporto.pt>
To: Zheng Li <li@pps.jussieu.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Re: Functional design for a basic simulation pipe.
Date: Thu, 11 Oct 2007 14:48:38 +0100	[thread overview]
Message-ID: <470E29B6.4060502@inescporto.pt> (raw)
In-Reply-To: <87fy0hvr15.fsf@pps.jussieu.fr>

Hello,

Zheng Li wrote:
> Hi,
> 
> Hugo Ferreira <hmf@inescporto.pt> writes:
>> My question is: how can one design and implement such a "pull pipe" and
>> solve the problem I have of propagating state back to a previous
>> function. If this is not possible functionally what other options do I
>> have? Better yet, what is the better way to implement such a system?
> 
> It seems that you want to program in a dataflow paradigm in OCaml. You don't
> have to use concurrent programming if you find it heavyweight, instead you
> should use stream (or lazy, or other sth alike) which is already provided by
> OCaml.
> 

Original idea was to use lazy data/functions and composition of
functions to do this. Issue is how to pass back a value so as to provide
feedback and alter the stream's output.

> Usually, you'll define a set of combinators include: map, dup, pipe, filter,
> until, combine/split, merge/switch etc to facile your work. 

Hmmm... these combinators seem to be well understood. Know of any
description (article, blog, etc) of these in a functional programming
setting?

> The only difficulty
> I can foresee is that OCaml only supports recursive value in a quite restrictive
> form. E.g. 
> 
>   let rec s = [<'1; s>]   or   let rec s1 = [<'1; s2>] and s2 = map f s1
> 
> is not directly supported. 

I see that recursion as shown above could be useful: one of the
outputs would simply be an input to another stream generator.

> One can make use of recursive function as
> workaround, but the semantics may not always identical.  However, if you have
> control over your data structure, 

This is the case.

> you can usually define your specific version
> of stream type, then this won't be a problem any more. 
> 
> In some dataflow languages I know, such kind of recursion is often represented
> through a special form -- "delay" which is provided as system primitive. If
> written in plain OCaml, the "delay" primitive won't be combinatorial as you
> want, so you have to require programmers to handle it specially. Fortunately,
> in most cases, a higer-level combinatorial form is usually sufficient, so that
> you can use it to hide the "delay" with sth like "recur".
> 

I (think) I see what you mean. Things seem to be coming together. What
you are saying is that I could use this "delay" so that only when the
value is available would it be "passed back" to the "stream generator"
thereby providing the "feedback" I need. In fact this "delay" is more
general and could be used to define various types of flows. Nice!

Assuming a standard definition of list, do you have any example of how
one would go about implementing this "delay"? I need to gives this some
thought.

> IIRC, OCaml was uses as the basis of some dataflow languages developed in
> french universities. Maybe they can give you more suggestions.
> 
> HTH.

It has.

Thanks.


  reply	other threads:[~2007-10-11 13:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-10  7:39 Hugo Ferreira
2007-10-10  8:34 ` [Caml-list] " skaller
2007-10-10 10:08   ` Hugo Ferreira
2007-10-10 10:31     ` Vincent Aravantinos
2007-10-10 10:56       ` Hugo Ferreira
2007-10-11 12:01         ` Pietro Abate
2007-10-11 13:52           ` Hugo Ferreira
2007-10-11 14:20             ` Pietro Abate
2007-10-10 15:00     ` skaller
2007-10-10 15:56       ` skaller
2007-10-11  6:57         ` Hugo Ferreira
2007-10-11  8:09           ` skaller
2007-10-11  9:54             ` Hugo Ferreira
2007-10-11 13:47               ` skaller
2007-10-11 11:17 ` Zheng Li
2007-10-11 13:48   ` Hugo Ferreira [this message]
2007-10-15 23:04     ` Zheng Li
2007-10-22  7:48       ` [Caml-list] " Hugo Ferreira

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=470E29B6.4060502@inescporto.pt \
    --to=hmf@inescporto.pt \
    --cc=caml-list@inria.fr \
    --cc=li@pps.jussieu.fr \
    /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).