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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 272D97EF53 for ; Mon, 24 Aug 2015 12:15:57 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of christoph.hoeger@tu-berlin.de) identity=pra; client-ip=130.149.7.33; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="christoph.hoeger@tu-berlin.de"; x-sender="christoph.hoeger@tu-berlin.de"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of christoph.hoeger@tu-berlin.de) identity=mailfrom; client-ip=130.149.7.33; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="christoph.hoeger@tu-berlin.de"; x-sender="christoph.hoeger@tu-berlin.de"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail.tu-berlin.de) identity=helo; client-ip=130.149.7.33; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="christoph.hoeger@tu-berlin.de"; x-sender="postmaster@mail.tu-berlin.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AkAQDF7dpVnCEHlYJdg21pgyWzeIhBhgMCgStMAQEBAQEBEgEBAQEBCAsJCSEuhCQBAQQjBFERCyEWCwICCQMCAQIBRRMGAgEBiCqxFpUvASuLV4URF4JSgUMFlDCBBIJAgVxqiX2GYJFfhCZvgkwBAQE X-IPAS-Result: A0AkAQDF7dpVnCEHlYJdg21pgyWzeIhBhgMCgStMAQEBAQEBEgEBAQEBCAsJCSEuhCQBAQQjBFERCyEWCwICCQMCAQIBRRMGAgEBiCqxFpUvASuLV4URF4JSgUMFlDCBBIJAgVxqiX2GYJFfhCZvgkwBAQE X-IronPort-AV: E=Sophos;i="5.15,736,1432591200"; d="scan'208";a="143624431" Received: from mail.tu-berlin.de ([130.149.7.33]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 24 Aug 2015 12:15:56 +0200 X-tubIT-Incoming-IP: 130.149.172.228 Received: from brego.uebb.tu-berlin.de ([130.149.172.228]) by mail.tu-berlin.de (exim-4.76/mailfrontend-7) with esmtpsa [UNKNOWN:AES128-SHA:128] for id 1ZTonC-00026Y-2g; Mon, 24 Aug 2015 12:15:55 +0200 To: caml-list@inria.fr References: <55D827DB.3010506@tu-berlin.de> <55D85FE7.2050001@tu-berlin.de> <0D467B24-3C94-4640-8264-85BE5312EB55@math.nagoya-u.ac.jp> <55DAB843.5010800@tu-berlin.de> From: =?UTF-8?Q?Christoph_H=c3=b6ger?= Organization: =?UTF-8?Q?Technische_Universit=c3=a4t_Berlin?= Message-ID: <55DAEEDA.6020709@tu-berlin.de> Date: Mon, 24 Aug 2015 12:15:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55DAB843.5010800@tu-berlin.de> Content-Type: multipart/mixed; boundary="------------020309050108010506010500" Subject: Re: [Caml-list] Expansion of type-constructors in ctype.ml This is a multi-part message in MIME format. --------------020309050108010506010500 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit find attached a patch against the 4.02.3 tree that solves my issue with compiling the problematic examples. I am pretty confident that the change to eqtype is sound, I do not know exactly what moregen() is intended to do, though and it seems that its side-effects are required (that is why I expand the types there in any case). I appreciate any further comments, Christoph -- Christoph Höger Technische Universität Berlin Fakultät IV - Elektrotechnik und Informatik Übersetzerbau und Programmiersprachen Sekr. TEL12-2, Ernst-Reuter-Platz 7, 10587 Berlin Tel.: +49 (30) 314-24890 E-Mail: christoph.hoeger@tu-berlin.de --------------020309050108010506010500 Content-Type: text/x-patch; name="large_classes.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="large_classes.patch" diff --git a/typing/ctype.ml b/typing/ctype.ml index d1ff9da..2125d00 100644 --- a/typing/ctype.ml +++ b/typing/ctype.ml @@ -2948,6 +2948,21 @@ let rec moregen inst_nongen type_pairs env t1 t2 = link_type t1 t2 | (Tconstr (p1, [], _), Tconstr (p2, [], _)) when Path.same p1 p2 -> () + | (Tconstr (p1, tl1, _), Tconstr (p2, tl2, _)) + when Path.same p1 p2 -> + begin try + moregen_list inst_nongen type_pairs env tl1 tl2 ; + (* expand afterwards, this seems to be an expected side-effect *) + ignore (expand_head env t1 ) ; + ignore (expand_head env t2 ) ; + with e -> + let t1' = expand_head env t1 in + let t2' = expand_head env t2 in + let t1' = repr t1' and t2' = repr t2' in + (* prevent non-termination (is this really necessary?) *) + if t1' == t1 && t2' == t2 then raise e else + moregen inst_nongen type_pairs env t1 t2 + end | _ -> let t1' = expand_head env t1 in let t2' = expand_head env t2 in @@ -3213,6 +3228,23 @@ let rec eqtype rename type_pairs subst env t1 t2 = end | (Tconstr (p1, [], _), Tconstr (p2, [], _)) when Path.same p1 p2 -> () + + | (Tconstr (p1, tl1, _), Tconstr (p2, tl2, _)) + when Path.same p1 p2 -> + (* Optimize equality of large type-constructors. + Equality of all arguments implies equality of the result, expand + only in case of non-equality (since equivalence does not hold) *) + begin try + eqtype_list rename type_pairs subst env tl1 tl2 + with e -> + let t1' = expand_head_rigid env t1 in + let t2' = expand_head_rigid env t2 in + let t1' = repr t1' and t2' = repr t2' in + (* prevent non-termination (is this really necessary?) *) + if t1' == t1 && t2' == t2 then raise e else + eqtype rename type_pairs subst env t1' t2' + end + | _ -> let t1' = expand_head_rigid env t1 in let t2' = expand_head_rigid env t2 in --------------020309050108010506010500--