Browse thread
Oddness with recursive polymorphic variants
-
Jeremy Yallop
-
luc.maranget@i...
- Michael Wohlwend
-
brogoff
-
Jeremy Yallop
-
brogoff
- luc.maranget@i...
-
brogoff
-
Jeremy Yallop
-
luc.maranget@i...
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ 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