caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Petter Urkedal <paurkedal@gmail.com>
To: "Jocelyn Sérot" <Jocelyn.Serot@univ-bpclermont.fr>
Cc: OCaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Q: functors and "has a" inheritance
Date: Wed, 6 Jul 2016 12:15:28 +0200	[thread overview]
Message-ID: <20160706101527.GA26606@dione.int.eideticdew.org> (raw)
In-Reply-To: <44623127-96C5-43FB-828D-0F42DCCBA36B@univ-bpclermont.fr>

On 2016-07-06, Jocelyn Sérot wrote:
> Hi Nicolas,
> 
> Thanks fro your answer.
> If i understand correctly, you mean that if i write, say :
> 
> module type S = sig type t val zero: t end
> module type T = sig type t val zero: t end
> module Make (X : S) = (struct type t = X.t * X.t let zero = X.zero, X.zero end : T)
> module M1 = Make (struct type t = int let zero = 0 end)
> module M2 = Make (struct type t = int let zero = 0 end)
> 
> then the compiler will never be able to deduce that M1.t and M2.t are indeed compatible. Am i right ?

Gerd nicely explained how, so I'm just add a note about why:

1. If the module contained a function rather than a plain constant, it
   would be undecidable in general whether the two structures were
   equal.

2. Even if we could (or adopted syntactic equality as an approximation),
   it would break abstraction:  Structures imported from or depending on
   external libraries could be coincidentally equal at some point and
   different after an upgrade.

So, we would be left with a rather ad-hoc rule about how to compare
structures.  The nominal approach taken by OCaml is consistent even if a
bit conservative.  Note that module paths may include functor
applications.

  parent reply	other threads:[~2016-07-06 10:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-05 15:25 Jocelyn Sérot
2016-07-06  7:49 ` Nicolas Ojeda Bar
2016-07-06  8:44   ` Jocelyn Sérot
2016-07-06  9:54     ` Gerd Stolpmann
2016-07-06 12:59       ` Mikhail Mandrykin
2016-07-06 13:35         ` Jocelyn Sérot
2016-07-06 10:15     ` Petter Urkedal [this message]
2016-07-06 12:29       ` Jocelyn Sérot

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=20160706101527.GA26606@dione.int.eideticdew.org \
    --to=paurkedal@gmail.com \
    --cc=Jocelyn.Serot@univ-bpclermont.fr \
    --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).