From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id 0FB297F1DD for ; Thu, 10 Jan 2013 21:15:34 +0100 (CET) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of bobzhang1988@gmail.com) identity=pra; client-ip=209.85.210.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="bobzhang1988@gmail.com"; x-sender="bobzhang1988@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail4-smtp-sop.national.inria.fr: domain of bobzhang1988@gmail.com designates 209.85.210.182 as permitted sender) identity=mailfrom; client-ip=209.85.210.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="bobzhang1988@gmail.com"; x-sender="bobzhang1988@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ia0-f182.google.com) identity=helo; client-ip=209.85.210.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="bobzhang1988@gmail.com"; x-sender="postmaster@mail-ia0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlMCAOcg71DRVdK2lGdsb2JhbABEvWMIFg4BAQEBCQkUEimCTBkBGx4DEgkHXQERAQUBIi6HawEDD5Ysgm2MM4J7hGYKGScNWYVrAQUMkRMDiGCNKo5oFimENQ X-IronPort-AV: E=Sophos;i="4.84,446,1355094000"; d="scan'208";a="168045628" Received: from mail-ia0-f182.google.com ([209.85.210.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 10 Jan 2013 21:15:33 +0100 Received: by mail-ia0-f182.google.com with SMTP id x2so881275iad.41 for ; Thu, 10 Jan 2013 12:15:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=Nmx9cYkhAQXxekLSTnQdrvRunV81pXHmPvl9b/1LlpE=; b=DxcBceI5Y2i7FKBEOBa+Nv0PRg6aF/eZpWHxWzh0JOoUON7ZUYVIk+/tjiEar5n7T+ 6uSpEPu2rgWIArSLEZTch+YX0v7kAuTW2uod9AaeYKAh+g1D2illgft5xqpvuWQnQht7 800SgIdnmmpCgxs+4HlkGUR4z3wQ7e+HH+8pIiUdycpWFuVIql4z4zBV8OA7ui5jXxAH 8SpJFYZhFp76ScFikD/cdBdUO1gDTAYutLOPI/XRZmvCRzyxdJk/uqvpFT3HFrAp/VMW Izn5BYg7zYLbxzgOKjg7myTLDALF+guE42JvTphGYIddfEqP/gDHmpPAYIa/up/5KfBt vELA== MIME-Version: 1.0 X-Received: by 10.50.10.194 with SMTP id k2mr2973763igb.41.1357848931994; Thu, 10 Jan 2013 12:15:31 -0800 (PST) Received: by 10.64.17.4 with HTTP; Thu, 10 Jan 2013 12:15:31 -0800 (PST) Date: Thu, 10 Jan 2013 15:15:31 -0500 Message-ID: From: bob zhang To: Caml List Content-Type: multipart/alternative; boundary=14dae93403f3400d0a04d2f4d748 Subject: [Caml-list] This ground coercion is not principal? --14dae93403f3400d0a04d2f4d748 Content-Type: text/plain; charset=ISO-8859-1 Hi List, I have came across a corner case in ocaml typing here, The source code is pasted below(extracted from a large code base), it triggers the warning 18. My question, is there any elegant solution without introducing local types? ------------------------------------------------------------------------------------------ type ant = [`Ant of string] type 'a mlist = [ `LNil | `LCons of ('a * 'a mlist ) | ant] let a = object(self) method ant : ant -> ant= fun (`Ant a) -> `Ant a method mlist: 'all_a0 'all_b0 . ('self_type -> 'all_a0 -> 'all_b0) -> 'all_a0 mlist -> 'all_b0 mlist= fun (type t) mf_a -> function | `LNil -> `LNil | `LCons (a0,a1) -> let a0 = mf_a self a0 in let a1 = self#mlist mf_a a1 in `LCons (a0, a1) | #ant as a0 -> (((* Obj.magic *) self#ant a0) :> (* 'all_b0 *) t mlist) end -- Regards -- Bob --14dae93403f3400d0a04d2f4d748 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi List,
=A0 I have came across a corner case in ocaml typing here,
The source code is pasted below(extracted from a large code base), i= t triggers the warning 18.
My question, is there any elegant solu= tion without introducing local types?=A0

-------------------------------------------------------= -----------------------------------
type ant =3D [`Ant of stri= ng]
type 'a mlist =3D
=A0 =A0 [ `LNil=A0
= =A0 =A0 | `LCons of ('a * 'a mlist )
=A0 =A0 | ant]
let a =3D object(self)
=A0 method a= nt : ant -> ant=3D
=A0 =A0 fun (`Ant a) =A0->
=A0= =A0 =A0 `Ant a
=A0 method mlist: 'all_a0 'all_b0 .
=
=A0 =A0 =A0 ('self_type -> 'all_a0 -> 'all_b0) ->=
=A0 =A0 =A0 =A0 'all_a0 mlist -> 'all_b0 mlist=3D
=A0 =A0 =A0 =A0 =A0 fun (type t) mf_a =A0->
=A0 =A0 =A0 =A0 = =A0 =A0 function
=A0 =A0 =A0 =A0 =A0 =A0 =A0 | `LNil -> =A0`LN= il
=A0 =A0 =A0 =A0 =A0 =A0 =A0 | `LCons (a0,a1) ->
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 let a0 =3D mf_a self a0 in
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 let a1 =3D self#mlist mf_a a1 in `LC= ons (a0, a1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 | #ant as a0 -> (((* = Obj.magic *) self#ant a0) :> (* 'all_b0 *) t mlist)
end




<= div>




<= div>









=



--
Regards
-- Bob --14dae93403f3400d0a04d2f4d748--