caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: Ashish Agarwal <agarwal1975@gmail.com>
Cc: OCaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] substituting recursive types inside a signature
Date: Thu, 5 Nov 2015 11:10:21 +0900	[thread overview]
Message-ID: <AC295BE4-9B35-41CA-9231-51FBDB92E34B@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <CAMu2m2L4jA3KeXQoTva=8UGYvsPHZ6FWEM=am3GkASGgkGhvzw@mail.gmail.com>

On 2015/11/03 05:01, Ashish Agarwal wrote:
> 
> $ cat foo.ml
> module M = struct
>   type t = A | B of u
>   and u = C of t
> end
> 
> module type N = sig
>   include module type of M
>     with type t = M.t
>     and type u = M.u
> end
> 
> $ ocamlc -c foo.ml
> File "foo.ml", line 8, characters 9-21:
> Error: This variant or record definition does not match that of type M.t
>        The types for field B are not equal.
> 
> I guess the "and" in the constraint doesn't make the constraints mutually recursive, so what does it do?

with constraints are handled incrementally. I.e., the code you wrote is exactly equivalent to:

   include (((module type of M) with type t = M.t) with type u = M.u)

It has always been that way. An interesting question is whether we could actually delay the checking to
after applying all the constraints. This would be a non-trivial change.

Jacques Garrigue

  reply	other threads:[~2015-11-05  2:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-02 20:01 Ashish Agarwal
2015-11-05  2:10 ` Jacques Garrigue [this message]
2015-11-05  3:22   ` Ashish Agarwal
2015-11-05  3:24     ` Ashish Agarwal

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=AC295BE4-9B35-41CA-9231-51FBDB92E34B@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=agarwal1975@gmail.com \
    --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;
as well as URLs for NNTP newsgroup(s).