Disjoint Union
Disjoint Union Builder: + , builds A + B, a collection whose members are the elements of A and the elements of B, labelled to mark their origins, e.g. (zero, a) for an a ? A and (one, b) for a b ? B
Assembly:
- inA: A ? A + B i.e. inA(a) = (zero,a)
- inB: B ? A + B i.e. inB(b) = (one,b)
Disassembly: Cases operation which checks the tag of its argument, removes it and gives the argument to the proper operation.
- If d is a value from A + B and f(x) = e1 and g(y) = e2 are the definitions of f:A ? C and g: B ? C, then
cases d of isA(x) ?e1 [] isB(x) ? e2 end