From: Dawid Toton <d0@wp.pl>
To: caml-list <caml-list@yquem.inria.fr>
Subject: [Caml-list] Constrain module type to reuse a sum type
Date: Sat, 04 Jun 2011 17:42:42 +0200 [thread overview]
Message-ID: <4DEA5272.9040905@wp.pl> (raw)
I have a functor F which itself applies its own arguments to some other
functors. Results R of these applications contain sum types. These R are
exposed in the outcome of F in two ways: as types carried by the
functions defined by F and all R packed into a wrapper module. I'd like
to tell the compiler that each sum type is equal in both contexts.
The problem boils down to the following:
B.ml:
module type A = sig type a = A end
module A = struct type a = A end
module E = A
type want_equal = A.a as 'a constraint 'a = E.a
B.mli:
module type A = sig type a = A end
module A : A
module type E = A (*with type a = A.a*)
module E : E
type want_equal = A.a as 'a constraint 'a = E.a
There are no problems with the module implementation. I can see right
types in the output of ocamlc -i .
But the interface is wrong, since it is forgotten that the sum types in
E and A are the same.
I have put a constraint in a comment - this is what I'm trying to achieve.
In my real case, the module type A is a big signature that comes from
somewhere else. The mentioned functor F should require as little changes
as possible for each change of the module type that corresponds to the
module type A in the above example.
This is why I'm looking for a way to constrain A to obtain E. How to do
this?
I would be grateful for any comments.
If the code is simplified too much, I can post something more similar to
my real code.
Dawid
next reply other threads:[~2011-06-04 15:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-04 15:42 Dawid Toton [this message]
2011-06-05 13:18 ` Jacques Garrigue
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=4DEA5272.9040905@wp.pl \
--to=d0@wp.pl \
--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