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=1.0 required=5.0 tests=AWL,SPF_FAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 317DBBC6B for ; Thu, 11 Oct 2007 13:16:14 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAK2iDUfAXQImh2dsb2JhbACOSgEBAQgKKQ X-IronPort-AV: E=Sophos;i="4.21,259,1188770400"; d="scan'208";a="4351487" Received: from discorde.inria.fr ([192.93.2.38]) by mail3-smtp-sop.national.inria.fr with ESMTP; 11 Oct 2007 13:16:13 +0200 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l9BBGCaS005304 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 11 Oct 2007 13:16:13 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAK2iDUdQW+UCn2dsb2JhbACOSgEBAQEHBAYJCBg X-IronPort-AV: E=Sophos;i="4.21,259,1188770400"; d="scan'208";a="4351485" Received: from main.gmane.org (HELO ciao.gmane.org) ([80.91.229.2]) by mail3-smtp-sop.national.inria.fr with ESMTP; 11 Oct 2007 13:16:12 +0200 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Ifw1A-0001tt-5v for caml-list@inria.fr; Thu, 11 Oct 2007 11:15:52 +0000 Received: from ivr94-8-88-162-26-239.fbx.proxad.net ([88.162.26.239]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 11 Oct 2007 11:15:52 +0000 Received: from li by ivr94-8-88-162-26-239.fbx.proxad.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 11 Oct 2007 11:15:52 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Zheng Li Subject: Re: Functional design for a basic simulation pipe. Date: Thu, 11 Oct 2007 13:17:58 +0200 Message-ID: <87fy0hvr15.fsf@pps.jussieu.fr> References: <470C8199.4080708@inescporto.pt> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: ivr94-8-88-162-26-239.fbx.proxad.net User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux) Cancel-Lock: sha1:cQy+yjLFhhV6nhS7bctAcPgkZlk= Sender: news X-Miltered: at discorde with ID 470E05FD.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 ocaml:01 combinators:01 dup:01 recursive:01 restrictive:01 recursive:01 semantics:01 recursion:01 iirc:01 foresee:98 rec:01 rec:01 pps:01 pps:01 Hi, Hugo Ferreira 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