<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 17 Dec 2010, at 21:44, Christopher Done wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_quote">On 17 December 2010 18:04, michael rice <span dir="ltr">&lt;<a href="mailto:nowgate@yahoo.com">nowgate@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" style="font:inherit"><span style="font-family:courier,monaco,monospace,sans-serif">===================<br><br>f :: [Int] -&gt; IO [Int]</span><br style="font-family:courier,monaco,monospace,sans-serif">

<span style="font-family:courier,monaco,monospace,sans-serif">f lst = do return lst</span><br style="font-family:courier,monaco,monospace,sans-serif"><br style="font-family:courier,monaco,monospace,sans-serif"><span style="font-family:courier,monaco,monospace,sans-serif">main = do let lst = f [1,2,3,4,5]</span><br style="font-family:courier,monaco,monospace,sans-serif">

<span style="font-family:courier,monaco,monospace,sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fmap (+1) lst</span></td></tr></tbody></table></blockquote><div>&nbsp;</div><div>The problem is that you are applying fmap to a type IO a.</div><div><br>
</div>
<div>fmap (+1) (return [1,2,3])</div><div><br></div><div>But to achieve the behaviour you expect, you need another fmap:</div><div><br></div><div>fmap (fmap (+1)) (return [1,2,3])</div></div></blockquote><br></div><div>Which can be more neatly written with Conal's semantic editor cominators as</div><div><br></div><div>(fmap . fmap) (+1) (return [1,2,3])</div><div><br></div><div>Of course, I question why the list is put in the IO monad at all here... surely this would be much better</div><div><br></div><div>return $ fmap (+1) [1,2,3]</div><br><div>Finally, that has the wrong type for main... perhaps you meant to print it out?</div><div><br></div><div>main :: IO ()</div><div>main = print $ fmap (+1) [1,2,3]</div><div><br></div><div>Bob</div></body></html>