Version française
Home     About     Download     Resources     Contact us    
Browse thread
type troubles with functors
[ 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] type troubles with functors
what about 

module type OrderedType = sig
      type t
      val compare : t -> t -> int
end


module type S = sig
      type elt
      type t
      type set
      val to_list : t -> elt list
      val to_set : t -> set
end

module Make (Ord : OrderedType) : S = struct
        module EltSet = Set.Make(Ord)
        type elt = EltSet.elt
        type set = EltSet.t
        type t = { l : elt list; s : set }
        let to_list t = t.l
        let to_set t = t.s

end


I'm far to be an expert, but this (or something similar) should work.

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