[Haskell-cafe] Why is Haskell flagging this?
Christopher Done
chrisdone at googlemail.com
Fri Dec 17 22:44:55 CET 2010
On 17 December 2010 18:04, michael rice <nowgate at yahoo.com> wrote:
> ===================
>
> f :: [Int] -> IO [Int]
> f lst = do return lst
>
> main = do let lst = f [1,2,3,4,5]
> fmap (+1) lst
The problem is that you are applying fmap to a type IO a.
fmap (+1) (return [1,2,3])
But to achieve the behaviour you expect, you need another fmap:
fmap (fmap (+1)) (return [1,2,3])
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20101217/fc93a78b/attachment.htm>
More information about the Haskell-Cafe
mailing list