[Haskell-cafe] Stacking monads
jake at pikewerks.com
Fri Oct 3 14:30:46 EDT 2008
Andrew Coppin wrote:
> (As an aside, Control.Monad.ap is not a function I've ever heard of.
> It seems simple enough, but what an unfortunate name...!)
I think it makes sense. It stands for "apply," or at least that is what
I think of when I see it. If we have a function f :: A -> B -> C -> D
and values a :: m A, b :: m B, c :: m C, then we can do:
f `liftM` a `ap` b `ap` c
... which is the same as (using Applicative):
f <$> a <*> b <*> c
... both having type m D.
More information about the Haskell-Cafe