My question is about the sequence
function in Prelude
, the signature of which is as follows:
sequence :: Monad m => [m a] -> m [a]
I understand how this function works for List
of Maybe
s. For example, applying sequence
on [Just 3, Just 9]
gives Just [3, 9]
.
I noticed that applying sequence
on List
of List
s gives its Cartesian Product. Can someone please help me understand how/why this happens?