caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <alain@frisch.fr>
To: David Allsopp <dra-news@metastack.com>,  OCaml List <caml-list@inria.fr>
Subject: Re: [Caml-list] GADT in an optional parameter
Date: Thu, 25 Jul 2013 14:11:44 +0200	[thread overview]
Message-ID: <51F11600.3010204@frisch.fr> (raw)
In-Reply-To: <E51C5B015DBD1348A1D85763337FB6D9CCA8264B@Remus.metastack.local>

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

  reply	other threads:[~2013-07-25 12:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-18 14:03 David Allsopp
2013-07-19  6:59 ` Jacques Garrigue
2013-07-19 10:37   ` Alain Frisch
2013-07-19 16:33     ` Gabriel Scherer
2013-07-25  9:31       ` David Allsopp
2013-07-25 12:11         ` Alain Frisch [this message]
2013-07-19  9:05 ` oleg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51F11600.3010204@frisch.fr \
    --to=alain@frisch.fr \
    --cc=caml-list@inria.fr \
    --cc=dra-news@metastack.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).