#clojure log - May 12 2015

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:46 cddr: Say you submit a PR to a clojure project that you want to use from your own project...

0:46 It's been merged but not yet released

0:46 What's the best way to reference the "-SNAPSHOT" version in your own project?

0:48 TEttinger: cddr: it depends if they're publishing snapshots to clojars I suppose

0:48 cddr: Yeah they are not

0:48 I guess I could see if they would mind doing that

0:49 TEttinger: my approach, which is probably terrible, is to do a temporary unofficial fork and put it on clojars with a clearly unofficial name, like com.github.tommyettinger/whatever instead of the project whatever

0:50 then your dependency is on the unofficial fork until it gets merged back

0:53 cddr: That was the other thing I thought of. Doesn't sound too terrible

1:20 escherize: anyone know the cure for uberjar woes?

1:22 I successfully compiled an uberjar. When I run it with java -jar myuberjar.java I get a stack trace with: java.lang.ClassNotFoundException: clojure.tools.nrepl.transport.Transport

1:25 loke: Why is it that when I call "recur" it calles the outermost lambda function if the argument count matches? That seems just bizarre to me.

1:25 In other words: (defn foo [x] ((fn [y] ... (recur A)) x))

1:26 the recur call in that example will call "foo"

1:26 But...

1:26 (defn foo [x z] ((fn [y] ... (recur A)) x))

1:26 In the latter example, recur will call the inner lambda function. That can't be right. I'd expect it to always call the inner one.

1:30 TEttinger: loke, hm that is odd. recur is very rarely used outside of loop, in my experience

1:31 loke: TEttinger: Well, I'm not experienced much in the clojure way of doing things, but it's quite natural for me to define a recursive algorithm using a lambda function. Perhaps it's because many other functional languages doesn't have explicit recursion.

1:31 TEttinger: escherize: how did you make the uberjar?

1:33 loke: mainly because just calling recur won't give you tail recursion optimization, IIRC -- it needs loop so it knows to compile down to similar code as a java while loop, reducing the chances of a stack overflow

1:34 loke: TEttinger: Yes, of course. I know this. The thing that confuses me is that the compiler decides that the recur belongs to the _outer_ function if they both have the same argument count. The funny thing is that that gives the error "can't recurse here" when the more obvious inner function is a perfectly legal recur target, as evidenced by the fact that all works fine if I add an extra dummy argument to the outer function.

1:35 TEttinger: yeah, that is odd

1:35 also, just so you know: fn can have a name, like defn

1:35 loke: Can I specify an explicit target for the recur?

1:37 TEttinger: ,(defn foo [x] ((fn bar [y] (if (> y 50) y (bar (+ y x)))) x))

1:37 clojurebot: #'sandbox/foo

1:37 TEttinger: ,(foo 6)

1:37 clojurebot: 54

1:37 TEttinger: I'm not sure what using recur even does outside of loop

1:41 loke: Supposed to call the innermost lambda

1:41 mbuf: is there a non-Oracle JVM for Clojure?

1:41 loke: However, seems my initial assessment wasn't actually correct. I'm still trying to understand under eactly what circumstances it calls the outer one

1:41 TEttinger: mbuf: OpenJDK works just fine.

1:42 avian might if you can compile it with openjdk's class library or the android one, but I doubt it

1:43 $google zulu openjdk

1:43 lazybot: [Zulu: 100% Open Source commercialized build of OpenJDK™ | Azul ...] http://www.azulsystems.com/products/zulu

1:44 TEttinger: mbuf, if you're looking to distribute a JVM, that might be a good option. they should have 32-bit builds sometime soon, but otherwise if you only care about servers and 64-bit, they seem good

1:44 otherwise, alexkasko makes openjdk 7 builds available

1:44 $google alexkasko openjdk

1:44 lazybot: [alexkasko/openjdk-unofficial-builds · GitHub] https://github.com/alexkasko/openjdk-unofficial-builds

1:44 mbuf: TEttinger, the openjdk site says it is copyright by Oracle

1:44 TEttinger: it's GPL IIRC

1:45 but it isn't the same as oracle's JVM

1:45 mbuf: TEttinger, okay

1:45 TEttinger: the oracle jvm (the one you download when you go to java.com or the oracle site) has a bunch of bundled junk, but also performs a few optimizations the others don't

1:46 however!

1:46 openjdk can be legally modified and rereleased

1:46 you can take one of alexkasko's builds, remove all of the swing stuff if you don't need it, and have a smaller binary

1:47 the one from oracle.com cannot be legally modified and rereleased, though I think you can rerelease it if you give their official installer only? in general, bundling should use an openjdl

1:47 jdk

1:47 mbuf: TEttinger, okay

