text: Q:
  
  Pass function with different signature than is expected
  
  I am using AMQP library for Haskell in a message consuming console application. I am binding a message handler like this:
    consumeMsgs ch "tasks" Ack taskHandler
  
  My problem is that consumeMsgs expects a message handler with this signature:
  taskHandler :: (Message, Envelope) -> IO ()
  
  ...but I need to pass in additional Channel and a Lock (Channel so I can publish the result to a different queue, Lock for printing to console), like this:
  taskHandler :: (Message, Envelope) -> Channel -> MVar () -> IO ()
  
  I come from Javascript land, but I don't expect a dirty solution like a global variable. What can be done here?
  
  A:
  
  I'm a little unclear on your constraints, but if you have what you need available at the consumeMsgs call site, you can use a closure.  (I assume ch is the channel you want)
  lock <- ...
  consumeMsgs ch "tasks" Ack (\(msg,env) -> taskHandler (msg,env) ch lock)
  
  (It's not strictly necessary to match on the tuple (msg,env) since it's just used directly, it was just the best name for the thing I could think of)
  If you change the order of the arguments to taskHandler you can get a very idiomatic Haskell solution with partial application:
  taskHandler :: Channel -> MVar () -> (Message, Envelope) -> IO ()
  
  ...
  
  consumeMsgs ch "tasks" Ack (taskHandler ch lock)
  
  