title: haskell reading and iterating
body: <p>I need your help guys. 
  Im trying to learn and do a simple task in haskell, but it's still hard for me.
  What im trying to do is: Read a line of numbers separated with whitespace, iterate over that list, check values, and if values are not zero add 1 otherwise -1. I was trying to do it watching some tutorials and other project code, but it just outputs a bunch of errors.
  My code:</p>
  
  <pre><code>import System.Environment
  import Control.Monad
  import Text.Printf
  import Data.List
  import System.IO
  
  solve :: IO ()
  solve = do
      nums &lt;- map read . words &lt;$&gt; getLine
      print (calculate nums)
  
  calculate (x:xs) = x + check xs
  
  check num
      | num == 0 =
          -1
      | otherwise = 
          1
  
  main :: IO ()
  main = do
      n &lt;- readLn
      if n /= 0
          then do 
              printf "Case: "
              solve
          else main
  </code></pre>
  
  <p>Errors:</p>
  
  <pre><code>C:\Users\Donatas\Documents\haskell\la3.hs:9:21: error:
      * Ambiguous type variable `b0' arising from a use of `read'
        prevents the constraint `(Read b0)' from being solved.
        Probable fix: use a type annotation to specify what `b0' should be.
        These potential instances exist:
          instance Read BufferMode -- Defined in `GHC.IO.Handle.Types'
          instance Read Newline -- Defined in `GHC.IO.Handle.Types'
          instance Read NewlineMode -- Defined in `GHC.IO.Handle.Types'
          ...plus 25 others
          ...plus six instances involving out-of-scope types
          (use -fprint-potential-instances to see them all)
      * In the first argument of `map', namely `read'
        In the first argument of `(.)', namely `map read'
        In the first argument of `(&lt;$&gt;)', namely `map read . words'
    |
  9 |         nums &lt;- map read . words &lt;$&gt; getLine
    |                     ^^^^
  
  C:\Users\Donatas\Documents\haskell\la3.hs:10:9: error:
      * Ambiguous type variable `a0' arising from a use of `print'
        prevents the constraint `(Show a0)' from being solved.
        Probable fix: use a type annotation to specify what `a0' should be.
        These potential instances exist:
          instance Show HandlePosn -- Defined in `GHC.IO.Handle'
          instance Show BufferMode -- Defined in `GHC.IO.Handle.Types'
          instance Show Handle -- Defined in `GHC.IO.Handle.Types'
          ...plus 27 others
          ...plus 13 instances involving out-of-scope types
          (use -fprint-potential-instances to see them all)
      * In a stmt of a 'do' block: print (calculate nums)
        In the expression:
          do nums &lt;- map read . words &lt;$&gt; getLine
             print (calculate nums)
        In an equation for `solve':
            solve
              = do nums &lt;- map read . words &lt;$&gt; getLine
                   print (calculate nums)
     |
  10 |         print (calculate nums)
     |         ^^^^^^^^^^^^^^^^^^^^^^
  
  C:\Users\Donatas\Documents\haskell\la3.hs:12:1: error:
      * Non type-variable argument in the constraint: Num [a]
        (Use FlexibleContexts to permit this)
      * When checking the inferred type
          calculate :: forall a. (Eq a, Num [a], Num a) =&gt; [a] -&gt; a
     |
  12 | calculate (x:xs) = x + check xs
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  Failed, no modules loaded.
  </code></pre>