caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Robust left to right flow for record disambiguation
@ 2013-10-23 20:52 Bob Zhang
  2013-10-24  1:40 ` Jacques Garrigue
  0 siblings, 1 reply; 8+ messages in thread
From: Bob Zhang @ 2013-10-23 20:52 UTC (permalink / raw)
  To: Caml List

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-10-26  6:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-23 20:52 [Caml-list] Robust left to right flow for record disambiguation 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
2013-10-25 12:39       ` Alain Frisch
2013-10-25 13:06         ` Wojciech Meyer
2013-10-26  6:05       ` oleg

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).