Closed Unisay closed 1 year ago
Product types, e.g. Tuples are compiled to the following code atm:
data Tuple = T Int Int fst :: Tuple -> Int fst (T x _) = x
T = function(value0) return function(value1) return { ["$ctor"] = "Tuple.T", value0 = value0, value1 = value1 } end end, fst = function(v) if "Tuple.T" == v["$ctor"] then return v.value0 else return error("No patterns matched") end end
the runtime ctor check isn't needed in case of product types as they always have at most one constructor:
T = function(value0) return function(value1) return { ["$ctor"] = "Tuple.T", value0 = value0, value1 = value1 } end end, fst = function(v) return v.value0 end
Product types, e.g. Tuples are compiled to the following code atm:
the runtime ctor check isn't needed in case of product types as they always have at most one constructor: