Fork me on GitHub
#beginners
<
2017-02-01
>
vinai06:02:20

Adding dependencies to my project always is a bit of a hurdle. After some time fiddling they work, but I think I must be doing something wrong. Any pointers what that is would be very much appreciated. Here are the steps I've taken: 1. lein new app example 2. Add a dependency, e.g. core.async to the project.clj

:dependencies [[org.clojure/clojure "1.8.0"]
                           [org.clojure/core.async "0.2.395"]]
3. Add :require to ns
(ns example.core
  (:require [core.async :refer [chan <!! >!]]))
4. Restart cider M-x cider-restart 5. Compile, but get CompilerException java.io.FileNotFoundException: Could not locate core/async__init.class or core/async.clj on classpath. 6. Kill repl, start a new one, compile - same result 7. Run lein deps in the project dir, restart repl, compile - same result

vinai06:02:42

I can see /Users/vinai/.m2/repository/org/clojure/core.async/0.2.395/core.async-0.2.395.jar is in the classpath.

vinai06:02:02

What am I doint wrong??

vinai06:02:35

Got it, it was me being tired (of course), need to require clojure.core.async instead of core.async. That same thing happened to me before!

vandr0iy17:02:23

Why doesn't this work properly:

(match ["AAA"]
  [#"AAA"] :a
  :else :b)
=>:b
while the tests state the exact opposite? https://github.com/clojure/core.match/blob/master/src/test/clojure/clojure/core/match/test/regex.clj

vandr0iy17:02:10

ok figured it out, - apparently I have to :require clojure.core.match.regex... but why in the world must I do that explicitly?

gdeer8117:02:43

@vandr0iy because namespaces 🙃

manutter5117:02:04

Maybe it’s replacing the #” operator with a custom macro?

manutter5117:02:24

That’s a wild guess, I have no clue really.

vandr0iy17:02:55

so, if I import clojure.core.match.foo namespaces the matcher will magically gain additional capabilities? I don't like magic

moxaj18:02:39

@vandr0iy not exactly magic, if you check out the source, you can see that it registers some multimethods and extends some protocols as a side effect

gdeer8118:02:05

I remember someone saying there was a way to add the docstring at the end of a function definition but I can't seem to find any documentation on how to do that.

manutter5118:02:04

@gdeer81 check out with-meta

okwori18:02:00

Does anyone know why am getting this on IntelliJ IDEA sometimes No nREPL ack received

gdeer8119:02:43

@manutter51 thanks, that's what I need I think. The discussion made it sound like you could add the string to the end but looking at defn you either need to use with meta or pass in the meta map at the end

gdeer8119:02:57

It's just that I'm defining a function that is one line but it's using specs so it feels like it needs some documentation about that and it would be nice to have that at the end so it doesn't clutter the function definition

Alex Miller (Clojure team)19:02:50

@gdeer81 defn allows you to add a final trailing meta map

Alex Miller (Clojure team)19:02:35

only in the multi-arity case though iirc

Alex Miller (Clojure team)19:02:06

(defn foo ([] nil) {:doc “looky!”})

Alex Miller (Clojure team)19:02:58

personally, I think that’s unusual enough syntax that it would be clearer to put it at the beginning :)

gdeer8119:02:52

@alexmiller awesome, that's what I was looking for. but yeah, now I'm thinking having (defn foo " mountain of .... multi-line ... documentation .. here ... " [] (do stuff)) isn't so bad

gdeer8119:02:22

it makes sense to put it at the end if you have a lot of different arity definitions I guess

genec19:02:52

hi - i'm fairly new to clojure and I'm having trouble finding good ide / repl setup. I've tried VSCode and Atom/proto-repl but I'm not really happy with either of them. I'm used to F# / Visual Studio where you can just alt-enter to send code to the repl. Any suggestions on where else I should look would be appreciated. I did try IntelliJ / Cursive (twice) and cannot get the repl setup - as my lein repl options are greyed out.

Alex Miller (Clojure team)19:02:17

Cursive works great - maybe ask in #cursive if you need help with that?

genec19:02:23

@alexmiller thanks, I'll do that

seancorfield20:02:16

@genec: did you just not like the ProtoREPL key bindings? You can evaluate code with just a keystroke (and run tests etc).

genec20:02:03

@seancorfield I do like ProtoREPL but I'm finding it a bit buggy. I'll try to execute a block (ctrl+, b) and i'll get an error msg, then I'll try it again and it will work. I'm starting the self hosted repl, not sure if that makes a difference. It's probably something I'm doing wrong with my ns setup.

genec20:02:59

@seancorfield continuing to test proto-repl and finding the nREPL is working better than the self hosted repl. my ns's are loading correctly now

seancorfield21:02:59

@genec There’s a #protorepl channel where folks are very helpful. I recently switched to ProtoREPL full-time after years of Emacs / CIDER, and I’m finding it really solid (although slower than Emacs sometimes for some larger files).

shaun-mahood22:02:32

Using clojure.java.jdbc from the REPL, every time I do a query I get something like (1) or (0) printing out. It's the only library I use regularly that does this, and I was wondering where I can go to read up about what it's using to do this and options to turn it on or off. I'm using the Cursive REPL if that makes a difference, I don't know if this is a REPL option or something specific to the jdbc library.

seancorfield22:02:31

It doesn’t print anything @shaun-mahood — however some JDBC operations return results like that.

seancorfield22:02:39

(jdbc/query …) simply returns the result set; other functions return a sequence of numbers of rows affected by the operation.

schmee22:02:25

everytime I use JDBC I can’t stop myself from asking: why?

schmee22:02:30

why they decided to return that particular value, that is

shaun-mahood22:02:15

@seancorfield: Pretend this conversation never happened - rogue println in one function. 🙂