How and why is ap defined as liftM2 id in Haskell
Posted
by
luke_randall
on Stack Overflow
See other posts from Stack Overflow
or by luke_randall
Published on 2011-03-18T23:40:26Z
Indexed on
2011/03/19
0:10 UTC
Read the original article
Hit count: 223
haskell
|applicative
Whilst trying to better understand Applicative, I looked at the definition of <*>, which tends to be defined as ap, which in turn is defined as:
ap :: (Monad m) => m (a -> b) -> m a -> m b
ap = liftM2 id
Looking at the type signatures for liftM2 and id, namely:
liftM2 :: (Monad m) => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r
id :: a -> a
I fail to understand how just by passing in id, the relevant part of the type signature seems to transform from (a1 -> a2 -> r) -> m a1
to m (a -> b)
. What am I missing here?
© Stack Overflow or respective owner