[Haskell-cafe] Functors [Comments from OCaml Hacker Brian Hurt]

Andrew Coppin andrewcoppin at btinternet.com
Sun Jan 18 06:23:04 EST 2009

Jonathan Cast wrote:
> On Sat, 2009-01-17 at 12:04 +0000, Andrew Coppin wrote:
>>> instance (Monad m) => Functor m where
>>>   fmap f ma = do a <- ma; return (f a)
>> While that's quite interesting from a mathematical point of view, how is 
>> this "useful" for programming purposes?
> Good Lord.  fmap (as above) is *at least* useful enough to be in the
> standard library!  (Control.Monad.liftM).

Given that liftM exists, why is having an identical implementation for 
fmap useful?

The example that leaps out at me is that (>>=) is identical to concatMap 
within the list monad. But using lists as a monad is a generally useful 
thing to do, and being able to substitute arbitrary monads has obvious 
utility. I'm not seeing how being able to treat something that isn't a 
container as if it was a container is useful.

More information about the Haskell-Cafe mailing list