From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: Nicolas Ojeda Bar <N.Ojeda.Bar@dpmms.cam.ac.uk>
Cc: caml-list <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] recursive types and modules problem
Date: Fri, 1 Nov 2013 08:43:03 +0900 [thread overview]
Message-ID: <98AF3DB4-B0DF-4958-9283-39E849520B29@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <D3CAEFBB-C3D5-4FCF-9291-25F380E33798@dpmms.cam.ac.uk>
2013/11/01 5:13、Nicolas Ojeda Bar <N.Ojeda.Bar@dpmms.cam.ac.uk> のメール:
> 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
> }
A slightly shorter version, using the fact that recursive modules containing only
types require no implementation:
module rec T : sig
type t1 = { stamp: int; x: t2 }
and t2 = { y: S.t }
end = T
and S : Set.S with type elt = T.t1 =
Set.Make
(struct open T type t = t1 let compare x1 x2 = x1.stamp - x2.stamp end)
Jacques Garrigue
prev parent reply other threads:[~2013-10-31 23:43 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
2013-10-31 23:43 ` Jacques Garrigue [this message]
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=98AF3DB4-B0DF-4958-9283-39E849520B29@math.nagoya-u.ac.jp \
--to=garrigue@math.nagoya-u.ac.jp \
--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