4:32 borkdude: is there also a deep merge in clojure, that returns this: (merge {:a {:b 1}} {:a {:c 2}) ;;=> {:a {:b 1 :c 2}}

4:34 Glenjamin: (doc merge-with)

4:34 clojurebot: "([f & maps]); Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping(s) from the latter (left-to-right) will be combined with the mapping in the result by calling (f val-in-result val-in-latter)."

4:37 borkdude: Glenjamin that doesn't merge an arbitrarily deep nested map, or does it?

4:37 ,(merge-with merge {:a {:b 1 :d {:a 1}}} {:a {:c 2} :d {:b 2}})

4:37 clojurebot: {:a {:b 1, :d {:a 1}, :c 2}, :d {:b 2}}

4:37 Glenjamin: it can, with a bit of fiddling around

4:38 i think you'd need to make it recursive

4:40 opqdonut: yep

4:40 ,(merge-with merge {:a {:b {:c {:d 1}}} {:a {:b {:c {:e 2}}}})

4:40 clojurebot: #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>

4:41 opqdonut: ,(merge-with merge {:a {:b {:c {:d 1}}}} {:a {:b {:c {:e 2}}}})

4:41 clojurebot: {:a {:b {:c {:e 2}}}}

4:44 hyPiRion: ,((fn f [m1 m2] (merge-with f m1 m2)) {:a {:b {:c {:d 1}}}} {:a {:b {:c {:e 2}}}})

4:44 clojurebot: {:a {:b {:c {:d 1, :e 2}}}}

4:44 opqdonut: indeed

4:46 borkdude: hyPiRion Thanks :)

5:03 I recently built a ruby on rails app and while I was doing it, I was wondering the following evil thought: has someone tried to make a mutable domain model for persistence like you have with ActiveRecord in a clojure app?

5:05 what was a bit annoying when I was testing a clojure application was, that I had to write my DDLs in a different SQL dialect just for testing. Usually those ORM libraries give you that for free.

5:38 socksy: what do you mean by a mutable domain model?

5:55 borkdude: socksy I mean mutable objects like you have with activerecord, hibernate, etc.

6:07 socksy: like atoms?

6:20 Ricardo-Arges: Hi

6:20 I've got a bit of code blindness here, so I could use an extra set of eyes.

6:20 https://gist.github.com/ricardojmendez/a8460fe868c1ff6848c6#file-project-clj-L121-L122

6:21 I can't get figwheel to actually call that handler on reload, even though reload _is_ properly taking place.

6:23 I have a workaround so I don't need it, but it's bugging me.

6:25 oddcully: isn't :builds a list?

6:25 wasamasa: I don't get how to insert an array of bytes into a database column that wants a blob

6:25 oddcully: e.g. https://github.com/bhauman/lein-figwheel/wiki/Quick-Start#third-option-on-jsload

6:25 wasamasa: the javadoc for blob tells me how to convert it back to the byte array

6:27 oddcully: and by list i mean vector

6:31 Ricardo-Arges: oddcully: Going to check if it changed, the default luminus template created it as a map by default, and it's getting the other values correctly (like the externs I added).

6:34 oddcully: Ricardo-Arges: blind guesswork on my end. my last lein new figwheel and the wiki state this. also note, that the wiki states 0.3.1 is the version for this syntax

6:35 Ricardo-Arges: oddcully: Thanks, will review.

6:37 oddcully: Ricardo-Arges: you might also want to ask this question in #clojurescript

6:37 Ricardo-Arges: Will do, going to tie some things up and run some tests first.

6:56 wasamasa: hmm, it was some other SQL thing, inserting blobs works actually

7:47 kaiyin: ,(into (sorted-map) [[:b ["hi"] [:a 1]]])

7:47 clojurebot: #error{:cause "Vector arg to map conj must be a pair", :via [{:type java.lang.IllegalArgumentException, :message "Vector arg to map conj must be a pair", :at [clojure.lang.APersistentMap cons "APersistentMap.java" 35]}], :trace [[clojure.lang.APersistentMap cons "APersistentMap.java" 35] [clojure.lang.RT conj "RT.java" 638] [clojure.core$conj__4095 invoke "core.clj" 85] [clojure.lang.PersistentVec...

7:47 justin_smith: I think you have a misplaced closed bracket

7:47 kaiyin: ah, yes.

7:48 justin_smith: ,(into (sorted-map) [[:b ["hi"]] [:a 1]])

7:48 clojurebot: {:a 1, :b ["hi"]}

7:48 egli: borkdude: doesn't korma shield you from sql dialects?

7:50 borkdude: egli can you do ddl with korma?

7:50 egli: borkdude: uh, that i don't know

7:50 borkdude: egli that's where I run into this, not with my normal queries, those are pretty standard

7:50 egli: ic

7:51 I agree

7:53 borkdude: so maybe a better question would be: is there something that shields me from different sql dialects in clojure, especially when it comes to ddls?

7:54 egli: borkdude: looks like you have to fall back to raw, which defeats the purpose

7:56 borkdude: Honey SQL lists "Create table" under TODO

7:56 justin_smith: borkdude: caribou abstracts over postgres, mysql, and h2

7:56 bcn-flor: How do I check if a vector contains a value from a list of values ? eg. I need to see if a vector v contains any element with the value :env, :tag or :meta ?

7:56 justin_smith: but it also uses these all in a unique way, it is not just an sql frontend

7:57 bcn-flor: ##(some #{:value :tag :meta} [:a :b :c])

7:57 lazybot: ⇒ nil

7:57 justin_smith: bcn-flor: ##(some #{:value :tag :meta} [:a :b :value :c])

7:57 lazybot: ⇒ :value

7:57 borkdude: justin_smith it would be nice if that could be used as an independent library?

7:57 justin_smith: borkdude: that's all caribou-core is

7:57 is the db abstraction

7:57 the web stuff etc. is all other libs

7:57 borkdude: justin_smith I'll check that out then

7:58 justin_smith: borkdude: but as I said it is not just a frontend for sql, it uses sql tables in its own manner

7:58 I am probably explaining that badly

7:58 borkdude: justin_smith hmm, yeah ok. I might just write my own bare bones sql generation thingie probably then

7:59 justin_smith: the difference with caribou's model is that the data model is modeled in the table, and all queries and results are presented as edn

8:00 egli: borkdude: have you looked at Lobos?

8:01 Lobos is a SQL database schema manipulation and migration library written in Clojure. It currently support supports H2, MySQL, PostgreSQL, SQLite and SQL Server

8:01 bcn-flor: justin_smith: thanks

8:01 borkdude: egli that might do it. I've even used it in the past, but forgot about it

8:02 egli: it seems a bit stale but if you've used it before it should be ok

8:27 powrtoc_`: Does anyone know how to print an object defined by a deftype, in a way that's readable via the clojure reader?

8:28 e.g. (deftype Foo [arg]) has a readable implementation #user.Foo ["my arg"] -- but how do I ask such a thing to print itself?

8:28 justin_smith: powrtoc_`: the easy way is to use a defrecord instead of a deftype

8:28 powrtoc_`: justin_smith: yeah I know that :-) just wondering how to do it with a deftype

8:28 justin_smith: pr-str

8:28 or pr rather than print (prn rather than println)

8:29 powrtoc_`: they don't work

8:29 they yield: #<Foo grafter_server.repl.Foo@74c6caac>

8:29 justin_smith: how do you know (deftype Foo [arg]) has a readable implementation | #user.Foo ["my arg"]

8:29 if it never prints?

8:29 kaiyin: What's wrong with this macro? https://gist.github.com/kindlychung/dc979b308a4bbb800415

8:30 powrtoc_`: justin_smith: because I defined it, and I'm only putting readable arguments into it

8:30 mpenet: powrtoc_`: you can define your own print-method

8:31 powrtoc_`: ok was wondering about that

8:31 mpenet: (doc print-method)

8:31 ,(doc print-method)

8:31 clojurebot: "; "

8:31 mpenet: bah

8:31 clojurebot: "; "

8:31 mpenet: https://clojuredocs.org/clojure.core/print-method

8:33 powrtoc_`: mpenet: Thanks

8:34 kaiyin: ah, should be aset instead of aget.

8:47 how do you make sure that a macro inside a let form has access to local vars? for example: https://gist.github.com/kindlychung/10bd14ecc4349f818c30

9:00 crocket: Where does it take 1-2 seconds to start a hello world program on clojure?

9:00 Glenjamin: the clojure compiler likes to build up the suspense

9:01 justin_smith: crocket: yeah, it's the compiler

9:01 crocket: justin_smith, a jar file takes 1-2 seconds to load.

9:01 justin_smith: crocket: the jar file isn't loading the clojure compiler, is it?

9:02 There are other factors. Lein and nrepl are both also slow to start.

9:02 and most people, when they run clojure, start up lein, and nrepl

9:03 crocket: Someone said it's as easy to shoot yourself in the foot with clojure as with C++.

9:03 What is the truth?

9:03 justin_smith: it's not easy, but it's possible

9:03 crocket: He said I would need as much discipline as a C++ programmer to use clojure without shooting myself in the foot.

9:04 I personally think C++ requires the most discipline.

9:05 wasamasa: crocket: unless seeing java backtraces counts, I doubt that really

9:06 hyPiRion: I'm not sure what discipline means though – they are entirely different languages altogether, so it's hard to compare them.

9:06 crocket: wasamasa, Does your nickname come from japanese?

9:06 wasamasa: crocket: nope

9:07 crocket: I'm dangerously intelligent.

9:08 justin_smith: crocket: one thing c++ and clojure share is that they provide abstractions over the lower level, but don't really prevent you from using it directly (along with all the risks of doing so)

9:08 in other ways c++ and clojure are very different though

9:09 crocket: justin_smith, Can you give me specific examples of abstractions over the lower level that C++ and clojure share?

9:09 justin_smith: crocket: they have different abstractions

9:10 but they both let you ditch the abstractions and work at a lower level

9:10 clojure's primary abstractions are immutable datatypes and function closures

9:11 crocket: Can you call clojure functions in scala easily?

9:11 or in java?

9:11 justin_smith: yes, via clojure.lang.RT

9:13 crocket: Very good

9:13 justin_smith, People say clojure is slow on android or on JVM.

9:13 Why do they say that?

9:13 What is clojure slow for?

9:13 wasamasa: because it is?

9:13 crocket: 3D games?

9:14 android 3D games

9:14 mpenet: they mean slow startup time, at least for android

9:14 wasamasa: the startup of the jvm is

9:14 crocket: After the startup, is it still slow?

9:14 wasamasa: nah

9:14 hyPiRion: define slow

9:14 mpenet: as slow as a jvm can be, so I doubt it

9:14 crocket: I can't.

9:14 * wasamasa is disappointed about crocket's smarts

9:15 drbobbeaty: crocket: I've done quite a bit of performance tuning in clojure - and C++ - and clojure is very very good for a JVM-based language.

9:16 crocket: Is it going to compete with hand-tuned C++ code? Nope, but that's an extreme case, and it takes a long time to write that kind of C++ code.

9:16 crocket: drbobbeaty, hand-tuned C++ code?

9:16 drbobbeaty: crocket: ...but I'm running on server boxes - not tablets or phones.

9:17 crocket: ok

9:17 Why would anyone want to use C++ instead of Rust or C?

9:17 mpenet: there's always jni for these extreme cases

9:17 crocket: JVM is reasonably fast for extreme cases...

9:17 I mean java

9:17 drbobbeaty: crocket: Imagine you have an algorithm - easy to understand, but by jumping the loops in sets of three, you actually get a significant performance boost. Knowing these tricks makes a big difference in the right environments. And they are **not** obvious.

9:18 mpenet: I used clj + jni for some hardcore physics simulations, the bits that had to be fast were c++, rest clojure

9:18 crocket: drbobbeaty, I would rather look for conceptual efficiency.

9:18 That's a low-hanging fruit.

9:20 justin_smith: what is conceptual efficiency?

9:24 crocket: justin_smith, Using a different kind of algorithm.

9:25 mpenet: crocket: it is fast enough for most cases. In this example the c++ stuff was the result of years of work/tunning by people way smarter than me, no way I'd rewrite that. I guess the same can be said for 3d stuff on android: there are plenty of (fast) game engines out there already

9:26 crocket: mpenet, It's 'people' who are smarter than you. not a person.

9:27 A person can't become intelligent without intelligent groups.

9:46 Yay

9:47 The joy of clojure...

9:48 wasamasa: somehow I suspect I've not put the binary data into the database the proper way

9:48 crocket: How many times is java as fast as clojure after loading?

9:48 wasamasa: as no matter what I do to retrieve them, I only get errors about the object already being closed

9:48 TimMc: crocket: Unfortunately, that's not a meaningful question.

9:49 crocket: Why is clojure not suitable on android for now?

9:49 wasamasa: must be BLOBs being stream-like, meh

9:49 TimMc: It depends on how you write your code. For the same task, you could write the Clojure to do exactly the same thing as you would in Java, or in more idiomatic Cloure style.

9:49 crocket: Because clojure people care enough about android?

9:49 Because clojure people don't care enough about android?

9:51 wasamasa: crocket: these questions start sounding trollish

9:51 crocket: or worse, gavino-like

9:52 andrei222: I just had a question "how about core.match performance?"

9:52 crocket: I just heard people in #android-dev say things in the line of 'you don't want to use clojure on android for now'.

9:52 andrei222: afaik there performence for core.match is not an issue. Anyone has a different opinion ?

9:52 s/there/th

9:52 *the

9:54 TimMc: crocket: Something about classloaders, I think.

9:54 crocket: There is an android app written in clojure. https://play.google.com/store/apps/details?id=com.swiftkey.clarity.keyboard

9:55 TimMc: crocket: Anyway, read this over: http://clojure-android.info/

9:55 mostly the second chunk of the Rationale section

11:12 datazombie: hello, I am new to clojure and I was wondering where can I start learning about making an rest api with clojure

11:13 maio`: datazombie: (no expert here) maybe http://clojure-liberator.github.io/liberator/

11:15 Ricardo-Arges: datazombie: Liberator is a good library, but make sure you understand the decision graph.

11:16 datazombie: In fact, if you're completely new to Clojure, you probably should start here: https://pragprog.com/book/dswdcloj/web-development-with-clojure

11:16 datazombie: I read the book already

11:17 just asking if the knowledge in it was still current

11:17 Ricardo-Arges: Should have said that first then. :-)

11:17 Yes, for the most part. There's some APIs that have changed in minor ways, but if you've already gone through the book, I expect you've found them.

11:19 datazombie: thanks

11:34 dysfun: is there an equivalent to 'partial' but which returns puts received arguments *after* the args the returned function takes?

11:34 wasamasa: what could possibly cause storing binary data in h2db (with the BINARY type) result in characters like ä being replaced with the codepoint 65533?

11:35 dysfun: i find myself writing a lot of #(foo % bar)

11:35 wasamasa: I'm uploading a file with enctype=multipart/form-data and retrieving gives me mangled data

11:39 println on the data as received when uploading indicates that it happens at this point, but no clue why

11:40 could it be because java bytes are signed?

11:40 mnngfltg: Is there a way to pretty-print a map with keys ordered?

11:41 (pr-str {:a 1 :b 2}) => "{:b 2, :a 1}" <-- but I'd prefer alphabetic ordering

11:41 dysfun: have you tried (sorted-map) ?

11:41 there are almost certainly some pretty-printers that do it too

11:42 kaiyin: how come there isn't any difference in performance here? https://gist.github.com/kindlychung/c0568e86ffe6f6566077

11:43 mnngfltg: dysfun, yes but I couldn't find the option with `fipp` or `clojure.pprint/pprint`

11:56 wasamasa: it's because the bytes were signed...

11:56 enough java idiocy for today

11:56 pjstadig: is there a way to get figwheel to listen on a secure websocket?

11:57 justin_smith: wasamasa: you silly, all bytes are signed in java-world

11:58 oh wait, you just said that

11:58 wasamasa: why.jpg

11:58 justin_smith: because having signed and unsigned types is needless complexity, of course

11:59 wasamasa: I mean, everything else was using signed bytes

12:00 justin_smith: in the future java will have signed bits too

12:00 values are -0 and 0

12:01 wasamasa: *unsigned

12:02 mnngfltg: dysfun, using this to sort a map for pretty printing now: (defn sort-map [m] (if (map? m) (into (sorted-map) (map (fn [[k v]] [k (sort-map v)]) m)) m))

12:06 dysfun: mnngfltg: ah, nice

12:48 phillord: Now, how do I jump to the test namespace in Emacs these days?

12:53 Glenjamin: (update-in votes [name] #(inc (or % 0)) ; is there a nice way to nil-save increment a key in a map?

12:55 oddcully: ,(merge-with + {:a 1 :b 2} {:c 1})

12:55 clojurebot: {:a 1, :b 2, :c 1}

13:11 uris77: what is the recommended way to test core.async in clojure? I have a "mult channel" with two taps. I'm trying to test what happens when different types of data are sent to the channel, but I can only have one test per file.

13:11 Even after adding a sleep

13:12 I'm just starting with core.async, so I know I'm doing it wrong.

13:18 justin_smith: uris77: why only one test per file?

13:21 uris77: okay, so I'm trying to test the following: when an item is saved, the data is pushed to two channels, and each channel transforms it and persists it into two separate databases.

13:22 when I have two tests that call this logic, test1 won't finish before test2 starts to push more data

13:23 justin_smith: uris77: I would wait on delivery of a promise, and make sure the promise is delivered after all conditions in the prior test have finalized

13:24 uris77: okay, thanks. Will try that.

13:24 justin_smith: (deftest foo-test (let [done (promise) ...] ... @done)

13:24 that won't return until somebody either kills the thread, or delivers a value to done

13:27 ecorrin: Glenjamin: You can use: (update-in votes [name] (fnil inc 0))

13:27 Glenjamin: ah, fnil!

13:28 finally, a chance to use it

13:29 justin_smith: (inc fnil)

13:29 lazybot: ⇒ 4

13:29 justin_smith: Glenjamin: the great part is trying to explain fnil to the coworkers, which involves saying it out loud over and over until it sounds like something from doctor seuss

13:29 I pronounce it with one syllable, the fn being a single sound

13:59 timvisher: clojure classpaths are left-most wins?

14:07 Zhadn: if I'm writing a function that takes a sequence as an argument, would it just be something like: (fn my-fun [x] ,,,) or is there a way to restrict input so the variable has to be a sequence?

14:10 timvisher: ,((fn [x] {:pre [(sequence? x)]} (first x)) [1 2 3])

14:10 clojurebot: #error{:cause "Unable to resolve symbol: sequence? in this context", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: Unable to resolve symbol: sequence? in this context, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6543]} {:type java.lang.RuntimeException, :message "Unable to resolve symbol: sequence? in this contex...

14:10 timvisher: ,((fn [x] {:pre [(sequential? x)]} (first x)) [1 2 3])

14:10 clojurebot: 1

14:10 timvisher: ,((fn [x] {:pre [(sequential? x)]} (first x)) #{1 2 3})

14:10 clojurebot: #error{:cause "Assert failed: (sequential? x)", :via [{:type java.lang.AssertionError, :message "Assert failed: (sequential? x)", :at [sandbox$eval75$fn__76 invoke "NO_SOURCE_FILE" 0]}], :trace [[sandbox$eval75$fn__76 invoke "NO_SOURCE_FILE" 0] [sandbox$eval75 invoke "NO_SOURCE_FILE" 0] [clojure.lang.Compiler eval "Compiler.java" 6792] [clojure.lang.Compiler eval "Compiler.java" 6755] [clojure.cor...

14:10 timvisher: Zhadn: ↑

14:11 as far as core is concerned

14:11 i think at that point you could also type hint

14:11 ,((fn [^ISequential x] {:pre [(sequential? x)]} (first x)) #{1 2 3})

14:11 clojurebot: #error{:cause "Unable to resolve classname: ISequential", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.IllegalArgumentException: Unable to resolve classname: ISequential, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6740]} {:type java.lang.IllegalArgumentException, :message "Unable to resolve classname: ISequential", :at [cloju...

14:11 timvisher: hrm...

14:11 ,(doc sequential?)

14:11 clojurebot: "([coll]); Returns true if coll implements Sequential"

14:11 timvisher: ,((fn [^Sequential x] {:pre [(sequential? x)]} (first x)) #{1 2 3})

14:11 clojurebot: #error{:cause "Unable to resolve classname: Sequential", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.IllegalArgumentException: Unable to resolve classname: Sequential, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6740]} {:type java.lang.IllegalArgumentException, :message "Unable to resolve classname: Sequential", :at [clojure....

14:12 timvisher: huh... line?

14:12 :)

14:12 Zhadn: I just started learning, :pre and :post were exactly what I was looking for

14:12 thank you!

14:13 timvisher: ,((fn [^clojure.lang.Sequential x] {:pre [(sequential? x)]} (first x)) #{1 2 3})

14:13 clojurebot: #error{:cause "Assert failed: (sequential? x)", :via [{:type java.lang.AssertionError, :message "Assert failed: (sequential? x)", :at [sandbox$eval171$fn__172 invoke "NO_SOURCE_FILE" 0]}], :trace [[sandbox$eval171$fn__172 invoke "NO_SOURCE_FILE" 0] [sandbox$eval171 invoke "NO_SOURCE_FILE" 0] [clojure.lang.Compiler eval "Compiler.java" 6792] [clojure.lang.Compiler eval "Compiler.java" 6755] [clojur...

14:13 timvisher: ,((fn [^clojure.lang.Sequential x] {:pre [(sequential? x)]} (first x)) '(1 2 3))

14:13 clojurebot: 1

14:13 timvisher: there we go

14:13 didn't know clojure.lang.* wasn't imported

14:14 Zhadn: if you run into the edges of what :pre and :post can do, be sure to check out core.typed and prismatic's schema

14:14 :pre and :post are really bare bones, and don't provide the clearest errors

14:15 Zhadn: so what do you recommend?

14:22 timvisher: Zhadn: i'd stick with :pre and :post until you realize they don't do everything :)

14:22 and then i'd go with schema until you realize you actually wan types

14:23 s/wan/want

14:23 and then i'd with core.typed :)

14:23 and then i'd go to Haskell ;)

14:26 Zhadn: haha thank you

14:31 timvisher: speaking of :pre and :post, is there any way to declare exception handling in situ with those?

14:31 or are you forced to push that logic out to clients?

14:39 justin_smith: timvisher: pre / post will create assertionerrors

14:42 timvisher: justin_smith: yes. but can you decaler a handler for said error in situ with them?

14:42 declare*

14:42 justin_smith: the point of assertionerrors is they are not exceptional runtime conditions, but erronious state

14:43 eg. they are meant to be fixed by fixing your code, not handled by a try/catch

14:43 err, I think I meant ie.

14:43 timvisher: yes. my thought would be that they would be logged somewhere, but yes, i mostly agree with you

14:44 justin_smith: which is another reason pre/post don't really do what people usually want - we actually want runtime conditions we can handle

14:44 though of course we can do the "wrong" thing and catch AssertionError

14:45 timvisher: but that's just as easily done with a centralized catch

14:45 justin_smith: but that has to be in the caller, in the case of :pre or :post, not in the function with the condition

14:45 timvisher: justin_smith: indeed. :)

14:45 justin_smith: which brings us back to way, etc.

14:46 *why

14:46 is "common lisp condition system" a faq for clojure yet?

14:47 something clojure will likely never have http://www.gigamonkeys.com/book/beyond-exception-handling-conditions-and-restarts.html

14:48 timvisher: justin_smith: i worked with a guy who had done common lisp and he would at least 2 or 3 times a week pine for conditions and restarts :)

14:48 but sadly i think it's impossible on the jvm?

14:48 i don't know all the reasons though

14:48 or even if that's accurate

14:48 justin_smith: not surprised -- very difficult at the least

14:49 timvisher: i think it was something about finally blocks

14:49 justin_smith: we could of course reify our own call stack over the jvm, but then the tradeoff would be that everything would be slow

14:49 noncom: in emacs package-list i see many packages marked 'obsolete'. what do i do with them? pressing U x does not do anything. It updated some packages, but there still remain some marked 'obsolete' ....

14:49 justin_smith: but the bonus would be automatic tail call optimization, conditions, and call/cc

14:50 "optimization" since we already massively de-optimized things by replacing the native stack

14:50 timvisher: noncom: #emacs might be a better place to ask but so long as you don't have two versions of the same package installed i wouldn't worry about it

14:51 noncom: yeah, sorry, i asked on #emacs, they just ignored the question although there are many ppl. trying to learn emacs for clojure so i thought one little question i ask.. :)

14:51 timvisher: noncom: no worries. it's not wrong to ask here. just figured you might not know about it

14:51 does what i said make sense?

14:52 noncom: also, do you happen to be trying to learn clojure and emacs at the same time?

14:53 camdez: noncom: I replied to you over in #emacs.

14:53 noncom: well, i know clojure pretty well, using it in production for long time, using eclipse... but emacs is a mystery i find myself repeatedly returning to... :)

14:53 timvisher: noncom: ok. so long as you're not doing both at once. :)

14:57 noncom: timvisher: hmm idk about two versions.. looks like it is the case.. but versioning is different.. so i switched to #emacs then

15:22 Zhadn: so I'm working through 4Clojure, and I'm on problem 57, which is about recursion: (= __ ((fn foo [x] (when (> x 0) (conj (foo (dec x)) x))) 5))

15:22 but I don't think you can apply Conj to numbers?

15:23 i'm sort of confused

15:26 the way I read it, if I had x, where x is 2. it would be conjoining 0 and 1 at the lowest level

15:27 angusiguess: There's something a little tricky going on here:

15:27 confused: Anybody know the best way to parse large xml files? I've tried using clojure.data.zip.xml with clojure.data.xml but I keep getting heap exception?

15:27 Zhadn: but (conj 0 1) or (conj x y) where x and y are numbers isn't valid?

15:27 angusiguess: Zhadn: You see the when clause in that function?

15:27 Zhadn: is the trick making the where not evaulate to true

15:27 and to nil?

15:27 angusiguess: ,(when false)

15:28 clojurebot: nil

15:28 Zhadn: but then nil != 5

15:28 angusiguess: (conj nil 5)

15:28 ,(conj nil 5)

15:28 clojurebot: (5)

15:30 TimMc: Zhadn: conj'ing onto nil is not idiomatic, just to be clear.

15:30 angusiguess: But it does form the base case for that function.

15:30 TimMc: Or at least, debateably.

15:32 angusiguess: The function could be made explicit with (if (> x 0) (conj (foo (dec x)) x) '())

15:33 confused: http://pastebin.com/dswWZq6k Here's a paste of what I have so far for parsing large xml files.

15:37 amalloy: angusiguess: of course, that would change the behavior ever so slightly (although not for the test cases on the actual problem)

15:41 angusiguess: amalloy: Ah, how?

15:41 amalloy: well, (foo 0) is now () instead of nil

15:41 angusiguess: oh ofc!

15:42 bensu: cflemming: I'm writing on the pros and cons of having the JVM as a target platfrom. I'd love to get your input on writing tooling and debuggers

15:42 is it easier, harder, or there are a number of factors?

15:46 tomaz_b: hi guys

15:48 i am more and more interested into Clojure. Can you tell me is there any web site listing bigger projects, products, used by, best for ... or something similar. I would like to draw a picture about Clojure. I don't like Java, I do belive JVM is great, i am interested into learning functional language... and i am focused into big data, high end backends, etc.

15:51 jtmarmon: tomaz_b: http://www.quora.com/Whos-using-Clojure-in-production

16:00 tomaz_b: jtmarmon: thanks for this... i took a look... and is quite nice. i appreciate it

16:13 mlb-: This may be a better question for #emacs, but is/was there a keybinding for switching the current buffer to the "-test" suffixed namespace?

16:15 dnolen: tomaz_b: http://www.cognitect.com/clojure#successstories

16:17 aaelony_: Is a long explanation string as metadata on a namespace recommended? a bad idea? Suppose a namespace needs a rationale, shouldn't that be metadata?

16:18 mgaare: aaelony_: a docstring should suffice. that's fairly common

16:19 aaelony_: actually just found this: http://stackoverflow.com/questions/11610678/clojure-documentation-for-libraries-namespaces

16:20 I'll go the docstring route

16:27 borkdude: Is there something in clojure that behaves like a typesafe hashmap + exception when you get something under a key that isn't there?

16:29 like: a hashmap that behaves according to a prismatic/validation spec

16:30 validation -> schema I mean

17:14 danielcompton: amalloy: what's the status of 4clojure development?

17:15 amalloy: there isn't any, really. i just keep it running

17:18 danielcompton: are you looking to accept improvements or is it just staying mostly the same?

17:20 amalloy: i'd rather just leave it alone

17:20 danielcompton: sure

17:20 well done on it, I really like it.

18:10 crack_user: hello guys

18:16 i'm trying to getting into clojure, but when I find a case where my application can take differents paths a always found my self between many nested cond functions, how can I improve that?

18:32 danielcompton: crack_user: Clojure has several ways to dispatch on different conditions, multimethods is probably your best bet in the general case, but it sounds like that's not going to fix your specific case. Can you post some sample code for us to take a look at?

18:34 kaiyin: Has anyone used this? http://neanderthal.uncomplicate.org/

18:36 crack_user: danielcompton: sorry I think I'm begin clear

18:36 danielcompton I will formulate a quick example

18:37 danielcompton: https://gist.github.com/anonymous/0c5c74a5ae03a0c3c024 well here is

18:38 danielcompton: if I add a client validation even using a lib I have to add more conditions to different ring responses

18:49 danielcompton: crack_user: if you're looking to handle HTTP requests cleanly, you could look at Liberator http://clojure-liberator.github.io/liberator/ I think it could be what you're after

18:51 dirtymike: Are there any good guides on using weavejester/environ

18:53 justin_smith: dirtymike: the readme on github is decent, it's pretty simple and doesn't do much

18:54 dirtymike: I might be thinking too hard about it. It's just when you run `lein test` and `lein repl`? And if you do `lein run` or `lein ring ...` it'll use environment variables?

18:56 justin_smith: dirtymike: or you can specify the values it should find via profiles in project.clj

18:56 the environment variables part is mostly for production, during dev you are probably specifying things in the project file

18:58 dirtymike: Is it customary to use environment variables in production?

18:59 _alejandro: dirtymike: pretty common: http://12factor.net/config

19:02 justin_smith: dirtymike: part of the idea is you don't want production credentials in your repo if possible.

19:02 dirtymike: otherwise you implicitly trust anyone who can read your code to full access to your production credentials

19:03 dirtymike: Sure, so we might have a compojure app running on a couple developer computers with their own postgres databases. Then a staging. Then a production. I imagined a profiles.clj (added to gitignore) for each of those environments. But now I'm thinking that might not play well in jenkins.

19:04 justin_smith: you shouldn't even have lein on production, or git, or profiles.clj

19:04 you should compile an uberjar, that uses environ to look up the credentials (environ will get the creds from the environment variables on production)

19:06 dirtymike: ok that makes sense, just trying to picture these pieces fitting together, thanks

19:06 justin_smith: np - the lein in production / git in production things that a lot of people do wrong IMHO

19:07 sorry, the grammar in that statement was terrible

19:07 dirtymike: yea, I'm not a fan of git/lein on production. I'm trying to see if I can use jenkins or some other automation tool so I'm not `scp`-ing every day.

19:10 justin_smith: yeah, that makes sense

19:10 when I used jenkins, we had a script that would git pull, lein uberjar, scp

19:11 crocket: Is clojure a good language to use on android now?

19:25 oddcully: crocket: is god a good deity to believe in

19:35 escherize`: so, lein run is giving me a stack trace, Caused by: java.lang.ClassNotFoundException: clojure.tools.nrepl.transport.Transport

19:36 what does that mean?

19:39 Also, this behavior persists - even on old versions of my project that worked.

19:40 crack_user: danielcompton: thx man I wil take a look, but it is not just cleanly http request is about how to write applications that require different branchs of execution in a clojure way

19:42 danielcompton: crack_user: well between cond, case, condp, multimethods, and records there are lots of ways to handle different branches of execution. The Clojure way is often to look at a problem and try to reduce it to its most basic, from there you can often eliminate several branches

19:43 crack_user: i.e. you don't need to explicitly branch on if a collection is empty, you can use the fact that some operations will return nil (falsey) and work from that

19:43 crack_user: I'm not explaining it very well, perhaps someone else can say it better

19:55 TEttinger: escherize: what leiningen version?

19:56 escherize: 2.5.0

19:56 wait, actually its:

19:56 Leiningen 2.5.1 on Java 1.8.0_20 Java HotSpot(TM) 64-Bit Server VM

19:57 TEttinger: have you changed the .m2 maven cache at all?

19:58 escherize: Not that I know of.

19:59 TEttinger: I'd try reinstalling leiningen by renaming the jars that it uses from a self-install, then running the start script with self-install (might be selfinstall, can't remember) as an argument

