title: How to create a polyvariadic haskell function?
body: <p>I need a function which takes an arbitrary number of arguments (All of the same type), does something with them and afterwards gives a result back. A list of arguments is impracticable in my specific case.</p>
  
  <p>As I looked through the haskell libs, I saw that the function <code>printf</code> (from module <code>Text.Printf</code>) uses a similar trick. Unfortunately, I couldn't understand that magic by looking at the source.</p>
  
  <p>Can somebody explain how to achieve this, or at least some webpage/paper/whatever where I could find a good description for this?</p>
  
  <p><strong>Motivation:</strong></p>
  
  <p>The reason I need this is really quite simple. For school (computer science class), we are required to write a module that is able to "record" a mathematical expression, express it as a string (Via writing an instance of Num/Real/etc for an own datatype), and perform various operations on it.  </p>
  
  <p>This datatype contains a special constructor for a variable, which may be replaced by a value or whatever by a specified function. One of the goals is to write a function, which takes such an expression with some number of variables (pairs of type <code>(Char,Rational)</code>) and calculates the result of the expression. We should look at how to express the goal of the function best. (My idea: The function returns another function which takes exactly as many arguments as vars that are defined in the function - seems to be impossible).</p>