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 F119FBB81 for ; Mon, 10 Apr 2006 10:51:49 +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 k3A8pjeg011456 for ; Mon, 10 Apr 2006 10:51:49 +0200 Received: by nproxy.gmail.com with SMTP id l24so604150nfc for ; Mon, 10 Apr 2006 01:51:45 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=J3Jf6luteEgVpinB88EGDUVGW/vq6vAL5Oo2PKPDb43z9vTSuBHwoHJ61YbvTfaC9cyfYsGYH8lXxusglMAcorZYhXydLlViS49K0hXPQokinurG+eQSmvi4bU5AQP4vtTwTWl474EI1n005BYjeEeJlwH5NCdNn5IKskMae3oI= Received: by 10.48.216.15 with SMTP id o15mr3537526nfg; Mon, 10 Apr 2006 01:51:44 -0700 (PDT) Received: by 10.49.55.13 with HTTP; Mon, 10 Apr 2006 01:51:44 -0700 (PDT) Message-ID: Date: Mon, 10 Apr 2006 10:51:44 +0200 From: "=?ISO-8859-2?Q?Tom_Primo=BEi=E8?=" To: caml-list@yquem.inria.fr Subject: Type Inference and Overloading MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_21979_27795092.1144659104756" X-Miltered: at nez-perce with ID 443A1CA1.004 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; inference:01 overloading:01 overloading:01 inference:01 gcaml:01 u-tokyo:01 gcaml:01 citeseer:01 compiler:01 compiler:01 u-tokyo:01 furuse:01 citeseer:01 psu:98 psu:98 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_50_60,HTML_MESSAGE, RCVD_BY_IP autolearn=disabled version=3.0.3 ------=_Part_21979_27795092.1144659104756 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I would like to pose one really perverse question (perverse because it mentions overloading). I have done a lot of thinking over the subject of type inference with overloading. I have also read a lot, however, no paper satisfied me. I don'= t like constraints (neither GCamlnor System CT like) as i find them to= o difficult for the user to understand. I have been trying to think of another mechanism for inferring overloaded types, but have yet been unsuccessful. Does anyone have any idea what kind of algorithm and structures would the compiler need to deploy to correctly infer the types for these functions: a : int -> float -> int a : float -> int -> int b : int -> int -> int b : float -> int -> int let f1 x y =3D let z =3D a x y in b x y + z let f1 x y z =3D let r =3D a x z in let s =3D a z y in b x y + r * s It is pretty clear to the human that f1 has type float -> int -> int, however, it takes a bit more thinking to realize that the type of f1 is int -> int -> float -> int. However, while human sees the whole "program" in on= e glance, the computer cannot perceive a picture as a whole. Thus, some supposedly pretty complicated algorithm should be used. Anyone has any idea? Tom ------=_Part_21979_27795092.1144659104756 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I would like to pose one really perverse question (perverse because it ment= ions overloading).

I have done a lot of thinking over the subject o= f type inference with overloading. I have also read a lot, however, no pape= r satisfied me. I don't like constraints (neither=20 GCaml nor= System CT l= ike) as i find them too difficult for the user to understand.

I hav= e been trying to think of another mechanism for inferring overloaded types,= but have yet been unsuccessful.=20

Does anyone have any idea what kind of algorithm and structures wou= ld the compiler need to deploy to correctly infer the types for these funct= ions:

a : int -&= gt; float -> int
a : float -> int -> int

b : int -> int ->= int
b : float -> int -> int<= br style=3D"font-family: courier new,monospace;">
let f1 x y =3D
=       let z =3D a x y in
      b x y + z

let f1 x y z =3D
&nb= sp;     let r =3D a x z in
    &= nbsp; let s =3D a z y in
      b x y + r * s
It is pretty clear to the human that f1=20 has type float -= > int -> int, however, it takes a bit more thinking to realize= that the type of f1 is int -> int -> = float -> int. However, while human sees the whole "program&q= uot; in one glance, the computer cannot perceive a picture as a whole. Thus= , some supposedly pretty complicated algorithm should be used.

Anyone has any idea?

Tom
------=_Part_21979_27795092.1144659104756--