caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques-Pascal Deplaix <jp.deplaix@gmail.com>
To: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] ocaml-4.00.0 compilation problem with first class modules and optional parameters
Date: Thu, 06 Sep 2012 09:30:58 +0200	[thread overview]
Message-ID: <50485132.5010403@gmail.com> (raw)
In-Reply-To: <949A205C-8823-45CF-89D5-6DAAA28A616C@math.nagoya-u.ac.jp>

Oh, I forgot to thank you.
So, thank you for your answer.

On 09/04/2012 04:54 AM, Jacques Garrigue wrote:
> OCaml 4.00 is much more agressive in propagating expected types when typing
> expressions. Unfortunately, there was a conflict between this upward propagation,
> and the somehow adhoc behaviour which removes optional arguments from
> a function passed as argument to a function or record/variant constructor not expecting
> optional arguments.
>
> Specifically, this is this behavior:
>
> val f : (unit -> unit) -> unit
> val g : ?x:int -> ?y:bool -> unit -> unit
>
> let () = f g
>
> This code triggers automatic discarding of the optional arguments of g,
> so that the type matches the expected one.
>
> But for this we need to first infer the type of the argument, to see that
> it doesn't match the expected one.
>
> I was not aware that this feature was widely used, and the behavior in 4.00.0
> is to restrict this feature to expressions where upward propagation doesn't
> make sense anyway:
> * identifiers
> * function applications
> * message sending
> * record field extraction
> * wrapping of "let open" around any of those
>
> Since "let module" is not included, this breaks the code in ocsimore...
>
> This is actually the same problem as reported in http://caml.inria.fr/mantis/view.php?id=5748
>
> The clean fix in your case is to move the "let module" outside of the application:
>
> let module Plugin = (val p: WikiPlugin) in desugar_content (desugar_string Plugin.wikiparser)
>
> If you don't care about compatibility with 3.12, you can even write:
>
> | WikiPlugin (module Plugin) ->
>                  desugar_content (desugar_string Plugin.wikiparser)
>
>
> I'm pondering what to do about this.
> Since this feature is described in the tutorial part of the reference manual, I suppose this
> qualifies as a bug. However, combining this behavior with upward propagation is difficult.
>
> Not propagating types to function arguments seems fine, but for variant and record
> constructors this is less clear-cut.
> Another option is to extend the  syntactic cases where the behavior is triggered, including
> "let" and "let module", but the above PR#5748 is about inlined functions, which could benefit
> from propagation.
>
> Jacques Garrigue


      reply	other threads:[~2012-09-06  7:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-03 20:39 Jacques-Pascal Deplaix
2012-09-04  2:54 ` Jacques Garrigue
2012-09-06  7:30   ` Jacques-Pascal Deplaix [this message]

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=50485132.5010403@gmail.com \
    --to=jp.deplaix@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=garrigue@math.nagoya-u.ac.jp \
    /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).