On Fri, May 29, 2009 at 8:04 PM, Bartosz Wójcik <[email protected]> wrote:
> On Friday 29 May 2009 22:10:51 Bryan O'Sullivan wrote:
>> > myFloat = try (symbol "-" >> float >>= return . negate)
>> >     <|>  try float
>> >     <|>  (integer >>= return . fromIntegral)
>>
>> Any time you see ">>= return .", something is being missed. Use liftM or
>> <$> instead, i.e. "fromIntegral <$> integer" instead of "integer >>= return
>> . fromIntegral".
>
> I don't undersdand what is being missed.
>
> liftM f m1              = do { x1 <- m1; return (f x1) }
> so
> liftM fromIntegral integer
> will result the same. Is it then not just a convenience?

For some monads, fmap (or <$>) has a more efficient definition than
liftM. Otherwise, it's just a style thing.

-- 
Dave Menendez <[email protected]>
<http://www.eyrie.org/~zednenem/>
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to