News for hackers. Stuff that matters.
Re:Applicative Functors by sfvisser on Sunday August 10, 2014 @11:50AM (#8159985)
This isn't true. They are absolutely not the same and don't yield the same behavior for every monad/applicative pair.

First, you probably meant:

    do x <- a
       y <- b
       return (x + y) -- not: a + b
With the current desugaring of do-syntax there is no way the compiler will know that the statement 'b' doesn't have a dependency on the variable 'x' and will desugar to:

    a >>= \x -> b >>= \y -> return (x + y)
or, maybe more legible:

    bind a (\x -> bind b (\y -> return (x + y))
So, even if the 'b' doesn't use 'x', it is implicitly sequential and the effects of 'a' yielding 'x' need to be done before the effects of 'b' yielding 'y'. This can be a waste, e.g. when both are network calls that can be done in parallel.

The `Applicative` interfaces statically guarantees there is no data dependency and might therefor have a smarter implementation. For `Monad` this simply isn't possible. It's a subtle, but very important, difference.

Re:Applicative Functors by gizmo686 on Sunday August 10, 2014 @12:30PM (#8160055)
Given the function "\x -> b", it is impossible for b to depend on x.
Re:Applicative Functors by sfvisser on Sunday August 10, 2014 @03:00PM (#8160399)
Yes, but with the same syntax you could have written '\x -> b x', changing that assumption entirely.