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.3 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 7E7E0BC69 for ; Fri, 19 Oct 2007 03:03:39 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAACefF0fLENaMnmdsb2JhbACOTgIBAQcEBhEYgSc X-IronPort-AV: E=Sophos;i="4.21,297,1188770400"; d="scan'208";a="18323388" Received: from ipmail01.adl2.internode.on.net ([203.16.214.140]) by mail4-smtp-sop.national.inria.fr with ESMTP; 19 Oct 2007 03:03:37 +0200 X-IronPort-AV: E=Sophos;i="4.21,297,1188743400"; d="scan'208";a="213831671" Received: from ppp121-44-36-108.lns10.syd7.internode.on.net (HELO [192.168.1.201]) ([121.44.36.108]) by ipmail01.adl2.internode.on.net with ESMTP; 19 Oct 2007 10:30:00 +0930 Subject: Re: [Caml-list] Help me find this pdf From: skaller To: Tom Cc: Jon Harrop , caml-list@yquem.inria.fr In-Reply-To: References: <200710181325.30668.jon@ffconsultancy.com> Content-Type: text/plain Date: Fri, 19 Oct 2007 10:59:59 +1000 Message-Id: <1192755599.13520.34.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.12.0 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; combinators:01 struct:01 2007,:98 sourceforge:01 sourceforge:01 wrote:01 terminate:01 caml-list:01 lazy:02 lazy:02 data:02 pattern:04 cons:04 stream:04 fix:05 > On 18/10/2007, skaller wrote: > > No, but Felix does it by default > > What do you mean? You mean that if I write a map > > map f [] = [] > map f x:xs = f x : map f xs > > I can apply it both to infinite and lazy lists? No, it means that when you write fun map[t] (f:t->u) (xs:list[t]) => ... it is indeterminate whether f and/or xs are evaluated before calling map (eager evaluation), or whether they're replaced by their arguments in the definition of map (lazy evaluation). If the list itself is given by a formula, this means the formula for the list may replace 'xs' in the map, and only be evaluated when required. In particular the list may be enumerated eagerly or lazily so it must be a list, not a stream, or your program may fail to terminate. In Felix a list is given by union list[t] = Empty | Cons of t * list[t]; and the combinators for | and * are eager, so all inductive data types in Felix are eager. Only function application has indeterminate timing. I'm not sure I can fix this because, for example, a product is just a C++ struct, and C++ operator. cannot be overloaded. However operator->() and operator *() can be overloaded, so it just might be possible to make pattern matching lazy. Thanks for asking this question .. forced me to think! -- John Skaller Felix, successor to C++: http://felix.sf.net