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

add scripting integration for haskell #12

Open
subes opened this issue Dec 29, 2023 · 6 comments
Open

add scripting integration for haskell #12

subes opened this issue Dec 29, 2023 · 6 comments

Comments

@subes
Copy link
Contributor

subes commented Dec 29, 2023

https://eta-lang.org/

Unsuitable because there is no ScriptEngine in eta: typelead/eta#466

@subes
Copy link
Contributor Author

subes commented Feb 27, 2024

Better alternative: https://github.com/Frege/frege-interpreter

Call Java from Frege:
http://mmhelloworld.github.io/blog/2013/07/10/frege-hello-java/

blocker: Frege/frege-interpreter#36 (comment) (fixed)

Repl with:
java -cp frege3.25-latest.jar frege.repl.FregeRepl

https://learnyouahaskell.com/introduction
https://github.com/Frege/frege/wiki/LYAH-adaptions-for-Frege
https://dierk.gitbooks.io/fregegoodness/content/

Frege ScriptEngine has a few flaws:

  • println does not work
  • arbitrary issues with multiple statements in a script (which works fine in repl)
  • can not find a way to access bindings

@subes subes changed the title add scripting integration for eta/haskell add scripting integration for haskell Feb 28, 2024
@subes
Copy link
Contributor Author

subes commented Feb 29, 2024

Won't do since ScriptEngines don't work for In-JVM usage. Could introduce a REPL based binding (which should also work for vanilla haskell "ghci"), but this would be in a separate project, not in invesdwin-context.

@subes subes closed this as completed Feb 29, 2024
@subes subes reopened this Feb 29, 2024
@subes
Copy link
Contributor Author

subes commented Feb 29, 2024

GHCI interpreter: https://stackoverflow.com/a/2144410

arch install "cabal-install" and "ghc-static"

cabal update
cabal install hint

$ ghci

import Language.Haskell.Interpreter
runInterpreter $ setImports ["Prelude"] >> eval "3 + 5"

@subes
Copy link
Contributor Author

subes commented Mar 3, 2024

@subes subes transferred this issue from invesdwin/invesdwin-context Oct 20, 2024
@subes
Copy link
Contributor Author

subes commented Oct 27, 2024

we need to use file communication

  • since haskell does not easily support global state to store a socket connection => instead directly replacing file references in function
  • since frege does not support sockets, instead one would have to implement one as a module manually which does not work inside the repl without a module file => instead defining a callback function with file handling embedded

Frege file reading:
https://stackoverflow.com/questions/19086049/what-is-the-frege-equivalent-to-haskell-readfile
https://github.com/Frege/frege/blob/master/frege/java/IO.fr#L190
frege also has writeFile/readFile https://github.com/Frege/frege/blob/a6787bc102536e03f7dc805a517b1741f13b5739/frege/Prelude.fr#L151

Haskell file reading:
https://stackoverflow.com/questions/28533626/reading-in-text-file
lines/unlines to add/remove newlines https://stackoverflow.com/questions/52290934/haskell-writefile

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

No branches or pull requests

1 participant