title: haskell Function taking 2 arguments returns function which takes one argument?
body: <p>Consider this code:</p>
  
  <pre><code>type Graph = (Char, Function) 
  type Function = Char -&gt; Int 
  doThingsWithGraph :: Graph -&gt; String
  func :: Function 
  graph :: Graph
  
  main = do  x &lt;- getChar
             y &lt;- getChar
             let graph = (x, func)
             putStrLn $ doThingsWithGraph graph
  </code></pre>
  
  <p>The implementation of <code>doThingsWithGraph</code> does not matter for now. Now the issue here is that the <code>func</code>'s output also depends on the second char I am getting from the user, but I have no idea how to pass it on to it. I can't pass it as an argument because func is implemented by third party and I can't change the type. So if haskell had global variables and <code>y</code> was one the <code>func</code>'s implementation would look something like this:</p>
  
  <pre><code>func char 
         |isDigit char = digitToInt char + digitToInt y
         |otherwise    = digitToInt y
  </code></pre>
  
  <p>This obviously doesn't work because <code>func</code> has no idea what <code>y</code> is, but that's the idea of what it should do. So <code>y</code> is the value that I need somehow to let <code>func</code> know about (it is the one I'm getting from user in the second line of <code>main</code>). I can't do <code>getLine</code> inside <code>func</code> because that won't be consistent with data type which I can't change (part of the large framework). Any ideas? Maybe some helper function can replace <code>func</code> in <code>let graph = (x, func)</code>and then return the function of type Function? This is just a guess..</p>