20:01 escherize: I don't exactly follow "renaming the jars that it uses

20:01 from a self-install"

20:04 I think i see: I ran lein self-install and it wants me to move the jar and rerun lein self-install

20:10 It looks like that fixed it. Thanks TEttinger! (inc TEttinger)

20:10 (inc TEttinger)

20:10 lazybot: ⇒ 53

20:24 TEttinger: woo!

20:28 escherize: I'm actually still getting the exact same error when running the uberjar (made with lein uberjar), though lein run does work. I moved .m2 and am redownloading everything in the off chance something there broke it.

20:55 crocket: Where is clojure the most strongly supported?

20:55 JVM?

20:55 CLR?

20:55 mono?

21:11 dominiclobue: crocket: JVM

21:11 crocket: Does clojureCLR run well on mono?

21:12 dominiclobue: no idea. never used it before.

21:12 sorry :(

21:12 gotta head out. good luck!

21:47 lvh: crocket: FWIW the people I know running CLR are running it on OSX, and, I think, Mono

21:49 crocket: Various pieces of clojure-clr's source code are consciously about supporting mono

21:49 crocket: basically I think it's probably fine; it'll be a bit experimental at times but it's unlikely given clojure's strong interop support by default that you'll find something totalyl gross

22:54 crocket: Yo, clojurians...

22:54 devn_: yo

22:58 escherize: Yo crocket

22:58 ,(-> "crocket" reverse reverse (#(apply str %)))

22:58 clojurebot: "crocket"

22:59 crocket: flip flip

23:03 escherize: are you running windows day to day?

23:09 crocket: Parenthesized to death.

23:10 Rich hickey's obituary says "parenthesized to death".

Logging service provided by n01se.net