title: The usage of before in ML
body: <p>ML's before is described in <a href="http://sml-family.org/Basis/general.html" rel="nofollow">http://sml-family.org/Basis/general.html</a> as</p>
  
  <blockquote>
    <p>a before b
    returns a. It provides a notational shorthand for evaluating a, then b, before 
    returning the value of a. </p>
  </blockquote>
  
  <p>When I tried to use this command expecting x = 4 and (4+1) is evaluated</p>
  
  <pre><code>val x = (3+1 before 4+1)
  </code></pre>
  
  <p>I have the error message:</p>
  
  <pre><code>Standard ML of New Jersey v110.78 [built: Sun Apr 26 01:06:11 2015]
  - stdIn:1.11-1.25 Error: operator and operand don't agree [overload conflict]
    operator domain: [+ ty] * unit
    operand:         [+ ty] * [+ ty]
    in expression:
      (3 + 1 before 4 + 1)
  - 
  </code></pre>
  
  <p>What might be wrong?</p>
  
  <h2>Edit</h2>
  
  <p>From Matt's answer, I should have used </p>
  
  <pre><code>val x = (3+1 before print "&lt;end&gt;")
  </code></pre>
  
  <p>I also found that <code>before</code> is used to close the stream after processing some FileIO functions. </p>
  
  <pre><code>(* http://stackoverflow.com/questions/2168029/open-file-in-mlsmlnj *)
  val infile = "input.txt" ;
  
  (*  reading from file follow this to list of string per line *)
  fun readlist (infile : string) = let 
      val ins = TextIO.openIn infile 
      fun loop ins = 
       case TextIO.inputLine ins of 
              SOME line =&gt; line :: loop ins 
            | NONE      =&gt; [] 
  in 
      loop ins before TextIO.closeIn ins 
  end ;
  
  val pureGraph =  readlist(infile);
  
  size (hd pureGraph)
  </code></pre>