caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Bob Zhang <bobzhang1988@gmail.com>
To: Caml List <caml-list@inria.fr>
Subject: [Caml-list] Robust left to right flow for record disambiguation
Date: Wed, 23 Oct 2013 16:52:29 -0400	[thread overview]
Message-ID: <CANcqPu70B1kOEtZgiNH1jxBTAUoo9dyp6Dt9hKb7OXwa7f1Wig@mail.gmail.com> (raw)

Hi all,
    Record disambiguation is a practical feature, it helps a lot in
writing open-free code.
    In practice, I found it is a bit limited, below is two scenarios
that the compiler can not infer in a correct way, will this be
improved in the future by any chance?
     From the user's point of view, annotating the toplevel is quite
acceptable, maybe the typechecker could take the type-annotation as a
higher priority.
    ---
    1.
         let f (ls:t) =
            ls |> List.map (fun x -> x.loc) (* cannot inferred x.loc*)
   2.
        type t = {loc:string}
        type v = {loc:string; x:int}
        type u = [`Key of t]
        let f (u:t) =
          match u with
          | `Key {loc} -> loc (* does not compile *)

-- 
Regards
-- Bob

             reply	other threads:[~2013-10-23 20:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-23 20:52 Bob Zhang [this message]
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
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=CANcqPu70B1kOEtZgiNH1jxBTAUoo9dyp6Dt9hKb7OXwa7f1Wig@mail.gmail.com \
    --to=bobzhang1988@gmail.com \
    --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).