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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: luc.maranget@i...
Subject: Re: [Caml-list] Oddness with recursive polymorphic variants

> > I'd like to understand why it behaves differently from the following:
> >
> >     let k (x:f) = (x:g)
> 
> Right, others have shown that you can do what you want with a coercion. The
> problem is that you are using exact types ("[" rather than "[>" ) and there
> is a mismatch of exact types. ":" is not a coercion, it just tells the type
> that should be there. ":>" coerces. x is not of type g, but it can be coerced to
> g.
> 

Indeed,

# let kk (x:f) = (x :> g);;
val kk : f -> g = <fun>

Thanks,

--Luc