title: In Haskell, when do we use in with let?
body: <p>In the following code, the last phrase I can put an <code>in</code> in front. Will it change anything? </p>
  
  <p>Another question: If I decide to put <code>in</code> in front of the last phrase, do I need to indent it? </p>
  
  <p>I tried without indenting and hugs complains </p>
  
  <blockquote>
    <p>Last generator in do {...} must be an expression</p>
  </blockquote>
  
  <pre><code>import Data.Char
  groupsOf _ [] = []
  groupsOf n xs = 
      take n xs : groupsOf n ( tail xs )
  
  problem_8 x = maximum . map product . groupsOf 5 $ x
  main = do t &lt;- readFile "p8.log" 
            let digits = map digitToInt $concat $ lines t
            print $ problem_8 digits
  </code></pre>
  
  <hr>
  
  <h3>Edit</h3>
  
  <p>Ok, so people don't seem to understand what I'm saying. Let me rephrase:
  are the following two the same, given the context above?</p>
  
  <p>1.</p>
  
  <pre><code>let digits = map digitToInt $concat $ lines t
  print $ problem_8 digits
  </code></pre>
  
  <p>2.</p>
  
  <pre><code>let digits = map digitToInt $concat $ lines t
  in print $ problem_8 digits
  </code></pre>
  
  <p>Another question concerning the scope of bindings declared in <code>let</code>: I read <a href="http://www.haskell.org/tutorial/patterns.html" rel="noreferrer">here</a> that:</p>
  
  <blockquote>
    <p><code>where</code> Clauses.</p>
  </blockquote>
  
  <p>Sometimes it is convenient to scope bindings over several guarded equations, which requires a where clause: </p>
  
  <pre><code>f x y  |  y&gt;z           =  ...
         |  y==z          =  ...
         |  y&lt;z           =  ...
       where z = x*x
  </code></pre>
  
  <p>Note that this cannot be done with a let expression, which only scopes over the expression <strong>which it encloses</strong>.</p>
  
  <p>My question: so, the variable digits shouldn't be visible to the last print phrase. Do I miss something here?</p>