Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Wojciech Meyer <wojciech.meyer@gmail.com>
To: Nicolas Ojeda Bar <N.Ojeda.Bar@dpmms.cam.ac.uk>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] recursive types and modules problem
Date: Thu, 31 Oct 2013 21:27:52 +0000	[thread overview]
Message-ID: <87r4b16sh3.fsf@gmail.com> (raw)
In-Reply-To: <D3CAEFBB-C3D5-4FCF-9291-25F380E33798@dpmms.cam.ac.uk> (Nicolas Ojeda Bar's message of "Thu, 31 Oct 2013 20:13:24 +0000")


Nicolas Ojeda Bar <N.Ojeda.Bar@dpmms.cam.ac.uk> writes:
> What is the best way to rewrite the following recursive definitions so that
> I can actually compile them?
>
> S = Set.Make (struct type t = t1 let compare x1 x2 = x1.stamp - x2.stamp end)
>
> type t1 = {
>   stamp : int;
>   x : t2
> }
>
> and t2 = {
>   y : S.t
> }

You just need to wrap it to recursive modules:

>>>>
module rec Foo : sig module Baz : sig type t1 end module S : sig type t end end  = struct

  module Baz = struct
    type t1 = {
      stamp : int;
      x : Bar.t2
    }
    type t = t1
 let compare x1 x2 = x1.stamp - x2.stamp  end

  module S = Set.Make(Baz)

end and Bar : sig type t2 end = struct

  type t2 = {
    y : Foo.S.t
  }

end
<<<<

--
Wojciech

  reply	other threads:[~2013-10-31 21:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-31 20:13 Nicolas Ojeda Bar
2013-10-31 21:27 ` Wojciech Meyer [this message]
2013-10-31 23:43 ` Jacques Garrigue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r4b16sh3.fsf@gmail.com \
    --to=wojciech.meyer@gmail.com \
    --cc=N.Ojeda.Bar@dpmms.cam.ac.uk \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox