title: Can I create a function at runtime by evaluating a string?
body: <p>In my program for solving discrete maths, I want to let the user input a string of logic operations; <em>e.g.,</em> if the user inputs <code>let f (x:y:_) = x &amp;&amp; y</code>, then I would get a function <code>f</code> for use in the rest of the program.  In GHCi, I can easily test my program by inputting <code>let f (x:y:_) = x &amp;&amp; y</code>.</p>
  
  <p>I have no idea how to achieve this task.  I have taken a look into the <a href="http://hackage.haskell.org/packages/archive/plugins/1.5.1.3/doc/html/System-Eval-Haskell.html" rel="noreferrer"><code>eval</code></a> function from the <code>plugins</code> package, but it seems not to be the right function.  Can I do this in Haskell?</p>
  
  <p>The code I'm planning to use this with is:</p>
  
  <pre><code>type TruthTable = [[Bool]]
  type TruthTableResult = [([Bool], Bool)]
  
  solveTable :: ([Bool] -&gt; Bool) -&gt; Integer -&gt; (TruthTableResult)
  solveTable f n = let table = truthTable n
                       result = map f table
                   in  zipWith (\v r -&gt; (v, r)) table result
  </code></pre>