Boris Yakobowski writes:
> On Tue, Dec 22, 2009 at 2:35 PM, Goswin von Brederlow
> wrote:
>> But the type inference should deduce that in
>>
>> (Obj.magic fn) x
>>
>> the 'a is actually 'b -> 'c as I am applying an argument to it.
>
> Sure, and it does. But it remains that the principal type of
On Tue, Dec 22, 2009 at 2:35 PM, Goswin von Brederlow wrote:
> But the type inference should deduce that in
>
> (Obj.magic fn) x
>
> the 'a is actually 'b -> 'c as I am applying an argument to it.
Sure, and it does. But it remains that the principal type of
(Obj.magic fn) is 'a, without any other
Boris Yakobowski writes:
> On Mon, Dec 21, 2009 at 2:44 PM, Goswin von Brederlow
> wrote:
>>> However it issues a warning so i acknowledge it's less elegant.
>>
>> Which I don't quite understand.
>
> The warning is based on the results of the type inference algorithm.
> You're not supposed to f
right, the use case is totally wrong
I'm automatically generating code from type declarations using camlp4 and it
would break down in presence of polymorphic record fields.
Here's the fix I chose (Thanks to Mr. Pouillard):
module type MagicSignature =
sig
val x : 'a
end
and I would replace eve
On Mon, Dec 21, 2009 at 2:44 PM, Goswin von Brederlow wrote:
>> However it issues a warning so i acknowledge it's less elegant.
>
> Which I don't quite understand.
The warning is based on the results of the type inference algorithm.
You're not supposed to find values of type 'a. 'a "in the wild",
"Damien Guichard" writes:
>> I once faced this situation and the solution is to use modules.
> That is one good practical solution.
>
> The simpler solution that immediatly came to my mind is eta-expansion.
>
> type foo = {bar : 'a. 'a -> 'a}
> let a : int -> int = fun x -> x
> let baz = {b
> I once faced this situation and the solution is to use modules.
That is one good practical solution.
The simpler solution that immediatly came to my mind is eta-expansion.
type foo = {bar : 'a. 'a -> 'a}
let a : int -> int = fun x -> x
let baz = {bar = fun x -> (Obj.magic a) x}
However i
Excerpts from Jacques Le Normand's message of Sun Dec 20 18:44:57 +0100 2009:
> Dear ocaml-list,
> the following code does not type check:
>
> type foo = {bar : 'a. 'a -> 'a}
> let a : int -> int = fun x -> x
> let baz = {bar = Obj.magic a}
>
> with the error
>
> Error: This field value has type
Dear ocaml-list,
the following code does not type check:
type foo = {bar : 'a. 'a -> 'a}
let a : int -> int = fun x -> x
let baz = {bar = Obj.magic a}
with the error
Error: This field value has type 'a -> 'a which is less general than
'b. 'b -> 'b
my question is: how could I use obj.m