From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p6QCI6Xg022799 for ; Tue, 26 Jul 2011 14:18:06 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApECAK2vLk7RVdivkGdsb2JhbAAoKAIXGwEfHgMUCAEHSRITARIBBQErPqctCBQBAQEBCQkNBxQEIatDglIKjCqCUIUFO4hsAgMGhjoEjXiEeoxIPINe X-IronPort-AV: E=Sophos;i="4.67,269,1309730400"; d="ml'?scan'208";a="114072580" Received: from mail-qy0-f175.google.com ([209.85.216.175]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 26 Jul 2011 14:17:59 +0200 Received: by qyk30 with SMTP id 30so1723220qyk.6 for ; Tue, 26 Jul 2011 05:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=qxHgeL3nqVBmmATBRGNf4C3GmwJoiZasF8SA9fs8hZA=; b=xuuOSLDgPwItA9QcT33yt7evP93yXsq+RPCMR3tMiNkIRXIAdKm+U4OhVXOGDTkzaP Wlyx+TO1PYF6tVPzMPyhWTRtCC85wk1g3xz8pgQBCEr4AKYlIUdCYKLc7LV1x3cLJ7Lg Da8UwsKVR0Q0Waie4QEPExK/bCfhMJtfFCdSM= MIME-Version: 1.0 Received: by 10.229.73.196 with SMTP id r4mr4696945qcj.266.1311682678691; Tue, 26 Jul 2011 05:17:58 -0700 (PDT) Received: by 10.229.241.129 with HTTP; Tue, 26 Jul 2011 05:17:58 -0700 (PDT) Date: Tue, 26 Jul 2011 14:17:58 +0200 Message-ID: From: Polux Moon To: caml-list Content-Type: multipart/mixed; boundary=0016364272711f18c404a8f7ecff Subject: [Caml-list] Problem with forall and method --0016364272711f18c404a8f7ecff Content-Type: multipart/alternative; boundary=0016364272711f18ba04a8f7ecfd --0016364272711f18ba04a8f7ecfd Content-Type: text/plain; charset=ISO-8859-1 (Sorry for duplicate mail, I forgot to change the subject in the first one) Hi, I have a type error on code similar to : ----- type 'par t = 'par let ident v = v class alias = object method alias : 'a . 'a t -> 'a = ident (* type error here *) end ----- Which gives : ----- Error: This expression has type 'a. 'a t -> 'a but an expression was expected of type 'b. 'b t -> 'b Type 'a a = 'a is not compatible with type 'b t = 'b ----- The problem is related to unification of foralls containing named type in a method. The compiler accepts equivalent code when not using the named type "t" or when not using a method (see attached file). Is it a [known] limitation ? Is there a way to work around it ? --0016364272711f18ba04a8f7ecfd Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
(Sorry for duplicate mail, I forgot to change th= e subject in the first one)

Hi,

I have a type error on code s= imilar to :

-----
type 'par t =3D 'par

let ident v= =3D v

class alias =3D
object
=A0 method alias : 'a . 'a t ->= 'a =3D ident (* type error here *)
end
-----

Which gives :

-----
Error: This expression ha= s type 'a. 'a t -> 'a
=A0=A0=A0=A0=A0=A0 but an expressio= n was expected of type 'b. 'b t -> 'b
=A0=A0=A0=A0=A0=A0 = Type 'a a =3D 'a is not compatible with type 'b t =3D 'b
-----

The problem is related to unification of foralls containing na= med type in a method.
The compiler accepts equivalent code when not usin= g the named type "t" or when not using a method (see attached fil= e).

Is it a [known] limitation ? Is there a way to work around it ?

--0016364272711f18ba04a8f7ecfd-- --0016364272711f18c404a8f7ecff Content-Type: text/x-ocaml; charset=US-ASCII; name="forallclass.ml" Content-Disposition: attachment; filename="forallclass.ml" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gqksfmxn0 dHlwZSAncGFyIHQgPSAncGFyCgpsZXQgaWRlbnQgdiA9IHYgKCogaGVyZSBh ZGRpbmcgOiAnYSAuICdhIGEgLT4gJ2EgY2hhbmdlcyBub3RoaW5nICopCgpj bGFzcyBhbGlhcyA9Cm9iamVjdAogIG1ldGhvZCBhbGlhcyA6ICdhIC4gJ2Eg dCAtPiAnYSA9IGlkZW50ICgqIE5PVCBPSyAqKQplbmQKCigqIGJ1dCAqKQps ZXQgYWxpYXMgOiAnYSAuICdhIHQgLT4gJ2EgPSBpZGVudCAoKiBPSyAqKQp0 eXBlIHIgPSB7IGFsaWFzIDogJ2EgLiAnYSB0IC0+ICdhfQpsZXQgYWxpYXMg PSB7IGFsaWFzID0gaWRlbnQgfSAoKiBPSyAqKQoK --0016364272711f18c404a8f7ecff--