For an exercise, I've been trying to implement liftM2 using just the functions ap and liftM. The functions are defined as:
ap :: IO (a -> b) -> IO a -> IO b
liftM :: (a -> b) -> IO a -> IO b
liftM2 :: (a -> b -> c) -> IO a -> IO b -> IO c
I can easily do liftM2 using do notation but not sure how to do it using just ap and liftM. I was thinking of having the result be something that looks like this:
liftM2 f a b = liftM (_) (ap _ a)
I'm confused on how to mess with f, which is (a -> b -> c) such that I can just turn a to b and b to c. Thank you.