Hi, all<br><br>I&#39;m new to haskell and currently reading yaht. I find some problems when trying to solve exercise 3.10.<br><br>The
exersices asks to read a list of numbers terminated by a zero, and
figure out the sum and product of the list. My program is as follows:<br>
<br>ex3_10 = do<br>  hSetBuffering stdin LineBuffering<br>  numbers &lt;- getNumber<br>  let sum = foldr (+) 0 numbers<br>      product = foldr (*) 1 numbers<br>  putStrLn &quot;The sum is &quot; ++ show(sum)<br>  putStrLn &quot;The product is &quot; ++ show(product)<br>

<br>getNumber = do<br>  putStrLn &quot;Give me a number (or 0 to stop):&quot;<br>  num &lt;- getLine<br>  if read num == 0<br>     then return []<br>     else do<br>       rest &lt;- getNumber<br>       return (read num : rest)<br>

<br>But when i load the program, ghci reports error:<br>    Couldn&#39;t match expected type `[a]&#39; against inferred type `IO ()&#39;<br>    In the first argument of `(++)&#39;, namely `putStrLn &quot;The sum is &quot;&#39;<br>

    In a stmt of a &#39;do&#39; expression:<br>          putStrLn &quot;The sum is &quot; ++ show (sum)<br><br>And i just don&#39;t understand the first sentence. Could you tell what does it mean?<br><br>Thanks for your reply