I'm currently preparing for my final exam regarding Haskell, and I am going over the Monads and we were giving an example such as:
Given the following definition for the List Monad:
instance Monad  where m >>= f = concatMap f m return x = [x]
where the types of
(>>=) :: [a] -> (a -> [b]) -> [b] concatMap :: (a -> [b]) -> [a] -> [b]
What is the result of the expression?
> [1,2,3] >>= \x -> [x..3] >>= \y -> return x [1, 1, 1, 2, 2, 3] //Answer
Here the answer is different from what I thought it to be, now we briefly went over Monads, but from what I understand
(>>=) is called bind and could be read in the expression above as "applyMaybe". In this case for the first part of bind we get
[1,2,3,2,3,3] and we continue to the second part of the bind, but
return x is defined to return the list of x. Which should have been
[1,2,3,2,3,3]. However, I might have misunderstood the expression. Can anyone explain the wrong doing of my approach and how should I have tackled this. Thanks.