title: How to replace "let/in" construction with "where" in IO () function in Haskell?
body: <p>I am studying Haskell and trying my first IO functions. Here a simple program that calculates the area of a rectangle, it works fine:</p>
  <pre><code>squareCalc :: IO ()
  squareCalc = do
    putStrLn &quot;Pease enter the lenght&quot;
    length &lt;- getLine
    putStrLn &quot;Pleas enter the width&quot;
    width &lt;- getLine
    let square = read length * read width
     in putStrLn (&quot;The square is &quot; ++ show square)
  </code></pre>
  <p>However, when I try to replace &quot;let/in&quot; with &quot;where&quot;:</p>
  <pre><code>squareCalc2 :: IO ()
  squareCalc2 = do
    putStrLn &quot;Pease enter the lenght&quot;
    length &lt;- getLine
    putStrLn &quot;Pleas enter the width&quot;
    width &lt;- getLine
    putStrLn (&quot;The square is &quot; ++ show square) 
      where
         square = (read length) * (read width)
  </code></pre>
  <p>the compiler returns an error error:</p>
  <blockquote>
  <p>Variable not in scope: width :: String</p>
  </blockquote>
  <p>I am wondering if there ever possible to use &quot;where&quot; in functions like this?</p>