English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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 caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners