title: Plug new FFI method into GHC
body: <p>Is there a way to plug a Haskell function of type</p>
  
  <pre><code>myFFI :: (C a) =&gt; String -&gt; IO a
  </code></pre>
  
  <p>(where <code>C</code> is some typeclass describing the types of variables I can import) into GHC as an FFI scheme so that I can write in my Haskell program stuff like</p>
  
  <pre><code>foreign import myFFI "foo" foo :: T1 -&gt; T2
  </code></pre>
  
  <p>that gets compiled into a call to <code>foo = unsafePerformIO $ myFFI "foo" :: T1 -&gt; T2</code>?</p>
  
  <p>I imagine this could be done by modifying GHC, but is there a way to do it via a plugin I can write without touching the GHC codebase proper?</p>