Scala Notes
Created at 2015-11-28T21:22:44.000Z

Basic References

Basic workflow with SBT, Ensime

g8 hi-ogawa/scala_my_template.g8 --name=here-comes-directly-name-for-package
  • Setup Ensime:

    • Run sbt gen-ensime in terminal or M-x ensime-do-sbt-gen-ensime in emacs to generates .ensime (a configuration file for ensime) in the package root directory.
    • Run M-x ensime to start ensime server in the buffer whose name is usually *inferior-ensime-server-root* with comint mode.
  • Coding in Emacs

    • C-c C-v t: Show type
    • C-c C-v d: Jump to document
    • C-c C-v i: List available methods in inspector view
      • ,: Navigate to previous inspector view
      • .: Navigate to next inspector view
    • C-c C-v ;: open inspector view from input (my own extension)
    • M-.: Go to source
    • C-c C-t t: Go to test file from implementation file
    • C-c C-t i: Go to implementation file from test file

  • Run SBT commands

    • C-c C-b r: sbt run
    • C-c C-b c: sbt compile
    • C-c C-b i: sbt console (my own extension)
    • C-c C-b o: sbt testOnly
    • C-c C-b E: sbt gen-ensime

  • Ensime notes

    • Ensime is buggy, so if you notice any problem, just run C-c C-c r to have ensime to reload source files or kill *inferior-ensime-server-root* buffer and restart ensime server again with ensime.
    • In some case, ensime causes waiting for connection holding up whole emacs operation. if you see that, just long press C-g.
    • If you changed build.sbt (e.g. add new library dependency), rerun sbt gen-ensime and maybe ensime, then C-c C-c r to reload source files.

  • SBT notes

    • Import some module automatically upon sbt console (reference)
initialCommands in console := "import scalaz._, Scalaz._"

General tips

Questions

  • completion in console in emacs buffer
  • map/dictionary in scala
  • how to get to document quickly like hoogle without ensime
  • is there any one command to open scala console and import current module?
  • get the history of scala console within emacs

Comparison with Haskell

Play framework