Hacker News new | past | comments | ask | show | jobs | submit login

Personally, I'm just not sure what the association with monads is supposed to be.

Shouldn't Joe Armstrong know what function composition is when he sees it? (Although it is really weird that it slots into the first argument position.)




I suspect Joe is referring to the fact that when you desugar "do notation" you arrive at basically a lot of function composition:

    do x <- f
       y <- g
       return $ h (x + y)
becomes

    f >>= (\x -> g >>= (\y -> return (h (x+y))))
I don't think Joe does a lot of Haskell, so I'm not sure his vision of monads matches up with a Haskeller's though. For me, the fact that monadic do-notation desugars this way is less meaningful than that a monad is anything that supplies the functions bind and return with the necessary types. After all, not every block introduced by "do" is an SSA-friendly looking series of assignments leading up to some function call.


slotting into the first argument position is not weird, it's the functional idiom for the pattern "take a single value and apply a sequence of transforms (some of which have side inputs) to it". in an object-oriented language it would be foo = bar.f(args).g(args).h(args) where bar is being "piped" through the functions f, g, and h.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: