[Caml-list] Re: Generalized Algebraic Datatypes

2010-10-29 Thread Sylvain Le Gall
On 29-10-2010, Jacques Le Normand 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: http://video.google.com/videoplay?docid=1704671501085578312&

[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

[Caml-list] Re: Generalized Algebraic Datatypes

2010-10-31 Thread Sylvain Le Gall
On 31-10-2010, Wojciech Daniel Meyer wrote: > bluestorm 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 rememb

[Caml-list] Re: Generalized Algebraic Datatypes

2010-10-31 Thread Sylvain Le Gall
On 31-10-2010, Lukasz Stafiniak wrote: > On Sun, Oct 31, 2010 at 3:35 PM, Sylvain Le Gall wrote: >> On 31-10-2010, Wojciech Daniel Meyer wrote: >>> bluestorm writes: >>> It was actually the case in Caml Light : each datatype constructor implicitly declared a constructor function with

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

2010-10-29 Thread bluestorm
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"

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

2010-10-29 Thread Wojciech Daniel Meyer
Stefan Monnier 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 above don't allow par

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

2010-10-29 Thread Jacques Le Normand
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 : ('

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 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 tri

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 no

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 i

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.

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 d

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

2010-10-31 Thread Wojciech Daniel Meyer
bluestorm 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) that people > weren'

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 wrote: > On 31-10-2010, Wojciech Daniel Meyer wrote: >> bluestorm 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 thi

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 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 point is to use