pufuwozu/roy — Issue #107: Type constructor should allow repeated types
Author: tokland
Created: 2012-02-10 10:32:40+00:00
State: open

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};;

See:

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