caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Ashish Agarwal <agarwal1975@gmail.com>
To: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
Cc: OCaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] substituting recursive types inside a signature
Date: Wed, 4 Nov 2015 22:24:02 -0500	[thread overview]
Message-ID: <CAMu2m2JAHtSZx=nrKz2JLUPq+c4is4ChaAPKiSTp8RXHnLa0xw@mail.gmail.com> (raw)
In-Reply-To: <CAMu2m2JHbGxBpJrD3ifrF5VC6u3Jckf4tF1e5DBLw-XGe6rhww@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1033 bytes --]

I pasted the wrong code. Slightly less typing is possible by doing "include
M" in N's implementation.

On Wed, Nov 4, 2015 at 10:22 PM, Ashish Agarwal <agarwal1975@gmail.com>
wrote:

> On Wed, Nov 4, 2015 at 9:10 PM, Jacques Garrigue <
> garrigue@math.nagoya-u.ac.jp> wrote:
>
> the code you wrote is exactly equivalent to:
>>
>>    include (((module type of M) with type t = M.t) with type u = M.u)
>>
>
> And the parentheses here don't matter right, so this is the same as:
>
> include module type of M
>     with type t = M.t
>     with type u = M.u
>
> So then why do we have the "and" syntax at all?
>
> Well, I can use manifest types to work around this, at the expense of some
> manual typing. Here's what works:
>
> $ cat foo.ml
> module M = struct
>   type t = A | B of u
>   and u = C of t
> end
>
> module N : sig
>   type t = M.t = A | B of u
>   and u = M.u = C of t
>   val f : t -> t
> end = struct
>   type t = M.t = A | B of u
>   and u = M.u = C of t
>   let f x = x
> end
>
> let x : M.t = M.A
> let _ = N.f x
>
>

[-- Attachment #2: Type: text/html, Size: 2156 bytes --]

      reply	other threads:[~2015-11-05  3:24 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
2015-11-05  3:22   ` Ashish Agarwal
2015-11-05  3:24     ` Ashish Agarwal [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='CAMu2m2JAHtSZx=nrKz2JLUPq+c4is4ChaAPKiSTp8RXHnLa0xw@mail.gmail.com' \
    --to=agarwal1975@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=garrigue@math.nagoya-u.ac.jp \
    /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).