Alain Frisch
Thu, 22 May 2008 23:19:11 -0700
Fabrice Marchant wrote:
Hi ! Apologize. This topic isnt't exactly at its right place : belongs to Beginners-list. However no answer about this question there and so much clever people here, a denser traffic... Please how to define recursive modules that are parametrized by an OrderedType ? Say these modules types are Mod and ModSet. (Because a function f in module Mod uses a Set of Mod) The problem is I need recursive functors that returns 2 modules.
I'm not sure to understand. Maybe a functor that returns a pair of mutually recursive modules is what you want.
module F(X : Set.OrderedType) = struct
module rec Mod : sig
type t = X of int * ModSet.t
val compare: t -> t -> int
val of_list: t list -> t
end
=
struct
type t = X of int * ModSet.t
let compare (X (i, _)) (X (j, _)) = compare i j
let of_list i l = X (i, List.fold_right ModSet.add l ModSet.empty)
end
and ModSet : Set.S with type elt = Mod.t = Set.Make(Mod)
end
-- 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