[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Kaustuv Chaudhuri <kaustuv.chaudhuri@i...> |
| Subject: | Re: [Caml-list] Defining a type and a module type recursively |
On Sat, Aug 28, 2010 at 10:30 AM, Daniel Bünzli
<daniel.buenzli@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