Connection Patterns

Higher order circuits built from other circuits, showing common structures independent of the components.

Example 6. A complete adder

adder (carryIn, (a:as, b:bs)) = (sum:sums, carryOut)
    where
        (sum, carry) = fullAdd (carryIn, (a, b))
        (sums, carryOut) = adder (carry, (as, bs))

adder (carryIn, ([], [])) = ([], carryIn)

Example 7. The row connection pattern

row circuit (carryIn, a:as) = (b:bs, carryOut)
    where
        (b, carry) = circuit (carryIn, a)
        (bs, carryOut) = row circuit (carry, as)

row circuit (carryIn, []) = ([], carryIn)
row_adder (carry, inputs) = row fullAdd (carry, inputs)