
Applicative and monadic composition *should* be the same, given that Applicative contains the law
(<*>) = ap
Ah, I probably wasn't too clear with that last comment. What I meant by "applicative and monadic composition don't always yield the same result" is that Compose m Maybe and MaybeT m are *not* interchangeable, despite their unwrapped types being the same. As you point out, the latter short-circuits but the former does not. I guess a better wording is that there is often more than one way to compose things. (Compose is from Data.Functor.Compose in the transformers package.) Chris
And in fact if we rewrite Andras solution as
try a b = (<|>) <$> a <*> b
It is still broken.
The fact that you find libraries where (<*>) is not ap has been confusing for me as well :P.
Evan's `try` doesn't use Applicative at all, but short-circuits manually. For this kind of stuff I usually use MaybeT.
Francesco