Question about typing

Tom Pledger
Fri, 6 Apr 2001 08:25:07 +1200

Toby Watson writes:
 | Intuitively the following scenarios seem to be related, can anyone
 | point my in the direction of formal work on this, or give me the
 | formal terms I need to search around?
 | 1. Adding two integers together: Int -> Int -> Int
 | 2. Adding two lists of Integers together: [Int] -> [Int] -> [Int]

If you're adding each element of the first list to the element in the
corresponding position in the second list, it's usually called
zipping.  The zipWith function in the prelude takes as its parameter a
function of type a->b->c (your scenario 1) and returns a function of
type [a]->[b]->[c] (your scenario 2).

If you're adding every element of the first list to every element of
the second list, it's sometimes called diagonalisation.

 | 3. Adding two lazy streams of integers together, possibly in seperate
 | (parallel) processes for example.

I think the term `zipping' can apply to most container types, even
those with branching structures which don't look like half an actual