caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Didier Remy <Didier.Remy@inria.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Robust left to right flow for record disambiguation
Date: Fri, 25 Oct 2013 13:27:42 +0200	[thread overview]
Message-ID: <526A55AE.8080208@inria.fr> (raw)
In-Reply-To: <526A37ED.6080901@frisch.fr>

> There is already a left-to-right propagation between arguments:
>
>   type t = {a: int};;
>   type s = {a: string};;
>   List.map (fun ({a} : t) -> a + 1) [{a=2}];;   (* accepted *)
>   List.map (fun {a} -> a + 1) [({a=2} : t)];;   (* rejected *)

Yes, but as you notice this is not principal.

> With -principal, the first case is reported as non principal (warning 18).
>
> Is there any practical or theoretical problem with specifying the information
> flow in order to make it principal?

I don't think specifying the information flow between left and right
(always-left-to-right, always-right-to-left, or depending-on-examples) is a
good design. This leads to non predictable type inference and less robust
programs: refactoring a function by just changing the order of parameters
(and consistently changing the order of arguments in all uses of the
function) may break existing programs and also require new annotations.

Also, such a biased will encourage people to write parameters of functions
in an order that works well for the uses they have in mind.  I think it odd
that type inference would have such an influence in choosing the order of
function parameters.

         Didier


  reply	other threads:[~2013-10-25 11:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-23 20:52 Bob Zhang
2013-10-24  1:40 ` Jacques Garrigue
2013-10-24  3:11   ` Bob Zhang
2013-10-25  9:20   ` Alain Frisch
2013-10-25 11:27     ` Didier Remy [this message]
2013-10-25 12:39       ` Alain Frisch
2013-10-25 13:06         ` Wojciech Meyer
2013-10-26  6: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=526A55AE.8080208@inria.fr \
    --to=didier.remy@inria.fr \
    --cc=caml-list@inria.fr \
    /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).