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=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id EBF34BC69 for ; Sat, 20 Oct 2007 01:17:34 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAM/XGEfUnw7Xnmdsb2JhbACCOIwcAQEBAQcEBik X-IronPort-AV: E=Sophos;i="4.21,302,1188770400"; d="scan'208";a="3370944" Received: from fhw-relay07.plus.net ([212.159.14.215]) by mail1-smtp-roc.national.inria.fr with ESMTP; 20 Oct 2007 01:17:34 +0200 Received: from [80.229.56.224] (helo=beast.local) by fhw-relay07.plus.net with esmtp (Exim) id 1Ij15y-0003Ri-57 for caml-list@yquem.inria.fr; Sat, 20 Oct 2007 00:17:34 +0100 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Help me find this pdf Date: Sat, 20 Oct 2007 00:09:06 +0100 User-Agent: KMail/1.9.7 References: <200710181818.31430.jon@ffconsultancy.com> <4718AA76.3010103@janestcapital.com> In-Reply-To: <4718AA76.3010103@janestcapital.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200710200009.06610.jon@ffconsultancy.com> X-Spam: no; 0.00; appending:01 haskell:01 syntax:01 non-trivial:01 compiler:01 ocaml's:01 compiler:01 camlp:01 frog:98 imho:01 wrote:01 rec:01 syntactic:01 syntactic:01 caml-list:01 On Friday 19 October 2007 14:00:38 you wrote: > Bad definition of a lazy list- the first element always has to be > forced. Using my definition from above: > > let rec f zlst = lazy ( > match Lazy.force zlst with > > | Empty -> Empty > | Cons (None, xs) -> Cons (None, f xs) > | Cons (Some x, xs) as t -> > > match Lazy.force xs with > > | Empty -> t > | Cons(None, ys) -> Cons(Some x, lazy (Cons(None, f ys))) > | Cons(Some y, ys) -> Cons (Some (x @ y), f ys) > > );; > > Not quite as pretty, I'll admit. Ugly as hell in the general case: you're basically stuck writing Lisp. > But it works. Sure. > And (modulo laziness around the options and appending) is the same as what > Haskell would do. Yes. > The only thing missing is some syntactic sugar to make the above pattern > matching nicer- I do not class pattern matching or laziness as "syntax". This would be non-trivial to implement. > computationally, the same values will need to be > forced. If you're arguing in favor of the syntactic sugar, I'm > sympathetic. If you're arguing that the compiler could somehow avoid > forcing the same values, I don't see how. OCaml's pattern match compiler could be productively extended to generate that code for you, IMHO. Implementing this as a camlp4 macro might be quite feasible... -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/products/?e