I'm not a Haskell programmer, but I'm curious about the following questions.
Informal function specification:
Let MapProduct be a function that takes a function called F and multiple lists. It returns a list containing the results of calling F with one argument from each list in each possible combination.
Example:
Call MapProduct with F being a function that simply returns a list of its arguments, and two lists. One of the lists contains the integers 1 and 2, the other one contains the strings "a" and "b". It should return a list that contains the lists: 1 and "a", 1 and "b", 2 and "a", 2 and "b".
Questions:
- How is MapProduct implemented?
- What is the function's type? What is F's type?
- Can one guess what the function does just by looking at its type?
- Can you handle inhomogeneous lists as input? (e.g. 1 and "a" in one of the input lists)
- What extra limitation (if any) do you need to introduce to implement MapProduct?