title: Is it possible to emulate a function using your own data type?
body: <p>Is it possible to emulate a function with your own data type with some GHC extension? What I want to do is e.g.</p>
  
  <p>(imaginary syntax)</p>
  
  <pre><code>data MyFunc = MyFunc String (Int->Int)
  
  instance (Int->Int) MyFunc where
      ($) (MyFunc _ f) i = f i
  
  inc = MyFunc "increment" (1+)
  
  test = inc 1</code></pre>
  
  <p>I.e. data that carries some meta-information with it and can be pattern matched, but which can still be called like a regular function. Now, I know that I could define my own infix operator like <code>$$</code> and call <code>inc $$ 1</code>, but being able to use the regular function call syntax would be very useful in embedded DSLs.</p>