Is there a Scala version of .irbrc or another way to define some default libraries for REPL use?
Posted
by Tom Morris
on Stack Overflow
See other posts from Stack Overflow
or by Tom Morris
Published on 2010-06-14T20:17:00Z
Indexed on
2010/06/14
22:12 UTC
Read the original article
Hit count: 257
I've written a little library that uses implicits to add functionality that one only needs when using the REPL in Scala. Ruby has libraries like this - for things like pretty printing, firing up text editors (like the interactive_editor gem which invokes Vim from irb - see this post), debuggers and the like. The library I am trying to write adds some methods to java.lang.Class and java.lang.reflect classes using the 'pimp my library' implicit conversion process to help you go and find documentation (initially, with Google, then later possibly with a JavaDoc/ScalaDoc viewer, and maybe the StackOverflow API eventually!). It's an itch-scratching library: I spend so much time copying and pasting classnames into Google that I figured I may as well automate the process.
It is the sort of functionality that developers will want to add to their system for use only in the REPL - they shouldn't really be adding it to projects (partly because it may not be something that their fellow developers want, but also because if you are doing some exploratory development, it may be with just a Scala REPL that's not being invoked by an IDE or build tool).
In my case, I want to include a few classes and set up some implicits - include a .jar on the CLASSPATH and import it, basically.
In Ruby, this is the sort of thing that you'd add to your .irbrc file. Other REPLs have similar ways of setting options and importing libraries.
Is there a similar file or way of doing this for the Scala REPL?
© Stack Overflow or respective owner