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 45D13BBCA for ; Tue, 26 Feb 2008 15:04:52 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAACCrw0fAXQImh2dsb2JhbACQYwEBAQgKKZts X-IronPort-AV: E=Sophos;i="4.25,407,1199660400"; d="scan'208";a="23063009" Received: from discorde.inria.fr ([192.93.2.38]) by mail4-smtp-sop.national.inria.fr with ESMTP; 26 Feb 2008 15:04:51 +0100 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m1QE4pc6030730 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Tue, 26 Feb 2008 15:04:51 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAKaqw0eBrw8En2dsb2JhbACQYwEBAQEBBgQGCQgYm2g X-IronPort-AV: E=Sophos;i="4.25,407,1199660400"; d="scan'208";a="9610161" Received: from ext.lri.fr ([129.175.15.4]) by mail3-smtp-sop.national.inria.fr with ESMTP; 26 Feb 2008 15:04:50 +0100 Received: from localhost (localhost [127.0.0.1]) by ext.lri.fr (Postfix) with ESMTP id C1B48A43FD; Tue, 26 Feb 2008 15:04:50 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at lri.fr Received: from ext.lri.fr ([127.0.0.1]) by localhost (ext.lri.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id X95tjLqQGyc0; Tue, 26 Feb 2008 15:04:50 +0100 (CET) Received: from [82.249.22.208] (lns-bzn-57-82-249-22-208.adsl.proxad.net [82.249.22.208]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ext.lri.fr (Postfix) with ESMTP id 57A6EA4332; Tue, 26 Feb 2008 15:04:50 +0100 (CET) Message-ID: <47C41C7C.6010006@lri.fr> Date: Tue, 26 Feb 2008 15:04:44 +0100 From: =?ISO-8859-1?Q?Jean-Christophe_Filli=E2tre?= User-Agent: Thunderbird 1.5.0.14pre (X11/20071022) MIME-Version: 1.0 To: Loup Vaillant Cc: Caml List Subject: Re: [Caml-list] Unexpected restriction in "let rec" expressions References: <6f9f8f4a0802260424o5bce2fd9i89fbfa38bb239a6a@mail.gmail.com> In-Reply-To: <6f9f8f4a0802260424o5bce2fd9i89fbfa38bb239a6a@mail.gmail.com> X-Enigmail-Version: 0.94.2.0 OpenPGP: url=http://www.lri.fr/~filliatr/mykey.asc Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Miltered: at discorde with ID 47C41C83.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; filliatre:01 filliatre:01 lri:01 haskell:01 ocaml:01 rec':01 rec':01 ocaml:01 rec:01 rec:01 caml-list:01 right-hand:01 expression:02 argument:02 argument:02 Loup Vaillant a écrit : > I was trying to translate this simple Haskell definition in Ocaml: > > loop :: ((a,c) -> (b,c)) -> a -> b > loop f a = b > where (b,c) = f (a,c) > > However, the direct translation doesn't work: > > # let loop f a = > let rec (b, c) = f (a, c) in > b;; > Characters 25-31: > let rec (b, c) = f (a, c) in > ^^^^^^ > Only variables are allowed as left-hand side of `let rec' > > So I try to bypass this restriction: > > # let loop f a = > let rec couple = f (a, snd couple) in > fst couple;; > Characters 34-51: > let rec couple = f (a, snd couple) in > ^^^^^^^^^^^^^^^^^ > This kind of expression is not allowed as right-hand side of `let rec' > > > Any ideas about what is this restriction, an what is it for? Ocaml has call-by-value, and it cannot figure out a value to be passed as f's second argument. To be convinced, just imagine that the type of this argument is empty (an empty type can be introduced by "type empty" without definition, for instance). -- Jean-Christophe