caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: Andreas Rossberg <rossberg@mpi-sws.org>
Cc: OCaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Equality between abstract type definitions
Date: Mon, 28 Oct 2013 12:30:43 +0900	[thread overview]
Message-ID: <54E55371-5BB8-4798-83AF-A684404A2DBE@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <FAB38C63-E179-41F0-8912-F7B90AF30C83@mpi-sws.org>

Dear Andreas,

It is a bit late to enter this discussion, but I just have two comments

1) All the bug reports (and messages on this list, but for this one) I have seen were
  about the non-generalization of type variables, not their interpretation. Namely,
  people have a hard time understanding why the following is not accepted:

    let f () =
      let id : 'a -> 'a = fun x -> x in
      (id 1, id true)

  I agree that in this respect SML’s choice of inferring a minimal scope (and allowing
  local generalization of named type variables) is more helpful.
  This part could be implemented without breaking existing programs.
  Note however that we already have other ways of introducing local type variables.
  (For instance, writing " id : ‘a. ‘a -> ‘a " in the above.)

2) In ocaml, type variables are also used for describing sharing in recursive types:
     (<m : int; self : 'a> as ‘a)
    and also for talking about types that have a row variable
     (< m : int; .. > as ‘a) -> ‘a
    These two cases use an existential view of type variables.

Jacques

> On Oct 25, 2013, at 01:23 , Jacques Garrigue <garrigue@math.nagoya-u.ac.jp> wrote:
>> In OCaml, type variables used in type annotations are just unification variables:
>> the type checker is allowed to merge them or instantiate them.
>> This is useful when you want to indicate that two things have the same type,
>> without writing the type by hand.
> 
> Jacques, do you think there is any chance that this will ever be changed? I think this keeps being one of the most annoying pitfalls in the OCaml type system, not what most people expect, and in 98% of the cases, not what they want either -- especially since there often is no convenient way to actually express what they want.
> 
> A simple proposal, which I'm sure has been made many times before, would be to interpret type variables of the form 'a, 'b as proper universal variables, and only ones of the form '_a, '_b as unification variables. That matches the notation that OCaml has always been using in its output. More expressive and clearer signalling of intent.
> 
> Obviously, such a change would break some code, code that actually relies on 'a being just a unification variable. But my optimistic guess is that such code is rather rare. And it would be trivial to adapt.
> 
> It would also break code that assumed the wrong behaviour and only compiled by accident (such as the Peter's example). But arguably, that's a good thing, because it uncovers actual bugs.
> 
> Anyway, just dreaming aloud… :)
> 
> /Andreas
> 


      parent reply	other threads:[~2013-10-28  3:30 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-24 22:57 Peter Frey
2013-10-24 23:23 ` Jacques Garrigue
2013-10-25  6:44   ` Andreas Rossberg
2013-10-25  8:29     ` Roberto Di Cosmo
2013-10-25  9:59       ` Ivan Gotovchits
2013-10-25 11:09         ` Gabriel Scherer
2013-10-25 14:24           ` Andreas Rossberg
2013-10-25 20:32             ` Yaron Minsky
2013-10-25 20:44               ` Jacques Le Normand
2013-10-26  1:08                 ` Norman Hardy
2013-10-26  5:28                   ` Jacques Garrigue
2013-10-27 12:16               ` Andreas Rossberg
2013-10-27 12:56                 ` Yaron Minsky
2013-10-27 14:28                   ` Gabriel Scherer
2013-10-27 14:43                     ` Yaron Minsky
2013-10-27 15:25                       ` Gabriel Scherer
2013-10-27 15:41                         ` Yaron Minsky
2013-10-25 12:35         ` Roberto Di Cosmo
2013-10-25 12:45           ` Jonathan Protzenko
2013-10-25 13:20             ` Roberto Di Cosmo
2013-10-25 14:03       ` Andreas Rossberg
2013-10-26  9:07         ` oleg
2013-10-26 14:11           ` Didier Remy
2013-10-26 17:32         ` Didier Remy
2013-10-27 12:07           ` Andreas Rossberg
2013-10-27 14:10             ` Roberto Di Cosmo
2013-10-28  3:30     ` 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=54E55371-5BB8-4798-83AF-A684404A2DBE@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --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).