November 3, 2015
Quick clj REPL with Boot
Quick way to experiment with Clojure Libraries
Here's a quick Pro Tip: want to quickly play around with a clojure or java library? No need to create an entire project or even a new directory. Just drop into a terminal and use the -d
flag to start a repl with the dependencies you want.
For example, I was curious about working with currency. A quick google search returned "joda-money" as the first result. Here's the boot command I used to drop into a repl and start playing around:
boot -d org.joda/joda-money:0.10.0 repl
After that, you can play around:
boot.user=> (.toString (let [usd (org.joda.money.Money/parse "USD 25.83")]
#_=> (.convertedTo usd org.joda.money.CurrencyUnit/EUR
#_=> (BigDecimal. 0.91)
#_=> java.math.RoundingMode/UP)))
"EUR 23.51"
There you go. Any clojure library. Any java library. One boot command away. The possibilities are endless.
If you're using Leinigen, check out the leinigen plugin called lein-try that does the same thing.