This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-17
Channels
- # bangalore-clj (1)
- # beginners (70)
- # boot (1)
- # cider (39)
- # cljs-dev (69)
- # clojure (56)
- # clojure-dev (1)
- # clojure-norway (1)
- # clojure-russia (4)
- # clojure-spec (1)
- # clojure-uk (10)
- # clojurescript (34)
- # clr (3)
- # community-development (3)
- # component (1)
- # datascript (1)
- # datomic (7)
- # emacs (1)
- # figwheel (3)
- # fulcro (5)
- # graphql (2)
- # hoplon (75)
- # jobs (4)
- # jobs-discuss (1)
- # luminus (15)
- # planck (3)
- # portkey (55)
- # re-frame (2)
- # reagent (2)
- # reitit (3)
- # ring (13)
- # ring-swagger (1)
- # shadow-cljs (72)
- # spacemacs (4)
- # tools-deps (2)
- # unrepl (7)
- # vim (2)
Hi guys, is there any example project who completely abuses clojure.spec
. I would like to study it!
How can I install Clojure dependencies from command-line?
@stardiviner Do you have the clj
command line tool installed? Or boot
?
(or do you mean you want to install some basic Clojure tooling, via a command line? If so, what O/S are you on?)
I have clj @seancorfield
I'm running Arch Linux
I want to add/install Clojure dependencies through Emacs Org-mode babel. It is a kind of literate programming style.
I tried clj with deps.edn
. Got an error. Here is what I do:
I create a file deps.edn
in a abritry directory (not clojure project dir). it is {:deps {clj-time {:mvn/version "0.14.2"}}}
Then I run command clj -Sdeps deps.edn
.
Here is the error:
Error building classpath. Don't know how to create ISeq from: clojure.lang.Symbol
java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
at clojure.lang.RT.seqFrom(RT.java:550)
at clojure.lang.RT.seq(RT.java:530)
at clojure.core$seq__5124.invokeStatic(core.clj:137)
at clojure.core$merge_with$merge2__5685.invoke(core.clj:3058)
at clojure.lang.ArrayChunk.reduce(ArrayChunk.java:58)
at clojure.core$reduce1.invokeStatic(core.clj:934)
at clojure.core$reduce1.invokeStatic(core.clj:926)
at clojure.core$merge_with.invokeStatic(core.clj:3051)
at clojure.core$merge_with.doInvoke(core.clj:3043)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invokeStatic(core.clj:659)
at clojure.core$apply.invoke(core.clj:652)
at clojure.tools.deps.alpha.reader$merge_deps.invokeStatic(reader.clj:73)
at clojure.tools.deps.alpha.reader$merge_deps.invoke(reader.clj:70)
at clojure.tools.deps.alpha.script.make_classpath$combine_deps_files.invokeStatic(make_classpath.clj:49)
at clojure.tools.deps.alpha.script.make_classpath$combine_deps_files.invoke(make_classpath.clj:43)
at clojure.tools.deps.alpha.script.make_classpath$run.invokeStatic(make_classpath.clj:68)
at clojure.tools.deps.alpha.script.make_classpath$run.invoke(make_classpath.clj:64)
at clojure.tools.deps.alpha.script.make_classpath$_main.invokeStatic(make_classpath.clj:103)
at clojure.tools.deps.alpha.script.make_classpath$_main.doInvoke(make_classpath.clj:78)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:702)
at clojure.core$apply.invokeStatic(core.clj:657)
at clojure.main$main_opt.invokeStatic(main.clj:317)
at clojure.main$main_opt.invoke(main.clj:313)
at clojure.main$main.invokeStatic(main.clj:424)
at clojure.main$main.doInvoke(main.clj:387)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:702)
at clojure.main.main(main.java:37)
@stardiviner All you need is clj
The -Sdeps
arg is to provide an EDN string on the command line that provides additional deps etc. clj
automatically reads the deps.edn
file in the current directory.
You can use -Sdeps
when you don't have a deps.edn
file (or when you want to provide additional dependencies).
I see. I misunderstand the clj --help
part -Sdeps EDN
. I thought it is a file. So it is a string. Thanks
For example, if you didn't have that deps.edn
file, you could do
clj -Sdeps '{:deps {clj-time {:mvn/version "0.14.2"}}}'
and it would start a REPL with clj-time
loaded.@stardiviner If you're interested, I have my ~/.clojure/deps.edn
file on GitHub https://github.com/seancorfield/dot-clojure/blob/master/deps.edn
Those aliases let me run various versions of Clojure, various dev and test tools, various REPLs...
@seancorfield This looks great. Helped me a lot. glad you share it.
@seancorfield Does those alias used like clj -A:1.8
?
@stardiviner Yes, so, for example, you can drop into a project and say clj -A:test:runner:1.8
and you'll get the :test
alias to bring in the test directories and test.check
, and the :runner
alias to get Cognitect's test-runner, and the :1.8
alias to bring in Clojure 1.8.
Hello all. I haven't done much with Clojure, and what I did was 4 years ago. I'm trying to follow an old Datomic tutorial on Youtube, but I'm running into this problem when I try to do
lein expectations
: Could not locate expectations__init.class or expectations.clj on classpath
I'm not behind a proxy
I've got [lein-expectations "0.0.8"]
in my .lein/profiles.clj and [expectations "2.2.0-rc3"]
in my project.clj
hey guys, which editor are you using? I'd like something simple that just works. I've been using Sublime for everything, but the clojure plugin seems weird :thinking_face:
It might not satisfy your definition of simple but after jumping between vanilla emacs and Cursive several times I ended up with spacemacs. It's really cool and provides most of the configuration out of the box.
I've tried out spacemacs before. it's cool, but one needs to learn a lot to use it - and I can't handle learning a language + an editor at once. thanks for the suggestion though, maybe someday :)
I also use Spacemacs, but I have a Vim background already so it didn’t seem too onerous. You could try Atom with Proto-REPL or Cursive which is a Clojure plugin for IntelliJ.
Cursive gives me no problems and "just works"
hi, in spacemacs, can I select some lines of code and send them to the repl? Evaluating the whole file is not an option since it has not matching parenthesis below
haven't tried cursive. In fact, I don't customize emacs/spacemacs, maybe I'll give it a spin. Do you find it superior to emacs? in what aspects?
emacs has the potential to be superior to cursive and any other program out there, unfortunately for us mere morals with limited lifespans it's usually more practical to use something that works, like Cursive
@lum Yes, though you usually don’t “select” lines of code, you instead put your cursor at the expression you want and invoke the “send to repl” command — are you using CIDER? Vim or Emacs mode?
@lum In Spacemacs, you can explore the available functions by hitting space twice (SPC SPC), then start typing, e.g. cider-
— you will find cider-eval-region
, cider-eval-defun-at-point
, cider-eval-last-sexp
— and their keyboard shortcut for future reference.
I'm going through Brave Clojure, and I'm having some trouble understanding this function:
(defn symmetrize-body-parts
"Expects a seq of maps that have a :name and :size"
[asym-body-parts]
(loop [remaining-asym-parts asym-body-parts
final-body-parts []]
(if (empty? remaining-asym-parts)
final-body-parts
(let [[part & remaining] remaining-asym-parts]
(recur remaining
(into final-body-parts
(set [part (matching-part part)])))))))
why is loop
being recur
ed with only one argument?just curious, is the clj
tool supposed to be replacing lein
ingen and boot
for modern clojure projects?
They have different goals. Lein and boot are intended to be full build/project management tools. clj is designed to build classpaths and launch programs. As people have since noticed, being able to set deps for your classpath and run arbitrary programs also means you can program your own build tools in any way you like.
@idas I don't think that is the full intent. But, for projects that can work fine with deps.edn
, the simplification is nice.
@idas I think it's fair to say that there is tremendous overlap. One of the big benefits of the new clj tools is that it provides a much simpler "get to the repl" experience for people just starting out.
And @mfikes Beat me to it. Again.
gotcha. thanks @mfikes and @russ767!
the reason I ask is that on the clojure subreddit (https://www.reddit.com/r/Clojure) i seem to see a few new things using clj
:
* https://oli.me.uk/2018-02-26-clojure-projects-from-scratch/
* https://github.com/kirang89/cljboot
* https://github.com/healthfinch/depstar
but books like Clojure Brave and True still suggesting boot
and lein
:
* https://www.braveclojure.com/getting-started/
* https://www.braveclojure.com/appendix-b/
in cursive, parenthesis are unbalanced, how to add closing parenthesis? Using vim keybindings
Paredit mode
@idas Possible it's just inertia - the clj tools have not been out all that long.
Also, at least IMO books need to explain what is as much as they explain what's about to be. At least that is the tact I took with Getting Clojure, where I mention the clj tools, boot and lein but mostly stick to lein for the bigger examples on the theory that that is what you will come across most often.
Does anyone still use Expectations, and does it currently work? I can't get a tiny simple project to build/run with it. I get Could not locate expectations__init.class or expectations.clj on classpath
Is it possible to reference a map property inside of itself in clojure? For example:
(def duration {:second 1000 :minute (* (:second duration) 60)})
That will only work if duration is already defined, but sure, your new definition of duration will pick up the old one when you rerun do the def.
But that would imply that you are re'defing duration which is not something you would really want to do. Def'ed bindings are meant to be mostly stable in production. In debugging/repl work we tend to honor that rule more in the breach but re'def is something you want to avoid in real programs.
Yeah, that was something I was hoping to avoid.
FWIW, the root issue is that map constructors are eager. There are lazy implementations. For example:
user=> (require '[lazy-map.core :refer [lazy-map]])
nil
user=> (def duration (lazy-map {:second 1000 :minute (* (:second duration) 60)}))
#'user/duration
user=> (:second duration)
1000
user=> (:minute duration)
60000
Interesting. I am going to avoid this, but this is good to know!
If I used that in the scenario I am working in, I feel it would be in the spirit of being clever over anything else.
Yeah, I wouldn't recommend it.
Planck and Lumo make use of it to replace the gigantic compiler environment map associated with the cljs.core
namespace with a lazily-loaded implementation, in order to shave off a few milliseconds from launch time. https://github.com/mfikes/planck/blob/master/planck-cljs/src/planck/repl.cljs#L215
In that case, they are using it truly for its lazy characteristic, and the fact that it looks like any other map, to a high enough fidelity to fool the ClojureScript compiler.
(def duration (let [second 1000
minute (* second 60)]
{:second second :minute minute}))
That is pretty neat.
@lum I think there's a plugin for that
and if not, there's always shift-0
I'm just kidding. there's probably something like rainbow parentheses and/or paredit