On Tue, Jan 18, 2011 at 09:16:06AM +0530, C K Kashyap wrote: > Hi, > I was going through http://en.wikipedia.org/wiki/Monad_(category_theory) - > under Formal Definition I notice that monad is a Functor T:C -> C > > My question is - when we think of Maybe as a functor T:C -> C .... should we > think that C here refers to Hakell types? As in, > (Int and Maybe Int are objects in C) and (Int -> Int and Maybe Int -> Maybe > Int are arrows in C) and T is an arrow between them. Is that right?
Yes, exactly. > I am not able to fully understand how those diagrams translate to haskell - > I can guess that T^2 -> T referes to things like concat operation but not > able to relate it to bind. The T^2 -> T operation in Haskell is called join :: Monad m => m (m a) -> m a which, as you correctly point out, is concat for the list monad. This presentation in terms of fmap, return, and join is another common way of presenting monads. To relate it with bind we have m >>= f = join (fmap f m) join m = m >>= id There are is also a form of the monad laws in terms of fmap, return, join. For more I recommend checking out http://en.wikibooks.org/wiki/Haskell/Category_theory -Brent _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe