Version française
Home     About     Download     Resources     Contact us    
Browse thread
records with polymorphic variants?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Eliot Handelman <eliot@g...>
Subject: Re: [Caml-list] Re: records with polymorphic variants?
Lukasz Stafiniak wrote:
> On 3/4/07, Zheng Li <li@pps.jussieu.fr> wrote:
>
> Yes, but the type f itself is not polymorphic, it is not [> f].
>>
>> I guess you want the follows
>>
>> # type 'a r = { x : 'a } constraint 'a = [> f]
>> type 'a r = { x : 'a; } constraint 'a = [> f ]
>> # {x = "test"}
>> Characters 6-12:
>>   { x = "test"};;
>>         ^^^^^^
>> This expression has type string but is here used with type [> f ]
>> # {x = `B "test"}
>> - : [> `A of int | `B of string ] r = {x = `B "test"}
>>
> Nice! I didn't realize this is possible. Thanks.

Just what I was looking for -- many thanks.

-- eliot