From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 4218FBBAF for ; Fri, 29 Oct 2010 23:37:53 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Au8AAB/bykzRVdivk2dsb2JhbACTWI1xCBUBAQEBCQkKCREDH6RciVmCF4YULohXAQEDBYVDBIpTiR0 X-IronPort-AV: E=Sophos;i="4.58,261,1286143200"; d="scan'208";a="64583650" Received: from mail-qy0-f175.google.com ([209.85.216.175]) by mail3-smtp-sop.national.inria.fr with ESMTP; 29 Oct 2010 23:37:52 +0200 Received: by qyk7 with SMTP id 7so6207349qyk.6 for ; Fri, 29 Oct 2010 14:37:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:sender:received :in-reply-to:references:from:date:x-google-sender-auth:message-id :subject:to:content-type; bh=8zfUFpmXulFDgNN1l0Mn/s3Uk86RiW9GxsuM1/7UUI0=; b=RdJ5SA1eSdYVo1XT6nj3rib5CVZy5SWBBC6x8gejlgasUj6hhFjWjszcXPVdMI0UqH 3E+GqHYIGWTEjkqrTsX7eoDVjxJi9OVirhBre7vpIwGVwkslfzGavRm68aFrKRQkM58v UJQWeBbf8nTyZo/eR07wkMPJ5wKeK2WVLDxLs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type; b=XWsyd59HKWD2EClyr1GyWEaVm7PihVUsCyDqasol59H+Iyx+OI3TnmrEH3B5oG+3hC 77eIG4g2i+KSMeTwHCAZh2zzIBxyma+Z0fA5kareNZjAweJ0P9CShE6TZJPj5fpLgveL NkLmKIcx2MfZly8Aob8QutsRj7/QTjZnyFPso= Received: by 10.229.213.146 with SMTP id gw18mr909329qcb.243.1288388271741; Fri, 29 Oct 2010 14:37:51 -0700 (PDT) MIME-Version: 1.0 Sender: gabriel.scherer@gmail.com Received: by 10.229.28.210 with HTTP; Fri, 29 Oct 2010 14:37:31 -0700 (PDT) In-Reply-To: References: <904846.44200.qm@web111513.mail.gq1.yahoo.com> From: bluestorm Date: Fri, 29 Oct 2010 23:37:31 +0200 X-Google-Sender-Auth: XdHUnsZNW4w8PLxtoXTVgIV2me0 Message-ID: Subject: Re: [Caml-list] Re: Generalized Algebraic Datatypes To: caml-list@inria.fr Content-Type: multipart/alternative; boundary=001636416495451cd20493c845ae X-Spam: no; 0.00; datatypes:01 bool:01 bool:01 syntax:01 constructors:01 iirc:01 ocaml:01 datatype:01 jacques's:01 syntax:01 constructors:01 iirc:01 ocaml:01 datatype:01 jacques's:01 --001636416495451cd20493c845ae Content-Type: text/plain; charset=ISO-8859-1 On Fri, Oct 29, 2010 at 11:10 PM, Stefan Monnier wrote: > > type _ t = > > | IntLit : int -> int t > > | BoolLit : bool -> bool t > > | Pair : 'a t * 'b t -> ('a * 'b) t > > | App : ('a -> 'b) t * 'a t -> 'b t > > | Abs : ('a -> 'b) -> ('a -> 'b) t > > > There's something "Haskellish" about this syntax, in the sense that type > > constructors are portrayed as being like functions. > > Indeed IIRC OCaml does not accept "App" as an expression (you have to > provide arguments to the construct). Maybe this is a good opportunity > to lift this restriction. It was actually the case in Caml Light : each datatype constructor implicitly declared a constructor function with the same name. I don't exactly know why this feature was dropped in Objective Caml, but I think I remember (from a previous discussion) that people weren't sure it was worth the additional complexity. 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. --001636416495451cd20493c845ae Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Fri, Oct 29, 2010 at 11:10 PM, Stefan Monnier= =A0<monnie= r@iro.umontreal.ca>=A0wrote:
=
> type _ t =3D
> =A0 | IntLit : int -> int t<= br>> =A0 | BoolLit : bool -> bool t
> =A0 | Pair : 'a t * &= #39;b t -> ('a * 'b) t
> =A0 | App : ('a -> 'b)= t * 'a t -> 'b t
> =A0 | Abs : ('a -> 'b) -> ('a -> 'b) t
> There's something "Haskellish" about this syntax, in th= e sense that type
> constructors are portrayed as being like function= s.

Indeed IIRC OCaml does not accept "App" as an expressio= n (you have to
provide arguments to the construct). =A0Maybe this is a g= ood opportunity
to lift this restriction.

It was actually the case in Caml Light : each datatype constructor implicit= ly declared a constructor function with the same name. I don't exactly = know why this feature was dropped in Objective Caml, but I think I remember= (from a previous discussion) that people weren't sure it was worth the= additional complexity.

Note that, as in Jacques's examples, the constructo= r function was not curryfied. (type t =3D 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
=A0=A0| App : ('a -> = 9;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.

--001636416495451cd20493c845ae--