caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Didier Remy <remy@morgon.inria.fr>
To: Alain Frisch <frisch@clipper.ens.fr>
Cc: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>,
	<pixel@mandrakesoft.com>, <caml-list@inria.fr>
Subject: Re: [Caml-list] [Q]: Co(ntra)variance and subtyping?
Date: 20 Nov 2001 10:58:00 +0100	[thread overview]
Message-ID: <m38adxhkbmf.fsf@morgon.inria.fr> (raw)
In-Reply-To: <Pine.GSO.4.33.0111191154580.25287-100000@clipper.ens.fr>

Alain Frisch <frisch@clipper.ens.fr> writes:

> > In the ML world, we mean complete type inference.
> 
> What does complete type inference mean ?  I would say that it implies
> that no type annotation is mandatory (if a program typechecks with a type
> annotation, it should also typecheck without). This property does not hold
> in OCaml; you can't remove type annotation in:
> 
> class o = object method f (x : int) = x end

Just to mention that examples can also be found in (almost) the core
language as well, you could choose ``ref []'' alone, which program will be
rejected by the compiler.

                              ----------------

I take this opportunity to raise a question about the meaning of "type
inference". Indeed, the answer of whether a language has type inference may
be more subtle than it first appears.  Checking whether types are/must be
mentioned in source programs may not be sufficient. Consider data-type
declarations:

        type 'a list = [] | Cons of 'a * 'a list 

Is this a type annotation?  Indeed, this declaration amounts to later
implicitly annotate every occurrence of a Cons as carrying arguments of
types 'a and 'a list.

The situation apparently looks simpler for the raw lambda-calculus, which
comes in two flavors untyped and typed and where the untyped version does
not mention types at all.  However, there is no untyped version of ML (with
datatypes/exceptions, etc.)  in the sense that types would not be mentioned
at all.

Even in the lambda-calculus it should be fair to consider that (fun x -> a)
carries the (implicit) type annotations ('a -> 'b).  So, isn't it unfair to
make a difference between type annotations that are plugged into the syntax
and more elaborated type annotations that would are explicitly in the
syntax. Formally, the distinction is not obvious: syntactic nodes (_ : t)
can well be seen as (i.e. replaced by) built-in primitives of types t -> t
(and given the same semantics as the identity).

Hopefully, there is always a lot of type information in programs, whether it
is implicit or explicit ---otherwise, type inference could not do much.
Furthermore, the difference between explicit and implicit annotations is not
always so clear, certainly not a binary notion.

My conclusions are that 

 - the typed and untyped version cannot be left implicit when talking about
type inference.

 - the property of ``having type inference'' should rather be replaced by a
measure of ``how much type inference'' (1) or ``what are the properties of
type inference'' (2). 

Answers to (2) the later can be made formal.  Answers to (1) tend to be
informal ---but it would be interesting to find a formal criteria...

        Didier Rémy
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


  reply	other threads:[~2001-11-20 11:16 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-16 19:37 Clemens Hintze
2001-11-17 14:18 ` Mark Wotton
2001-11-17 14:55   ` Mark Wotton
2001-11-17 17:50   ` [Caml-list] " Clemens Hintze
2001-11-17 23:17     ` Mark Wotton
2001-11-18  9:16       ` Clemens Hintze
2001-11-18 13:18         ` Alain Frisch
2001-11-19  9:54           ` Remi VANICAT
     [not found]       ` <9t7v4d$gij$1@qrnik.zagroda>
2001-11-18 11:57         ` Marcin 'Qrczak' Kowalczyk
2001-11-18 13:34 ` [Caml-list] " Andreas Rossberg
2001-11-18 21:22   ` Pixel
2001-11-19  0:33     ` Jacques Garrigue
2001-11-18 22:35       ` David Gurr
2001-11-19  7:24         ` [Caml-list] " Clemens Hintze
2001-11-19 12:03           ` Markus Mottl
2001-11-19  8:29         ` [Caml-list] " Xavier Leroy
2001-11-19 11:03       ` Alain Frisch
2001-11-20  9:58         ` Didier Remy [this message]
2001-11-19 11:14       ` Pixel
2001-11-18 22:30   ` [Caml-list] Re: variance, subtyping and monads... oh, my! james woodyatt
2001-11-19  8:11     ` Francois Pottier
2001-11-19  9:02       ` james woodyatt
2001-11-19  9:58         ` Markus Mottl
2001-11-19 20:47           ` james woodyatt
2001-11-19 12:56       ` Frank Atanassow
2001-11-19 10:39     ` Andreas Rossberg
2001-11-19 12:21       ` Markus Mottl
2001-11-19 13:43         ` [Caml-list] Kylix and OCaml Christophe Raffalli
2001-11-20  2:05           ` Vitaly Lugovsky
2001-11-20  8:51             ` Christophe Raffalli
2001-11-22  1:42               ` Vitaly Lugovsky
2001-11-20 10:00             ` Benjamin Monate
2001-11-20 10:24               ` [Caml-list] [Bug in an interface between C++ and OCAML due to some pointer encapsulation] Sylvain Kerjean
2001-11-20 12:14             ` [Caml-list] Kylix and OCaml Maxence Guesdon

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=m38adxhkbmf.fsf@morgon.inria.fr \
    --to=remy@morgon.inria.fr \
    --cc=caml-list@inria.fr \
    --cc=frisch@clipper.ens.fr \
    --cc=garrigue@kurims.kyoto-u.ac.jp \
    --cc=pixel@mandrakesoft.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).