On Sat, Aug 28, 2010 at 10:30 AM, Daniel Bünzli
<daniel.buen...@erratique.ch> wrote:
> Is it possible to define a type and a module type recursively ?

Technically, you can use recusive modules to encode all kinds of
recursive type definitions. Here, for example, is your case:

    module rec M : sig
      type 'a t = 'a * (module N.T)
    end = struct
      type 'a t = 'a * (module N.T)
    end

    and N : sig
      module type T = sig
        type s = S of int M.t
      end
    end = struct
      module type T = sig
        type s = S of int M.t
      end
    end

    type 'a t = 'a M.t
    module type T = N.T

It's pretty ugly. Please only use such patterns if you have solid
reasons not to go with something simpler.

-- Kaustuv

_______________________________________________
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