Scala's flatMap is not Haskell's >>=
The behaviour of flatMap
in Scala:
scala> List(1, 2, 3, 4) flatMap (Some(_)) res0: List[Int] = List(1, 2, 3, 4)
The behaviour of >>=
in Haskell:
> [1, 2, 3, 4] >>= Just <interactive>:4:18: Couldn't match expected type `[b0]' with actual type `Maybe a0' Expected type: a0 -> [b0] Actual type: a0 -> Maybe a0 In the second argument of `(>>=)', namely `Just' In the expression: [1, 2, 3, 4] >>= Just