3 ms·
It certainly doesn't have to be flatmap. But the idea is that someone takes some time to think up an English name and does a bit of user testing to make sense t
by skybrian 11y ago
It certainly doesn't have to be flatmap. But the idea is that someone takes some time to think up an English name and does a bit of user testing to make sense to regular programmers.
This seems to be the approach that Elm is taking. (Although they're reluctant to add monads at all since they take ease of use seriously.)
- gclaramunt 11y agoWhat's wrong with 'bind' ?
- skybrian 11y agoWhat's being bound? Perhaps "then" would work. JavaScript promises use it to good effect, and they're a monad.
- VladimirGolovin 11y agoSmaller computations are being bound into a larger computation, where the monad provides the the code that is executed 'between the lines'. (BTW, my own take on renaming a monad into something less scary is daisychain, or, slightly more to-the-point, chainable.)
- tel 11y ago(>>=) :: M a -> (a -> M b) -> M b The `a` is bound in the second argument.
- wetmore 11y agoWe all know that naming is one of the hard problems in computer science. Monads in programming have been around for 20+ years now, and you are certainly not the first one to complain about their name. So where are the better alternatives? Surely someone must have come up with a better one by now? Instead we get nice "English" names which only work for certain monad instances and fail to adequately describe others. Elm uses "andThen" instead of "bind", which works pretty well for the monadic types in its core library. But you need to start stretching your imagination to see why "andThen" makes sense for other monadic types. Honestly, I'm fine with "andThen", especially in the context of Elm and the monads it implicitly uses. But in the wider world of programming where exotic but useful monad instances exist I'd rather stick to the most general name. By the way, the more pressing reason for Elm not having monads is the fact that it doesn't have typeclasses (or a similar concept) and doesn't allow you to parametrize over higher-kinded types (like Maybe).