paldepind / union-type

A small JavaScript library for defining and using union types.
MIT License
477 stars 28 forks source link

Product type #50

Open xgrommx opened 7 years ago

xgrommx commented 7 years ago

Hello @paldepind How can I implement Product type in union-type? Smth like var Tuple3 = daggy.tagged('x', 'y', 'z') in daggy.

glebec commented 6 years ago

@xgrommx years later…

There is no distinct product type, but you can fake it with a sum of only one tag.

const Tuple3 = Type({ Tuple3: [Number, Number, Number] })
const t3 = Tuple3.Tuple3(1, 2, 3)