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
Modules within classes
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-09-13 (09:37)
From: Pietro Abate <Pietro.Abate@a...>
Subject: Re: [Caml-list] Modules within classes
On Wed, Sep 13, 2006 at 09:44:30AM +0200, Martin Hofmann wrote:
> Can someone explain what is wrong here and perhaps suggest a workaround? 

maybe you can try to encapsulate your class in a functor ? 
but I guess this doesn't  really solve your problem...

module Make(T : sig type a end) = struct
    class test ( l : T.a list) =
       method result =
         let module M =
            type t = T.a
            let compare x y =
              if x < y then -1 else if x > y then 1 else 0
        let module MSet = Set.Make(M)
        in  MSet.elements (List.fold_right MSet.add l MSet.empty)


++ Blog: http://blog.rsise.anu.edu.au/?q=pietro
++ "All great truths begin as blasphemies." -George Bernard Shaw
++ Please avoid sending me Word or PowerPoint attachments.
   See http://www.fsf.org/philosophy/no-word-attachments.html