I have no trouble calling functions in lein repl from my namespaces when I have created a lein new app .... But I don't seem to be able to call functions in lein repl when I just create a library project via lein new .... Details follow:
When I create a lein app with, say lein new app my-app, and then, from the project directory (the directory that contains project.clj), I do lein repl. The repl leaves me in the namespace my-app.core
my-app.core=>
I can now call functions in the repl, even functions defined in side files.
my-app.core=> (-main)
; Hello, world!
my-app.core=> (my-app.anotherfile/foo)
; Hey, there; this is foo from anotherfile
so long as I :require [my-app.anotherfile] in the ns macro of core.clj.
Ok, great; now I would like to do similarly with a lein library. So I lein new my-lib, then lein repl, and I'm in the user namespace:
user=>
huh? Ok, well, my lib contains a function that I want to call (this is just the one that leiningen creates by default)
(ns my-lib.core)
(defn foo
"I don't do a whole lot."
[x]
(println x "Hello, World!"))
I try
user=> (in-ns 'my-lib.core)
my-lib.core=> (foo 42)
; CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:1:1)
nope. How about this?
user=> (my-lib.core/foo 42)
; ClassNotFoundException two-files-lib.core java.net.URLClassLoader$1.run (URLClassLoader.java:202
aha! Different error, but still no cure in sight. lein compile and lein javac don't seem to do anything either.
I have been unable to find or deduce the correct incantations in the docs or online and would be grateful for advice.