caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Re: Generalized Algebraic Datatypes
Date: Sat, 30 Oct 2010 14:14:56 +0900	[thread overview]
Message-ID: <AB5502F2-4E57-4A03-970B-DA3A5B8414F6@gmail.com> (raw)
In-Reply-To: <AANLkTik85Suo0xO8a1K8ZYvOeYM+jhH4cw0d5KzNWf9V@mail.gmail.com>

On 2010/10/30, at 8:01, Jacques Le Normand wrote:
> On Fri, Oct 29, 2010 at 5:37 PM, bluestorm <bluestorm.dylc@gmail.com> wrote:
> Note that, as in Jacques's examples, the constructor function was not curryfied. (type t = A of bool * int) would generate a function (A : bool * int -> t). It doesn't help the already tricky confusion between (A of bool * int) and (A of (bool * int))...
> By the way, it is unclear if
>  | App : ('a -> 'b) t -> 'a t -> 'b t
> would be accepted in Jacques proposal. If not, I think going back to a "of ..." syntax would be wiser.
> 
> It is accepted. In fact, that constructor is part of an example on my webpage.
> If there's any doubt, you can always download the source and try it out.

Actually, curryfied constructors are not allowed, so this is not accepted.
(Existential types are allowed, which may have confused the other Jacques)

To go back to the main subjec,t the syntax with an explicit return type was chosen
because it is closer to the way gadts are implemented here than a syntax based
on constraints. Namely the the type of the expression matched get refined
through unification with the return type of the corresponding case.
It also happens to be the usual syntax in Coq and Haskell, so this
should not come as a shock to most people.

If the risk of confusion with constructors-as-functions is deemed problematic,
a syntax like
   App of ('a -> 'b) t * 'a t : 'b t
seems OK too.
Actually this would have the advantage of allowing the scope of existential variables
to be explicit. I.e. one could write
  App of 'a. ('a -> 'b) t * 'a t : 'b t

Jacques Garrigue


  reply	other threads:[~2010-10-30  5:15 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-29 14:32 [Caml-list] " Dario Teixeira
2010-10-29 15:03 ` Jacques Le Normand
2010-10-29 15:19   ` Sylvain Le Gall
2010-10-29 15:53 ` [Caml-list] " Jacques Le Normand
     [not found] ` <129751088.61814.1288367649864.JavaMail.root@zmbs4.inria.fr>
2010-10-29 16:02   ` Xavier Leroy
2010-10-29 16:42     ` Dario Teixeira
2010-10-29 21:10 ` Stefan Monnier
2010-10-29 21:37   ` [Caml-list] " bluestorm
2010-10-29 23:01     ` Jacques Le Normand
2010-10-30  5:14       ` Jacques Garrigue [this message]
2010-10-30 13:04         ` Jacques Carette
2010-10-30 13:50         ` Dario Teixeira
2010-10-31 14:15     ` Wojciech Daniel Meyer
2010-10-31 14:35       ` Sylvain Le Gall
2010-10-31 14:49         ` [Caml-list] " Lukasz Stafiniak
2010-10-31 15:08           ` Sylvain Le Gall
2010-10-31 15:31             ` [Caml-list] " Lukasz Stafiniak
2010-10-29 22:05   ` Wojciech Daniel Meyer
2010-10-30 13:35   ` Dario Teixeira
     [not found] <jwvvd4jf9z0.fsf-monnier+inbox@gnu.org>
2010-10-31 12:22 ` Dario Teixeira

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=AB5502F2-4E57-4A03-970B-DA3A5B8414F6@gmail.com \
    --to=garrigue@math.nagoya-u.ac.jp \
    --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;
as well as URLs for NNTP newsgroup(s).