caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] question: restrictions on `let rec`
@ 2016-07-12 21:37 Hongbo Zhang (BLOOMBERG/ 731 LEX)
       [not found] ` <CAKR7PS-2wF19FXo0Qo=x1SM-cuMDUpS-333d10fJzzDBR8XoTg@mail.gmail.com>
  2016-07-14  9:07 ` Goswin von Brederlow
  0 siblings, 2 replies; 4+ messages in thread
From: Hongbo Zhang (BLOOMBERG/ 731 LEX) @ 2016-07-12 21:37 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 1168 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 1683 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: [Caml-list] question: restrictions on `let rec`
@ 2016-07-13 13:56 Hongbo Zhang (BLOOMBERG/ 731 LEX)
  0 siblings, 0 replies; 4+ messages in thread
From: Hongbo Zhang (BLOOMBERG/ 731 LEX) @ 2016-07-13 13:56 UTC (permalink / raw)
  To: caml-list, milanst

[-- Attachment #1: Type: text/plain, Size: 1058 bytes --]

Hi , I found another work around, thanks for your suggestion!

From: milanst@gmail.com At: 07/12/16 18:18:08
To: Hongbo Zhang (BLOOMBERG/ 731 LEX), caml-list@inria.fr
Subject: Re: [Caml-list] question: restrictions on `let rec`


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


[-- Attachment #2: Type: text/html, Size: 2685 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-07-14  9:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-12 21:37 [Caml-list] question: restrictions on `let rec` Hongbo Zhang (BLOOMBERG/ 731 LEX)
     [not found] ` <CAKR7PS-2wF19FXo0Qo=x1SM-cuMDUpS-333d10fJzzDBR8XoTg@mail.gmail.com>
     [not found]   ` <CAKR7PS94hePcfyMUKGq0wH-VUZQYdu=hN2jcCXD9z3jcFSwHiw@mail.gmail.com>
     [not found]     ` <CAKR7PS_0=p9mLSVo0vE0YN=DDH4PhCoHboEE_1NWPAf+opq_jg@mail.gmail.com>
2016-07-12 22:17       ` Milan Stanojević
2016-07-14  9:07 ` Goswin von Brederlow
2016-07-13 13:56 Hongbo Zhang (BLOOMBERG/ 731 LEX)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).