From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 154E77EEF8 for ; Fri, 31 Jul 2015 16:18:33 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of agarwal1975@gmail.com) identity=pra; client-ip=209.85.212.181; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="agarwal1975@gmail.com"; x-sender="agarwal1975@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of agarwal1975@gmail.com designates 209.85.212.181 as permitted sender) identity=mailfrom; client-ip=209.85.212.181; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="agarwal1975@gmail.com"; x-sender="agarwal1975@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wi0-f181.google.com) identity=helo; client-ip=209.85.212.181; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="agarwal1975@gmail.com"; x-sender="postmaster@mail-wi0-f181.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DCAQBxgrtVlLXUVdFbhFcGgx3BFgKBKgdMAQEBAQEBEgEBAQEHCwsJHzCEIwEBAQMBEhEEGQEbHQEDAQsGBQQHAwoqAgIhAQERAQUBHAYTCBqHdgEDCgijSoEsPjGLP4FsgnmLIgoZJw1XhFgBAQEBAQUBAQEBAQEWAQUOi0CCToI5B4JpgUMBBJRyBopegWuSD4VkEiOBFxeEKCIxgkwBAQE X-IPAS-Result: A0DCAQBxgrtVlLXUVdFbhFcGgx3BFgKBKgdMAQEBAQEBEgEBAQEHCwsJHzCEIwEBAQMBEhEEGQEbHQEDAQsGBQQHAwoqAgIhAQERAQUBHAYTCBqHdgEDCgijSoEsPjGLP4FsgnmLIgoZJw1XhFgBAQEBAQUBAQEBAQEWAQUOi0CCToI5B4JpgUMBBJRyBopegWuSD4VkEiOBFxeEKCIxgkwBAQE X-IronPort-AV: E=Sophos;i="5.15,584,1432591200"; d="scan'208";a="141707611" Received: from mail-wi0-f181.google.com ([209.85.212.181]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 31 Jul 2015 16:18:32 +0200 Received: by wicgj17 with SMTP id gj17so19952738wic.1 for ; Fri, 31 Jul 2015 07:18:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=prLAzv3eSwMuhHCkl/KAnSLhNpO9ilz7opIHWhpMlTU=; b=sAkcJ9L5dppnNSXzZ0If9/ZLOF8q70ccCu+l6N2Z3Z5MMTexN71S0aaYMyStBTo/EG faiXy74+BJQxx8TFh+szGjUTweP6SMpXThxkwamI0PUV9twXQd1eyatBYm04RtsSb+aQ bOPkr/7Jj4b1NVQd7r5WhoTGKVpg+eYpzJjV64ghK6qYSqAB8iVvWkKcfRyaUzrTkCFY +OlqvOATr87q1eh2BeOLlSisW+FtROStiMNUP+cotGzy1IeBNKNe5+ubHY7e7gZA8su/ 8cNt02b3iSqAjov8G81rabpBcBMUj8ttcyrMY+nSeD1VC11+Qecpd93Z1Y7n4DWAzD8d cFCg== X-Received: by 10.180.182.40 with SMTP id eb8mr7077561wic.47.1438352312169; Fri, 31 Jul 2015 07:18:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.27.82.86 with HTTP; Fri, 31 Jul 2015 07:18:12 -0700 (PDT) In-Reply-To: References: From: Ashish Agarwal Date: Fri, 31 Jul 2015 10:18:12 -0400 Message-ID: To: Carl Eastlund Cc: Caml List Content-Type: multipart/alternative; boundary=047d7b66f46fa0fb5f051c2c7edc Subject: Re: [Caml-list] selecting GADT parameter --047d7b66f46fa0fb5f051c2c7edc Content-Type: text/plain; charset=UTF-8 You essentially still have 2 constructors, so this isn't quite what I'm aiming for. On Fri, Jul 31, 2015 at 9:57 AM, Carl Eastlund wrote: > Perhaps like this? (Caveat: I typed this straight into gmail, I haven't > tried to compile or run this code at all.) > > type ('a, 'b, 'c) tag = > | Tag1 : ('a, int, int) tag > | Tag2 : ('a, string, 'a) tag > > type 'a t = > | Foo : ('a, 'b, 'c) tag * 'a * 'b -> 'c t > > On Fri, Jul 31, 2015 at 9:48 AM, 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? >> >> > > > -- > Carl Eastlund > --047d7b66f46fa0fb5f051c2c7edc Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
You essentially still have 2 constructors, so this isn'= ;t quite what I'm aiming for.=C2=A0


On Fri, Jul 31, 2015 at 9:57 AM,= Carl Eastlund <ceastlund@janestreet.com> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px= #ccc solid;padding-left:1ex">
Perhaps like this? =C2= =A0(Caveat: I typed this straight into gmail, I haven't tried to compil= e or run this code at all.)

type ('a, 'b, '= c) tag =3D
| Tag1 : ('a, int, int) tag
| Tag2 : ('a, = string, 'a) tag

type 'a t =3D
| = Foo : ('a, 'b, 'c) tag * 'a * 'b -> 'c t

On Fri, Jul 31, 2015 at 9:48 AM, Ashish Agarwal <agarwal1975= @gmail.com> wrote:
I have:

type _ t =3D
| Foo1 : 'a = * int -> int t
| Foo2 : 'a * string -> 'a t

but I really want to merge these two cases. I want the re= turn 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?



--
C= arl Eastlund

--047d7b66f46fa0fb5f051c2c7edc--