On 05/19/2010 02:24 PM, Christophe Raffalli wrote:
Does anyone see a way to avoid it

I propose:


module rec T : sig
  type t = U.t
  val compare : t -> t -> int
end = struct
  include U

  let compare u v = match u, v with
    Leaf, Leaf -> 0
  | Node u', Node v' -> S.compare u' v'
  | Leaf, Node _ -> -1
  | Node _, Leaf -> 1
end

and S : Set.S with type elt = T.t = Set.Make(T)

and U : sig
  type t =
    Node of S.t
  | Leaf
end = U


The type definition is given only once.


-- Alain

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to