I'm confused as to why I got this in GHCi
:t sequence [Just,Just]
sequence [Just, Just] :: a -> [Maybe a]
To elaborate, I can understand sequence [Just 1, Just 2] :: Num a => Maybe [a]
because when looking at the type of sequence
sequence :: (Monad m, Traversable t) => t (m a) -> m (t a)
it is clear that this function takes a collection of monadic values and return a single monadic value of the collection. Thus, when we call sequence [Just 1, Just 2]
we should get back a Just
of [1,2]
. Following that train of thoughts, shouldn't sequence [Just, Just]
return a single Just
?
Thanks.