If you want to write your app entirely in Frege, that will be trickier. You'll need to write wrappers for the Android API, because the FregeAndroid wrapper seems to be missing some files.
However, if you want to write your UI in Java, and call into Frege for your application logic, I have a sample project which shows how to do that.
My example project has this function in Frege:
extraText :: String -> String
extraText who = "\nHello, " ++ who ++ "!"
which I then call from Java:
public class FregeActivity extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView textView = (TextView) findViewById(R.id.txt);
textView.append(FregeCode.extraText("Android"));
}
}
which looks like this
My example project uses Frege 3.23, so for that you would use the old way of calling Frege from Java. I haven't tried using Frege 3.24, but if you want to try that, you'd use the new way.
The only really tricky part was getting a build.gradle
that would build the Frege code. I started with a snippet posted by Andreas Ländle on the Frege mailing list, and then I fleshed it out into a complete build.gradle. I wasn't able to get Proguard to work, so the resulting APK contains the entire frege.jar
. That bloats the app a bit, and it required turning on Multidex, but otherwise it seems to be fine.
Also, note that my sample project requires API Level 21 or higher, because Frege needs ForkJoinPool, which Android only has in level 21 and up.