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 DA89381799 for ; Thu, 25 Jul 2013 14:11:46 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of alain@frisch.fr) identity=pra; client-ip=193.252.23.213; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="alain@frisch.fr"; x-sender="alain@frisch.fr"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of alain@frisch.fr) identity=mailfrom; client-ip=193.252.23.213; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="alain@frisch.fr"; x-sender="alain@frisch.fr"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@msa.smtpout.orange.fr) identity=helo; client-ip=193.252.23.213; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="alain@frisch.fr"; x-sender="postmaster@msa.smtpout.orange.fr"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AigBAGMV8VHB/BfVlGdsb2JhbABagzy7L4J9gS4OAQEBAQcNCQkUAyWCJAEBBThAEQsOCgkWDwkDAgECAUUGAQwIAQGIELkqkASEAAOXX4YjjkA X-IPAS-Result: AigBAGMV8VHB/BfVlGdsb2JhbABagzy7L4J9gS4OAQEBAQcNCQkUAyWCJAEBBThAEQsOCgkWDwkDAgECAUUGAQwIAQGIELkqkASEAAOXX4YjjkA X-IronPort-AV: E=Sophos;i="4.89,743,1367964000"; d="scan'208";a="22234748" Received: from msa04.smtpout.orange.fr (HELO msa.smtpout.orange.fr) ([193.252.23.213]) by mail3-smtp-sop.national.inria.fr with ESMTP; 25 Jul 2013 14:11:46 +0200 Received: from [192.168.1.111] ([81.249.36.212]) by mwinf5d16 with ME id 4cBk1m0084adkht03cBkNW; Thu, 25 Jul 2013 14:11:45 +0200 Message-ID: <51F11600.3010204@frisch.fr> Date: Thu, 25 Jul 2013 14:11:44 +0200 From: Alain Frisch User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:23.0) Gecko/20100101 Thunderbird/23.0 MIME-Version: 1.0 To: David Allsopp , OCaml List References: <000001ce83bf$879e6520$96db2f60$@metastack.com> <37C2C45C-A317-408E-8545-4FD426E3C817@math.nagoya-u.ac.jp> <51E91707.60002@frisch.fr> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] GADT in an optional parameter On 07/25/2013 11:31 AM, David Allsopp wrote: > Alain Frisch wrote: >> The idea would be to have a different kind of optional argument, which >> specifies as part of the function type an expression to be expanded >> syntactically on the call site when the argument is not provided >> explicitly. (In your example, the Exn constructor would need to be >> available from the call site. -- Or do you interpret "Exn" as a typed >> reference to the Exn constructor on the value declaration site?) >> >> If we assume that the "default" can be an arbitrary "parse tree" >> (untyped) expression, I guess that type equality would require these >> expressions to be strictly equal (modulo locations). > > That seems very powerful, but presumably similarly hard? I'm guessing that at the moment the .cmi file doesn't contain any indication of whether an optional argument has a default or not (because it's an implementation detail transformed in the code as Oleg explained). Would that be a reasonably easy change to make? It feels very weird suddenly needing code to be included in a type! Or is this is a better halfway house... Indedd, it requires to store (untyped) parsetree fragments in types, which I'm sure will be considered as an abomination by most. But from a technical point of view, I don't see any difficulty. Alain