From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Tyng-Ruey Chuang <trc@iis.sinica.edu.tw>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] module constraints bug?
Date: Mon, 30 Jul 2001 14:41:50 +0200 [thread overview]
Message-ID: <20010730144150.A20368@pauillac.inria.fr> (raw)
In-Reply-To: <200107272209.GAA24340@iota.iis.sinica.edu.tw>; from trc@iis.sinica.edu.tw on Sat, Jul 28, 2001 at 06:09:07AM +0800
> There seems to be a bug in the way o'caml handling higher-order modules
> with constrained module arguments.
It's not a bug, it's the intended behavior of the "SIG with module A = M"
construct. But I understand that in your particular example, this
behavior is not what you want!
"SIG with module A = M" means: take signature SIG and replace the
entry "module A : ..." in it with "module A : <principal signature of M>".
In your example:
> module ThisF: F =
> struct
> module A =
> struct
> type t = Pink | Blue
> end
>
> module Eta = functor (X: SELF with module Self = A) ->
> struct
> let t2t x = match x with A.Pink -> A.Blue | A.Blue -> A.Pink
> end
> end
the principal signature of A is
sig type t = A.t = Pink | Blue end
(a type t with two constructors Pink and Blue, and that is equal to A.t).
Hence, SELF with module Self = A expands to
sig module Self : sig type t = A.t = Pink | Blue end end
instead of what you expected:
sig module Self : sig type t = A.t end end
and which corresponds to the non-principal signature for A
sig type t = A.t end
> However, if we change the module constraint to a type constraint
> in the definition of Eta, as shown below in module ThatF,
> [i.e. SELF with type Self.t = A.t]
> then it will type-check.
Yes, because "SELF with type Self.t = A.t" expands to what you expect:
sig module Self : sig type t = A.t end end
Hope this makes the issue a bit clearer,
- Xavier Leroy
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
prev parent reply other threads:[~2001-07-30 12:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-07-27 22:09 Tyng-Ruey Chuang
2001-07-30 12:41 ` Xavier Leroy [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=20010730144150.A20368@pauillac.inria.fr \
--to=xavier.leroy@inria.fr \
--cc=caml-list@inria.fr \
--cc=trc@iis.sinica.edu.tw \
/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