Re: [Caml-list] Re: Generalized Algebraic Datatypes

2010-10-31 Thread Dario Teixeira
Hi, If I misunderstood you, then I still misunderstand you: the App constructor you quoted took only 1 argument (a pair), so you can't partially apply it, and that's from the type declaration. IOW the type declaration you quoted is *not* curried. Now I get what you mean, and there's

Re: [Caml-list] Re: Generalized Algebraic Datatypes

2010-10-31 Thread Wojciech Daniel Meyer
bluestorm bluestorm.d...@gmail.com writes: 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)

[Caml-list] Re: Generalized Algebraic Datatypes

2010-10-31 Thread Sylvain Le Gall
On 31-10-2010, Wojciech Daniel Meyer wojciech.me...@googlemail.com wrote: bluestorm bluestorm.d...@gmail.com writes: 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

Re: [Caml-list] Re: Generalized Algebraic Datatypes

2010-10-31 Thread Lukasz Stafiniak
On Sun, Oct 31, 2010 at 3:35 PM, Sylvain Le Gall sylv...@le-gall.net wrote: On 31-10-2010, Wojciech Daniel Meyer wojciech.me...@googlemail.com wrote: bluestorm bluestorm.d...@gmail.com writes: It was actually the case in Caml Light : each datatype constructor implicitly declared a constructor

[Caml-list] Re: Generalized Algebraic Datatypes

2010-10-31 Thread Sylvain Le Gall
On 31-10-2010, Lukasz Stafiniak lukst...@gmail.com wrote: On Sun, Oct 31, 2010 at 3:35 PM, Sylvain Le Gall sylv...@le-gall.net wrote: On 31-10-2010, Wojciech Daniel Meyer wojciech.me...@googlemail.com wrote: bluestorm bluestorm.d...@gmail.com writes: It was actually the case in Caml Light :

Re: [Caml-list] Re: Generalized Algebraic Datatypes

2010-10-31 Thread Lukasz Stafiniak
On Sun, Oct 31, 2010 at 4:08 PM, Sylvain Le Gall sylv...@le-gall.net wrote: Function names and values are low id in OCaml (first letter must be uncapitalized). If you try to define let MyConstr = 0 in an OCaml toplevel, you will get a syntax error... In unmodified toplevel, but the whole

Re: [Caml-list] Re: Generalized Algebraic Datatypes

2010-10-30 Thread Jacques Carette
On 30/10/2010 1:14 AM, Jacques Garrigue wrote: On 2010/10/30, at 8:01, Jacques Le Normand 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). Actually, curryfied constructors are

Re: [Caml-list] Re: Generalized Algebraic Datatypes

2010-10-30 Thread Dario Teixeira
Hi, While this does make sense in Haskell, in Ocaml it feels a bit out of place, because you cannot, for example, partially apply a type constructor. The types above don't allow partial applications either.  They use the OCaml/SML style of constructors were partial application is not

Re: [Caml-list] Re: Generalized Algebraic Datatypes

2010-10-30 Thread Dario Teixeira
Hi, 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 -

[Caml-list] Re: Generalized Algebraic Datatypes

2010-10-29 Thread Sylvain Le Gall
On 29-10-2010, Jacques Le Normand rathere...@gmail.com wrote: I didn't know about this alternate syntax; can you please describe it? cheers --Jacques It is on page 14: http://gallium.inria.fr/~xleroy/talks/cug2008.pdf And around 14:22 in the video:

[Caml-list] Re: Generalized Algebraic Datatypes

2010-10-29 Thread Stefan Monnier
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

Re: [Caml-list] Re: Generalized Algebraic Datatypes

2010-10-29 Thread bluestorm
On Fri, Oct 29, 2010 at 11:10 PM, Stefan Monnier monn...@iro.umontreal.ca 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

Re: [Caml-list] Re: Generalized Algebraic Datatypes

2010-10-29 Thread Wojciech Daniel Meyer
Stefan Monnier monn...@iro.umontreal.ca writes: 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. I wish to see first class data constructors in OCaml someday. The types

Re: [Caml-list] Re: Generalized Algebraic Datatypes

2010-10-29 Thread Jacques Le Normand
On Fri, Oct 29, 2010 at 5:37 PM, bluestorm bluestorm.d...@gmail.com wrote: On Fri, Oct 29, 2010 at 11:10 PM, Stefan Monnier monn...@iro.umontreal.ca wrote: type _ t = | IntLit : int - int t | BoolLit : bool - bool t | Pair : 'a t * 'b t - ('a * 'b) t | App : ('a - 'b) t * 'a

Re: [Caml-list] Re: Generalized Algebraic Datatypes

2010-10-29 Thread Jacques Garrigue
On 2010/10/30, at 8:01, Jacques Le Normand wrote: On Fri, Oct 29, 2010 at 5:37 PM, bluestorm bluestorm.d...@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