title: Haskell: Getting error when accepting string input in user defined function
body: <p>I'm a newbie in Haskell. Was trying a code to take input string in user defined function and further perform tasks as per argument passed to function in main.</p>
  <pre><code>main :: IO()
  main=do
  {
      print(f 2)
  }
  f::Int-&gt;Int
  f n=do
  {
      inp&lt;-getLine;
      if (inp==&quot;hello&quot;) then (n+2);
      else                   (n);
  }
  </code></pre>
  <p>Since this function takes int and returns int, I defined it as Int-&gt;Int. However I feel something's missing.
  I'm getting the following error:-</p>
  <pre><code>[1 of 1] Compiling Main             ( main.hs, main.o )
  main.hs:9:5: error:
      • Couldn't match expected type ‘Int’ with actual type ‘IO b0’
      • In a stmt of a 'do' block: inp &lt;- getLine
        In the expression:
          do inp &lt;- getLine
             if (inp == &quot;hello&quot;) then (n + 2) else (n)
        In an equation for ‘f’:
            f n
              = do inp &lt;- getLine
                   if (inp == &quot;hello&quot;) then (n + 2) else (n)
    |
  9 |     inp&lt;-getLine;
    |     ^^^^^^^^^^^^
  main.hs:10:29: error:
      • Couldn't match expected type ‘IO b0’ with actual type ‘Int’
      • In the expression: (n + 2)
        In a stmt of a 'do' block:
          if (inp == &quot;hello&quot;) then (n + 2) else (n)
        In the expression:
          do inp &lt;- getLine
             if (inp == &quot;hello&quot;) then (n + 2) else (n)
     |
  10 |     if (inp==&quot;hello&quot;) then (n+2);
     |                             ^^^
  main.hs:11:29: error:
      • Couldn't match expected type ‘IO b0’ with actual type ‘Int’
      • In the expression: (n)
        In a stmt of a 'do' block:
          if (inp == &quot;hello&quot;) then (n + 2) else (n)
        In the expression:
          do inp &lt;- getLine
             if (inp == &quot;hello&quot;) then (n + 2) else (n)
     |
  11 |     else                   (n);
     |                             ^
  </code></pre>
  <p>How to rectify this error??</p>