No problem.  Haskell is a different animal than even other functional languages in my experience, and it takes time to get used to the coolness in the type system, the lazy evaluation, the point free style, functional composition and all the other interesting techniques you now have at your fingertips for writing very expressive code :-).<div>
<br></div><div><div>Do that for a while then go back to algol based languages, and wonder why the heck anyone uses those on purpose :-).  (yeah there&#39;s good reasons to use them, but it starts to feel confining)</div><div>
<br></div><div>Dave</div><div><div><br><div class="gmail_quote">On Fri, Dec 17, 2010 at 4:28 PM, 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">Hi, all.<br><br>Plenty of answers. Thank you.<br><br>Putting the list in the IO monad was deliberate. Another one I was looking at was<br>
<br>f :: String -&gt; IO String<br>f s = do return s<br><br>main = do ios &lt;- f &quot;hello&quot;<br>          fmap tail ios<br><br>which worked fine<br><br>So, the big error was trying to add  1 + [1,2,3,4,5].<br><br>I considered that I needed an additional fmap and thought I had tried<br>
<br>fmap (fmap (1+)) iol<br><br>but must have messed it up, because I got an error. I guess I was on the right track.<br><br>I like to try various combinations to test my understanding. It&#39;s kind of embarrassing when I get stumped by something simple like this, but that&#39;s how one learns.<br>
<br>Thanks again,<br><br>Michael<br><br>--- On Fri, 12/17/10, Daniel Fischer
 &lt;<a href="mailto:daniel.is.fischer@googlemail.com" target="_blank">daniel.is.fischer@googlemail.com</a>&gt; wrote:<br><br><br>    From: Daniel Fischer &lt;<a href="mailto:daniel.is.fischer@googlemail.com" target="_blank">daniel.is.fischer@googlemail.com</a>&gt;<br>
    Subject: Re: [Haskell-cafe] Why is Haskell flagging this?<br>    To: <a href="mailto:haskell-cafe@haskell.org" target="_blank">haskell-cafe@haskell.org</a><br>    Cc: &quot;michael rice&quot; &lt;<a href="mailto:nowgate@yahoo.com" target="_blank">nowgate@yahoo.com</a>&gt;<br>
    Date: Friday, December 17, 2010, 4:24 PM<div class="im"><br><br>    On Friday 17 December 2010 18:04:20, michael rice wrote:<br>    &gt; I don&#39;t understand this error message. Haskell appears not to understand<br>
    &gt; that 1 is a Num.<br>    &gt;<br></div><div class="im">    &gt; Prelude&gt; :t 1<br>    &gt; 1 :: (Num t) =&gt; t<br>    &gt; Prelude&gt; :t [1,2,3,4,5]<br>    &gt; [1,2,3,4,5] :: (Num t) =&gt; [t]<br>    &gt; Prelude&gt;<br>
    &gt;<br>    &gt;
 Michael<br>    &gt;<br>    &gt; ===================<br>    &gt;<br>    &gt; f :: [Int] -&gt; IO [Int]<br>    &gt; f lst = do return lst<br>    &gt;<br>    &gt; main = do let lst = f [1,2,3,4,5]<br>    &gt;           fmap (+1) lst<br>
<br></div>    The fmap is relative to IO, your code is equivalent to<br><br>    do let lst = (return [1,2,3,4,5])<br>       fmap (+1) lst<br><br>    ~&gt;<br><br>    fmap (+1) (return [1,2,3,4,5])<br><br>    ~&gt;<br><br>
    do lst &lt;- return [1,2,3,4,5]<br>       return $ (+1) lst<br><br>    but there&#39;s no instance Num [Int] in scope<br><br>    You probably
 meant<div class="im"><br><br>    do let lst = f [1,2,3,4,5]<br></div>       fmap (map (+1)) lst<div class="im"><br><br>    &gt;<br>    &gt; ===============================<br>    &gt;<br>    &gt; Prelude&gt; :l test<br>
    &gt; [1 of 1] Compiling Main             ( test.hs, interpreted )<br>    &gt;<br>    &gt; test.hs:5:17:<br>    &gt;     No instance for (Num [Int])<br>    &gt;       arising from the literal `1&#39; at test.hs:5:17<br>
    &gt;     Possible fix: add an instance declaration for (Num [Int])<br>    &gt;     In the second argument of `(+)&#39;, namely `1&#39;<br>    &gt;     In the first argument of
 `fmap&#39;, namely `(+ 1)&#39;<br>    &gt;     In the expression: fmap (+ 1) lst<br>    &gt; Failed, modules loaded: none.<br>    &gt; Prelude&gt;<br><br><br></div>--- On <b>Fri, 12/17/10, Daniel Fischer <i>&lt;<a href="mailto:daniel.is.fischer@googlemail.com" target="_blank">daniel.is.fischer@googlemail.com</a>&gt;</i></b> wrote:<br>
<blockquote style="border-left:2px solid rgb(16, 16, 255);margin-left:5px;padding-left:5px"><br>From: Daniel Fischer &lt;<a href="mailto:daniel.is.fischer@googlemail.com" target="_blank">daniel.is.fischer@googlemail.com</a>&gt;<br>
Subject: Re: [Haskell-cafe] Why is Haskell flagging this?<br>To: <a href="mailto:haskell-cafe@haskell.org" target="_blank">haskell-cafe@haskell.org</a><br>Cc: &quot;michael rice&quot; &lt;<a href="mailto:nowgate@yahoo.com" target="_blank">nowgate@yahoo.com</a>&gt;<br>
Date: Friday, December 17, 2010, 4:24 PM<br><br><div><div class="im">On Friday 17 December 2010 18:04:20, michael rice wrote:<br>&gt; I don&#39;t understand this error message. Haskell appears not to understand<br>&gt; that 1 is a Num.<br>
&gt;<br></div><div class="im">&gt; Prelude&gt; :t 1<br>&gt; 1 :: (Num t) =&gt; t<br>&gt; Prelude&gt; :t [1,2,3,4,5]<br>&gt;
 [1,2,3,4,5] :: (Num t) =&gt; [t]<br>&gt; Prelude&gt;<br>&gt;<br>&gt; Michael<br>&gt;<br>&gt; ===================<br>&gt;<br>&gt; f :: [Int] -&gt; IO [Int]<br>&gt; f lst = do return lst<br>&gt;<br>&gt; main = do let lst = f [1,2,3,4,5]<br>
&gt;           fmap (+1) lst<br><br></div>The fmap is relative to IO, your code is equivalent to<br><br>do let lst = (return [1,2,3,4,5])<br>   fmap (+1) lst<br><br>~&gt;<br><br>fmap (+1) (return [1,2,3,4,5])<br><br>~&gt;<br>
<br>do lst &lt;- return [1,2,3,4,5]<br>   return $ (+1) lst<br><br>but there&#39;s no instance Num [Int] in scope<br><br>You probably meant<div class="im"><br><br>do let lst = f [1,2,3,4,5]<br></div>   fmap (map (+1)) lst<div class="im">
<br><br>&gt;<br>&gt; ===============================<br>&gt;<br>&gt; Prelude&gt; :l test<br>&gt; [1 of 1] Compiling Main             ( test.hs, interpreted
 )<br>&gt;<br>&gt; test.hs:5:17:<br>&gt;     No instance for (Num [Int])<br>&gt;       arising from the literal `1&#39; at test.hs:5:17<br>&gt;     Possible fix: add an instance declaration for (Num [Int])<br>&gt;     In the second argument of `(+)&#39;, namely `1&#39;<br>
&gt;     In the first argument of `fmap&#39;, namely `(+ 1)&#39;<br>&gt;     In the expression: fmap (+ 1) lst<br>&gt; Failed, modules loaded: none.<br>&gt; Prelude&gt;<br><br></div></div></blockquote></td></tr></tbody></table>
<br>

      <br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br></div></div></div>