From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 3A5287FCCD for ; Wed, 13 Jul 2016 00:17:52 +0200 (CEST) IronPort-PHdr: 9a23:LvoZghKx/Lcdstx+/9mcpTZWNBhigK39O0sv0rFitYgVKvrxwZ3uMQTl6Ol3ixeRBMOAuqoC0Lud6vqocFdDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXsq3G/pQQfBg/4fVIsYL+kQsiJ3o/ujaibwN76W01wnj2zYLd/fl2djD76kY0ou7ZkMbs70RDTo3FFKKx8zGJsIk+PzV6nvp/jtLYqySlbuuog+shcSu26Ov1gFf0LRAghZkAy4sLhslHxTQKJ6TNIUncWmxxHWVmYxBv+WZD0uCbguax71TXMeYXdRLUwERCj9LsjHBThjSNCMz8i7EnWjNZxheRVukTyiQZ4xtvxYYWcMs1FYqrbetEXW2tKFpJUVihIBJigR4QKBusFe+1fqt+u9BM1sRKiCFz0V6vUwThSiyqzhPVi3g== Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=milanst@gmail.com; spf=Pass smtp.mailfrom=milanst@gmail.com; spf=None smtp.helo=postmaster@mail-io0-f178.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of milanst@gmail.com) identity=pra; client-ip=209.85.223.178; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="milanst@gmail.com"; x-sender="milanst@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of milanst@gmail.com designates 209.85.223.178 as permitted sender) identity=mailfrom; client-ip=209.85.223.178; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="milanst@gmail.com"; x-sender="milanst@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-io0-f178.google.com) identity=helo; client-ip=209.85.223.178; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="milanst@gmail.com"; x-sender="postmaster@mail-io0-f178.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BeAACEa4VXhrLfVdFchRAGpXqHT4s4gXmGGAKBLgc4FAEBAQEBAQEBEQEBAQgLCwkhL4IyBAESAYITAQUSEQQZARseAwwGBQQBBgMKKgICIgERAQUBHAYBEiKHcwEDF6NegTE+MYs7gWqCWgWFQQoZJw1Sg0wBAQEBAQEEAQEBAQEBARgCBhCGGoRNh0KCWgWZG45Ujy6OVRIegQ8eglCBcyAyiSUBAQE X-IPAS-Result: A0BeAACEa4VXhrLfVdFchRAGpXqHT4s4gXmGGAKBLgc4FAEBAQEBAQEBEQEBAQgLCwkhL4IyBAESAYITAQUSEQQZARseAwwGBQQBBgMKKgICIgERAQUBHAYBEiKHcwEDF6NegTE+MYs7gWqCWgWFQQoZJw1Sg0wBAQEBAQEEAQEBAQEBARgCBhCGGoRNh0KCWgWZG45Ujy6OVRIegQ8eglCBcyAyiSUBAQE X-IronPort-AV: E=Sophos;i="5.28,353,1464645600"; d="scan'208";a="226537766" Received: from mail-io0-f178.google.com ([209.85.223.178]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 13 Jul 2016 00:17:51 +0200 Received: by mail-io0-f178.google.com with SMTP id 38so29985288iol.0 for ; Tue, 12 Jul 2016 15:17:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to; bh=UQaHsH5mKNG8y9DoE5SbFWu4WveaGmFou9lytSaK2hs=; b=DbuFpbIQ/pAZ1asxUgjsgYrW5HWCStPv77Ax+ltoSWXws58p89GMApk40LqXGy6DMX cspdH2aHxtZrLY6XXw2/P8fHmYohga3LrHNPHLfrJh1yNWXbJzTGEyiWnJrqFU5FVdSS 7f7cUhfyirQ5MmIMsles2YuNp+qLZYXX/UmAG9mehbhMc8c+VbK9Rn12vudhJJelJUnz ug/1kPlLz31NJE1r4qEFehDGqBejhw869AzL48KLU7Rut3z7OhgKwmKQbI5qxe7RAR5i xyA7G0lNqQWO/emlXpvu9D108SRAiLg/d+PkROdasFwhmcEkifSrYDA2KzQQdZhDLafM VUAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to; bh=UQaHsH5mKNG8y9DoE5SbFWu4WveaGmFou9lytSaK2hs=; b=AiAVQI+VOobjUD2hX9rVC17VWK2vVvqYoxPKtXuMGw6D2IfLmySJu2yIwe0ovdqZ7+ rGhZGob+s3FiDuvQhleWtsNOcWAI2r0KP1JRtuqBT997oX1fye+CqehXQ7Ijpucygzsn 32FBn45GR5OCvUxj9BA3hyl1akKmZQxFtBcjiZcOXUz8agsf9Kkyjve5FfH/Djkbdths yV7kuawh5d1E5ObLptcD+5Vd55xKG/zm2CdROUPSaWIj5luy1BPkB4DY1GRmuMsMSjOl N/K1mfcQ5roMhajNdSiIahV34X5dV/5KbTMYwb4By/ZUUF11AstdJcbatQbZ1cHo86l7 Jd1w== X-Gm-Message-State: ALyK8tI//62NHWuzlbQ5tvQTBY0+FUdzdO6I9NRsW97SBT63dN+76vb24urFqHMYjdTcHRNipMt5InoUsQE4oQ== MIME-Version: 1.0 X-Received: by 10.107.198.147 with SMTP id w141mr5436413iof.146.1468361869963; Tue, 12 Jul 2016 15:17:49 -0700 (PDT) Received: by 10.79.77.137 with HTTP; Tue, 12 Jul 2016 15:17:49 -0700 (PDT) Received: by 10.79.77.137 with HTTP; Tue, 12 Jul 2016 15:17:49 -0700 (PDT) In-Reply-To: References: <5785631702290072003908A6_0_132218@p057> Date: Tue, 12 Jul 2016 18:17:49 -0400 Message-ID: From: =?UTF-8?Q?Milan_Stanojevi=C4=87?= To: Hongbo Zhang , Caml List Content-Type: multipart/alternative; boundary=94eb2c042c22a94488053777a304 Subject: Re: [Caml-list] question: restrictions on `let rec` --94eb2c042c22a94488053777a304 Content-Type: text/plain; charset=UTF-8 What are you trying to accomplish exactly? What type do you want fib to have? I usually use lazy and force to get around let rec limitations and that usually allows for only local uglyness, the lazy types usually don't escape. > > On Jul 12, 2016 5:37 PM, "Hongbo Zhang (BLOOMBERG/ 731 LEX)" < hzhang295@bloomberg.net> wrote: >> >> Hi all, >> I have a question simplified as below: >> >> let rec fib = fun x -> fib (x - 1);; >> val fib : int -> 'a = >> # let rec fib = (Obj.magic (fun x -> fib (x - 1)) : int -> 'a);; >> Characters 15-47: >> let rec fib = (Obj.magic (fun x -> fib (x - 1)) : int -> 'a);; >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> Error: This kind of expression is not allowed as right-hand side of `let rec' >> >> I know `fib` is a legal expression, is there any way to work around it? >> Thanks -- Hongbo --94eb2c042c22a94488053777a304 Content-Type: text/html; charset=UTF-8


What are you trying to accomplish exactly?
What type do you want fib to have?

I usually use lazy and force to get around let rec limitations and that usually allows for only local uglyness, the lazy types usually don't escape.
>
> On Jul 12, 2016 5:37 PM, "Hongbo Zhang (BLOOMBERG/ 731 LEX)" <hzhang295@bloomberg.net> wrote:
>>
>> Hi all,
>> I have a question simplified as below:
>>
>> let rec fib = fun x -> fib (x - 1);;
>> val fib : int -> 'a = <fun>
>> # let rec fib = (Obj.magic (fun x -> fib (x - 1)) : int -> 'a);;
>> Characters 15-47:
>> let rec fib = (Obj.magic (fun x -> fib (x - 1)) : int -> 'a);;
>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> Error: This kind of expression is not allowed as right-hand side of `let rec'
>>
>> I know `fib` is a legal expression, is there any way to work around it?
>> Thanks -- Hongbo

--94eb2c042c22a94488053777a304--