paldepind / union-type

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

Product type #50

Open xgrommx opened 8 years ago

xgrommx commented 8 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)