Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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) =
    object
       method result =
         let module M =
          struct
            type t = T.a
            let compare x y =
              if x < y then -1 else if x > y then 1 else 0
          end
      in
        let module MSet = Set.Make(M)
        in  MSet.elements (List.fold_right MSet.add l MSet.empty)
    end;;
end

:)
p

-- 
++ 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