caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Leo White <lpw25@cam.ac.uk>
To: Andreas Rossberg <rossberg@mpi-sws.org>
Cc: David Sheets <sheets@alum.mit.edu>,  Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] First-class Functor Forgetting for Free
Date: Mon, 12 Aug 2013 16:17:15 +0100	[thread overview]
Message-ID: <867gfrndl0.fsf@cam.ac.uk> (raw)
In-Reply-To: <5208EE0D.3000507@mpi-sws.org> (Andreas Rossberg's message of "Mon, 12 Aug 2013 16:15:41 +0200")

Andreas Rossberg <rossberg@mpi-sws.org> writes:

> On 08/12/2013 03:06 PM, Leo White wrote:
>>>
>>> With constraints generally map _type paths_ to _type constructors_.
>>
>> OCaml doesn't allow deep with-constraints (e.g. with type M.t = foo) so
>> they are actually mappings from names.
>
> That's not correct. It has been supported since 4.0 (IIRC).
>

Somehow I managed to miss that change. It should probably be added to
the manual.

>>> (Mind you, OCaml doesn't currently allow revealing type constructors in package types, but that is a limitation
>>> that seems much more important to lift than what we are discussing here.)
>>
>> Allowing type constructors to be revealed by package types would
>> complicate things, but I don't think it would be hard to
>> accomodate. There is a fairly obvious analogy between:
>>
>>    (module S with type 'a t = 'a list and ..)
>>
>> and
>>
>>    < t: 'a. 'a list; .. >
>
> No, that's not the same at all. One is a quantified type, the other a parameterised type (constructor). When you allow
> higher-order type variables, you get into the business of higher-order unification, which is complicated, and
> undecidable in the general case. You'd need to investigate very carefully what restrictions to impose to avoid being
> pulled down that rabbit hole.

I think The required type-checking is quite similar for these two cases,
although the comparison is possibly not that useful. Note that I have
not suggested adding any higher-order type variables.

This is besides the point anyway, as this problem is entirely orthogonal
to the addition of row polymorphism. If you want to allow revealing type
constructors in package types then you need to solve this issue. For
example, type-checking this:

let f 
    (x: (module S with type 'a t = 'a foo * 'b)) 
    (y: (module S with type 'a t = 'a bar * int)) = [x; y];;

requires you to know how to unify:

  module S with type 'a t = 'a foo * 'b

with

  module S with type 'a t = 'a bar * int

>
> OK, I see. But all that would make package typing even more ad-hoc, and divorce its semantics from that of proper
> signatures and signature matching even more. 

I disagree. The point of a package type is to ensure that the module
type that the package was packed with matches the module type that the
package is unpacked with. There is no reason to assume that this is best
done by a carbon copy of the module types. 

Row polymorphism would make first-class modules significantly less
awkward to use (in the same way that it makes objects significantly less
awkward to use). If anything it would be less ad-hoc than the current
system, which uses forward type propagation to try to infer the correct
with-constraints for a package expression.

> That's the opposite of the direction I'd like the package feature to go. It
> would be fairly hostile to future generalisations of packages.

Again, I disagree. I see no reason that it would be hostile to future
generalisations. Do you have anything particular in mind? 

> So, yes, perhaps you could make something work along the lines you sketch, assuming enough restrictions are in
> place. But the price seems way too high for the minor convenience it provides. Wouldn't you agree?

I don't think that any restrictions are needed, so obviously I don't
agree that there is a high price.

Regards,

Leo

  reply	other threads:[~2013-08-12 15:14 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
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 [this message]
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=867gfrndl0.fsf@cam.ac.uk \
    --to=lpw25@cam.ac.uk \
    --cc=caml-list@inria.fr \
    --cc=rossberg@mpi-sws.org \
    --cc=sheets@alum.mit.edu \
    /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).