From: Ashish Agarwal <agarwal1975@gmail.com>
To: Goswin von Brederlow <goswin-v-b@web.de>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] selecting GADT parameter
Date: Wed, 5 Aug 2015 13:26:41 -0400 [thread overview]
Message-ID: <CAMu2m2JYb2vGNC_rWby=Z0r6ggJOS1Gr5oOMBHjExhYJfZkq=w@mail.gmail.com> (raw)
In-Reply-To: <20150804092129.GB5689@frosties>
[-- Attachment #1: Type: text/plain, Size: 1157 bytes --]
Thanks for the answers. I see now the difficulty in this. (Though it seems
possible in theory if we required type annotations in various places.)
On Tue, Aug 4, 2015 at 5:21 AM, Goswin von Brederlow <goswin-v-b@web.de>
wrote:
> On Fri, Jul 31, 2015 at 09:48:13AM -0400, Ashish Agarwal wrote:
> > I have:
> >
> > type _ t =
> > | Foo1 : 'a * int -> int t
> > | Foo2 : 'a * string -> 'a t
> >
> > but I really want to merge these two cases. I want the return type to be
> > based on the second arg when the second arg is int, and be based on the
> > first arg otherwise. Any way to accomplish that?
>
> Say you had (imaginary syntax):
>
> type _ t =
> | Foo : 'a * int -> int t
> | Foo : 'a * string -> 'a t
>
> let x1 = Foo (1, 1) : int t
> let x2 = Foo (1, "x") : int t
>
> match (x : int t) with
> | Foo (a, b) -> ...
>
> What is the type of (a, b) now? Is it (int, int) or (int, string)?
>
> MfG
> Goswin
>
> --
> Caml-list mailing list. Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
[-- Attachment #2: Type: text/html, Size: 2013 bytes --]
prev parent reply other threads:[~2015-08-05 17:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-31 13:48 Ashish Agarwal
2015-07-31 13:57 ` Carl Eastlund
2015-07-31 14:18 ` Ashish Agarwal
2015-07-31 14:31 ` Lukasz Stafiniak
2015-07-31 14:33 ` Runhang Li
2015-08-04 9:21 ` Goswin von Brederlow
2015-08-05 17:26 ` Ashish Agarwal [this message]
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='CAMu2m2JYb2vGNC_rWby=Z0r6ggJOS1Gr5oOMBHjExhYJfZkq=w@mail.gmail.com' \
--to=agarwal1975@gmail.com \
--cc=caml-list@inria.fr \
--cc=goswin-v-b@web.de \
/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