F#-like REPL/Worksheet for Scala in Idea

Hello,

I've recently seen a demo of the F# REPL/Worksheet (I guess that's nothing unique to F#, other languages/IDEs have this as well), where the basic workflow was:

  1. there's a file where you write the code; the file is like other source files
  2. you can select parts of code and evaluate them
  3. the results appear immediately in a console window
    • I assume there's a compiler running in the background which takes chunks of code and processes them
  4. the surrounding environment (libraries, classes) are available for use (on the "classpath" of the evaluation window)


As a result the cycle to write some code and see how it works was *very* fast. Of course I got envious ;)

I tried two things, but:

  1. the worksheet
    • you can only re-run the whole thing
    • even with external compilation on, it still takes a considerable amount of time to compile&run (it's slow ;) )
  2. scala console
    • classpath isn't set properly (the classes from my project aren't available)


Am I missing some crucial option maybe? :)

Thanks,
Adam

6 comments
Comment actions Permalink

This is not IntelliJ, but I have a standalone REPL that I think does what you are describing: https://github.com/Sciss/ScalaInterpreterPane/

If you want your dependencies on the class path, you will have to create a mini sbt project.

Best, ..h.h..

0
Comment actions Permalink

Thanks, this looks interesting, though I would really like to use the excellent Idea editor, code completion, auto-import, etc. That's also why just using the sbt console is out of the question.

Adam

0
Comment actions Permalink

Sure. I am also dreaming of having this functionality in IDEA, as I could imagine building a future version of my computer music system on top of the IDEA platform API. An essential part of it is the possibility to manage code fragments (for which I use ScalaInterpreterPane now), so an API inside IDEA to which I could easily connect would increase my motivation of doing that step :)

It would have to have the possibility to manage the relevant stuff on the class path and the "visibility" or scope of things, so that one could work with a predefined set of imported symbols without actually having to write "import ..." explicitly.

Best, .h.h.

0
Comment actions Permalink

We will start to work on improving Scala Worksheet in IDEA at the beginning of next year.
As for classpath of Scala console, we have pull request for it: https://github.com/JetBrains/intellij-scala/pull/43. Actually it's weird that it's not merged yet, but we will do it soon.

Best regards,
Alexander Podkhalyuzin.

0
Comment actions Permalink

Great, can't wait :)

Will the new worksheet have any of the functionalities I mentioned? (like partial evaluation)

Adam

0
Comment actions Permalink

Not sure. We don't know yet how we will do it faster, so I don't know yet will it be possible or not.

Best regards,
Alexander Podkhalyuzin.

0

Please sign in to leave a comment.