puffnfresh / roy

Small functional language that compiles to JavaScript.
http://roy.brianmckenna.org/
MIT License
836 stars 74 forks source link

Type constructor should allow repeated types #107

Closed tokland closed 12 years ago

tokland commented 12 years ago

This code:

data Animal a b = Cat a | Dog b b

Compiles into:

var Cat = function(a){this._0 = a};
var Dog = function(b, b){this._0 = b;this._1 = b};;

Note the repeated arguments in function Dog. A simple solution is indexing the arguments:

var Cat = function(a_0){this._0 = a_0};
var Dog = function(b_0, b_1){this._0 = b_0;this._1 = b_1};;

Proposal:

https://github.com/tokland/roy/commit/b91cf9370da99f228f64d38684f9611692aad856

puffnfresh commented 12 years ago

Thanks!