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.1 required=5.0 tests=AWL,SPF_NEUTRAL 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 CA35FBBCB for ; Thu, 28 Feb 2008 00:32:32 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAABCBxUdA6bL7mGdsb2JhbACQaAEBAQEBBgQECQoYlSyHfA X-IronPort-AV: E=Sophos;i="4.25,416,1199660400"; d="scan'208";a="23134446" Received: from hs-out-0708.google.com ([64.233.178.251]) by mail4-smtp-sop.national.inria.fr with ESMTP; 28 Feb 2008 00:32:32 +0100 Received: by hs-out-0708.google.com with SMTP id h53so2361682hsh.11 for ; Wed, 27 Feb 2008 15:32:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=GLv7bKeU9OSkPGgHlMwl1EMc755yPH5TE6RjR/wTmVY=; b=A2EMbG2eltNK8OdeSHnPCDMUpC+eTKPRNE7pMPZYVl3ACbQr39pOCMBjhUWt2Rjjt3Dw7MgZ5g1WA26ErilMEcrTn9Gd9ZVpOwh+MjBzZlJ1xH4BsrpOaL42rQaPBsP5JnBX3BjtHCFGL74rmENKSnZF1+vQ2GTM3KqeA1i1AyM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=tk+lVeNMU8PCqKqgrdsKv4tGZn/ZvAUz7Yp1YumUnk+QEaBqQEbXbtKp2CyljZw3fOJre9hPJVTkOSOJOyCD1NeSHO6FBzi/K7v4rPRf96C7LbergdvoAuQfTrt+1zgsysV+J2TGCzGwQ8oy7bHBmqh2fzYRYthVO3Wpy1LhSXI= Received: by 10.100.195.15 with SMTP id s15mr4622059anf.56.1204155149570; Wed, 27 Feb 2008 15:32:29 -0800 (PST) Received: by 10.100.248.15 with HTTP; Wed, 27 Feb 2008 15:32:29 -0800 (PST) Message-ID: <6f9f8f4a0802271532w76e23340n67ebb6828dc3f904@mail.gmail.com> Date: Thu, 28 Feb 2008 00:32:29 +0100 From: "Loup Vaillant" To: "Dirk Thierbach" Subject: Re: [Caml-list] Unexpected restriction in "let rec" expressions Cc: caml-list@yquem.inria.fr In-Reply-To: <20080227164104.GA3176@feanor> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <6f9f8f4a0802260424o5bce2fd9i89fbfa38bb239a6a@mail.gmail.com> <47C524F3.9030005@fmf.uni-lj.si> <6f9f8f4a0802270143o68c58cbfh2ea059cda5c0a744@mail.gmail.com> <20080227120248.GA8000@feanor> <6f9f8f4a0802270604q5c144f26i27214fd738500a74@mail.gmail.com> <20080227164104.GA3176@feanor> X-Spam: no; 0.00; 0100,:01 inlining:01 recursive:01 lambda:01 recursive:01 trivial:01 factorial:01 wrote:01 rec:01 caml-list:01 precisely:01 int:01 int:01 lazy:02 expression:02 2008/2/27, Dirk Thierbach : > On Wed, Feb 27, 2008 at 03:04:03PM +0100, Loup Vaillant wrote: > > Yes, it does, but I have difficulties reducing this expression. > > Where is the problem? After reducing the call to loop and inlining f in the resulting expression, I couldn't reduce the recursive let anymore. I thought of replacing the let by a lambda expression, but since it is recursive, it can't be done (or at least it's not trivial). But this is not a problem anymore. > > Do you have another example which can be reduced to head normal form > > (say the result is an int instead of a list)? > > Not with ground types, but would the factorial function help? > > f (x,g) = (g x, g') where > g' 0 = 1 > g' y = y * g (y-1) > > *Main> [loop f x | x <- [0..10]] > [1,1,2,6,24,120,720,5040,40320,362880,3628800] Cool, this is exactly what I wanted, thanks. > BTW, lazy evaluation uses weak head normal form (WHNF), not head normal > form. This is precisely why I wanted the result type to be such that WHNF=>HNF. Int is such a type. List is not. Loup