From: Gabriel Mayr <gabriel.mayr@mail.de>
To: caml-list@inria.fr
Subject: [Caml-list] unnamed records in match on multiple constructors
Date: Thu, 15 Dec 2016 15:12:39 +0100 [thread overview]
Message-ID: <20161215141240.01BE740092@smtp03.mail.de> (raw)
[-- 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 --]
next reply other threads:[~2016-12-15 14:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-15 14:12 Gabriel Mayr [this message]
2016-12-15 15:08 ` Gabriel Scherer
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=20161215141240.01BE740092@smtp03.mail.de \
--to=gabriel.mayr@mail.de \
--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