From: "\"Márk S. Zoltán\"" <zoltan.s.mark@dravanet.hu>
To: Caml Mailing List <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Type visibility limitation in recursive modules
Date: Sun, 23 Dec 2007 19:00:27 +0100 [thread overview]
Message-ID: <476EA23B.3020001@dravanet.hu> (raw)
In-Reply-To: <200712231220.56613.peng.zang@gmail.com>
Peng Zang wrote:
> I do not know if this is the intended behavior. It may very well be.
> However, it appears we can easily work around this by simply abstracting the
> type later. Eg.
>
> module rec Aleph :
> sig
> type t = Tag of Beth.t
> end =
> struct
> type t = Tag of Beth.t
> end
> and Beth :
> sig
> type t = Aleph.t list
> val scandalous : Aleph.t
> end =
> struct
> type t = Aleph.t list
> let scandalous = Aleph.Tag((* HERE BE DRAGONS *) [])
> end
>
> module Beth = (Beth:sig type t val scandalous : Aleph.t end)
>
>
> # Beth.scandalous;;
> - - : Aleph.t = Aleph.Tag []
> # Aleph.Tag [];;
> - - : Aleph.t = Aleph.Tag []
> # (Aleph.Tag []) = Beth.scandalous;;
> - - : bool = true
>
> Happy Holidays,
>
> Peng
>
>
Agreed, this does work for the code on the outside, but I wanted to hide
the actual gory details of Beth.t from the implementation of Aleph too.
The real-life Aleph contains a huge mess of inherited code (inherited
from myself, but I wrote it years ago), plus some serious potential for
quasi-macaronic growth. I wanted to make sure that none of that code
makes assumptions about Beth.t, because the choice of Beth.t could
easily have serious performance implications, and I would like to
isolate the rest of the code from the impact of Beth.t turning overnight
into an Aleph.t array or worse. That can only be done if the
implementation of Beth is the only place where the details of Beth.t are
known.
This is not exactly a showstopper issue for me, though. The reason I
posted it was that (1) I suspect this is a bug (more likely a design
bug, not an implementation one), and I like finding bugs, or (2) this is
a pointer into something I really should understand about modules, and
with any help I will understand it soon, as more replies come in.
Happy Holidays,
Z-
next prev parent reply other threads:[~2007-12-23 18:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-23 14:24 "Márk S. Zoltán"
2007-12-23 17:20 ` [Caml-list] " Peng Zang
2007-12-23 18:00 ` "Márk S. Zoltán" [this message]
2007-12-24 11:44 ` "Márk S. Zoltán"
2007-12-27 23:13 ` "Márk S. Zoltán"
2007-12-28 10:02 ` Keiko Nakata
2007-12-28 12:46 ` "Márk S. Zoltán"
2007-12-28 13:42 ` Keiko Nakata
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=476EA23B.3020001@dravanet.hu \
--to=zoltan.s.mark@dravanet.hu \
--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