title: How do you print inside a case statement in SML?
body: <p>I'm just starting out with SML, and I'm trying to modify some code so I understand what it's doing (I can't find a decent SML/NJ debugger, but that's a separate question).</p>
  <pre><code>fun type_check e theta env non_gens = 
    case e of
      constant_int _  =&gt; (integer, theta) 
    | constant_bool _ =&gt; (boolean, theta) 
    | ...
  </code></pre>
  <p>Assume this is valid code in that <code>constant_int</code> is part of a datatype already declared, etc. How do I add a print statement to say 'Returning &quot;integer&quot;' to the case? I tried:</p>
  <pre><code>...
  constant_int _ =&gt; (print &quot;returning integer&quot;) (integer, theta)
  ...
  </code></pre>
  <p>But I get:</p>
  <pre>
      stdIn:167.22-167.65 Error: operator is not a function [tycon mismatch]
        operator: unit
        in expression:
          (print "returning integer") (integer,theta)
  </pre>
  <p>I think I'm just not understanding how to execute a sequence of statements, only the last of which should be treated as the return value. Any advice?</p>
  <p>Also, how would I print my own datatype value? SML didn't like when I tried to pass a datatype value into <code>print()</code> so I probably have to create a new print function for each datatype, is that correct?</p>