caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Zheng Li <li@pps.jussieu.fr>
To: caml-list@inria.fr
Subject: Re: Functional design for a basic simulation pipe.
Date: Thu, 11 Oct 2007 13:17:58 +0200	[thread overview]
Message-ID: <87fy0hvr15.fsf@pps.jussieu.fr> (raw)
In-Reply-To: <470C8199.4080708@inescporto.pt>

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.

Usually, you'll define a set of combinators include: map, dup, pipe, filter,
until, combine/split, merge/switch etc to facile your work. 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. 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, 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".

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

HTH.

-- 
Zheng Li
http://www.pps.jussieu.fr/~li


  parent reply	other threads:[~2007-10-11 11:16 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 [this message]
2007-10-11 13:48   ` [Caml-list] " Hugo Ferreira
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=87fy0hvr15.fsf@pps.jussieu.fr \
    --to=li@pps.jussieu.fr \
    --cc=caml-list@inria.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).