waneck / testrepo

0 stars 0 forks source link

Issue 1288 - GADT - haxe #1288

Closed waneck closed 11 years ago

waneck commented 11 years ago

[Google Issue #1288 : http://code.google.com/haxe/issues/detail?id=1288] by ncanna...@gmail.com, at 2012-11-21T23:19:38.000Z Look at the possibility of adding GADT to the language :

Allow a return type for an enum constructor :

enum E<T> { Int( i : Int ) : E<Int>; Bool( b : Bool ) : E<Bool>; Add( a : E<Int>, b : E<Int> ) : E<Int>; And( a : E<Bool>, b : E<Bool> ) : E<Bool>; ... }

...and check that the type is the enum itself.

Should be actually all that is needed ?

waneck commented 11 years ago

[comment from stephane...@gmail.com, published at 2012-11-22T22:55:09.000Z] (copied in the issue from ML) I think it is not complete GADTs as there's no way to compose types based on constructors parametric types. In the sense of this (haskell) taken from wikipedia page: http://en.wikipedia.org/wiki/Generalized_algebraic_data_type

data Lam :: * -> * where Lift :: a -> Lam a Tup :: Lam a -> Lam b -> Lam (a, b) Lam :: (Lam a -> Lam b) -> Lam (a -> b) App :: Lam (a -> b) -> Lam a -> Lam b Fix :: Lam (a -> a) -> Lam a

To support that, we would need the ability to provide type param on constructors like so:

enum Lam { Lift(x : A) : Lam; Tup<A, B>(x : Lam, y : Lam) : Lam<{ x : A, y : B}>; // I know, I know, no tuples in haxe, pseudo code here.. Lam<A, B>(f : Lam -> Lam) : Lam<A -> B>; etc... etc... }

waneck commented 11 years ago

[comment from ncanna...@gmail.com, published at 2012-12-02T14:16:53.000Z] This issue was closed by revision r5608.

waneck commented 11 years ago

[comment from ncanna...@gmail.com, published at 2012-12-02T14:18:18.000Z] @Stephane, added both explicit return type and per-constructor type parameters. Looking for some testers, I'm sure there are some bugs :) Should not break at all the existing code however, so it's fine to improve from here.

stephane commented 11 years ago

I'm not the Stephane you intend to notify :)

waneck commented 11 years ago

Sorry, that was a test issue imported from Google Code. I guess I'll have to take off @[some-name] to avoid this later ! :)