caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] unnamed records in match on multiple constructors
@ 2016-12-15 14:12 Gabriel Mayr
  2016-12-15 15:08 ` Gabriel Scherer
  0 siblings, 1 reply; 2+ messages in thread
From: Gabriel Mayr @ 2016-12-15 14:12 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 949 bytes --]

Hi,   I'm using utop version 1.19.3 (using OCaml version 4.03.0).   Using an NAMED record in a type definition and afterwards match on multiple constructors WORKS:  # type a = {i:int};; #type t = A of a | B of a;; # let x = A {i=10};; # match x with
| A e | B e -> print_int e.i;;      Using an UNNAMED record in a type definition and afterwards match on multiple constructors DOES NOT WORK: # type t = A of {i:int} | B of {i:int};; # let x = A {i=10};; # match x with
| A e | B e -> print_int e.i;; 
"Error: The variable e on the left-hand side of this or-pattern has type t.A but on the right-hand side it has type t.B"       I don't know if this is behaviour of OCaml is desired or it's a fault.   Hope I could help you with this little hint.   Best regards,   Gabriel

-------------------------------------------------------------------------------------------------
FreeMail powered by mail.de - MEHR SICHERHEIT, SERIOSITÄT UND KOMFORT

[-- Attachment #2: Type: text/html, Size: 1397 bytes --]

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

end of thread, other threads:[~2016-12-15 15:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-15 14:12 [Caml-list] unnamed records in match on multiple constructors Gabriel Mayr
2016-12-15 15:08 ` Gabriel Scherer

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