caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: Dawid Toton <d0@wp.pl>
Cc: caml-list <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Constrain module type to reuse a sum type
Date: Sun, 5 Jun 2011 22:18:24 +0900	[thread overview]
Message-ID: <299C6C20-7A2D-481D-9FD2-320DC6DACFD4@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <4DEA5272.9040905@wp.pl>

On 2011/06/05, at 0:42, Dawid Toton wrote:

> 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.

Your constraint (in comment) is the right one.
Unfortunately,  it was not allowed up to 3.12.0 (a full definition, including constructors, was required).
The upcoming 3.12.1 will allow it.

Jacques Garrigue

      reply	other threads:[~2011-06-05 13:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-04 15:42 Dawid Toton
2011-06-05 13:18 ` Jacques Garrigue [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=299C6C20-7A2D-481D-9FD2-320DC6DACFD4@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@yquem.inria.fr \
    --cc=d0@wp.pl \
    /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;
as well as URLs for NNTP newsgroup(s).