3 ms·
My definition of flatten would be: m m a -> m a Definitely not arbitrary but maybe not useful for many monads (??)
by bryan0 5y ago
My definition of flatten would be:
m m a -> m a
Definitely not arbitrary but maybe not useful for many monads (??)
- Dylan16807 5y agoThat's just a signature though, and the implementation could do so many things for complex and/or strange data structures. So in a sense yes it's "just" this function that could do anything following the signature. But now you're in the same place you already were, looking at a simple type signature with massive hidden implications, and if you treat it like a list you'll miss those implications. "flatmap generalized to a vast field of dissimilar types" is much more complicated than just "flatmap"
- wyager 5y agoYeah, in formal terminology that’s “join”. Join + return + monad laws is a perfectly reasonable definition of a monad.
- acomar 5y agoyou need fmap as well.