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 OAA03529; Sat, 27 Jul 2002 14:06:11 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 OAA03568 for ; Sat, 27 Jul 2002 14:06:10 +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 g6RC69X07704 for ; Sat, 27 Jul 2002 14:06:09 +0200 (MET DST) Received: by corwin.mutu.net (Postfix, from userid 1000) id 41D8515902D; Sat, 27 Jul 2002 14:06:07 +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 14:06:06 +0200 In-Reply-To: <4.3.2.7.2.20020726173231.02b36ae0@mail.d6.com> Message-ID: <87sn25v0i9.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 a lazy concrete_type_of_abstract_type in the module interface. 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 as intellectually satisfying as views are, etc. but it works :-) Maybe some camlp4 syntactic sugar could do the trick. -- Dimitri Ara ------------------- 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