Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] troubles with polymorphic variant in class
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-06-14 (14:48)
From: nakata keiko <keiko@k...>
Subject: Re: [Caml-list] troubles with polymorphic variant in class
I hope this would be of some help.

module type Ct = sig type t end

module type Crec =
    module T : Ct
    class button : object method add_child : T.t -> unit end

module COt(Crec : Crec) = 
  struct type t = [`Whatever|`Button of Crec.button] 

module CO(Crec : Crec) =
    module T = COt(Crec)
    class button =
        val mutable children : T.t list = [`Whatever]
        method add_child x = children <- x::children
module rec X : (Crec with module T = COt(X)) = CO(X)

As I done, you can specify the type of elements of the list "children"
inside "COt".
The above code is taken from

with best regards.

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: