Browse thread
Oddness with recursive polymorphic variants
-
Jeremy Yallop
-
luc.maranget@i...
- Michael Wohlwend
- brogoff
-
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: | Michael Wohlwend <micha-1@f...> |
| Subject: | Re: [Caml-list] Oddness with recursive polymorphic variants |
On Thursday 04 May 2006 19:10, Luc Maranget wrote: > > I have two polymorphic variant types, as follows: > > > > type f = [`A | `B of f] > > type g = [f | `C] > > > > Next, I have a function from f to g: > > > > let s1 : f -> g = function > > > > | `A -> `A > > | `B b -> b > > > > Sadly, the compiler rejects this: > > > > Characters 57-58: > > | `B b -> b;; > > that may be too complicated, but it works :-) type 'a f = [`A | `B of 'a];; type 'a g = ['a f | `C];; let s1 (p : 'a f) : 'a g = match p with `A -> `A | `B b -> b;; # s1 (`B (`B `A));; - : 'a g as 'a = `B `A Michael -- C offers you enough rope to hang yourself. C++ offers a fully equipped firing squad, a last cigarette and a blindfold.