title: How to implement Java interfaces in Frege?
body: <p>I have been trying out <a href="https://github.com/Frege/frege" rel="nofollow">Frege</a> and one of the first things I would like to do is implement a Java interface.</p>
  
  <p>How is that done?</p>
  
  <p>Here's my example in Java:</p>
  
  <pre><code>package mypkg;
  
  import frege.repl.FregeRepl;
  import frege.runtime.Concurrent;
  import org.osgi.framework.BundleActivator;
  import org.osgi.framework.BundleContext;
  
  
  public class FregeMain implements BundleActivator {
  
      public FregeMain() {
  
      }
  
      @Override
      public void start( BundleContext context ) throws Exception {
          System.out.println( "Frege Bundle activated" );
          new Thread( () -&gt; FregeRepl.main( new String[ 0 ] ) ).start();
      }
  
      @Override
      public void stop( BundleContext context ) throws Exception {
          System.out.println( "Frege stopping. Goodbye!" );
          Concurrent.shutDownIfExists();
      }
  
  }
  </code></pre>
  
  <p>To implement this in Frege, I would need to know:</p>
  
  <ul>
  <li><p>how to declare something that will be visible as a class called <code>mypkg.FregeMain</code> implementing <code>BundleActivator</code> in JVM bytecode (notice that this is important as the OSGi framework will scan the jar for classes implementing that interface, and call them automatically).</p></li>
  <li><p>How to implement a <code>Runnable</code> (as a Haskell lambda, probably) and pass it on to the <code>Thread</code> constructor. Also same issue: implement a Java interface, but this time with an anonymous class or lambda.</p></li>
  </ul>
  
  <p>I tried to understand the <a href="http://mmhelloworld.github.io/blog/2013/07/10/frege-hello-java/" rel="nofollow">Calling Java from Frege</a> post, but probably due to my lack of experience in Frege/Haskell, I just don't understand most of that.</p>
  
  <p>Thanks for any input.</p>