Renato
Renato

Reputation: 13700

How to implement Java interfaces in Frege?

I have been trying out Frege and one of the first things I would like to do is implement a Java interface.

How is that done?

Here's my example in Java:

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( () -> FregeRepl.main( new String[ 0 ] ) ).start();
    }

    @Override
    public void stop( BundleContext context ) throws Exception {
        System.out.println( "Frege stopping. Goodbye!" );
        Concurrent.shutDownIfExists();
    }

}

To implement this in Frege, I would need to know:

I tried to understand the Calling Java from Frege post, but probably due to my lack of experience in Frege/Haskell, I just don't understand most of that.

Thanks for any input.

Upvotes: 1

Views: 158

Answers (1)

Dierk
Dierk

Reputation: 1308

The simplest way to implement Java interface in Frege is possibly to use an inline module definition. Some thorough examples are in https://github.com/Frege/FregeFX/blob/master/fregefx/src/main/frege/fregefx/JavaFxUtils.fr

Upvotes: 1

Related Questions