Some things I made to help my Clojure repl and you can too.
[com.gfredericks/repl-utils "0.2.16"]
bg
bg
is a macro that is similar to future
but with lots of
repl-friendly features.
First a brief example:
user> (require '[com.gfredericks.repl.bg :refer [bg]])
nil
user> (bg (Thread/sleep 2500) (inc 41))
Starting background task bg0
nil
user> nil
user> bg0
42
user> (bg (/ 42 0))
Starting background task bg1
nilnil >
user> bg1
nil
The main idea is that bg
is based on vars while future
returns an IDeref
. This means
that instead of typing
user> (def f (future (inc 41)))
#'user/f
user> @f
42
you can type
user> (bg (inc 41))
Starting background task bg2
nilnil
user> bg2
42
I.e., you get a name for free, and you don't have to use @
/deref
.
#'bg1
) will print with
state and timing info.*out*
when the task finishes/errors.(-> #'bg1 meta :future)
in case
you want to block on the result or whatever.(-> #'bg1 meta :form)
in case you
lose track of what you originally evaluated or something.(bg some-name ...)
if you
find that useful.mexpand-all
A variant of clojure.walk/macroexpand-all
that has fewer bugs and
does not fully qualify symbols when possible (for the sake of better
readability).
user> (require '[com.gfredericks.repl.mexpand :refer [mexpand-all]])
nil
user> (mexpand-all '(fn [[x]] (identity x)))
(fn*
([p__21032]
(let*
[vec__21034 p__21032 x (clojure.lang.RT/nth vec__21034 0 nil)]
(identity x))))
Copyright © 2013 Gary Fredericks
Distributed under the Eclipse Public License, the same as Clojure.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close