From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id E44B3BB81 for ; Mon, 10 Apr 2006 16:43:14 +0200 (CEST) Received: from nproxy.gmail.com (nproxy.gmail.com [64.233.182.187]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k3AEhEed029408 for ; Mon, 10 Apr 2006 16:43:14 +0200 Received: by nproxy.gmail.com with SMTP id l24so657824nfc for ; Mon, 10 Apr 2006 07:43:14 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=fx4SwfRttxHeZVFIijqNxA0Q2ZBN+AE28m8RDcT8CwqiYudu9weLzun6K79bgar7lU0r2foRhkSwTxrT4X7LEml8Fm7UenALY4fVN+kQNgXGjqroQmqZdjHhxEbXo/DMXeEx66crlUCkSt7PsC52q8ucTHWVLVsLnrLTg5yYWJw= Received: by 10.49.5.13 with SMTP id h13mr633443nfi; Mon, 10 Apr 2006 07:43:14 -0700 (PDT) Received: by 10.49.55.13 with HTTP; Mon, 10 Apr 2006 07:43:14 -0700 (PDT) Message-ID: Date: Mon, 10 Apr 2006 16:43:14 +0200 From: "=?ISO-8859-2?Q?Tom_Primo=BEi=E8?=" To: "Brian Hurt" Subject: Re: [Caml-list] Type Inference and Overloading Cc: caml-list@yquem.inria.fr In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_25207_23318038.1144680194086" References: X-Miltered: at nez-perce with ID 443A6F02.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; inference:01 overloading:01 compiler:01 overload:01 overloading:01 ocaml:01 functors:01 ocaml:01 threads:01 haskell's:01 ambiguities:01 compiler:01 overload:01 functors:01 threads:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=HTML_30_40,HTML_MESSAGE, RCVD_BY_IP autolearn=disabled version=3.0.3 ------=_Part_25207_23318038.1144680194086 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 10/04/06, Brian Hurt wrote: > > > a : int -> float -> int > > a : float -> int -> int > > I'm not sure there is one- in fact, I don't think there is. Consider if = I > have the following case as above, and then I type: > > let g =3D a;; > > what's the type of g? Is it int -> float -> int or float -> int -> int? Hm... I definitely agree that there is no way to find out the type of g in this case, there do in fact exist 3 ways of how to deal with it: 1. reject it (i believe this is the "right" way), 2. have the compiler automatically overload value g, producing two functions, or 3. make one value of a the /default/ value and use the type of that one. As a more general rule, how I deal with overloading in Ocaml is to use > modules and functors. > But I fear you might have misunderstood myself. I am in no way trying eithe= r to convince anyone to implement overloading in OCaml nor saying that there are no (useful) alternatives. During my quest I have scanned many threads o= f this list over and over, and I know that any such suggestions and complaint= s are dealt with in a pretty harsh way. I am young and naive and full of idealistic illusions. So I believe in overloading. As a great tool for the user. (Haskell's type classes are just as irritating as the 1.5 + 0. type error, if you ask me.) My point was, that in cases that function actually DO have a non-ambiguous type (f1 : float -> int -> int, f1 : int -> int -> float -> int), while it is quite easy for human to infer it, it (seems) extremely hard for a machin= e to do so. Thus I am looking for a (hopefully cheap) mechanism to infer the types correctly in such cases. I will deal with ambiguities in another way. ------=_Part_25207_23318038.1144680194086 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline

On 10/04/06, Brian Hurt <bhurt@spnz.or= g> wrote:
> a : int -> float -> int
> a : float -> int -> int
I'm not sure there is one- in fact, I don't think there is.  = ;Consider if I
have the following case as above, and then I type:
let g =3D a;;

what's the type of g?  Is it int -> float -> int or= float -> int -> int?

 Hm... I definitely a= gree that there is no way to find out the type of g in this case, there do = in fact exist 3 ways of how to deal with it:
  1. reject it (i believe this is the "right" way),
  2. have the compiler automatically overload value g, producing two func= tions, or
  3. make one value of a the /default/ value and use the type = of that one.
A= s a more general rule, how I deal with overloading in Ocaml is to use
mo= dules and functors. =20

But I fear you might have misunderstood myself. = I am in no way trying either to convince anyone to implement overloading in= OCaml nor saying that there are no (useful) alternatives. During my quest = I have scanned many threads of this list over and over, and I know that any= such suggestions and complaints are dealt with in a pretty harsh way.=20

I am young and naive and full of idealistic illusions. So I believe= in overloading. As a great tool for the user. (Haskell's type classes are = just as irritating as the 1.5 + 0. = type error, if you ask me.)

My point was, that in cases that functio= n actually DO have a non-ambiguous type ( f1 : float ->= int -> int, = f1 : int -> i= nt -> float -> int ), while it is quite easy for human to infer it, it (seems) extremel= y hard for a machine to do so. Thus I am looking for a (hopefully cheap) me= chanism to infer the types correctly in such cases. I will deal with ambigu= ities in another way.=20
=20 ------=_Part_25207_23318038.1144680194086--