Version française
Home     About     Download     Resources     Contact us    
Browse thread
value restriction
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Le Normand <rathereasy@g...>
Subject: Re: value restriction
on another note (but staying very much on the same topic), why won't the
following generalize:

# let foo =
    let counter  = ref 0 in
    let bar = !counter  in
    let baz = fun x -> bar
    in
      baz


val foo : '_a -> int = <fun>


baz clearly has a polymorphic type, yet foo doesn't.
Is there any way around this ?

--Jacques L.

On Fri, Jan 1, 2010 at 6:05 PM, Jacques Le Normand <rathereasy@gmail.com>wrote:

> Hello caml-list,
> with respect to the value restriction, what exactly constitutes a value?
> the textbook definition doesn't seem to hold, since the following
> generalizes:
>
> let f = let x = 1 in fun g h x -> g (h x);;
>
> while this won't:
>
> let f () = let x = (fun x -> x) (fun x -> x) in fun g h x -> g (h x);;
>
> cheers
>
> --Jacques L.
>