From: Peng Zang <peng.zang@gmail.com>
To: caml-list@yquem.inria.fr
Cc: "Márk S. Zoltán" <zoltan.s.mark@dravanet.hu>
Subject: Re: [Caml-list] Type visibility limitation in recursive modules
Date: Sun, 23 Dec 2007 12:20:54 -0500 [thread overview]
Message-ID: <200712231220.56613.peng.zang@gmail.com> (raw)
In-Reply-To: <476E6FB7.6040100@dravanet.hu>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
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
On Sunday 23 December 2007 09:24:55 am Márk S. Zoltán wrote:
> Behold the following code snippet:
>
> module rec Aleph :
> sig
> type t = Tag of Beth.t
> end =
> struct
> type t = Tag of Beth.t
> end
> and Beth :
> sig
> type t
> val scandalous : Aleph.t
> end =
> struct
> type t = Aleph.t list
> let scandalous = Aleph.Tag((* HERE BE DRAGONS *) [])
> end
>
> The compiler complains that the empty list after HERE BE DRAGONS has
> type 'a list but it is used with type Beth.t. I'd expect the compiler to
> discover that those types can be unified via 'a == Aleph.t, since as far
> as I can tell, all necessary facts are visible at that point. Replacing
> "Beth : sig type t ..." with "Beth : sig type t = Aleph.t list ..." does
> away with the error, but I would very much like to keep Beth.t an opaque
> type. Is this an intended behavior? And if it is intended, is there a
> way to tell the compiler what I really want it to do?
>
> Thanks in advance for any help.
>
> Z-
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
iD8DBQFHbpj4fIRcEFL/JewRAiRrAJ9lkWenFBHkG2IwRTuRDVN92JCRPQCgjjZV
INwvriBZ/NF25J3ApX8lKn8=
=UpHJ
-----END PGP SIGNATURE-----
next prev parent reply other threads:[~2007-12-23 17:21 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 ` Peng Zang [this message]
2007-12-23 18:00 ` [Caml-list] " "Márk S. Zoltán"
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=200712231220.56613.peng.zang@gmail.com \
--to=peng.zang@gmail.com \
--cc=caml-list@yquem.inria.fr \
--cc=zoltan.s.mark@dravanet.hu \
/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