caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jeremy Yallop <yallop@gmail.com>
To: "Christoph Höger" <christoph.hoeger@tu-berlin.de>
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Expansion of type-constructors in ctype.ml
Date: Sat, 22 Aug 2015 10:23:04 +0100	[thread overview]
Message-ID: <CAAxsn=G=JgZeYu_Z3ZJDpnxebRaD6Wz6HzfCFC22B3Z+-HS5bQ@mail.gmail.com> (raw)
In-Reply-To: <55D827DB.3010506@tu-berlin.de>

On 22 August 2015 at 08:42, Christoph Höger
<christoph.hoeger@tu-berlin.de> wrote:
> 1. In the case of equality, it seems fairly simple. Iff the path of two
> constructors is the same and both argument lists are equal, the types
> are equal, right?

"If", but not "iff", unless you expand first.  Consider

   type 'a t = unit

Then 'int t' and 'float t' should be considered equal, since they both
expand to 'unit', even though the argument lists are unequal

> 2. In the case of unification, if both paths are the same, the argument
> lists are of the same length, we can directly unify the arguments, right?

Again, you need to expand the path first.  Consider the following
function, using the same definition of 't' as above:

   fun (a : 'a) (b : 'b) ->
      let c : 'a t = ()
      and d : 'b t = () in
      ignore [c; d];

The last line involves unifying the types 'a t and 'b t.  Unifying the
type arguments 'a and 'b results in the following type for the
function:

    'a -> 'a -> unit

Expanding 't' before unifying means that 'a and 'b are not unified,
and the function can be given the more general type:

    'a -> 'b -> unit

  reply	other threads:[~2015-08-22  9:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-22  7:42 Christoph Höger
2015-08-22  9:23 ` Jeremy Yallop [this message]
2015-08-22 11:41   ` Christoph Höger
2015-08-23 22:18     ` Jacques Garrigue
2015-08-24  6:22       ` Christoph Höger
2015-08-24 10:15         ` Christoph Höger
2015-08-25 14:02           ` Jacques Garrigue
2015-08-25 15:47             ` Christoph Höger
2015-08-26  1:26               ` Jacques Garrigue
2015-11-05 11:29   ` Goswin von Brederlow

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='CAAxsn=G=JgZeYu_Z3ZJDpnxebRaD6Wz6HzfCFC22B3Z+-HS5bQ@mail.gmail.com' \
    --to=yallop@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=christoph.hoeger@tu-berlin.de \
    /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).