Modules and Imports - blancas/eisen GitHub Wiki

For convenience Eisen helps setting up the eisen.user namespace with local references to Clojure functions and names provided by the host program. In addition, this or any other Eisen module may load and refer to any namespace using declarations similar to those in Clojure.

We load the Eisen repo to run the examples.

(use 'blancas.eisen.core)
(init-eisen)
(eisen-repl)
-- user:

Modules

An Eisen module is simply a namespace. It should follow the rules of Clojure namespaces. A module declaration is stand-alone and it doesn't nest imports.

module eisen.user
-- eisen.user:

Imports

An Eisen import declaration is equivalent to a use or require form in Clojure. If the as modifier is included, then the import will work as a require; otherwise as a use.

This line will import clojure.walk as a use.

import clojure.walk
walk inc identity [1 10]
-- (2 3 4 5 6 7 8 9 10 11)

This line will import two functions from clojure.string as a use. Note that the names are in backquotes because dashes are not allowed in regular Eisen names.

import clojure.string only [`lower-case`, `upper-case`]
`upper-case` "foobar"
-- FOOBAR

This line will import most functions from clojure.set as a use but we want to hide join, which we already have from clojure.string (by the function init-clojure).

import clojure.set hide [join]
difference #{1, 2, 3} #{3, 4, 5}
-- #{1 2}