#clojure log - Jul 31 2014

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

0:00 sritchie: odd; if I call a js function at the repl, I see the code printed out;

0:00 but if I pr-str a call inside of an om protocol fn call,

0:00 clojurebot: Pardon?

0:01 sritchie: there seems to be a whole wrapper around it from cljs

0:01 <function (data__68246__auto__,owner80568,var_args){

0:01 var p__80570 = null;if (arguments.length > 2) {

0:01 p__80570 = cljs.core.array_seq(Array.prototype.slice.call(arguments, 2),0);}

0:01 etc

0:01 it calls a delegate: return users_typeahead__delegate.call(this,data__68246__auto__,owner80568,p__80570);}>

0:01 brehaut: sritchie: are you knee deep in the madness that is jquery plugins?

0:02 sritchie: brehaut: trying to get this damned typeahead module to work on an om text input field without rewriting everything

0:02 brehaut: knee deep for sure

0:02 brehaut: sritchie: youch; im sorry to hear that. I fear you might be in a bit of a pickle; doesnt Om blitz a node if it wants to update it?

0:03 DomKM: sritchie: there's an om typeahead example. It doesn't use jquery but it might be helpful https://github.com/swannodette/om/blob/master/examples/typeahead/src/core.cljs

0:03 sritchie: yeah, that’s what I’m trying to figure out - the typeahead props stick around, so that’s fine,

0:03 DomKM: yeah, that doesn’t use the twitter typeahead module

0:03 which I’m depending on for its autocomplete engine, prefetching, etc

0:04 brehaut: sritchie: my experience with jquery plugins is that a lot of them do funny things stashing stuff in the elements (such as the object that represents all the JS shenanigans, or an ID to look up said object in a ‘map’)

0:04 sritchie: that’s what this one does for sure

0:04 BUT, I got the google places autocomplete to work just fine,

0:04 and it was doing similar manipulations

0:04 so I have hope :)

0:04 brehaut: sritchie: what you might need to do is scrap all that nonsense out of the element and store it in your model somewhere, and then reattach it when you build the node?

0:05 sritchie: brehaut: nice, that’ll work if I hit that issue, and then just handle the events myself if those props need to change

0:06 brehaut: sritchie: im not sure about ‘nice’ ;) but yeah, that’s where i would look. that and a bottle of tequila

0:06 sritchie: brehaut: trust me, I’m HEAVILY caffeinated

0:07 this way lies madness

0:07 brehaut: sritchie: a much more effective chemical

0:07 sritchie: I’ve been avoid the typeahead thing for days now… I went so far as to port ~half of the react-bootstrap library over to om

0:07 brehaut: sritchie: yeah; jquery developers seem to have decided that throwing out all the best practises of software dev is the ideal way forward

0:07 coupling? sure! single namespace? sure!

0:08 duck punching objects you down own? a double helping please!

0:08 sritchie: gotta draw in the ruby devs somehow

0:08 Jaood: sritchie: or just use JS!

0:09 justin_smith: (inc brehaut)

0:09 sritchie: Jaood: the typeahead + react integration problems aren’t due to cljs

0:09 justin_smith: for duck punching, I know you didn't invent it, but it delights me

0:09 brehaut: i did however invent duck wrapping (the term, not the behaviour)!

0:10 justin_smith: brehaut: turduckening is when you mix that with multiple inheritance

0:10 or something

0:10 brehaut: hah indeed

0:25 rhg135: how do you get a var from a ns from it's symbol?

0:26 justin_smith: TEttinger: I only just now notice that Bort is a potential output of your name generator

0:26 TEttinger: bort!

0:26 trptcolin: (resolve ‘map)

0:26 ,(resolve ‘map)

0:26 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ‘map in this context, compiling:(NO_SOURCE_PATH:0:0)>

