caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Lukasz Stafiniak <lukstafi@gmail.com>
To: Ashish Agarwal <agarwal1975@gmail.com>
Cc: Carl Eastlund <ceastlund@janestreet.com>, Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] selecting GADT parameter
Date: Fri, 31 Jul 2015 16:31:45 +0200	[thread overview]
Message-ID: <CAJMfKEWDpdJrPRzp4Q+Lh+3hpGehQedfvBOKq0oxDz5zQs3-_A@mail.gmail.com> (raw)
In-Reply-To: <CAMu2m2LPx8fcunKgGCYsefQM7OCuVDNRAXog0Sg1jFruCd6OfA@mail.gmail.com>

On the face of it, this is not possible. There must be as many pattern
matching branches as there are reachable conditions in the formulation
of the type, because only a pattern matching branch introduces a
conditional (an implication) into reasoning about types. In
particular, you need to pattern match against Tag1 and Tag2 if you
don't want to treat the parameter of the type "t" as an abstract type.

On Fri, Jul 31, 2015 at 4:18 PM, Ashish Agarwal <agarwal1975@gmail.com> wrote:
> 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 <ceastlund@janestreet.com>
> 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

  reply	other threads:[~2015-07-31 14:32 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 [this message]
2015-07-31 14:33     ` Runhang Li
2015-08-04  9:21 ` Goswin von Brederlow
2015-08-05 17:26   ` Ashish Agarwal

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=CAJMfKEWDpdJrPRzp4Q+Lh+3hpGehQedfvBOKq0oxDz5zQs3-_A@mail.gmail.com \
    --to=lukstafi@gmail.com \
    --cc=agarwal1975@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=ceastlund@janestreet.com \
    /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;
as well as URLs for NNTP newsgroup(s).