From: Thorsten Ohl <ohl@hep.tu-darmstadt.de>
To: caml-list@inria.fr
Cc: Norman Ramsey <nr@eecs.harvard.edu>
Subject: help wanted with recursive types across module boundaries
Date: Fri, 11 Aug 2000 17:14:01 +0200 (CEST) [thread overview]
Message-ID: <14740.6201.936205.643362@heplix4.ikp.physik.tu-darmstadt.de> (raw)
In-Reply-To: <200008101713.NAA18938@labrador.eecs.harvard.edu>
> If I were writing Standard ML, I would attempt the following:
>
> module type ValueDist = sig
> include Dist
> type v' = V of dist Value.v
> sharing type v = v'
> end
AFAIK, there is no `sharing' keyword in O'Caml, but you should be able
to use the `with' operator instead:
module type Dist =
sig
type v
type dist
end
module Value =
struct
type name
type 'vdist v
= Int of int
| Record of (name * 'vdist v) list
| Function of ('vdist v -> 'vdist)
end
(* If the implementation were absent, one could not refer
to Dist.dist below. Strangely enough, placing Dist in
a separate dist.mli file (w/o a dist.ml) would work.
I've never understood the reason for this behavior ... *)
module Dist : Dist =
struct
type v
type dist
end
type vdv = V of Dist.dist Value.v
module type ValueDist =
sig
include Dist
type v' = vdv
end with type v = vdv
At least it compiles and if type equivalence is transitive, it should
do the right thing:
ohl@heplix4:~tmp$ ocamlc -i -c nr.ml
module type Dist = sig type v and dist end
module Value :
sig
type name
and 'a v =
Int of int
| Record of (name * 'a v) list
| Function of ('a v -> 'a)
end
module Dist : Dist
type vdv = V of Dist.dist Value.v
module type ValueDist = sig type v = vdv and dist and v' = vdv end
Cheers,
-Thorsten
--
Thorsten Ohl, Physics Department, TU Darmstadt -- ohl@hep.tu-darmstadt.de
http://heplix.ikp.physik.tu-darmstadt.de/~ohl/ [<=== PGP public key here]
prev parent reply other threads:[~2000-08-14 16:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-08-10 17:13 Norman Ramsey
2000-08-11 15:14 ` Thorsten Ohl [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=14740.6201.936205.643362@heplix4.ikp.physik.tu-darmstadt.de \
--to=ohl@hep.tu-darmstadt.de \
--cc=caml-list@inria.fr \
--cc=nr@eecs.harvard.edu \
/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