What advantage does Monad give us over an Applicative?

Posted by arrowdodger on Stack Overflow See other posts from Stack Overflow or by arrowdodger
Published on 2013-07-01T16:26:15Z Indexed on 2013/07/02 5:05 UTC
Read the original article Hit count: 126

I've read this article, but didn't understand last section.

The author says that Monad gives us context sensitivity, but it's possible to achieve the same result using only an Applicative instance:

let maybeAge = (\futureYear birthYear -> if futureYear < birthYear
    then yearDiff birthYear futureYear
    else yearDiff futureYear birthYear) <$> (readMay futureYearString) <*> (readMay birthYearString)

It's uglier for sure, but beside that I don't see why we need Monad. Can anyone clear this up for me?

© Stack Overflow or respective owner

Related posts about haskell

Related posts about functional-programming