News for hackers. Stuff that matters.
Re:Brilliance of Haskell's Maybe type and the Value of Stati... by jewbacca on Sunday July 25, 2010 @10:51PM (#1546970)
WARNING: This is the blind leading the blind. I was already well-upvoted for my previous post before realizing (thanks to you, tkahn) that my definition of bind was actually fmap (I think). Crying out for authority here; help us out HN.

---

You are not, strictly/pedantically speaking, because fmap is the single function that defines a Functor to begin with [1]:

  class Functor f where
    fmap :: (a -> b) -> f a -> f b
and Monads are a special case of Functors; so, as the defining relation of a Functor, it doesn't a priori have anything to do with Monads.

You are right in seeing that fmap is lifting -- liftM, which is defined in terms of just bind and return for Monads, is (I believe... see warning above) identically fmap. fmap = map for Lists as seen as Functors, for example, which lifts a function (a -> b) to ([a] -> [b])... "into" the Functor/Monad, I suppose.

---

[1] http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4...

There are no comments on this comment yet.