> I know this has been written about way too much, but I was 
> wondering what
> people thought about using 'liftM f' as opposed to '>>= 
> return . f'.  I
> would probably have written Andrew's code using liftM, but I 
> don't know if
> one is necessarily better than the other.  Does anyone have strong
> thoughts on this?

so, using liftM:

        (number g >>= return . show)

becomes

        (liftM show (number g))

or
        (show `liftM` number g)

but it's important not to get too carried away with abstractions - this
example requires a bit of a trawl around the library documentation for
someone not familiar with liftM.  Personally, unless I was writing
fragments like this a lot, I'd just write it as

        (do r <- number g; return (show r))

Each to his own I suppose.

Cheers,
        Simon
_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to