From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id XAA09659; Sat, 27 Jul 2002 23:59:32 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id XAA09568 for caml-list@pauillac.inria.fr; Sat, 27 Jul 2002 23:59:32 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA02688 for ; Sat, 27 Jul 2002 12:53:07 +0200 (MET DST) Received: from corwin.mutu.net (mutu.net [80.65.226.162]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g6RAr6X06764 for ; Sat, 27 Jul 2002 12:53:06 +0200 (MET DST) Received: by corwin.mutu.net (Postfix, from userid 1000) id 4F42015902D; Sat, 27 Jul 2002 12:53:02 +0200 (CEST) To: caml-list@inria.fr Subject: Re: wanted features (was: Re: [Caml-list] Bigarray map & set/get (long)) References: <4.3.2.7.2.20020726154400.027ce640@mail.d6.com> <4.3.2.7.2.20020726153129.02ac9100@mail.d6.com> <4.3.2.7.2.20020725105657.024dbef0@mail.d6.com> <4.3.2.7.2.20020724194422.028aa970@mail.d6.com> <20020719.155940.19123621.Christophe.Troestler@umh.ac.be> <20020719.155940.19123621.Christophe.Troestler@umh.ac.be> <20020722113136.A10720@pauillac.inria.fr> <4.3.2.7.2.20020724194422.028aa970@mail.d6.com> <4.3.2.7.2.20020725105657.024dbef0@mail.d6.com> <4.3.2.7.2.20020726153129.02ac9100@mail.d6.com> <4.3.2.7.2.20020726154400.027ce640@mail.d6.com> <4.3.2.7.2.20020726173231.02b36ae0@mail.d6.com> X-face: '|!UPdE>Ot'L}nt?6Tf|'s{y%l~,+Yc5|p8A}ibew|_!vc48pPNPPx@7QA~$`$g=|yH*8sh9R]Xj1(CV7oUe>#/,t.(Z4F From: Dimitri Ara Date: 27 Jul 2002 12:53:02 +0200 In-Reply-To: <4.3.2.7.2.20020726173231.02b36ae0@mail.d6.com> Message-ID: <874relxx0x.fsf@corwin.mutu.net> User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Chris Hecker a écrit : > >I can't find a link to any papers by Okasaki on this subject. > > http://citeseer.nj.nec.com/okasaki98view.html One way to achieve okasaki goal is to provide in the module interface a lazy concrete_type_of_abstract_type. Thus, we could write Okasaki's example (page 15) this way: module type SEQUENCE = sig type 'a t val empty : 'a t val cons : 'a -> 'a t -> 'a t val append : 'a t -> 'a t -> 'a t val lazy_list_of_sequence : 'a t -> 'a Stream.t end module Sequence : SEQUENCE = struct type 'a t = Empty | Cons of 'a * 'a t | Append of 'a t * 'a t let empty = Empty let cons hd tl = Cons hd tl let append l1 l2 = Append l1 l2 let rec lazy_list_of_sequence = function | Empty -> [< >] | Cons a b -> [< 'a ; lazy_list_of_sequence b >] | Append a b -> [< lazy_list_of_sequence a; lazy_list_of_sequence b >] end open Sequence let length l = let rec length_aux = parser | [< 'hd ; tl >] -> 1 + length_aux tl | [< >] -> 0 in length_aux (lazy_list_of_sequence l) let l = append (cons 1 (cons 2 (cons 3 empty))) (cons 4 empty) in Printf.printf "%d\n" (length l) It's syntactically heavy (on an easy example...), it's not intellectually satisfying, it wastes memory, etc. but it works :-) Maybe some camlp4 syntactic sugar could do the trick. -- Selon les logs, il y a des pertes de porteuses, mais surtout des requêtes de déconnexion qui viennent de votre machine. Il faut se rappeler que windows 95 est un systeme bio-dégradable. -+- Support technique HOL in: Guide du Cabaliste Usenet - CQFD ! -+- ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners