caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David Sheets <sheets@alum.mit.edu>
To: Andreas Rossberg <rossberg@mpi-sws.org>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] First-class Functor Forgetting for Free
Date: Sun, 11 Aug 2013 14:29:20 +0100	[thread overview]
Message-ID: <CAAWM5TyHwpyWHpWmzCyBGsH5PpVp8_9_PMLhMC+4FdUAej1CPA@mail.gmail.com> (raw)
In-Reply-To: <1407E74D-EDC8-4638-8917-4CAC80B4C682@mpi-sws.org>

On Sun, Aug 11, 2013 at 8:53 AM, Andreas Rossberg <rossberg@mpi-sws.org> wrote:
> On Aug 11, 2013, at 03:55 , David Sheets <sheets@alum.mit.edu> wrote:
>> I understand why structural subtyping requires a module cast but I
>> don't see why type relaxation would.
>> I looked at the generated assembly and this line seems to disappear.
>>
>> Why is it needed?
>
> There is no implicit subtyping in OCaml's core language. The reason for that is not code generation, but type inference. For example, what type should the following function be given if the subtyping you ask for could apply?
>
>   let g x = let module X = (val x : D) in X.(f x)

Something like val g : [< (module D)] or simply val g : (module D)
where the type constraint relation is implicit seems reasonable. I
don't know if you consider polymorphic variant types as part of the
core language (or perhaps they aren't implicit because they propagate
inequalities?).

I guess the module system isn't part of the core as it does implicit
structural subtyping. This makes the embedding of the module type
system into the value type system surprising.

> That said, as usual in OCaml, you can force subtyping explicitly. That is, you are able to just say
>
>   let module M' = (val f (x :> (module D)) : C) in …

Good to know! I looked briefly and did not see this mentioned in the manual.

> in your example. (Explicit subtyping on package types is still very limited, though, i.e. only allows forgetting type equations on the same named signature.)

This seems somewhat strange. Why are aliases not followed?

David

  reply	other threads:[~2013-08-11 13:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-11  1:55 David Sheets
2013-08-11  7:53 ` Andreas Rossberg
2013-08-11 13:29   ` David Sheets [this message]
2013-08-11 14:32     ` Andreas Rossberg
2013-08-11 14:58       ` Leo White
2013-08-12 11:01         ` Andreas Rossberg
2013-08-12 11:37           ` Leo White
2013-08-12 12:15             ` Andreas Rossberg
2013-08-12 13:06               ` Leo White
2013-08-12 14:15                 ` Andreas Rossberg
2013-08-12 15:17                   ` Leo White
2013-08-12 16:08                     ` Andreas Rossberg
2013-08-12 16:46                       ` Leo White
2013-08-13 11:22                         ` 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=CAAWM5TyHwpyWHpWmzCyBGsH5PpVp8_9_PMLhMC+4FdUAej1CPA@mail.gmail.com \
    --to=sheets@alum.mit.edu \
    --cc=caml-list@inria.fr \
    --cc=rossberg@mpi-sws.org \
    /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).