0:26 TEttinger: ,(resolve 'map)

0:26 clojurebot: #'clojure.core/map

0:26 rhg135: ,(resolve 'clojure.core)

0:26 clojurebot: #<ClassNotFoundException java.lang.ClassNotFoundException: clojure.core>

0:26 justin_smith: TEttinger: as are words like Yes and Box

0:26 rhg135: hmm

0:27 trptcolin: welp thanks autocorrect-to-weird-quote

0:27 rhg135: i want the ns not a symbol from the ns

0:27 justin_smith: ,`map

0:27 clojurebot: clojure.core/map

0:27 justin_smith: rhg135: maybe you want `

0:27 trptcolin: ,(doc ns-resolve)

0:27 clojurebot: "([ns sym] [ns env sym]); Returns the var or Class to which a symbol will be resolved in the namespace (unless found in the environment), else nil. Note that if the symbol is fully qualified, the var/Class to which it resolves need not be present in the namespace."

0:27 rhg135: i want the ns's var though

0:28 justin_smith: ns's var? you mean the name of the ns?

0:28 rhg135: where clojure attaches metadata

0:28 trptcolin: oh. that’s not a var

0:29 ,(the-ns 'clojure.core)

0:29 clojurebot: #<Namespace clojure.core>

0:29 rhg135: yeah i hava the ns object

0:29 need the var

0:30 justin_smith: ,(meta (the-ns 'clojure.core))

0:30 clojurebot: {:doc "Fundamental library of the Clojure language"}

0:30 rhg135: hmm

0:30 justin_smith: ns holds vars, they are not in any var

0:30 rhg135: weird

0:30 i didn't see any meta on mine

0:30 justin_smith: did you put any on it?

0:31 rhg135: doesn't clojure put line numbers?

0:32 ,(meta *ns*)

0:32 clojurebot: nil

0:32 justin_smith: on vars

0:32 sm0ke: ,(vary-meta (the-ns 'clojure.core) assoc :doc "Foo")

0:32 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Namespace cannot be cast to clojure.lang.IObj>

0:32 rhg135: ,(class *ns*)

0:32 clojurebot: clojure.lang.Namespace

0:33 sm0ke: ,(vary-meta 'clojure.core assoc :doc "Foo")

0:33 clojurebot: clojure.core

0:36 dbasch: golf time if anyone cares: compute the count of the numbers under one million for which the digits add to 42. Can you do less than 90 chars?

0:37 talios: TEttinger / technomancy - http://blog.sonatype.com/2014/07/ssl_connectivity_for_central

0:38 bbloom: $mail timsg i'll be around tomorrow, ping me again if you still need help

0:38 * bbloom still doesn't know how to use the bot

0:38 justin_smith: lazybot is not here

0:39 bbloom: damn lazy bot

0:39 TEttinger: interesting, talios

0:39 trptcolin: dbasch: 85 so far

0:39 justin_smith: sleeping on the job, I am sure

0:39 talios: 12. signups.

0:39 rhg135: i must have missed it, it's working

0:42 trptcolin: oh whoops, nm, 93

0:43 justin_smith: ,(count (filter (fn [n] (= 42 (reduce + (map #(Integer. (str %)) (str n))))) (range 1000000)))

0:43 clojurebot: 6062

0:44 justin_smith: err, that % bothers me

0:44 oh, never mind

0:44 d'oh, bedtime

0:48 trptcolin: heh, 82 if you trim out whitespace doing things like (count(filter(fn[n](= 42 ... etc

0:51 technomancy: talios: urgh; this is fairly misleading

0:51 "In 2012 we weren’t sure how many people not already running repository managers were interested in SSL access."

0:51 this implies they were willing to give SSL access to people not running repository managers, which was not at all true

0:52 I mean, very good news

0:52 just a nitpick

0:53 trptcolin: snap, that was quick

0:57 talios: even if they had made it available to all, very few people would still be able to use it since noone actually tells maven to use http or https, or central. not without releasing a new version of maven and forcing everyone to upgrade ( of course, that should have been done anyway )

0:57 technomancy: yeah, I would push out a new lein version within days of public non-preview access

0:58 talios: and then wait for masses complaining about how much slowwwwwweeeerrrrrr maven was ;p

0:59 technomancy: talios: also holy crap; only twelve requests =\

0:59 I'm fairly embarrassed that I didn't request it till this weekend tbh

1:00 talios: :) I didn't even know about it. I knew central moved to running nexus, but somehow I missed the SSL stuff

1:00 technomancy: but even though I requested it, I never got it actually working, because I need direct access, not nexus-mediated access

1:00 talios: and its not like sonatype made money out of it. hell - they're forking out $150k for central bandwidth. youch

1:00 *nod*

1:01 I wonder how big clojars is these days?

1:01 technomancy: I have 2-year-old numbers

1:01 100GB in a month I think?

1:02 talios: not bad. any idea of total static size?

1:03 technomancy: that's easier, hang on

1:03 hah

1:03 only 15GB

1:04 rhg135: anybody know if there is a better way to write section* here https://www.refheap.com/88742

1:07 talios: only 15? but sending out 100gb? youch - some folk need some caching :)

1:08 technomancy: talios: I'm sure a ton of that is CI stuff

1:09 talios: technomancy - which should *cough* come from a caching repo manager :) altho, clojars contains SNAPSHOTs of stuff doesn't it?

1:09 or not

1:09 dbasch: ,(count(filter(fn[n](= 42(apply +(map #(Integer. (str %))(str n)))))(range 1e6))) ; justin_smith down to 80

1:09 clojurebot: 6062

1:09 technomancy: talios: I don't think travis caches anything

1:10 talios: technomancy - sadly. tho thats also part of its charm. its simple.

1:10 technomancy: talios: the s3 transfer for lein's uberjar (one single file) was 347GB in May

1:11 TEttinger: modified justin_smith's answer, 79:

1:11 ,(count(filter(fn[n](= 42(reduce +(map #(-(int %)48)(str n)))))(range 1000000)))

1:11 clojurebot: 6062

1:11 technomancy: we got off S3 for 2.4.x, so it was 200 in june and so far only 160 in july, but ... yeah.

1:11 lots of jiggabytes

1:15 talios: also 15GB is today's number. 100GB traffic was on a much smaller repo.

1:16 I'd get the latest traffic numbers if it weren't time for me to call it a night.

1:16 talios: yep - almost home time here too

1:16 gfredericks: trptcolin: thx

1:17 trptcolin: ;)

1:18 brehaut: talios: enjoy the traffic

1:19 talios: ?

1:19 brehaut: for your commute

1:19 talios: Only heading to Mt Eden - curry night :)

1:19 brehaut: isnt that what living in auckland is all about?

1:19 haha

1:19 talios: so yes - about an hour ;P

1:19 brehaut: nice

1:19 talios: not.

1:26 dbasch: ,(count (filter #(= 42 %) (map (fn d [n] (if (> 10 n) n (+ (mod n 10) (d (quot n 10))))) (range 1e6)))) ; justin_smith longer but much faster

1:26 clojurebot: 6062

1:37 TEttinger: ok, can anyone get shorter than 75?

1:37 ,(count(filter(fn[n](= 42(reduce +(map #(-(int %)48)(str n)))))(range 1e6)))

1:37 clojurebot: 6062

1:39 trptcolin: TEttinger: substitute reduce -> apply

1:39 for 74

1:58 TEttinger: hm, I'm thinking it may be possible to go under 74 using unquote-splicing

2:00 ,(count(filter(fn[n](=(apply +(map #(-(int %)48)(str n)))42))(range 1e6)))

2:00 clojurebot: 6062

2:00 TEttinger: so that's 73

2:48 je: I have a cljs function which compares two dates (and it works alright), but every time it compiles I get the error: WARNING: cljs.core/<, all arguments must be numbers, got [nil js/Date] instead.

2:48 https://gist.github.com/jacobemcken/04d264257718f2edea35

2:50 Am I comparing dates wrong, or is the warning an error i ClojureScript

2:51 mpenet: js is forgiving, clj(s) not so much

2:51 comparing nil and an Object for > is a bit weird

2:52 you probably want to guard against the nil at least

2:53 je: mpenet: it is the same for two js dates: https://gist.github.com/jacobemcken/04d264257718f2edea35

2:53 piranha: je: js/Data :-)

2:54 but that's strange, why would it give you a warning during compilation...

2:54 mpenet: then maybe getTime on the date instances

2:54 je: piranha: hehe thanks :)

2:54 piranha: hah, it gives me a warning as well

2:55 yeah, I was about to say that comparing two date objects is asking for trouble

2:55 I don't think js compares them properly

2:55 probably it converts them to strings and then tries to compare :))

2:56 mpenet: the call to getTime should make it long vs long

2:56 hopefully

2:57 piranha: yeah, unless it's null :)

2:57 btw, just checked - JS seems to compare date objects just fine (i.e. feels like real comparison, and not through toString)

2:59 je: piranha: Indeed it does, that is why I don't get why ClojureScript can't do it as well

2:59 piranha: je: no idea, to be honest, maybe it's just that comparing non-numbers in js is very error-prone, so it makes sense to forbid it completely :)

3:00 je: well ClojureScript can it just "complains" about it :)

3:00 mpenet: well, the js behavior is just weird

3:00 it's neither > or < or = against null, its ... I dont' know what

3:00 always returns false

3:01 je: piranha: perhaps... how would know if it is intentionally or something that has been overlooked?

3:02 *how = who

3:02 piranha: David Nolen I would say :)

3:02 and there are few other candidates, but it's too early for USA to be up, so you would have more chances getting an answer if you ask that in mailing list

3:04 ttasterisco: early? it's only midnight in the west coast :)

3:05 je: hehe

3:07 piranha: ttasterisco: well, it's already 31 of July there for 4 minutes, so technically it can be described "early" :-)

3:11 ttasterisco: yes, it's pretty early, the night's still a child

3:12 mindbender1: I'm still getting the following compilation errors: https://gist.github.com/johnbendi/9b4f5f1f46c270f63b51#file-clojure-compilation-failure . Has anyone got similar experience trying to compile clojure?

3:15 Xorlev: mindbender1: Not a Clojure guy, but it looks to me like you have an asm lib conflict.

3:15 Probably between ASM3 and ASM4

3:17 mindbender1: Xorlev: Where can I check for that?

3:18 hiredman: mindbender1: are you building against master?

3:18 maybe run mvn clean and try again

3:20 Xorlev: mindbender1: If that doesn't work, the maven dependency tree plugin

3:20 mindbender1: Both master and previous tags report the errors. I'm trying mvn clean && mvn -e install now.

3:21 hiredman: Xorlev: if you look at the class name it is clojure.asm.*

3:21 which is the version of asm bundled with clojure

3:22 mindbender1: the error is very odd, so it seems likely you have some kind of old or stale partial build state or something

3:22 mindbender1: hiredman: mvn clean helps. It's compiling now.

3:23 Xorlev: hiredman: Thanks

4:05 Bosky101: what am i missing here? http://pastebin.com/Ar2n44gp

4:06 (trying to fwd arguments from 1 fund to another )

5:07 robothor: Bosky101: I suspect you really want to apply in "foo" when forwarding to "foo*"

5:32 erdos: hello, in clojure 1.5.1 clojure.test/are one example is (are [x y] (= x y) 2 (+ 1 1) 4 (* 2 2)) . clearly, if i change it to (are [x y] (= x y) 2, (+ 1 1) 4 5) it fails and returns false. but if i change it to (are [x y] (= x y) 2 3, 4 (* 2 2)) the the result is still true. i am not sure if it means that the test is passes, which should not as the first expression should be false. the docs also says that (are) forms expand to (do (is)

5:33 is it an intended behavior, if it is to, could you please explain the reason why the first modification returns false and the second true? thanks.

5:33 ticking: Is there an error printed on the console?

5:34 erdos: wow, there is an error printed. i was only listening to the return value.

5:34 ticking: `do` will evaluate its arguments in order for side effects, in this case printing the error is one of those side effects, and then return the value of the last expression

5:34 erdos: ticking, ok, i see, but does the return value have any meaning then?

5:34 ticking: since the last test succeeds it will return true

5:35 there are cases where the return value of do is useful, but in this case it seems not

5:37 erdos: ok, thanks

5:40 an other question: in clj1.5.1 core.clj:719 the defition of if-not is `(if (not ~test) ~then ~else). i do not understand the extra call to `not` (which expands to and extra `if), and why it is not simply `(if ~test ~else ~then)

5:40 mbac: is there a clojure web framework that's uses continuation passing style like weblocks?

5:41 scottj: mbac: no popular ones afaik

5:41 mbac: d'oh

5:54 blunte: What is the best way to get a list of all methods that work on a particular class? Like clojure.lang.PersistentHashMap

5:57 opqdonut: blunte: something like (map str (.getMethods (class the-thing)))

5:57 blunte: I'm trying to understand why I can't do (keys somemap). I get this error: clojure.lang.PersistentHashMap cannot be cast to java.util.Map$Entry

5:58 opqdonut: blunte: or just (map str (.getMethods clojure.lang.PersistentHashMap)) if you know the class already

5:58 blunte: somemap is probably not a map but a sequence of maps

5:58 observe:

5:58 ,(keys [{:a 1}])

5:58 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.util.Map$Entry>

5:58 blunte: oh you're right

5:58 opqdonut: keys loops through the thing it gets and extracts the key

5:59 so the error message is an artefact of the implementation

5:59 blunte: opqdonut: thanks!

6:12 eskatrem: Hey, I can't use org.bson.types.ObjectId for the mongodb driver

6:13 What is the proper way to import it? I added [org.bson.types] in my project.clj but Leiningen can't find it in the central repos

6:14 TEttinger: eskatrem, lein doesn't know what packages are where

6:16 eskatrem, you have [com.novemberain/monger "2.0.0"] in project.clj ?

6:16 eskatrem: TEttinger doing it now

6:16 TEttinger: yeah in fact I have it

6:16 TEttinger: hm

6:17 eskatrem: Here's what lein tells me:

6:17 Could not find artifact org.bson.types:org.bson.types:jar:jar in central (http://repo1.maven.org/maven2/)

6:18 basically when I try to use the ObjectId from monger like in the example, I get: "No matching ctor found for class org.bson.types.ObjectId" and I dont know how to tell Leiningen to get them

6:19 TEttinger: right, well org.bson.types is a package, not a lein project

6:20 it is probably provided by monger, but might need a driver for mongo

6:20 so take out org.bson.types from project.clj deps... and it's possible you're not constructing the objectID how it expects

6:21 eskatrem: yeah, I just took it out, but the code to that uses ObjectId crashes

6:21 that's my imports:

6:21 (:import [com.mongodb MongoOptions ServerAddress ]

6:21 [org.bson.types ObjectId])

6:22 I can use mongo from clojure just fine, just I can't access to the _id field

6:44 AWizzArd: eskatrem: what happens when you try it? How do you try it (minimal example)?

6:44 eskatrem: AWizzArd: I'm trying to build the minimal example actually

6:45 AWizzArd: Did you try something like (:_id db-entry) or (:_ID db-entry) and such?

6:45 eskatrem: somehow I am confused, how can I just make a project and run it from lein-run (my problem is with a web app I'm making with luminus)

6:46 yeah I tried with (:_id db-entry) but it doesn't match to the _id from my field

6:46 AWizzArd: is it :_id or :_Id or :_ID ?

6:47 eskatrem: (basically clojure is not able to know that {_id: 123} is {_id: ObjectId(123)})

6:47 AWizzArd: or maybe (get entry "_id") or "_Id" or "_ID"

6:47 eskatrem: I did it with _id

6:49 I'll try with (get entry "_id")

6:49 actually

6:49 the real problem is for an update

6:50 the line that is not working is: (mc/update db coll {:_id _id} {:$set {lang-keyword message}} {:upsert true})

6:56 mbac: is there an idiom for printfing sequences?

6:56 most of the time i end up with clojure.lang.LazySeq@45101e88

6:56 Glenjamin: ,(prn (range 10))

6:56 clojurebot: (0 1 2 3 4 ...)\n

6:56 Glenjamin: oh, rptinf

6:57 eskatrem: ,(apply println (range 10))

6:57 clojurebot: 0 1 2 3 4 5 6 7 8 9\n

6:57 Glenjamin: ,(format "%s" (prn-str (range 10))

6:57 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

6:58 mbac: sure, but then i need to know the tree of whatever it is i'm trying to print out

6:58 Glenjamin: ,(format "%s" (prn-str (range 10))) ; this, i guess

6:58 clojurebot: "(0 1 2 3 4 ...)\n"

6:58 mbac: which i don't. that's why i'm trying to print it :)

6:58 Glenjamin: either use prn instead of printf, or prn-str before passing to prinf i think

6:59 mbac: sweet!

6:59 hyPiRion: pr-str instead of prn-str if you want to avoid the newlines

6:59 AWizzArd: pr-str

6:59 Glenjamin: oh right, whoops

7:01 ro_st: thheller: ping

7:02 visof: hello

7:04 eskatrem: AWizzArd: now that's strange, (mc/find-maps db coll {:_id "53d79d8f3943fede9c1c63a2" } ) works just fine

7:06 visof: i'm using ring, i got error for POST request the details are here https://www.refheap.com/88762

7:06 can anybody help

7:09 ro_st: visof: is "hello, world" a valid json value?

7:09 i bet (json/generate-string "hello, world") fails

7:09 visof: ro i just observed this and i fixed it

7:09 thanks man

7:13 hey (json/generate-string "hello, world")

7:13 "\"hello, world\""

7:17 Xack: is there anyway to directly insert javascript in a clojurescript file?

7:18 eskatrem: I don't know much about clojurescript, but can you call from clojurescript the javascript eval and dump your code here? (prize of elegance)

7:19 Xack: ^

7:19 Xack: ah, thanks eskatrem :)

7:20 eskatrem: Xack: it's just a bad solution coming from someone who never used clojurescript in his life, but I'd be curious to know if it works

7:21 thheller: Xack: it is possible, but there rarely is a reason to do it

7:21 Xack: eskatrem: it should work, I wasn't even aware javascript had that, i'm new to javascript (and clojure), i'm currently making a game with it :)

7:21 thheller: better to just write javascript in javascript and then use it from cljs

7:21 interop is so easy

7:30 Xack: it works :)

7:49 wink: anyone ever heard of a js minifier written in clojure?

7:55 visof: defresource return fn object

7:55 how can i deal with it?

7:56 clgv: visof: what?

7:59 visof: clgv: https://www.refheap.com/88764 check this?

8:00 clgv: visof: where is defresource from?

8:01 visof: clgv: [liberator.core :refer [defresource resource request-method-in]])

8:01 nathan7: wink: no, but why would you need one?

8:01 wink: you could use Google Closure from Clojure just fine

8:01 wink: nathan7: someone mentioned it, but didnt remember the name. and I couldn't quickly google it.

8:03 clgv: wink: maybe a ring middleware?

8:03 Glenjamin: dieter

8:03 perhaps?

8:05 clgv: visof: are you sure that you are supposed to call a resource like that?

8:05 visof: clgv: what do you mean?

8:05 clgv: visof: well there is certainly documentation for it

8:11 mbac: what's the idiom for filtering non-nil stuff out of a seq

8:11 i'm writing this (filter (fn [x] (not (nil? x))) seq)

8:11 er, for filtering nil stuff out of a seq

8:11 clgv: mbac: do you use "map" before the filtering? then you can simply switch to "keep"

8:12 swi: mbac: (complement nil?)

8:12 llasram: mbac: (remove nil? s)

8:12 Or in 1.6+ (filter some? s)

8:19 mbac: hmm, keep wins i thik

8:26 jinks_: wink: this one? https://github.com/yogthos/asset-minifier

8:29 wink: jinks_: I don't know. but thanks, will have a look!

8:32 mindbender1: Is there a standard way to convert a MapEntry to a map of itself?

8:32 [:a "foo"] => {:a "foo'} for example.

8:33 clgv: ,(into {} (first {:a :b}))

8:33 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword>

8:33 verma: ,(into {} [[:a :b]])

8:33 clojurebot: {:a :b}

8:34 nathan7: ,(apply hash-map [:a :b])

8:34 clojurebot: {:a :b}

8:34 verma: nice

8:34 clgv: yeah better use apply+hash-map

8:34 verma: ,(apply hash-map [:a :b :c :d])

8:34 clojurebot: {:c :d, :a :b}

8:34 verma: ,(apply hash-map [:a :b :c :d :e])

8:34 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: No value supplied for key: :e>

8:34 nathan7: I spent a while thinking about that before realising "wait, so basically the same as pasting it into {}… wait…"

8:35 mindbender1: Alright. Thanks.

8:54 clgv: ,(mapv (partial apply hash-map) {:a 1 :b 2})

8:54 clojurebot: [{:b 2} {:a 1}]

9:07 mpenet: ,(conj {:a 1} [:b 2])

9:07 clojurebot: {:b 2, :a 1}

9:23 Ven: erm, I wonder what's the difference between repeat and constantly

9:23 clgv: Ven: constantly creates a function that constantly returns the given value

9:23 swi: Hello. what difference between rest and next functions ? i dont' get it

9:24 clgv: Ven: "repeat" creates a sequence with the given length that contains only the given element

9:24 ,((juxt rest next) [a])

9:24 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0:0)>

9:24 clgv: ,((juxt rest next) [1])

9:24 clojurebot: [() nil]

9:25 Ven: clgv: so `constantly` is like `fn []` ?

9:25 or is it used like a "let over lambda" kind of thing ?

9:26 justin_smith: Ven: (fn [& _] :foo)

9:26 takes zero or more arguments, returns value

9:27 Ven: justin_smith: (plus does caching :) !). alright, thanks. Because the example I saw was `(map (constantly 42) (range 10))` and I was like, you could `(take 10 (repeat 42))`

9:27 justin_smith: ,(take 5 (repeatedly (constantly (rand-int))))

9:27 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core/rand-int>

9:27 justin_smith: ,(take 5 (repeatedly (constantly (rand-int 5))))

9:27 clojurebot: (0 0 0 0 0)

9:28 justin_smith: Ven: yeah, constantly is more useful if you make a call which returns the function to apply - it may have (constantly :some-default) as one thing it gives you

9:29 swi: clgv: well, in this https://www.refheap.com/88766 if i replace rest for next in 3rd string, function working, but wit rest it's stacked :) I mean what the diff in this situation ?

9:30 clgv: ,(source constantly)

9:30 clojurebot: #<SecurityException java.lang.SecurityException: denied>

9:30 clgv: $source constantly

9:30 :/

9:30 Ven: it creates a function and returns it

9:30 ,(type (constantly 5))

9:30 clojurebot: clojure.core$constantly$fn__4085

9:31 clgv: ,(type (repeat 10 5))

9:31 clojurebot: clojure.lang.LazySeq

9:37 clgv: ,(mapv sequential? [nil []])

9:37 clojurebot: [false true]

9:38 clgv: swi: nil is not sequential whereas an empty vector/sequence is

9:39 swi: clgv: ah, so when i use rest it's work right the same as with next, but on the last iteration it's get [] and iterate over it forever?

9:39 clgv: ,(rest [])

9:39 clojurebot: ()

9:40 justin_smith: ,(take 10 (iterate rest []))

9:40 clojurebot: ([] () () () () ...)

9:40 swi: got it :)

9:40 clgv: justin_smith thanks :)

9:40 clgv: swi: yeah, you'll have to ask for empty?

9:40 Ven: clgv: thanks too :)

9:44 visof: https://www.refheap.com/88767 i can't use post

9:44 can anybody help me in this?

9:46 justin_smith: visof: if you want to accept post, why do you only declare GET ?

9:46 visof: justin_smith: https://www.refheap.com/88768

9:46 i fixed it, i don't get anything though

9:47 clgv: visof: "(slurp body)" looks pretty strange

9:47 justin_smith: are you sure you need to slurp?

9:47 ring should just give you the body

9:47 visof: justin_smith: so i need to remove slurp?

9:48 justin_smith: yeah, just use the body directly

9:48 visof: justin_smith: okay i'm trying

9:49 justin_smith: also, even if the body was an input stream, slurp would not be the right way to consume it

9:49 visof: justin_smith: i got this error https://www.refheap.com/88769

9:49 justin_smith: yeah, you want to get the string from the HttpInput

9:50 visof: so how can i do this?

9:50 drbobbeaty: visof: justin_smith: ... don't mean to butt in, but you need the 'slurp' to convert the body.

9:50 justin_smith: usually I use a middleware that does that for me

9:50 drbobbeaty: really?

9:51 visof: justin_smith: can you give me simple Example for how middleware do this?

9:51 justin_smith: OK, sorry, I guess I am so dependent on my habitual middleware that I didn't realize

9:51 drbobbeaty: Here's what I've done - and it works: (POST "/blah" [:as {body :body}] (let [lst (json/parse-string (slurp body))] ...

9:52 where the 'json' namespace is the cheshire library.

9:52 justin_smith: visof: https://github.com/ring-clojure/ring-json wrap-json-params is what I use

9:52 sveri: Hi, does it make sense / is it possible to use core.typed only partially in an applicatoin? I want to use more as a kind of documentation like, here, this method returns an int

9:54 boxed: sveri: I thought partial use was sort of the point ^_-

9:54 blunte: I have a PersistentHashMap that looks like this when printed: [:key1 val1] [:key2 val2]. I'm trying to put it into a defined record that looks like (defrecord Foo [key1 key2]), but I cannot figure out the right way to convert the hashmap so the ->Foo works

9:55 Is there a standard way of populating a record from a hashmap (where the keys are specified, not just a list of values)?

9:55 justin_smith: ,(slurp (-> "hello" .getBytes java.io.ByteArrayInputStream.))

9:55 clojurebot: "hello"

9:56 justin_smith: blunte: map->Foo is generated automatically when you define a record Foo

9:57 visof: drbobbeaty: that's my code based on what you told https://www.refheap.com/88770 and i got nothing

9:57 shouldn't i got the json again on the browser?

9:57 drbobbeaty: visof: let me have a look-see...

9:57 visof: okay

9:58 blunte: justin_smith: that works in repl, where my hash-map printed looks like {:key1 val1, :key2 val2}. But for some reason, the data I'm processing in my program claims to be a PersistentHashMap (but prints like [:key1 val1] [:key2 val2]). And map->Foo fails because it is receiving too many arguments.

9:59 justin_smith: blunte: someone called seq on the hash-map

9:59 you can either use (into [] s) to make it a hash-map again, or make it not get turned into a seq

9:59 sorry, (into {} s)

10:00 blunte: justin_smith: ok, it's coming out of jdbc as a lazy sequence. I'm doing doall, but the doall map apply % stuff is making my head spin.

10:00 justin_smith: (doall (map #(apply create-rec (into {} %)) recs)) ; where create-rec is the function map->Foo

10:00 justin_smith: ,(into {} ([:a 0] [:b 1]))

10:00 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Key must be integer>

10:00 drbobbeaty: visof: Ah... nope. You need to have the return value from your route be a map with a :body key and the value of a map. So if you changed it to: {:status 200, :body (postResource lst)} - try that...

10:01 justin_smith: ,(into {} '([:a 0] [:b 1]))

10:01 clojurebot: {:a 0, :b 1}

10:01 drbobbeaty: visof: I'm preparing a Gist for you of exactly what I do...

10:02 justin_smith: blunte: apply is calling seq on the map

10:02 ,(apply identity {:a 0 :b 1})

10:02 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core/identity>

10:02 blunte: Ohh

10:02 justin_smith: so you likely don't need into, just don't use apply

10:03 blunte: justin_smith: Yeah, what I receive from jdbc looks like ({:key1 val1, :key2 val2} {:key1 ... :key2 ...})

10:03 I was just trying to iterate over all elements and stuff them into records

10:04 justin_smith: so yeah, you don't need apply, just (doall (map map->Foo ...))

10:04 blunte: justin_smith: ahh, that makes some sense. Thanks much

10:05 clgv: please don't (doall (map ...)) just use (mapv ...) ;)

10:07 blunte: ok

10:08 drbobbeaty: visof: Have a look at this: https://gist.github.com/drbobbeaty/e580eba3e13a799b91c1

10:08 blunte: clgv: why is a vector preferred to a sequence?

10:08 for output

10:08 drbobbeaty: visof: It has several useful functions to return JSON and codes, etc.

10:09 visof: I got a lot of help from gfredericks on this...

10:10 clgv: blunte: it's not the vector. why do you want to explicitely construct a lazy sequence that you immediately force to evaluate?

10:10 blunte: in your case just use the eager "mapv" instead of the lazy "map"

10:11 blunte: clgv: how did you know I was going to immediately evaluate the end result? :) I am, so it makes sense here. But isn't the idea that you try to stay lazy as long as possible?

10:11 justin_smith: clgv: because outside that block, the result stream you are consuming is no longer valid. Though the vector overhead is small, it is there, and not needed if the output will be consumed in order anyway.

10:11 clgv: blunte: because you accepted the doall+map suggestion :P

10:12 justin_smith: the (transient) vector construction is much faster than what doall+map offers you ;)

10:13 justin_smith: yeah exactly that is the reason you should process it there, but still "mapv" is preferable then

10:13 justin_smith: clgv: the vector construction can't be faster than a doall on a map - it calls map eagerly internally

10:13 clgv: blunte: no not necessarily. I'd only use lazy where it fits

10:13 justin_smith: and using a vector sequentially is not faster than using a realized lazy-seq

10:15 clgv: justin_smith: you are wrong there. there is no optimization for "doall" on lazy-seqs, hence there are a lot of temporary lazy-seq objects created

10:16 hyPiRion: clgv: It's unchunked vs. chunked essentially.

10:17 clgv: hyPiRion: I guess database results are not chunked, right?

10:17 clojurebot: Titim gan éirí ort.

10:18 hyPiRion: clgv: I dunno, they might be? I wasn't saying you were wrong btw, I was saying that creating a vector of size n is cheaper than creating a lazy-seq of size n, if you were to realise everything immediately.

10:18 clgv: hyPiRion: ah ok^^

10:19 hyPiRion: you'd agree to prefer "(mapv f coll)" over "(doall (map f coll))" in general?

10:20 hyPiRion: clgv: If that's the last time you're going to map over the collection, yes

10:21 clgv: hyPiRion: what is the reason for the restriction?

10:21 mapping over anything seqable shouldnt make a difference, right?

10:24 blunte: why convert a lazy sequence into something fully realized, then back to another lazy one

10:24 that's my guess

10:24 hyPiRion: clgv: If you really need performance and want to do multiple mappings on a seq, better use reducers.

10:24 avoid the intermediate seqs.

10:25 clgv: blunte: because you need to force it anyway - so why not use the fast and syntax-wise lightweight approach?

10:25 blunte: clgv: makes sense. And honestly, this is all still so very vague for me... I'll use whatever works and that I can wrap my head around. I know the nuanced/idiomatic use will come with experience

10:25 clgv: hyPiRion: ah ok right. I was only considering "map" vs "mapv" here ;)

10:26 hyPiRion: clgv: right, then I'd go mapv all day

10:26 clgv: blunte: as far as I observed it, "mapv" was introduced as better version of "doall+map" ;)

10:26 hyPiRion: (if you do a doall over it)

10:26 blunte: Thanks for the advice. Brevity is a nice bonus too

10:37 justin_smith: blunte: you are right about mapv, mea culpa https://www.refheap.com/88773

10:38 I clearly underistimated the overhead on a lazy-seq (even a realized one)

10:39 schmee: if I have a function (defn listener [socket running]

10:39 ), how can I apply partial to the second argument, so I get function (defn L [socket])?

10:39 joegallo: partial doesn't do that

10:39 use #(listener % second-arg-here)

10:39 and you'll get the same net effect

10:39 more or less

10:39 schmee: gah, of course!

10:40 thanks!

10:40 joegallo: anytime

10:40 clgv: blunte: that was me ;)

10:40 justin_smith: try replacing the chunked (range 10) with (take 10 (iterate inc 0))

10:41 blunte: Fancy!

10:41 :)

10:41 clgv: oops lol mean justin_smith: ^^

10:41 :P

10:41 justin_smith: clgv: oops

10:41 heh

10:41 clgv: complete reference confusion :D

10:50 hugod: Is there any way to add a namespace dependency in clojurescript, other than via the ns form? (ie. I'm looking for the equivalent of a top-level `require` in clojure)

10:50 gfredericks: hugod: I doubt it

10:51 hugod: the ns form can't be the output of a macro either :(

10:53 gfredericks: yeah I believe it's a lot more actually-declarative and less hackable than clojure's

10:54 hugod: I am trying to do plugin discovery of javascript components via clojure namespace enumeration

11:00 s/javascript/om clojurescript/

11:10 michaelr525: hi

11:10 anyone works with liberator?

11:11 why post!ing a new item can't return a response? is it because of the HTTP standard?

11:12 according to the decission graph I have to return new? => false and respond-with-entity? => true and then I get a 200 status with the response I provide in handle-ok.

11:12 so this works, but why this way?

11:19 ok, I think I should use handle-created

11:20 yeah

11:20 it works

11:20 thanks anyway :)

11:22 Fare: I've started getting this error: IllegalArgumentException No method in multimethod 'done?' for dispatch value: class skylark.lexer.Σ clojure.lang.MultiFn.getFn (MultiFn.java:160)

11:22 but the very same thing used to work, and the namespaces look correct to me, so I'm baffled.

11:24 how do I inspect the MultiFn object?

11:25 clgv: Fare: you might have forgotten to load a namespace that defines the corresponding method

11:25 Fare: maybe due to changed :require statements in your ns-form

11:26 Fare: `(defmethod ...) shows the correct namespaces

11:26 I grouped the :use and :require statements --- maybe that's the issue? But why does `(defmethod done? ...) show the apparently correct thing?

11:28 oh, maybe the class got overwritten after defining the method?

11:29 or something like that?

11:33 clgv: Fare: redefinition of the class after the method definition is problematic, if it happened

11:34 did you restart the repl to try whether it works then?

11:35 Fare: same

11:36 clgv: ok. if your last action had to do with reorganizing the :use/:require statements you should look at the differences to see if an error happened there

11:37 each namespace containing defmethods that was removed is a problem

11:58 Fare: could my build be corrupted somehow?

11:58 how do I inspect a multifn ?

12:15 clgv: Fare: maybe with that method https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/MultiFn.java#L577

12:18 Bronsa: clgv: Fare there's clojure.core/methods

12:18 Fare: I'm totally confused: this used to work, and stopped working suddenly. From the user namespace, I can define methods on vectors, but not on the defrecord I care for. WTF?

12:19 Bronsa: that's does what clgv linked, but as a function

12:19 clgv: Fare: well you could use "git bisect" to find the commit that introduced the problematic changes

12:19 Fare: also works with a new record class

12:20 I know which commit it is, but it has plenty of unrelated changes

12:20 clgv: your best bet is that the method definition is not loaded.

12:21 Bronsa: or you have a redefinition of that record somewhere

12:21 clgv: couldnt you just reevaluate the desired method definition?

12:21 Fare: clgv: doesn't look like it's working

12:21 Bronsa, not voluntarily, though there might be some symbol clash with namespaces, though I didn't seen any error or warning

12:22 Bronsa: Fare: does (= (class some-instance) the-record) return true?

12:22 clgv: Fare: reevaluting the desired defmethod does not work? then something is seriously wrong since that should fix the class-redefinition issue

12:22 Bronsa: Fare: might also be a problem with mixing AOT code w/ JIT

12:22 Fare: Bronsa, yes

12:23 Bronsa: no idea then

12:23 Fare: Bronsa, wait, no

12:23 clojurebot: excusez-moi

12:23 Fare: how is that possible???

12:23 Bronsa: ,(defrecord x [])

12:23 clojurebot: sandbox.x

12:23 Fare: the class has the same name

12:23 Bronsa: ,(def a (x.))

12:23 clojurebot: #'sandbox/a

12:23 Bronsa: ,(defrecord x [])

12:23 clojurebot: sandbox.x

12:24 Bronsa: ,(= x (class a))

12:24 clojurebot: false

12:24 Bronsa: Fare: ^

12:24 Fare: I don't get it

12:24 Bronsa: Fare: the second defrecord overwrites the first one

12:25 Fare: but a is an instance of the first record, not the second one

12:25 even if the two records have the same class name, they are not the same class

12:26 Fare: if you don't have a redefinition of your record, you are probably AOT compiling the record somewhere, that messes things up

12:28 Fare: I have no idea where my defrecord is somehow defined twice, though.

12:28 Bronsa, probably, though I have no idea how

12:32 clgv: Fare: do you have namespaces with hyphens?

12:34 if so, make sure they are all written identically in the require clauses. using "my-ns" and "my_ns" in differents ns forms loads my-ns twice

12:34 at least this was the case with Clojure 1.4.0

12:48 Ro_: Hello, is there a book/paper for functional scalable modular software creation

12:48 ?

12:48 or similar

12:53 jjwatt: Ro_: Maybe you want "on the criteria to be used in decomposing systems into modules," "out of the tarpit," "why functional programming?," or "equal rights for functional objects."

12:53 all are great papers

12:54 bbloom_: jjwatt: those are all definitely great

12:54 jjwatt: and not too specific

12:54 bbloom_: Ro_: or are you looking for more info about how to structure larger code bases in a functional language?

12:54 jjwatt: hopefully

12:55 Ro_: bbloom, yes

12:55 bbloom_: Ro_: watch this: https://www.destroyallsoftware.com/talks/boundaries

12:55 Ro_: but I think both

12:55 mdrogalis: stuartsierra's Clojure in the Large talk was pretty good, Ro_.

12:56 jjwatt: bbloom_: cool, i've never seen that

12:57 Ro_: Ok, I am going to see those. If you'll think something more, notify me. :)

12:57 btw, thanks :)

12:57 jjwatt: heh. there are a ton more. but hopefully, that's a good start.

12:58 Ro_: is there a list?

12:58 jjwatt: i think there might be a list of papers on the clojure site somewhere.

12:59 bbloom_: jjwatt: are you thinking of the clojure bookshelf?

12:59 ~bookshelf ; i hope

12:59 clojurebot: excusez-moi

12:59 jjwatt: not a huge list, though. a lot of papers you just hear people refer to in their talks or books

12:59 bbloom_: clojurebot: bookshelf is http://www.amazon.com/Clojure-Bookshelf/lm/R3LG3ZBZS4GCTH

12:59 clojurebot: c'est bon!

13:00 jjwatt: bbloom_: no, I meant papers specifically

13:00 bbloom_: do share if you find it

13:01 jjwatt: looks like fogus has a list, but they're not all functional and some are fundamentals heavy: http://blog.fogus.me/2011/09/08/10-technical-papers-every-programmer-should-read-at-least-twice/

13:02 which reminds me, his bibliographies are a great place to find papers and books!

13:02 Ro_: I was right coming here and asking! :D

13:03 jjwatt: oh, i found the papers list i was talking about. it's actually on github! https://github.com/papers-we-love/papers-we-love

13:04 there's a clojure section, funtional section, and a ton more

13:04 wonder if that's in the bot.

13:05 justin_smith: ~papers

13:05 clojurebot: It's greek to me.

13:08 TimMc: make it so

13:11 jjwatt: clojurebot: papers is https://github.com/papers-we-love/papers-we-love

13:11 clojurebot: Ack. Ack.

13:14 timothyw: clojure.core.cache/through

13:15 oops… that was supposed to go in the search bar

13:25 hoverbear: Is there a library for Clojure to make OAuth HTTP requests?

13:26 technomancy: depending on what you need, this can be done in ~20 lines with clj-http and cheshire

13:26 hoverbear: technomancy: Perfect. I'll check those out

13:27 technomancy: https://github.com/technomancy/syme/blob/master/src/syme/web.clj#L21

13:34 hoverbear: technomancy: Thanks :)

13:37 timothyw: I’m having some Clojure / Core.Async Dependency Issues (see https://groups.google.com/forum/#!topic/clojure/YYH6XUJ2PzE)

13:37 looks to be the same “No such var: clojure.core.cache/through” as here: http://www.raynes.me/logs/irc.freenode.net/clojure/2013-09-11.txt

13:38 but explicitly including org.clojure/core.cache didn’t work for me

13:38 anyone else seeing this?

13:40 jjwatt: haven't seen it; using core.async

13:42 timothyw: the current page (https://github.com/clojure/core.async/) recommends [org.clojure/clojure "1.6.0"]

13:42 [org.clojure/core.async "0.1.303.0-886421-alpha"]

13:42 I’ve tried different permutations to no avail

13:42 jjwatt: just rebuilt this project on a server yesterday

13:43 yeah, i'm using 1.6

13:43 [org.clojure/core.async "0.1.303.0-886421-alpha"]

13:43 timothyw: and you’re good?

13:44 … I even tried a clean .m2/repository

13:44 jjwatt: yeah. hmm. I don't :refer :all

13:44 not sure if that makes a diff

13:44 maybe you wouldn't pull in some defs

13:45 hiredman: timothyw: what version of lein?

13:45 jjwatt: [clojure.core.async :as a :refer

13:45 [chan go go-loop close! <!! <! >! >!!]]


13:45 timothyw: tried removing :refer :all - same error

13:45 Leiningen 2.3.4 on Java 1.7.0_55 OpenJDK 64-Bit Server VM

13:46 hiredman: there is an issue with certain versions of lein and some line plugins that causes that exception

13:46 what plugins are you using?

13:46 oh

13:46 timothyw: umm… a bunch (in ~/.lein/profiles.clj)

13:47 jjwatt: i'm only using cider-nrepl

13:47 hiredman: lein deps :tree will print a list of depdencies and may print out warnings for things that stomping on the depdencies of other things

13:47 timothyw: commenting out all the plugins and see what happens

13:47 timothyw: ok, lemme try

13:49 nope. I tried commenting out all my plugins (below), but no dice.

13:49 :plugins [[lein-ancient "0.5.5"][codox "0.8.10"][lein-ritz "0.7.0"][lein-midje "3.1.3"][lein-midje-doc "0.0.22"][lein-ring "0.8.11"][lein-try "0.4.1"][lein-localrepo "0.5.3"][alembic "0.2.1"][hiccup-bridge "1.0.0-SNAPSHOT"][lein-cljsbuild "1.0.3"][lein-release "1.1.3"]]

13:50 lemme try disabling ~/.lein/profiles.clj

13:50 hiredman: so run lein deps :tree and see what conflicting versions of core.cache are being required

13:52 timothyw: ok, I got it

13:52 disabling ~/.lein/profiles.clj fixed the problem

13:52 so something in there is conflicting with core.cache

13:52 xeqi: jjwatt: are you in the houston area?

13:53 jjwatt: xeqi: no, in the south, though.

14:05 jinks_: is there a prettier/fancier way to express "(if (> p 10) 10 p)"?

14:06 technomancy: max

14:06 err

14:06 min

14:07 justin_smith: and don't forget minimax http://en.wikipedia.org/wiki/Minimax

14:07 amalloy: minimax's big brother maxerrmin

14:07 that actually sounds like a cool name. i wouldn't mind being named Max Errmin

14:07 technomancy: it's just a /nick away

14:08 oh, except your karma is not transferrable

14:08 amalloy: technomancy: i have access to the karma database though

14:08 jinks_: augh... could've thought of that. Looks like there's too much blood in my caffeine circulation :)

14:08 technomancy: amalloy: you wouldn't...

14:08 amalloy: $karma MaxErrmin

14:08 lazybot: MaxErrmin has karma 0.

14:08 amalloy: apparently i wouldn't

14:13 Fare: so the only change I made that could have messed AOT was adding a :main foo.core to the project.clj

14:13 would that explain why my defmethod didn't work anymore?

14:15 amalloy: Fare: it's certainly suspicious, anyway

14:15 AOT is just a vehicle for sadness

14:16 mdrogalis: Shotgun!

14:19 * Fare renames the Sigma into FooState and things work again.

14:20 amalloy: Fare: probably lein clean would have had the same effect

14:20 Fare: amalloy: quite possible

14:20 amalloy: thanks for the tip

14:29 amalloy: &(class (hash-map))

14:29 lazybot: ⇒ clojure.lang.PersistentArrayMap

14:29 xeqi: $karma MaxErrmin

14:29 lazybot: MaxErrmin has karma 1000.

14:29 * mdrogalis gasps.

14:29 amalloy: reeeeeally

14:30 xeqi: yearly reminder

14:30 jinks_: amalloy: must be _random_ database corruption...

14:30 xeqi: those cosmic rays

14:31 aperiodic: you can't *disprove* it

14:31 * technomancy blames CAP theorem

14:32 bbloom_: hash-map is such a strange function name compared to the other data structure factory names

14:32 Bronsa: bbloom_: well map was already taken

14:32 amalloy: srsly though who did that? i actually didn't touch MaxErrmin's karma, and karma is channel-local, so it can't have been set in PM. does xeqi have db access?

14:33 bbloom_: Bronsa: and there's an alternative conflict with the name "assoc" if you wanted to call them "associations"

14:34 amalloy: bbloom_: it seems consistent with the other datastructure factory names. hash-map, hash-set, array-map

14:34 Bronsa: bbloom_: there's still dict though

14:34 bbloom_: amalloy: i would clarify, but i know you knew what i meant :-P

14:34 Bronsa: for some reason dict just seems wrong to me...

14:35 but i guess (map seq), (dict & keyvals), (assoc dict & keyvals) works out

14:36 barring my discomfort, that's probably a good solution

14:36 especially since my discomfort doesn't count for anything

14:40 amalloy: $karma MaxErrmin

14:40 lazybot: MaxErrmin has karma -1000.0.

14:40 amalloy: haha a float. silly me

14:43 expez: (try (schema/validate MySchema {}) (catch Exception e (println e))) at the repl works fine, but if I replace println with log/error (from timbre) it just hangs, why?

14:44 validate throws an ExceptionInfo

14:44 I had this in a (future ...) and I think this explains why it inexplicably dies, without printing any stacktrace

14:45 mdrogalis: expez: Correct.

14:49 expez: mdrogalis: why does this happen?

14:50 mdrogalis: expez: When you spin up a future, you're no longer on the main thread. Std out/err from other threads goes to, at least in Emacs, *nrepl-server*, not *nrepl* to avoid mixing the two, I guess.

14:51 At least, that was always my understanding. Can anyone confirm/disconfirm?

14:51 Even when not using Emacs, stderr will be thrown out in a future if not caught. I dont know why on that one.

14:51 I suppose because the thread just gets terminated if the exception bubbles all the way up. End of game.

14:52 expez: mdrogalis: I had (future (try (catch ..(log/error e)) thinking that would at least let me know about any failures, but that is indeed causing a freeze not just in emacs?

14:52 justin_smith: you could wrap your future in a try/catch that logs

14:52 jynx

14:53 mdrogalis: You're seeing a freeze? I would have expected that to log just fine.

14:53 justin_smith: unless you have a problem in your catch block maybe?

14:55 expez: yes, it appears to just die at the (validate ..)

14:55 I added some logging just prior and after, and jus the line prior prints

14:55 I'm using the default configuration for timbre, so this is all logging to console

15:08 vdmit11: Hi folks. Can clojure sets (I mean data structures) handle large elements? The elements may be several megabytes in size and I need to keep them unique, so can I use sets and how slow that would be?

15:11 bbloom_: vdmit11: the only thing that matters is the speed of your hash and equality functions

15:12 vdmit11: if you're storing immutable byte blobs for example, you can either pre-hash or lazy (ie caching) hash them

15:13 in that case, the size won't matter at all really

15:14 justin_smith: bbloom_: or give them a hash function that does not require reading the whole element

15:15 celwell: Would it be possible (and reasonable) to make macro that let's you use a period as a composition operator? (e.g., haskell's "(x . y)" instead of "(comp x y)") ... Hmm... now that I think about it, that's not prefix notation. Any thoughts?

15:16 justin_smith: celwell: . is picked up on the reader level

15:16 gtrak: ,(read-string "(x . y)")

15:16 clojurebot: (x . y)

15:16 gtrak: oh, huh

15:16 justin_smith: wait, maybe I am wrong...

15:16 gtrak: not what I expected to happen

15:17 aperiodic: isn't . just a special form and the other interop forms are macros that expand to .?

15:17 gtrak: in the first position yes

15:17 ,.

15:17 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: . in this context, compiling:(NO_SOURCE_PATH:0:0)>

15:17 justin_smith: ahh, it is position dependent

15:17 gtrak: ,do

15:17 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: do in this context, compiling:(NO_SOURCE_PATH:0:0)>

15:17 justin_smith: ,(do (def . :hello) .)

15:17 clojurebot: :hello

15:18 gtrak: ,`.

15:18 clojurebot: .

15:18 gtrak: ,'`.

15:18 clojurebot: (quote .)

15:18 xeqi: ,(second "(read-string "(x . y)")

15:18 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading string>

15:18 xeqi: ,(second "(read-string "(x . y)"))

15:18 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading string>

15:18 justin_smith: ,(do (def . :hello) (. . getName))

15:18 clojurebot: "hello"

15:18 gtrak: why isn't that namespaced?

15:18 ,`do

15:18 clojurebot: do

15:18 gtrak: ,`somesym

15:18 clojurebot: sandbox/somesym

15:19 gtrak: funny

15:19 justin_smith: I still think binding . will have weird effects

15:19 Bronsa: gtrak: special-symbols aren't namespaced

15:19 and ` doesn't namespace them

15:19 justin_smith: since it is special in the first position, see my last clojurebot invocation

15:19 Bronsa: well except import*

15:20 vdmit11: bbloom_: tnx

15:20 Bronsa: wich I just realized ` doesn't handle

15:33 sveri: Hi, I am trying to use core.typed in a namespace where I require datomic.api and get this error: Type Error (NO_SOURCE_FILE) Internal Error (:<NO LINE>) File for datomic.api not found on classpath: datomic/api.clj What can I do to exclude datomic?

15:35 Bronsa: sveri: https://groups.google.com/d/msg/clojure-core-typed/ptVyTMmSHyQ/jN5jquozM2IJ

15:36 sveri: Bronsa: ah, thats funny, just a few hours old this thread, thank you very much

15:47 schmee: is it idiomatic to use `juxt` for side-effects (if you don't care about the returned array)?

15:47 amalloy: seems a little weird

15:48 i'd write (doseq [f [a b]] (f x y z))

15:48 gfredericks: s/a b/g h/

15:48 amalloy: but ((juxt a b) x y z) is understandable too

15:49 gfredericks: naw, that implies that f is in the same family as g and h, where really it's the general name for any of them

15:49 gfredericks: amalloy: I'll fight you.

15:49 * gfredericks is learning social skills from Raynes

15:49 amalloy: bahaha

16:50 eskatrem: Sorry for the noob question, but how (or where can I find how) write and compile a program in clojure that simply puts hello world on the command line?

16:51 rlb: eskatrem: one option -- http://leiningen.org/

16:51 and then "lein new app my-app" followed by "cd my-app; lein run"

16:51 justin_smith: eskatrem: if you run "lein new", that will create something very close to a hello world clojure app

16:51 rlb: you can see the core code in new/my_app/core.clj

16:51 justin_smith: or what rlb said

16:51 rlb: s/new/src/

16:52 i.e. src/my_app/core.clj

16:52 eskatrem: the fact is: I am building a web app right now, and I realized I didn't know how to reproduce outside the web app simple problems

16:53 rlb: So I'm relatively new to kerodon/peridot, but it seems like wrap-ssl-redirect as :middleware breaks them. Is that expected and is there a fix, or am I just doing it wrong?

16:54 xeqi: rlb: how does it break them?

16:54 rlb: xeqi: it *seems* to be forgetting the session

16:56 i.e. to make it simple, if I try (request "/login" ... :password ...) (request "/foo"), that works fine without the redirect, but with it, the second request fails, redirecting to /login, as if it couldn't find the session or the :user in the session anymore.

16:57 (don't know for sure yet if it lost the session, or somehow cleared the user from the session)

16:57 but the latter's unlikely

16:58 xeqi: if it helps, this was via lib-noir's app-handler :middleware setting.

16:58 i.e. :middleware [#(wrap-ssl-redirect % {:ssl-port ssl-port})]

16:58 and there's also a

16:58 :access-rules [{:rule authorized-user? :on-fail redirect-to-login}]

16:59 suppose I should strip down to a trivial application and make sure I can still reproduce it there

17:00 xeqi: rlb: are you adding (follow-redirect) in between the requests?

17:00 petrust: hey peeps. I’m having some trouble getting Light Table to connect to an nREPL for a particular project. My ~/.lein/profiles.clj file contains the [lein-light-nrepl "0.0.18"] dependency and :repl-options {:nrepl-middleware [lighttable.nrepl.handler/lighttable-ops]}}. The error I get is: Unable to resolve var: lighttable.nrepl.handler/lighttable-ops in this context

17:00 rlb: xeqi: not sure that matters -- it's redirecting to /login when I ask for /foo, which I assume means it forgot who you are?

17:01 xeqi: rlb: I'm more thinking (request "/login" ...) is sending back a redirect due to wrap-ssl

17:01 rlb: but no, in the current test case, I'm not

17:02 well I can see that the login has succeeded (i.e. I print the response and it's at the normal post-login page)

17:02 let me double check that, though

17:13 xeqi: ok, thanks for the help -- it looks like it may be a url problem (which was causing unexpected redirects), at least for peridot. If that's true, then I'll have to see if the same issue applies at the kerodon level.

17:15 xeqi: quack

17:26 michaelr525: sometimes cider returns just the first line of the stacktrace, it drives me crazy

17:26 good evening

17:27 justin_smith: michaelr525: do you know about clojure.repl/pst ?

17:27 danielcompton: michaelr525: good morning

17:27 justin_smith: ~ugt

17:27 clojurebot: ugt is Universal Greeting Time: http://www.total-knowledge.com/~ilya/mips/ugt.html

17:29 ben_vulpes: i'd like to get .00001 instead of 1e-5 - what is my brain failing to figure out today?

17:29 ,(/ 1 100000000)

17:29 clojurebot: 1/100000000

17:29 ben_vulpes: ,(/ 1 100000000.0)

17:29 clojurebot: 1.0E-8

17:29 justin_smith: ,(format "%f" 0.00001)

17:29 clojurebot: "0.000010"

17:29 ben_vulpes: justin_smith to the rescue again

17:29 thanks boss

17:29 justin_smith: heh, np

17:31 michaelr525: justin_smith: what's clojure.repl/pst?

17:32 justin_smith: ,(1)

17:32 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>

17:32 justin_smith: ,(clojure.repl/pst)

17:32 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to java.lang.Throwable>

17:32 justin_smith: oops

17:32 ,(do (1) (clojure.repl/pst))

17:32 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>

17:33 justin_smith: anyway, the repl keeps track of the last exception thrown, pst prints the stack trace for that exception

17:33 ben_vulpes: justin_smith: any way to force format to return more decimals?

17:33 * ben_vulpes dives into java docs

17:33 gws: ,(format "%.20f" 0.0001)

17:33 clojurebot: "0.00010000000000000000"

17:33 justin_smith: ,(format "%20.20f" 0.00001)

17:33 clojurebot: "0.00001000000000000000"

17:33 justin_smith: yeah, something like that

17:34 gws: I guess 20 is the magic number

17:34 gws: haha guess so

17:34 i know it's not a telepathic connection with you otherwise i'd be a lot smarter

17:35 justin_smith: oh, pshaw

17:35 michaelr525: justin_smith: ok, sounds usefull.. :)

17:36 but why cut the stack trace in the first place

17:36 ?

17:36 ben_vulpes: ,(format "20.20%f" (/ 2 100000000.0))

17:36 clojurebot: "20.200.000000"

17:36 amalloy: michaelr525: because newcomers complain that stacktraces are scary

17:36 ben_vulpes: d'oh

17:37 michaelr525: amalloy: I pitty newcomers who try emacs+cider..

17:38 Looks like I use emacs all the time now, but I still kind of hate it :)

17:38 ben_vulpes: michaelr525: one must learn emacs and lisp at the same time!

17:38 justin_smith: ben_vulpes: the 20.20 means at least 20 wide, 20 points after the decimal point (kind of redundant, I was being sloppy)

17:38 ben_vulpes: fascinating, justin_smith, i have lots of javadoc reading backlog :(

17:38 the formatter in particular is a great mystery to me

17:39 learning java from clojure is a pretty hilarious experience

17:40 justin_smith: indeed

17:40 (that's how I learned java too)

17:41 ben_vulpes: javadocs in emacs is p neat.

17:41 amalloy: does cider hide the stacktrace by default? i thought it was just clojure's built-in repl

17:41 ben_vulpes: amalloy: mine catches the stacktrace and the puts it into its own buffer, and i haven't put the time into making it not yet.

17:41 amalloy: ben_vulpes: clojure's formatter is based on c's printf, so you can read about that and apply most of what you learned to java's

17:42 ben_vulpes: amalloy: neat! thanks.

17:42 another excuse to dabble in C.

17:42 justin_smith: amalloy: put a small ttl on any the cache for any answer to does cider [x]?

17:42 * ben_vulpes remembers the last time he played with valgrind on os x

17:43 amalloy: justin_smith: yeah. a co-worker today asked me for help with cider where sometimes when he loaded his project it blew up because it couldn't find "pp" in some namespace he wasn't requiring

17:43 justin_smith: lol

17:43 amalloy: he was like "hang on i'll try getting the latest version of cider"

17:43 justin_smith: even better

17:43 amalloy: me: man i would try getting a REALLY OLD version of cider

17:44 my 2010 swank is still running like a dream

17:44 ben_vulpes: surely you want really really really fancy stack trace handling

17:44 justin_smith: putting it that way makes me imagine some old hoopty with air fresheners on the rear view

17:44 amalloy: ben_vulpes: swank's is better!

17:44 justin_smith: duct tape on the glove box "still purrs like a kitten"

17:45 andyf_: When one runs "java -cp clojure.jar clojure.main", how is it that the function clojure.main/main is then called?

17:46 justin_smith: andyf_: I think it is related to the fact that fns are runnable / callable

17:46 and you are telling java to execute that method

17:46 amalloy: andyf_: the namespace clojure.main is gen-classed, and its main(String[] args) delegates to -main

17:46 andyf_: I mean, why clojure.main/main and not one of the other functions in that namespace?

17:47 amalloy: andyf_: actually, that was a lie

17:47 src/jvm/clojure/main.java

17:48 requires clojure.main, then calls clojure.main/main

17:49 andyf_: Thanks. The only .java file in that source directory, which I have probably never noticed before

17:50 amalloy: yeah, same here

17:50 but it was the only explanation once clojure.main turned out not to be gen-classed like i expected

18:02 jjwatt: cleaner way to say this? (reduce-kv (fn [i k v] (into i {k (if (nil? v) "unknown" v)})) {} {:ip_addr nil :id 1})

18:04 justin_smith: whay not assoc instead of into?

18:05 also, you could do ({nil "unknown"} v v) but that may be excessively clever

18:07 jjwatt: oh yeah. assoc would make it a little less noisy. I seem to have gotten in the habit of using into, and I barely use assoc

18:08 is assoc more performant?

18:09 justin_smith: jjwatt: in that case maybe barely - since it does not need to create the hash map just to break it down again immediately

18:09 jjwatt: that's what I was thinking

18:09 justin_smith: but regardless it avoids pointless nesting

18:10 jjwatt: it could matter over millions of times, and yeah, avoiding the nesting is even more important.

18:11 justin_smith: looks a surprising amount nicer

18:11 justin_smith: cool

18:11 Bronsa: uh weird, I'd have expected ((fnil assoc "unknown") {} :foo nil) to work

18:12 justin_smith: fnil looks at the first arg, right?

18:12 Bronsa: I never realized fnil is positional

18:13 justin_smith: ,((fnil + 0) nil 1)

18:13 clojurebot: 1

18:13 justin_smith: ,((fnil + 0) 1 nil)

18:13 clojurebot: #<NullPointerException java.lang.NullPointerException>

18:13 eskatrem: what's fnil?

18:13 justin_smith: replaces the first arg if nil

18:13 otherwise acts like the function provided

18:13 Bronsa: ,((fnil + 0 0) 1 nil)

18:13 clojurebot: 1

18:14 justin_smith: ahh, fnil is varargs, of course :)

18:14 I should have expected that

18:14 so replaces Nth arg if Nth arg is nil

18:14 Bronsa: yeah

18:15 eskatrem: so (fnil+0 0) is equivalent to #(if (nil? %) 0 (+ 1 %)) ?

18:15 justin_smith: ,((fnil assoc nil nil "unknown") {} :foo nil)

18:15 clojurebot: {:foo "unknown"}

18:15 Bronsa: justin_smith: uhm it's not vararg, only 1-to-3

18:15 justin_smith: eskatrem: you missed some spaces in there

18:15 Bronsa: OK, that's weird

18:16 eskatrem: justin_smith: in my lambda?

18:16 justin_smith: in your fnil call

18:16 eskatrem: sorry I just had this chan open and I noticed something I've never seen before (fnil), so I'm just curious, so I'm bumping in the conversation with stupid questions

18:17 jjwatt: yeah, i had never seen it either

18:17 eskatrem: oh yeah right, fnil + 0, not fnil+0, of course

18:17 Bronsa: justin_smith: it is, I have no idea why it isn't vararg

18:17 clojurebot: Gabh mo leithscéal?

18:17 justin_smith: eskatrem: fnil returns a function, (fnil + 0 0) takes N numbers, and if the first or second number is nil they get replaced with 0

18:17 Bronsa: seems like it shouldn't be hard to implement as such

18:17 justin_smith: eskatrem: otherwise it is +

18:18 jjwatt: that just prompted me to search for every fn with "nil" in the name hehe

18:18 it looks like it's only the two

18:18 eskatrem: justin_smith: gotcha!!

18:18 justin_smith: eskatrem: but (fnil+0 0) is an invocation of the nonexistant fnil+0 function

18:18 DomKM: Anyone familiar with what ^not-native, ^clj, and ^clj-or-nil does in cljs?

18:19 eskatrem: justin_smith: yeah exactly, asef+0 is a legal variable name in clojure

18:20 justin_smith: ,(let [?1+1=2 5] ?1+1=2)

18:20 clojurebot: 5

18:20 hyPiRion: ,(let [  10] )

18:20 clojurebot: 10

18:20 hyPiRion: those variable names.

18:21 jjwatt: justin_smith: so, can you use fnil to do the reduce-kv I was doing?

18:21 bbloom_: hyPiRion: what is that? a non-breaking space or something?

18:21 jjwatt: seems like you would need an apply. probably uglier.

18:21 verma: can I memoize a function defined inside deftype (and implementing a protocol)?

18:21 justin_smith: ,((fnil assoc nil nil "unknown") {} :foo nil) eskatrem: yeah but it's ugly I think

18:21 clojurebot: {:foo "unknown"}

18:21 hyPiRion: bbloom_: yeah, just a nsbp which incidentally is a legal clojure variable name

18:22 and, java for that matter.

18:22 Bronsa: justin_smith: http://sprunge.us/NFjC?clj

18:22 bbloom_: hyPiRion: 'puters

18:22 how do they work?

18:23 cbp: o man fnil has gotta be one of the least used functions

18:23 jjwatt: if you press the buttons the right way for long enough, money comes out

18:23 justin_smith: Bronsa: looks about right at first glance, nice

18:23 cbp: hmm or at least i had forgotten about it

18:23 bbloom_: i use fnil all the time for (def conjs (fnil conj #{})) and (def conjv (fnil conj [])) for the purposes of update-in conjs etc

18:24 Bronsa: bbloom_: me too, I think think I only used fnil for update-in

18:24 justin_smith: bbloom_: (fnil inc 0) is a good one too

18:24 bbloom_: ah, yes, i call that one zinc :-)

18:37 rlb: xeqi: ok, so smaller example -- with this, the session is clobbered for the second per/request: https://www.refheap.com/f951cfb67b36c8eb477c08af3

18:38 and if we print *noir-session* from our access-rules rule function, it's valid for the first request and gone for the second one.

18:39 of course it may still be something we're doing wrong, so I'll need to narrow further

18:43 Bronsa: justin_smith: http://dev.clojure.org/jira/browse/CLJ-1486

18:43 justin_smith: nice

18:44 ahoenigmann: added the paredit package but forward slurp isnt working

18:44 C-<right arrow>

18:44 or C-)

18:45 got this on emacs startup:

18:45 /.emacs.d/elpa/paredit-22/paredit.el at Thu Jul 31 15:34:11 2014

18:45 In paredit-kill-region:

18:45 paredit.el:1650:4:Warning: kill-region called with 3 arguments, but accepts

18:45 only 2

18:45 In paredit-recentre-on-sexp:

18:45 paredit.el:1765:37:Warning: `goto-line' used from Lisp code

18:45 That command is designed for interactive use only

18:47 jjwatt: Bronsa: awesome

18:47 justin_smith: ahoenigmann: just to double check, you are doing c-<right arrow> while inside the parens that should be slurping?

18:47 ahoenigmann: yes

18:47 im on mac

18:47 jjwatt: type C-h k

18:47 ahoenigmann: with meta mapped to alt key

18:47 jjwatt: and then hit right arrow

18:47 ahoenigmann: okay

18:47 jjwatt: and see what emacs tells you. er, I mean C-<right arrow>

18:48 C-h k C-<right>

18:48 ahoenigmann: says Describe key (or click or menu item):

18:48 in mini buffer

18:48 jjwatt: mine's always messed up in urxvt

18:48 and tmux

18:48 yeah hit c-right there

18:48 Jaood: do you guys invert cmd and option for emacs on osx_

18:48 ?

18:48 ahoenigmann: doesnt do anything just like in the buffer thats in paredit-mode

18:49 justin_smith: ahoenigmann: so emacs is not receiving the C-<right> keystroke

18:49 ahoenigmann: to install I just put paredit in list of packages, then i did M-x paredit-mode after emacs startup

18:49 ok

18:49 justin_smith: check your os / desktop key bindings, you may need to change one that steals that one

18:49 technomancy: ahoenigmann: many keystrokes are impossible to represent with terminal keycodes

18:49 ahoenigmann: sucks

18:49 technomancy: since ctrl and meta are represented as bitmasks on normal keycodes

18:50 it does

18:50 ahoenigmann: so i have to use emacs outside the terminal, seems so wrong

18:50 jjwatt: there's some blargs or w/e if you google around for paredit and iterm

18:50 technomancy: ahoenigmann: not at all; just pick new bindings

18:50 jjwatt: or term or whatever it's called on macs

18:50 justin_smith: but if you use a windowed emacs it can do fancy things like inline svg!

18:50 ahoenigmann: iterm fixes this?

18:51 jjwatt: ahoenigmann: when i'm too lazy or stuborn to change my bindings, I just M-x paredit-slurp-sexp

18:51 Jaood: iterm lets you control modifiers keys

18:51 jjwatt: every key in emacs is a command

18:53 Jaood: the nice thing about vim is that key bindings do not interfere with the world ;)

18:53 justin_smith: Jaood: dunno, last time I used it it interfered with my vi muscle memory

19:07 xeqi: rlb: and this works w/o wrap-ssl?

19:08 rlb: sorry, no -- that was a red herring

19:09 it just doesn't work -- disabling our access-rules *does* fix it, but I'm not sure yet if that's symptom or related to cause

19:10 xeqi: rlb: I've never really worked wit hlib-noir, but my instinct is to say if *noir-session* isn't being populated then the correct cookie must not be kept between request 1 and 2

19:11 rlb: xeqi: ok -- thanks -- I'll keep poking around -- see if I can isolate the problem better.

19:12 xeqi: is it possible to print the response state out and the next request to see if the cookies make it across correctly?

19:14 justin_smith: rlb: is this way of wrapping the session the type where you need to explicitly put any data to be persisted under the :session key of your response?

21:03 ben_vulpes: does anyone know why clj-time.format/formatter takes either a string or a datetimezone and many strings? what are the implications of using a formatter without a datetime zone?

21:07 gws: you get UTC if you don't specify a tz

21:08 ben_vulpes: gotcha

21:18 gozala: can someone please help me figure out why do I get this error ?

21:18 https://gist.github.com/Gozala/fc26deeabac7e05e42c6

21:20 timsg: gozala: try making it state#?

21:21 DomKM: gozala: also diff#

21:21 timsg: gozala: and model#

21:21 though I guess you don’t use it

21:22 amalloy: well, he probably wants the field to be publicly visible and named state, not state__1234__auto__5678

21:22 oh, but that's just the method param

21:34 xeqi: has anyone put together a list of design pattenrs for clojure?

21:35 justin_smith: xeqi: many of us agree with stuart halloway http://thinkrelevance.com/blog/2007/05/17/design-patterns-are-code-smells

21:35 xeqi: justin_smith: but yet things like "middleware" still exist

21:36 fwiw I agree w/ respect to many of the gof patterns

21:36 justin_smith: it's true, but I think anyone who tried to write the "clojure design patterns" book would get shown that blog post, and would likely be expected to at least respond to it

21:36 xeqi: cat theory based patterns... maybe

21:37 brehaut: if you think of patterns as common solutions to acknowledged tradeoffs (identifying the pros and cons of said trade off) then the idea that they can be languages with no patterns is absurd

21:38 even the gof book has patterns that it basically says ‘this is what we do in C++ but in smalltalk its just a block'

21:38 justin_smith: brehaut: that's a good point

21:38 john2x: I like this comment in the article: "Design patterns are programming language smell."

21:39 justin_smith: brehaut: and even if it is just using simple language features (or a well respected community lib), it's good to document how they are most successfully used

21:39 brehaut: i think in clojure the tendancy is to write a little library that packages an idiom up as functions or macros (ie, semi-formally) rather than as text on a webpage

21:40 explaining to new clojure programmers when to use agents, atoms and refs is in a lot of ways the same sort of discussion as when to use various patterns

21:40 justin_smith: yeah, we can reify patterns into functions or syntax quite trivially, but it is still useful to document

21:41 brehaut: right

21:41 xeqi: I'm a fan of naming things makes it easier to communicate them

21:41 justin_smith: so instead of "which pattern to use here?" we can end up with "should I use an agent or a go block for this"

21:43 brehaut: xeqi: totally agreed

21:47 justin_smith, xeqi: i think the other thing is that once you get past basic language deficiencies, patterns tend to be architectural rather than simply behavioural

21:47 s/behavioural/implementational/?

21:47 xeqi: brehaut: do you have an example of the later?

21:47 brehaut: xeqi: strategy is a poor mans first class function

21:52 xeqi: ah right, looking up the gof book and it has creational / structural / behavioural

21:52 been awhile since I've leafed through it

21:53 brehaut: the nuts and bolts of the book have mostly aged into irrelevance

21:53 but the discussion around it is still quite intereseting i think

22:28 LukePaul: I am trying to figure out defrecord. I am wanting to implement my own "empty?" method for the record that I am making, but I don't quite understand what I am doing. Like what protocol should I be using for this?

22:28 bbloom_: empty? is already defined for records...

22:28 ,(defrecord EmptyRecord [])

22:29 clojurebot: sandbox.EmptyRecord

22:29 bbloom_: ,(empty? (EmptyRecord.))

22:29 clojurebot: true

22:29 bbloom_: ,(empty? (assoc (EmptyRecord.) :x 1))

22:29 clojurebot: false

22:29 bbloom_: but generally, records with fields can't be empty:

22:29 ,(defrecord Foo [x])

22:29 clojurebot: sandbox.Foo

22:29 bbloom_: ,(Foo. 1)

22:29 clojurebot: #sandbox.Foo{:x 1}

22:29 bbloom_: ,(dissoc (Foo. 1) :x) ; note: no longer a Foo

22:29 clojurebot: {}

22:34 LukePaul: My record has a cljs.core.async channel that acts as a queue and I have a field (queue-count) that records the number of items in that queue. I was hoping to override empty? to check if the queue-count is 0 or less.

22:35 bbloom_: that seems unwise

22:36 (doc empty?)

22:36 clojurebot: "([coll]); Returns true if coll has no items - same as (not (seq coll)). Please use the idiom (seq x) rather than (not (empty? x))"

22:36 bbloom_: your use doesn't seem to match that doc string

22:36 if you want a map-like thing, you (preferably just use a map or) use defrecord

22:36 alternatively, you can make custom data structures with deftype

22:36 but in this case, it sounds like you just want to define a function of your own

22:37 justin_smith: LukePaul: sounds more like .available than empty?

22:48 LukePaul: Thanks, I wasn't convinced that I was doing it right, so that helps. I will just define a new function outside of the record to check.

22:54 kelseygi: i wrote this function so i could use it in a ->> : https://www.refheap.com/88784

22:55 is there a simpler/more idiomatic way to do that?

22:55 justin_smith: (identity coll) is coll

22:55 and defn contains an implicit do

22:56 (defn log-size [coll] (log/debug (str "filtering " (count coll) " items")) coll)

23:01 kelseygi: oh duh

23:01 thanks!

23:01 there isn't like a "run" with side effects that returns what's passed in?

23:01 justin_smith: doto

23:02 but that goes by first arg, not last

23:02 otherwise I would have suggested it :)

23:02 ,(doto 1 println)

23:02 clojurebot: 1\n1

23:02 kelseygi: ah ok! that'd work with -> then

23:02 justin_smith: yeah

23:02 even works with more args...

23:03 ,(doto 1 (println "is the loneliest number..."))

23:03 clojurebot: 1 is the loneliest number...\n1

23:03 justin_smith: very similar to -> actually

23:03 someone should make otod, for ->> forms

23:04 or maybe dotoo, to follow the -> to ->> transformation

23:11 oskarkv: Hm ""Parameter declaration let should be a vector" pointing to the closing paren of this function declaration https://www.refheap.com/93692024c74d2fb9536b51134 Am I blind or what's the problem?

23:14 justin_smith: I see nothing wrong there (except for that dirty naughty mutation)

23:18 oskarkv: Oh, now I see it, in the next function. :P

23:20 Thanks for taking a look justin_smith

23:21 justin_smith: np

23:44 ben_vulpes: the funniest part about cider is how " Error compiling:

23:44 /Users/mrfox/repos/van/api/test/van/handler_test.clj:368:17"

23:44 is not linked to the source

23:45 justin_smith: wow, in emacs that is really low hanging fruit

23:45 compilation mode alreayd has all the code to parse that file / line / char info

Logging service provided by n01se.net