* Defining a type and a module type recursively
@ 2010-08-28 8:30 Daniel Bünzli
2010-08-28 19:31 ` [Caml-list] " Kaustuv Chaudhuri
0 siblings, 1 reply; 2+ messages in thread
From: Daniel Bünzli @ 2010-08-28 8:30 UTC (permalink / raw)
To: caml-list
Hello,
I have now side stepped the issue but I wonder. Is it possible to
define a type and a module type recursively ?
E.g., something like
type 'a t = 'a * (module T)
and module type T = sig ... (* mentions 'a t somewhere *) ... end
Thanks,
Daniel
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] Defining a type and a module type recursively
2010-08-28 8:30 Defining a type and a module type recursively Daniel Bünzli
@ 2010-08-28 19:31 ` Kaustuv Chaudhuri
0 siblings, 0 replies; 2+ messages in thread
From: Kaustuv Chaudhuri @ 2010-08-28 19:31 UTC (permalink / raw)
To: caml-list
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-08-28 19:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-28 8:30 Defining a type and a module type recursively Daniel Bünzli
2010-08-28 19:31 ` [Caml-list] " Kaustuv Chaudhuri
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).