
I am having hard time making sense of the types in the following example from the Applicative Programming paper: http://www.cs.nott.ac.uk/~ctm/IdiomLite.pdf ap :: Monad m ⇒ m (a → b ) → m a → m b ap mf mx = do f ← mf x ← mx return (f x ) Using this function we could rewrite sequence as: sequence :: [ IO a ] → IO [ a ] sequence [ ] = return [ ] sequence (c : cs ) =* return (:) 'ap' c *'ap' sequence cs I am specifically confused over the type of "m" in: return (:) 'ap' c "c" is obviously an instance of IO a monad. "return (:)" on the other hand (at least as I would expect it) is an instance of " ->" monad. a) are the above statements correct? b) if so, does it make sense for the "ap" function to have two different instances of the "m"? thanks for you help daryoush