From: Pietro Abate <Pietro.Abate@anu.edu.au>
To: caml-list@inria.fr
Subject: [Caml-list] type and modules... (sig mismatch again)
Date: Wed, 18 Jun 2003 20:41:00 +1000 [thread overview]
Message-ID: <20030618104059.GA25514@anu.edu.au> (raw)
Hi all,
my daily question :-))
I would like to write a module definition as below:
the problem is (of course) with the t1_t and t2_t type definition because the
use the same variant names. however in my understanding the signature + the "(A
with type t1 = t1_t and type t2 = t2_t)" bit in the functor declaration should
be enough to make clear to the compiler that tutu gets t1 and return t2. Hence
in the pattern matching the first A is of the type t1 and the B is of type t2.
how can I force this behavior without changing t1_t and t2_t ?
why the signature doesn't enforce the right type matching ?
regards,
pietro
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
--
Civilization advances by extending the number
of important operations which we can perform
without thinking. (Alfred North Whitehead)
-------------------
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
next reply other threads:[~2003-06-18 10:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-18 10:41 Pietro Abate [this message]
2003-06-18 11:07 ` Damien Pous
2003-06-18 11:09 ` Andreas Rossberg
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=20030618104059.GA25514@anu.edu.au \
--to=pietro.abate@anu.edu.au \
--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