From: "Andrzej M. Ostruszka" <ostruszk@order.if.uj.edu.pl>
To: Caml List <caml-list@inria.fr>
Subject: Re: # and polymorphic variants
Date: Thu, 1 Feb 2001 10:50:08 +0100 [thread overview]
Message-ID: <20010201105008.A9515@order.if.uj.edu.pl> (raw)
In-Reply-To: <200102010037.BAA12641@sunstroke.informatik.uni-tuebingen.de>; from pfitzen@informatik.uni-tuebingen.de on Thu, Feb 01, 2001 at 01:37:59AM +0100
On Thu, Feb 01 (2001), Juergen Pfitzenmaier wrote:
> and f (x : t) =
> match x with
> | #t1 -> f1 x (* this is not allowed !! *)
> | #t2 -> f2 x;;
>
> The compiler can't constrain the type t of x to t1/t2 in the call to f1/f2.
What about alias patterns? The following seems to work:
type t1 = [ `A of int ]
type t2 = [ `B of string ]
type t = [ `A of int | `B of string ]
let f1 (`A x) = print_int x
and f2 (`B x) = print_string x
and f (x : t) = match x with
| #t1 as a -> f1 a
| #t2 as b -> f2 b
Best regards
--
____ _ ___
/ | \_/ |/ _ \ Andrzej Marek Ostruszka
/ _ | | (_) | Instytut Fizyki, Uniwersytet Jagiellonski (Cracow)
/_/ L|_|V|_|\___/ (PGP <-- finger ostruszk@order.if.uj.edu.pl)
next prev parent reply other threads:[~2001-02-02 15:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-02-01 0:37 Juergen Pfitzenmaier
2001-02-01 9:50 ` Andrzej M. Ostruszka [this message]
2001-02-01 14:31 ` Jacques Garrigue
2001-02-04 8:37 ` Julian Assange
2001-02-02 1:45 ` Brian Rogoff
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=20010201105008.A9515@order.if.uj.edu.pl \
--to=ostruszk@order.if.uj.edu.pl \
--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