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=none 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 EC803BBCA for ; Tue, 26 Feb 2008 15:51:55 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAOe1w0fVujhf/2dsb2JhbACtMQ X-IronPort-AV: E=Sophos;i="4.25,407,1199660400"; d="asc'?scan'208";a="23065482" Received: from witko.kerneis.info ([213.186.56.95]) by mail4-smtp-sop.national.inria.fr with ESMTP; 26 Feb 2008 15:51:55 +0100 Received: from [2001:660:3301:8061:216:41ff:fe10:7097] (helo=tatanka.kerneis.info) by witko.kerneis.info with esmtpsa (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1JU19v-00069n-2x for caml-list@yquem.inria.fr; Tue, 26 Feb 2008 15:51:55 +0100 Received: from localhost ([127.0.0.1] helo=tatanka.kerneis.info) by tatanka.kerneis.info with esmtp (Exim 4.69) (envelope-from ) id 1JU19u-0003xu-QW for caml-list@yquem.inria.fr; Tue, 26 Feb 2008 15:51:54 +0100 Date: Tue, 26 Feb 2008 15:51:39 +0100 From: Gabriel Kerneis To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Unexpected restriction in "let rec" expressions Message-ID: <20080226155139.49dbf70b@tatanka.kerneis.info> In-Reply-To: <6f9f8f4a0802260634j133a6b5fl1868c6886f308c1b@mail.gmail.com> References: <6f9f8f4a0802260424o5bce2fd9i89fbfa38bb239a6a@mail.gmail.com> <958FA43C-037A-47D3-9352-682443875A69@inria.fr> <6f9f8f4a0802260634j133a6b5fl1868c6886f308c1b@mail.gmail.com> Organization: ENST X-Mailer: Claws Mail 3.3.1 (GTK+ 2.12.8; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/htoVmUuc/wFA2Dn7Xf4sVlz"; protocol="application/pgp-signature"; micalg=PGP-SHA1 X-SA-Exim-Connect-IP: 2001:660:3301:8061:216:41ff:fe10:7097 X-SA-Exim-Mail-From: kerneis@enst.fr X-SA-Exim-Scanned: No (on witko.kerneis.info); SAEximRunCond expanded to false X-Spam: no; 0.00; 0100,:01 val:01 fixpoint:01 val:01 recursion:01 haskell:01 stack:01 rec:01 rec:01 caml-list:01 ghc:01 lazy:02 modules:02 caml:02 compiling:02 X-Attachments: type="application/pgp-signature" name="signature.asc" name="signature.asc" --Sig_/htoVmUuc/wFA2Dn7Xf4sVlz Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Le Tue, 26 Feb 2008 15:34:37 +0100, "Loup Vaillant" a =E9crit : > # let loop f a =3D > let rec couple () =3D f (a, snd (couple ())) in > fst (couple ());; > val loop : ('a * 'b -> 'c * 'b) -> 'a -> 'c =3D >=20 > Now, I have yet to figure out the purpose of this so called "fixpoint > operator" (and if the above will work at all :-). No, it won't: Objective Caml version 3.10.1 # let loop f a =3D let rec couple () =3D f (a, snd (couple ())) in fst (couple ());; val loop : ('a * 'b -> 'c * 'b) -> 'a -> 'c =3D # loop (fun x -> x) 1 ;; Stack overflow during evaluation (looping recursion?). Whereas: GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. Prelude> :load test [1 of 1] Compiling Main ( test.hs, interpreted ) Ok, modules loaded: Main. *Main> loop id 1 1 You could (maybe) get it using the Lazy module. Regards, --=20 Gabriel Kerneis --Sig_/htoVmUuc/wFA2Dn7Xf4sVlz Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFHxCeK6a2JmXQu5bYRAjQKAJ9upl9Z/jxIxENaBGPqchUWnCOesACgl0j0 f8emLNZ79n+BkYerIdrb1bg= =CUCb -----END PGP SIGNATURE----- --Sig_/htoVmUuc/wFA2Dn7Xf4sVlz--