Of course, creating a Cartesian product of heterogeneous lists can be done in several ways in Haskell, for example:
[(x,y) | x <- [1,2,3], y <- [4,5,6]]
or
(,) <$> [1,2,3] <*> [4,5,6]
But I want this to be a function:
heteroCartesian :: (a1, a2, ... , an) -> (b1, b2, ... , bn) -> ((a1,b1), (a1,b2), ... , (a1,bn), (a2,b1), (a2,b2), ... , (a2,bn), (an,b1), ... ,(an,b2), ... , (an,bn))
So, I can do something like this:
f (1,'a',True) (2,'b') == ((1,2),(1,'b'),('a',2),('a','b'),(True,2),(True,'b'))
I donβt mind if I use tuples or something else, but I need to save the type information as I have above.
The reason I want this is to create test cases. I have a bunch of n and m functions. In the end, I will display a function above them that reduces them all to the same type (a Test ), but up to this point there are many different types for n*m test boxes that I want to execute (this is not really as simple as some functions can take only limited subsets of values).
Therefore, naturally, it would be nice to have other functions in these heterogeneous lists, for example, something like map .
I looked at HList , but it was not updated last year and a little, and I was not sure that this was the most suitable tool.