Question in "Monads for Functional Programming"

Hi all, I am referring to P. Wadler, "Monads for functional programming," Advanced Functional Programming, pp. 24-52, 1995. I cannot understand in chapter 2.6, why a*k = k a. I cannot ask anyone else this time of night (3am here J), thus I posted here! Best regards! -- Aggelos Mpimpoudis Doctoral Researcher, Pervasive Computing [p-comp.di.uoa.gr] SDE, Nessos IT S.A. [www.nessos.gr] (m): +306942075153 http://gr.linkedin.com/in/aggelosmp Description: Linkedin http://www.facebook.com/aggelosmp Description: Facebook http://www.studentguru.gr/blogs/grnemo/ Description: Blog RSS http://twitter.com/aggelosmp Description: Twitter

On Friday 14 January 2011 01:10:39, Aggelos Mpimpoudis wrote:
Hi all,
I am referring to P. Wadler, "Monads for functional programming," Advanced Functional Programming, pp. 24-52, 1995. I cannot understand in chapter 2.6, why a*k = k a.
Wadler uses (*) in that paper for what is (>>=) in Haskell (and unit for return). In 2.6, he treats the identity monad (in Haskell, you have to wrap it in a newtype, Wadler uses a type synonym). If partial application of type synonyms were possible in Haskell, the identity monad would be type Id a = a instance Monad Id where -- return :: Monad m => a -> m a return x = x -- (>>=) :: Monad m => m a -> (a -> m b) -> m b m >>= f = f m For the unwrapped identity monad, you'd have return :: a -> a {- = Id a -} (>>=) :: a -> (a -> b) -> b A function of type a -> (a -> b) -> b can basically only be the flipped application (ignoring seq and undefineds). Actually (with the newtype), it's newtype Identity a = Identity { runIdentity :: a } instance Monad Identity where return x = Identity x -- f :: a -> Identity b (Identity x) >>= f = f x
I cannot ask anyone else this time of night (3am here J), thus I posted here!
You can also ask on #haskell, it's always *not* 3 am somewhere ;) HTH, Daniel
participants (2)
-
Aggelos Mpimpoudis
-
Daniel Fischer