caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: Markus Mottl <markus.mottl@gmail.com>
Cc: OCaML List Mailing <caml-list@inria.fr>
Subject: Re: [Caml-list] Clever typing for client-server communication?
Date: Sun, 9 Aug 2015 22:04:15 +0900	[thread overview]
Message-ID: <A82FAD3E-EB30-417E-8A3C-9C081452AABF@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <CAP_800qwdDkqZdMEpQTJmes-sy+TNHGGfUHUKukSnBNAOADLqA@mail.gmail.com>

On 2015/08/09 06:39, Markus Mottl wrote:
> 
> The object type trick is pretty neat and can actually be used with
> module types, too.  The advantage there is that whereas object types
> are "flat", module types support more structure via submodules, e.g.:
> 
>  module type Bla = sig module Foo : sig type t end end
>  type 'a t = 'foo_t constraint 'a = (module Bla with type Foo.t = 'foo_t)
> 
> Sadly, there is one significant shortcoming here: there does not seem
> to be any way to exploit subtyping with module types.  Not sure, but
> the only reason for this seems to be that values of module type (i.e.
> first-class modules) cannot be reasonably implemented with subtyping,
> because unlike objects they don't carry around a dictionary at runtime
> for looking up entries in the module.
> 
> Please correct me if I'm wrong, but from a pure typing perspective I
> think that there should be no reason to disallow support for
> expressing subtyping with module types.  The compiler is already able
> to infer whether module signatures satisfy subtyping relationships
> anyway.


The problem is that if you allow expression subtyping for module types,
then I see no way to avoid its being applied to … modules. Which we want to
avoid, since the semantics of subtyping for modules is not the same as
for expressions (i.e., modules require coercions).

By the way, you can also define deep structures with object types, so
I don’t see the advantage of using module types. For an example of
nested object structures, you can see lablgtk, with its sub-object approach
for signals.

Jacques Garrigue

      reply	other threads:[~2015-08-09 13:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-24 11:01 Markus Weißmann
2015-07-24 11:20 ` Nicolas Ojeda Bar
2015-07-24 18:41 ` Mikhail Mandrykin
2015-07-24 20:23 ` octachron
2015-07-24 20:25 ` Jeremy Yallop
2015-07-24 20:57   ` Török Edwin
2015-07-25 12:42     ` Oleg
2015-07-25 15:55       ` mandrykin
2015-08-08 21:39   ` Markus Mottl
2015-08-09 13:04     ` 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=A82FAD3E-EB30-417E-8A3C-9C081452AABF@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=markus.mottl@gmail.com \
    /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).