Re:Monoids, Functors, Applicatives, and Monads: Main Ideas
by dllthomas on Wednesday January 07, 2015 @11:47AM
(#8851532)
Specialized in the sense of a more restricted type. From your answer, it seems like "no" - though my Scala is superficial and rusty.
The Haskell equivalent is join :: Monad m => m (m a) -> m a
We also have the equivalent specialized to lists: concat :: [[a]] -> [a]
And as you say, join = bind id = (>>= id).
Incidentally, in math that function is the "eta" in the triple representing a monad.
Don't know the equivalent of flatten in Haskell, but if you want a signature then it is something like:
Or another way of thinking about it ... So basically, in order to define a monad, implementing flatMap is equivalent to implementing flatten. And I think that "flatten" as a verb is very intuitive, although intuitiveness is subjective since it's tightly related to familiarity - but flatten has been used in many languages as an operation available for collections and it works for monads in general just as well.