Skip to content

Installing and using light table

marick edited this page Oct 19, 2012 · 2 revisions

One simple way to install Clojure is to install the Light Table playground instead. It is something like an IDE for Clojure, with the interesting property that it evaluates expressions as you type them. You can find out more at Chris Granger's site.

You'll work in something Light Table calls the "Instarepl". That's its version of the Clojure read-eval-print loop (typically called "the repl"). You type text in the left half of the window, and the result appears in the right. It looks like this:

Light Table

The book doesn't show input and output in the same split screen style. Instead, it shows input preceded by a prompt, and output starting on the next line:

user=> (if true 5)
5

Important: as of this writing, Light Table does not automatically include all the normal repl functions. You have to manually include them with this magic incantation:

(use 'clojure.repl)

(Note the single-quote mark: it's required.)

Connecting to a project

The book occasionally suggests loading files, and Part II requires libraries that don't come with Clojure. At some point after the introduction to Clojure, you'll have to "connect" Light Table to the exercise sources and solutions on disk. Here's how.

  • First, install the book's source. Here's a recap of the instructions from the first chapter: If you use git, clone the source like this:

    git clone git://github.com/marick/fp-oo.git
    

    You can also download Zip or Tar files.

  • When you launch Light Table, you have the choice between the Instarepl and the Table. Choose the Table:

  • You'll be asked if you want to connect to a new project. Agree, then select the directory where you installed the exercise code:

  • You've now downloaded and installed the needed libraries. You won't actually need the Table from now on, but as far as I can tell you have to take the tutorial.

  • There's a little arrow button at the bottom right of the screen. Click it and select Menu:

  • You're now back at the starting screen and can once again use the Instarepl. To test it out, try loading the two libraries you'll be using:

    user=> (use 'patterned.sweet)
    user=> (use 'clojure.algo.monads)

    If you see error messages, take your problem to the mailing list.

As far as I can tell, you have to connect to the project each time you use Light Table.

You can’t perform that action at this time.