Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embedding the Frege compiler #375

Open
deliciouslytyped opened this issue Mar 28, 2019 · 6 comments
Open

Embedding the Frege compiler #375

deliciouslytyped opened this issue Mar 28, 2019 · 6 comments
Labels

Comments

@deliciouslytyped
Copy link

deliciouslytyped commented Mar 28, 2019

Hi, thanks for working on Frege it seems like a great project.

I would like to embed Frege in another application that supports a scripting interface (I don't want to use it just for "scripting" though.) so that I can get Haskell language support.

I searched everywhere I could and the only information I could find is at https://groups.google.com/forum/#!topic/frege-programming-language/hL0b1dVfgLc

I'm not very experienced with java and I didn't see any APIs that would clearly be what I want.

How can I go about embedding the Frege compiler jar in an application, call it/pass some source code files to it, and get something I can run out of it?

I imagine the overall steps would be something like the following:

  • Have the Frege compiler on the classpath
  • initialize the compiler / pass some files to it
  • get some java classes (?) out of it
  • run the java stuff
  • pass do things back and forth over FFI
  • be happy

Edit:
To clarify: I would like the capability to compile and run code at "runtime", and not just loading some precompiled code.

I saw mentions of a scripting API, but I'm not sure if that's appropriate for running "proper" programs?

@Ingo60
Copy link
Member

Ingo60 commented Mar 29, 2019

It looks like you're after frege-repl or frege-interpreter or both.

@deliciouslytyped
Copy link
Author

Thanks, https://github.com/Frege/frege-interpreter/tree/master/frege-interpreter-java-support looks relevant to what I want. Do I need to read the source to figure out how to use it?

@Ingo60
Copy link
Member

Ingo60 commented Mar 29, 2019

This https://github.com/Frege/frege-interpreter/blob/master/frege-interpreter-core/src/test/java/frege/interpreter/scriptengine/FregeScriptEngineTest.java could give you an idea how to use the script interface at least. As I understand it, this should be quite standard-ish and alike no matter what scripting language is used. (But I never did such stuff myself.)

@deliciouslytyped
Copy link
Author

I think the current JSR 223 API is explained here https://docs.oracle.com/javase/9/scripting/java-scripting-api.htm , but I'm not sure.

per Wikipedia: The specification, however, was withdrawn later on December 13, 2016 after a Maintenance Review Ballot,[1] where it was decided that this functionality would be included as an integral part of Java 9 and onward.
( https://en.wikipedia.org/wiki/Scripting_for_the_Java_Platform )

Is this tied to java 1.8 or do I just bump the version?
https://github.com/Frege/frege-interpreter/blob/a1d81b6112e722c20eb45c2810ca7903aa65b321/frege-interpreter-java-support/src/main/java/frege/interpreter/javasupport/MemoryJavaCompiler.java#L51

Thanks!

@Ingo60
Copy link
Member

Ingo60 commented Mar 29, 2019

The 1.8 is just an option for the javac compiler. It makes sure compiled Frege code can run with a jdk8. It is not so important in the REPL, where any JDK >= 1.8 would theoretically do, but 1.8 is the lowest common denominator, so to speak.

@deliciouslytyped
Copy link
Author

deliciouslytyped commented May 23, 2019

I'm still interested in this but haven't had the spare cycles to pursue it.
The goal would be to try to do something similar to https://github.com/edmcman/ghidra-scala-loader .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants