News for hackers. Stuff that matters.
Re:Swift Functors, Applicatives, and Monads in Pictures by quchen on Tuesday July 14, 2015 @06:04PM (#9888384)
"flatmap" hints at it consisting of two components, flattening and mapping. Both are to be seen in a generalized context though, and the words are familiar to many when thinking about collections.

1. Mapping - the same as what Functor/Mappable provides. We use this to "map" over a structure, producing a nested structure.

2. Flattening: we just built our nested structure, time to squash it again.

In types akin to templates,

    Structure<A>
    ------------------------ (map something suitable over it)
    Structure<Structure<B>>
    ------------------------ (flatten it)
    Structure<B>
It's not a terrible name, but it probably doesn't help seeing the bigger picture either. "Flattening" a parser, a subroutine, an empty thing -- that's not really something very intuitive.
Re:Swift Functors, Applicatives, and Monads in Pictures by Tyr42 on Wednesday July 15, 2015 @09:14AM (#9891053)
Join (flatten) is a fundamental monadic operation.

    join:: m (m a) -> m a
I have a parser of a single character and a way to generate new character parsers

char :: Char -> Parser Char x :: (Parser Char) let y = fmap (char . toUpper) x :: (Parser (Parser Char))

It's a parser which creates a new parser out of the input it consumes.

I do think that fmap/pure/join is the easier to understand set of defining functions for monads.

Re:Swift Functors, Applicatives, and Monads in Pictures by quchen on Wednesday July 15, 2015 @02:07PM (#9892991)
join is one possible fundamental monadic operation. You can also define monads in other ways, such as endofunctors such that the Kleisli structure forms a category. In this case, you have the identity arrow (called return in Haskell) and Kleisli composition (<=< in Haskell) as fundamental operations. Neither of these is more fundamental than the other. You can convert back and forth,

    f >=> g = \x -> f x >>= g
    m >>= f = (f <=< id) m
    
    join = (>>= id)
    m >>= f = join (fmap f m)
So if you're focused on composing monadic operations, thinking about it in terms of >=> is often a good idea.