10 lines
409 B
JavaScript
10 lines
409 B
JavaScript
// Product-type (also called: pair, tuple)
|
|
|
|
// A Product-type always has only two fields, called "left" and "right".
|
|
// Product-types of more fields (called Structs) can be constructed by nesting Product-types.
|
|
|
|
|
|
// In JS, all products are encoded in the same way:
|
|
export const newProduct = l => r => ({l, r});
|
|
export const getLeft = product => product.l;
|
|
export const getRight = product => product.r;
|