Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Mixed class / type
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Remi VANICAT <vanicat@l...>
Subject: Re: [Caml-list] Mixed class / type
"Warp" <warplayer@free.fr> writes:

> Hello,
> 
> I got this problem :
> - two classes called wmenu and wmenuitem, are mutaly recursive
> - one wmenuitem can be constructed either with a wmenu or with a wmenuitem
> 
> so I need a type like this :
> 
> type menu =
>     Mainmenu of wmenu
>     | Menuitem of wmenuitem
> 
> So I tryied :
> 
> type menu = .....
> and
>     class wmenuitem : menu -> object ... end
> and
>     class wmenu : object ... end
> 
> But it doesn't work.
> Any clue is welcomed.

This problem already have been answer. :

type ('a, 'b) menu_t =
     Mainmenu of 'a 
   | Menuitem of 'b

class wmenuitem : (wmenuitem, wmenu) menu_t -> object .... end
and wmenu : object ... end

type menu = (wmenuitem, wmenu) menu_t

-- 
Rémi Vanicat
vanicat@labri.u-bordeaux.fr
http://dept-info.labri.u-bordeaux.fr/~vanicat
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr