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 24478BBAF for ; Sat, 30 Oct 2010 01:01:41 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhABAAvvykxKfVK2kGdsb2JhbACTGI4jCBUBAQEBCQkMBxEDH6QoiVqCF4YSLohXAQEDBYU/BIFaiHqFdA X-IronPort-AV: E=Sophos;i="4.58,261,1286143200"; d="scan'208";a="64585328" Received: from mail-wy0-f182.google.com ([74.125.82.182]) by mail3-smtp-sop.national.inria.fr with ESMTP; 30 Oct 2010 01:01:38 +0200 Received: by wyb42 with SMTP id 42so3739227wyb.27 for ; Fri, 29 Oct 2010 16:01:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=20iz2d/XulVqW51Kk6eh20adCBceieyWaXm3VbRD5cM=; b=Cgs2Vpbb8f92AJAFtD38Ks4yQhtuPQyjqEUbXHVy/k2o+4bkqZV6VZrpAhvzcNcJaQ +GuWCl1Fm1ZPCg9eZ1JRT9ozbs+1DsLOpvKXvFx3TCA8otT9Q3qzhLOCDuwifb2rbpfS vEu/zuwf10BHEndTVotvkplCNwXtoiec6mV+c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=i9uhVCNS14c0g0AxvRSF4MQ96ozCBj7K1kuo4lSj7pHw7A/fSz0Sq2fmCtNAFvOLYB EFWIZELjfBfAiWlsBbbVRDhP2xcqiquAuMMi4XYMWiS1mTDv5FbI5kORVJ5o8uiP8n0m ki/Iaq3fEp4vZ9xsEQkMT5nuZTTs8W23BQxFk= MIME-Version: 1.0 Received: by 10.216.93.9 with SMTP id k9mr12613166wef.89.1288393298301; Fri, 29 Oct 2010 16:01:38 -0700 (PDT) Received: by 10.216.161.12 with HTTP; Fri, 29 Oct 2010 16:01:38 -0700 (PDT) In-Reply-To: References: <904846.44200.qm@web111513.mail.gq1.yahoo.com> Date: Fri, 29 Oct 2010 19:01:38 -0400 Message-ID: Subject: Re: [Caml-list] Re: Generalized Algebraic Datatypes From: Jacques Le Normand To: bluestorm Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary=0016e6d7df98e056350493c970a4 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 cheers:01 beginner's:01 ocaml:01 bug:01 constructors:01 --0016e6d7df98e056350493c970a4 Content-Type: text/plain; charset=ISO-8859-1 On Fri, Oct 29, 2010 at 5:37 PM, bluestorm wrote: > 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. > > 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. cheers, Jacques > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > > --0016e6d7df98e056350493c970a4 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Fri, Oct 29, 2010 at 5:37 PM, bluesto= rm <bluest= orm.dylc@gmail.com> wrote:
On Fri, Oct 29, 2010 at 11:10 PM, Stefan Monnier= =A0<monnier@iro.umontreal.ca>=A0wrote:
> type _ t =3D
> =A0 | IntLit : int -> int t
> =A0 |= BoolLit : bool -> bool t
> =A0 | Pair : 'a t * '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 -> 'b) t -> 'a t -> 'b t
woul= d be accepted in Jacques proposal. If not, I think going back to a "of= ..." syntax would be wiser.


It is accepted. In fa= ct, that constructor is part of an example on my webpage. If there's an= y doubt, you can always download the source and try it out.
cheers,
Jacques

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.in= ria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


--0016e6d7df98e056350493c970a4--