
On Mon, 24 Dec 2012, Kim-Ee Yeoh
the result is of type [()] but for a cartesian n-product, you would like [[a]]
Right. So what we have here is a product over a count of 0 sets, which is isomorphic to the function space that has the null set as domain. The latter has exactly one element: the trivial function.
My apologies for misreading what OP wrote:
This looks to me to be a violation of the rule that the Cartesian product of an empty list of lists is a list with one element in it.
I thought he meant something along the lines of sequence ["","x"].
-- Kim-Ee
Thanks, Kim-Ee! Your answer and also Chaddai's are very helpful. I hope to post more in this thread. oo--JS.
On Mon, Dec 24, 2012 at 4:42 PM, Chadda� Fouch�
wrote: On Mon, Dec 24, 2012 at 8:01 AM, Jay Sulzberger
wrote: sequence [] [] it :: [()]
This looks to me to be a violation of the rule that the Cartesian product of an empty list of lists is a list with one element in it. It looks to be a violation because "[]" looks like a name for an empty list. But we also have
length (sequence []) 1 it :: Int
which almost reassures me.
Well the type of the first response is a dead give-away : the result is of type [()] but for a cartesian n-product, you would like [[a]] (with a maybe instantiated to a concrete type) ... What's happening here is that sequence is not "the cartesian n-product" in general, it is only that in the list monad but in "sequence []" there's nothing to indicate that we're in the list monad, so GHC default to the IO monad and unit () so sequence has the type "[IO ()] -> IO [()]" and there's no IO action in the list parameter, so there's nothing in the result list.
Try :
sequence [] :: [[Int]] and you should be reassured.
-- Jeda�
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners