[Haskell-cafe] need help making sense of the type ...
Daryoush Mehrtash
dmehrtash at gmail.com
Wed Sep 24 22:51:07 EDT 2008
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080924/8186adef/attachment.htm
More information about the Haskell-Cafe
mailing list