From: Andreas Rossberg <rossberg@ps.uni-sb.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] type and modules... (sig mismatch again)
Date: Wed, 18 Jun 2003 13:09:56 +0200 [thread overview]
Message-ID: <3EF04884.2010400@ps.uni-sb.de> (raw)
In-Reply-To: <20030618104059.GA25514@anu.edu.au>
Pietro Abate wrote:
>
> how can I force this behavior without changing t1_t and t2_t ?
You can wrap them in auxiliary modules. One purpose of modules is name
space management.
> why the signature doesn't enforce the right type matching ?
Due to the way data type declarations work, this is not a typing issue,
but purely a scoping issue. The first constructor A is simply shadowed
by the second one, so A always refers to the latter.
Beside that, modules are typed independently of any signature
constraint. The latter is checked only after typing the module body.
This is an important design principle of the module language. So even if
both A's could be disambiguated by typing in some way, the information
provided by the signature would come "too late".
- Andreas
> module type A = sig
> type t1
> type t2
> val tutu : t1 -> t2
> end
>
> type t1_t = A of int
> type t2_t = A of int | B of int
>
> module Make : (A with type t1 = t1_t and type t2 = t2_t) = struct
> type t1 = t1_t
> type t2 = t2_t
> let tutu = function
> |A(x) -> B(x)
> end
--
Andreas Rossberg, rossberg@ps.uni-sb.de
"Computer games don't affect kids; I mean if Pac Man affected us
as kids, we would all be running around in darkened rooms, munching
magic pills, and listening to repetitive electronic music."
- Kristian Wilson, Nintendo Inc.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
prev parent reply other threads:[~2003-06-18 11:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-18 10:41 Pietro Abate
2003-06-18 11:07 ` Damien Pous
2003-06-18 11:09 ` Andreas Rossberg [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=3EF04884.2010400@ps.uni-sb.de \
--to=rossberg@ps.uni-sb.de \
--cc=caml-list@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