#clojure logs

2014-07-31

00:00sritchieodd; if I call a js function at the repl, I see the code printed out;
00:00sritchiebut if I pr-str a call inside of an om protocol fn call,
00:00clojurebotPardon?
00:01sritchiethere seems to be a whole wrapper around it from cljs
00:01sritchie<function (data__68246__auto__,owner80568,var_args){
00:01sritchievar p__80570 = null;if (arguments.length > 2) {
00:01sritchie p__80570 = cljs.core.array_seq(Array.prototype.slice.call(arguments, 2),0);}
00:01sritchieetc
00:01sritchieit calls a delegate: return users_typeahead__delegate.call(this,data__68246__auto__,owner80568,p__80570);}>
00:01brehautsritchie: are you knee deep in the madness that is jquery plugins?
00:02sritchiebrehaut: trying to get this damned typeahead module to work on an om text input field without rewriting everything
00:02sritchiebrehaut: knee deep for sure
00:02brehautsritchie: 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?
00:03DomKMsritchie: 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
00:03sritchieyeah, that’s what I’m trying to figure out - the typeahead props stick around, so that’s fine,
00:03sritchieDomKM: yeah, that doesn’t use the twitter typeahead module
00:03sritchiewhich I’m depending on for its autocomplete engine, prefetching, etc
00:04brehautsritchie: 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’)
00:04sritchiethat’s what this one does for sure
00:04sritchieBUT, I got the google places autocomplete to work just fine,
00:04sritchieand it was doing similar manipulations
00:04sritchieso I have hope :)
00:04brehautsritchie: 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?
00:05sritchiebrehaut: nice, that’ll work if I hit that issue, and then just handle the events myself if those props need to change
00:06brehautsritchie: im not sure about ‘nice’ ;) but yeah, that’s where i would look. that and a bottle of tequila
00:06sritchiebrehaut: trust me, I’m HEAVILY caffeinated
00:07sritchiethis way lies madness
00:07brehautsritchie: a much more effective chemical
00:07sritchieI’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
00:07brehautsritchie: yeah; jquery developers seem to have decided that throwing out all the best practises of software dev is the ideal way forward
00:07brehautcoupling? sure! single namespace? sure!
00:08brehautduck punching objects you down own? a double helping please!
00:08sritchiegotta draw in the ruby devs somehow
00:08Jaoodsritchie: or just use JS!
00:09justin_smith(inc brehaut)
00:09sritchieJaood: the typeahead + react integration problems aren’t due to cljs
00:09justin_smithfor duck punching, I know you didn't invent it, but it delights me
00:09brehauti did however invent duck wrapping (the term, not the behaviour)!
00:10justin_smithbrehaut: turduckening is when you mix that with multiple inheritance
00:10justin_smithor something
00:10brehauthah indeed
00:25rhg135how do you get a var from a ns from it's symbol?
00:26justin_smithTEttinger: I only just now notice that Bort is a potential output of your name generator
00:26TEttingerbort!
00:26trptcolin(resolve ‘map)
00:26trptcolin,(resolve ‘map)
00:26clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ‘map in this context, compiling:(NO_SOURCE_PATH:0:0)>
00:26TEttinger,(resolve 'map)
00:26clojurebot#'clojure.core/map
00:26rhg135,(resolve 'clojure.core)
00:26clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: clojure.core>
00:26justin_smithTEttinger: as are words like Yes and Box
00:26rhg135hmm
00:27trptcolinwelp thanks autocorrect-to-weird-quote
00:27rhg135i want the ns not a symbol from the ns
00:27justin_smith,`map
00:27clojurebotclojure.core/map
00:27justin_smithrhg135: maybe you want `
00:27trptcolin,(doc ns-resolve)
00:27clojurebot"([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."
00:27rhg135i want the ns's var though
00:28justin_smithns's var? you mean the name of the ns?
00:28rhg135where clojure attaches metadata
00:28trptcolinoh. that’s not a var
00:29trptcolin,(the-ns 'clojure.core)
00:29clojurebot#<Namespace clojure.core>
00:29rhg135yeah i hava the ns object
00:29rhg135need the var
00:30justin_smith,(meta (the-ns 'clojure.core))
00:30clojurebot{:doc "Fundamental library of the Clojure language"}
00:30rhg135hmm
00:30justin_smithns holds vars, they are not in any var
00:30rhg135weird
00:30rhg135i didn't see any meta on mine
00:30justin_smithdid you put any on it?
00:31rhg135doesn't clojure put line numbers?
00:32rhg135,(meta *ns*)
00:32clojurebotnil
00:32justin_smithon vars
00:32sm0ke,(vary-meta (the-ns 'clojure.core) assoc :doc "Foo")
00:32clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Namespace cannot be cast to clojure.lang.IObj>
00:32rhg135,(class *ns*)
00:32clojurebotclojure.lang.Namespace
00:33sm0ke,(vary-meta 'clojure.core assoc :doc "Foo")
00:33clojurebotclojure.core
00:36dbaschgolf 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?
00:37taliosTEttinger / technomancy - http://blog.sonatype.com/2014/07/ssl_connectivity_for_central
00:38bbloom$mail timsg i'll be around tomorrow, ping me again if you still need help
00:38justin_smithlazybot is not here
00:39bbloomdamn lazy bot
00:39TEttingerinteresting, talios
00:39trptcolindbasch: 85 so far
00:39justin_smithsleeping on the job, I am sure
00:39talios12. signups.
00:39rhg135i must have missed it, it's working
00:42trptcolinoh whoops, nm, 93
00:43justin_smith,(count (filter (fn [n] (= 42 (reduce + (map #(Integer. (str %)) (str n))))) (range 1000000)))
00:43clojurebot6062
00:44justin_smitherr, that % bothers me
00:44justin_smithoh, never mind
00:44justin_smithd'oh, bedtime
00:48trptcolinheh, 82 if you trim out whitespace doing things like (count(filter(fn[n](= 42 ... etc
00:51technomancytalios: urgh; this is fairly misleading
00:51technomancy"In 2012 we weren’t sure how many people not already running repository managers were interested in SSL access."
00:51technomancythis implies they were willing to give SSL access to people not running repository managers, which was not at all true
00:52technomancyI mean, very good news
00:52technomancyjust a nitpick
00:53trptcolinsnap, that was quick
00:57talioseven 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 )
00:57technomancyyeah, I would push out a new lein version within days of public non-preview access
00:58taliosand then wait for masses complaining about how much slowwwwwweeeerrrrrr maven was ;p
00:59technomancytalios: also holy crap; only twelve requests =\
00:59technomancyI'm fairly embarrassed that I didn't request it till this weekend tbh
01:00talios:) I didn't even know about it. I knew central moved to running nexus, but somehow I missed the SSL stuff
01:00technomancybut even though I requested it, I never got it actually working, because I need direct access, not nexus-mediated access
01:00taliosand its not like sonatype made money out of it. hell - they're forking out $150k for central bandwidth. youch
01:00talios*nod*
01:01taliosI wonder how big clojars is these days?
01:01technomancyI have 2-year-old numbers
01:01technomancy100GB in a month I think?
01:02taliosnot bad. any idea of total static size?
01:03technomancythat's easier, hang on
01:03technomancyhah
01:03technomancyonly 15GB
01:04rhg135anybody know if there is a better way to write section* here https://www.refheap.com/88742
01:07taliosonly 15? but sending out 100gb? youch - some folk need some caching :)
01:08technomancytalios: I'm sure a ton of that is CI stuff
01:09taliostechnomancy - which should *cough* come from a caching repo manager :) altho, clojars contains SNAPSHOTs of stuff doesn't it?
01:09taliosor not
01:09dbasch,(count(filter(fn[n](= 42(apply +(map #(Integer. (str %))(str n)))))(range 1e6))) ; justin_smith down to 80
01:09clojurebot6062
01:09technomancytalios: I don't think travis caches anything
01:10taliostechnomancy - sadly. tho thats also part of its charm. its simple.
01:10technomancytalios: the s3 transfer for lein's uberjar (one single file) was 347GB in May
01:11TEttingermodified justin_smith's answer, 79:
01:11TEttinger,(count(filter(fn[n](= 42(reduce +(map #(-(int %)48)(str n)))))(range 1000000)))
01:11clojurebot6062
01:11technomancywe got off S3 for 2.4.x, so it was 200 in june and so far only 160 in july, but ... yeah.
01:11technomancylots of jiggabytes
01:15technomancytalios: also 15GB is today's number. 100GB traffic was on a much smaller repo.
01:16technomancyI'd get the latest traffic numbers if it weren't time for me to call it a night.
01:16taliosyep - almost home time here too
01:16gfrederickstrptcolin: thx
01:17trptcolin;)
01:18brehauttalios: enjoy the traffic
01:19talios?
01:19brehautfor your commute
01:19taliosOnly heading to Mt Eden - curry night :)
01:19brehautisnt that what living in auckland is all about?
01:19brehauthaha
01:19taliosso yes - about an hour ;P
01:19brehautnice
01:19taliosnot.
01:26dbasch,(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
01:26clojurebot6062
01:37TEttingerok, can anyone get shorter than 75?
01:37TEttinger,(count(filter(fn[n](= 42(reduce +(map #(-(int %)48)(str n)))))(range 1e6)))
01:37clojurebot6062
01:39trptcolinTEttinger: substitute reduce -> apply
01:39trptcolinfor 74
01:58TEttingerhm, I'm thinking it may be possible to go under 74 using unquote-splicing
02:00TEttinger,(count(filter(fn[n](=(apply +(map #(-(int %)48)(str n)))42))(range 1e6)))
02:00clojurebot6062
02:00TEttingerso that's 73
02:48jeI 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.
02:48jehttps://gist.github.com/jacobemcken/04d264257718f2edea35
02:50jeAm I comparing dates wrong, or is the warning an error i ClojureScript
02:51mpenetjs is forgiving, clj(s) not so much
02:51mpenetcomparing nil and an Object for > is a bit weird
02:52mpenet you probably want to guard against the nil at least
02:53jempenet: it is the same for two js dates: https://gist.github.com/jacobemcken/04d264257718f2edea35
02:53piranhaje: js/Data :-)
02:54piranhabut that's strange, why would it give you a warning during compilation...
02:54mpenetthen maybe getTime on the date instances
02:54jepiranha: hehe thanks :)
02:54piranhahah, it gives me a warning as well
02:55piranhayeah, I was about to say that comparing two date objects is asking for trouble
02:55piranhaI don't think js compares them properly
02:55piranhaprobably it converts them to strings and then tries to compare :))
02:56mpenetthe call to getTime should make it long vs long
02:56mpenethopefully
02:57piranhayeah, unless it's null :)
02:57piranhabtw, just checked - JS seems to compare date objects just fine (i.e. feels like real comparison, and not through toString)
02:59jepiranha: Indeed it does, that is why I don't get why ClojureScript can't do it as well
02:59piranhaje: 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 :)
03:00jewell ClojureScript can it just "complains" about it :)
03:00mpenetwell, the js behavior is just weird
03:00mpenetit's neither > or < or = against null, its ... I dont' know what
03:00mpenetalways returns false
03:01jepiranha: perhaps... how would know if it is intentionally or something that has been overlooked?
03:02je*how = who
03:02piranhaDavid Nolen I would say :)
03:02piranhaand 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
03:04ttasteriscoearly? it's only midnight in the west coast :)
03:05jehehe
03:07piranhattasterisco: well, it's already 31 of July there for 4 minutes, so technically it can be described "early" :-)
03:11ttasteriscoyes, it's pretty early, the night's still a child
03:12mindbender1I'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?
03:15Xorlevmindbender1: Not a Clojure guy, but it looks to me like you have an asm lib conflict.
03:15XorlevProbably between ASM3 and ASM4
03:17mindbender1Xorlev: Where can I check for that?
03:18hiredmanmindbender1: are you building against master?
03:18hiredmanmaybe run mvn clean and try again
03:20Xorlevmindbender1: If that doesn't work, the maven dependency tree plugin
03:20mindbender1Both master and previous tags report the errors. I'm trying mvn clean && mvn -e install now.
03:21hiredmanXorlev: if you look at the class name it is clojure.asm.*
03:21hiredmanwhich is the version of asm bundled with clojure
03:22hiredmanmindbender1: the error is very odd, so it seems likely you have some kind of old or stale partial build state or something
03:22mindbender1hiredman: mvn clean helps. It's compiling now.
03:23mindbender1Xorlev: hiredman: Thanks
04:05Bosky101what am i missing here? http://pastebin.com/Ar2n44gp
04:06Bosky101(trying to fwd arguments from 1 fund to another )
05:07robothorBosky101: I suspect you really want to apply in "foo" when forwarding to "foo*"
05:32erdoshello, 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)
05:33erdosis 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.
05:33tickingIs there an error printed on the console?
05:34erdoswow, there is an error printed. i was only listening to the return value.
05:34ticking`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
05:34erdosticking, ok, i see, but does the return value have any meaning then?
05:34tickingsince the last test succeeds it will return true
05:35tickingthere are cases where the return value of do is useful, but in this case it seems not
05:37erdosok, thanks
05:40erdosan 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)
05:40mbacis there a clojure web framework that's uses continuation passing style like weblocks?
05:41scottjmbac: no popular ones afaik
05:41mbacd'oh
05:54blunteWhat is the best way to get a list of all methods that work on a particular class? Like clojure.lang.PersistentHashMap
05:57opqdonutblunte: something like (map str (.getMethods (class the-thing)))
05:57blunteI'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
05:58opqdonutblunte: or just (map str (.getMethods clojure.lang.PersistentHashMap)) if you know the class already
05:58opqdonutblunte: somemap is probably not a map but a sequence of maps
05:58opqdonutobserve:
05:58opqdonut,(keys [{:a 1}])
05:58clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.util.Map$Entry>
05:58blunteoh you're right
05:58opqdonutkeys loops through the thing it gets and extracts the key
05:59opqdonutso the error message is an artefact of the implementation
05:59blunteopqdonut: thanks!
06:12eskatremHey, I can't use org.bson.types.ObjectId for the mongodb driver
06:13eskatremWhat 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
06:14TEttingereskatrem, lein doesn't know what packages are where
06:16TEttingereskatrem, you have [com.novemberain/monger "2.0.0"] in project.clj ?
06:16eskatremTEttinger doing it now
06:16eskatremTEttinger: yeah in fact I have it
06:16TEttingerhm
06:17eskatremHere's what lein tells me:
06:17eskatremCould not find artifact org.bson.types:org.bson.types:jar:jar in central (http://repo1.maven.org/maven2/)
06:18eskatrembasically 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
06:19TEttingerright, well org.bson.types is a package, not a lein project
06:20TEttingerit is probably provided by monger, but might need a driver for mongo
06:20TEttingerso take out org.bson.types from project.clj deps... and it's possible you're not constructing the objectID how it expects
06:21eskatremyeah, I just took it out, but the code to that uses ObjectId crashes
06:21eskatremthat's my imports:
06:21eskatrem(:import [com.mongodb MongoOptions ServerAddress ]
06:21eskatrem [org.bson.types ObjectId])
06:22eskatremI can use mongo from clojure just fine, just I can't access to the _id field
06:44AWizzArdeskatrem: what happens when you try it? How do you try it (minimal example)?
06:44eskatremAWizzArd: I'm trying to build the minimal example actually
06:45AWizzArdDid you try something like (:_id db-entry) or (:_ID db-entry) and such?
06:45eskatremsomehow 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)
06:46eskatremyeah I tried with (:_id db-entry) but it doesn't match to the _id from my field
06:46AWizzArdis it :_id or :_Id or :_ID ?
06:47eskatrem(basically clojure is not able to know that {_id: 123} is {_id: ObjectId(123)})
06:47AWizzArdor maybe (get entry "_id") or "_Id" or "_ID"
06:47eskatremI did it with _id
06:49eskatremI'll try with (get entry "_id")
06:49eskatremactually
06:49eskatremthe real problem is for an update
06:50eskatremthe line that is not working is: (mc/update db coll {:_id _id} {:$set {lang-keyword message}} {:upsert true})
06:56mbacis there an idiom for printfing sequences?
06:56mbacmost of the time i end up with clojure.lang.LazySeq@45101e88
06:56Glenjamin,(prn (range 10))
06:56clojurebot(0 1 2 3 4 ...)\n
06:56Glenjaminoh, rptinf
06:57eskatrem,(apply println (range 10))
06:57clojurebot0 1 2 3 4 5 6 7 8 9\n
06:57Glenjamin,(format "%s" (prn-str (range 10))
06:57clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
06:58mbacsure, but then i need to know the tree of whatever it is i'm trying to print out
06:58Glenjamin,(format "%s" (prn-str (range 10))) ; this, i guess
06:58clojurebot"(0 1 2 3 4 ...)\n"
06:58mbacwhich i don't. that's why i'm trying to print it :)
06:58Glenjamineither use prn instead of printf, or prn-str before passing to prinf i think
06:59mbacsweet!
06:59hyPiRionpr-str instead of prn-str if you want to avoid the newlines
06:59AWizzArdpr-str
06:59Glenjaminoh right, whoops
07:01ro_stthheller: ping
07:02visofhello
07:04eskatremAWizzArd: now that's strange, (mc/find-maps db coll {:_id "53d79d8f3943fede9c1c63a2" } ) works just fine
07:06visofi'm using ring, i got error for POST request the details are here https://www.refheap.com/88762
07:06visofcan anybody help
07:09ro_stvisof: is "hello, world" a valid json value?
07:09ro_sti bet (json/generate-string "hello, world") fails
07:09visofro i just observed this and i fixed it
07:09visofthanks man
07:13visofhey (json/generate-string "hello, world")
07:13visof"\"hello, world\""
07:17Xackis there anyway to directly insert javascript in a clojurescript file?
07:18eskatremI don't know much about clojurescript, but can you call from clojurescript the javascript eval and dump your code here? (prize of elegance)
07:19eskatremXack: ^
07:19Xackah, thanks eskatrem :)
07:20eskatremXack: 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
07:21thhellerXack: it is possible, but there rarely is a reason to do it
07:21Xackeskatrem: 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 :)
07:21thhellerbetter to just write javascript in javascript and then use it from cljs
07:21thhellerinterop is so easy
07:30Xackit works :)
07:49winkanyone ever heard of a js minifier written in clojure?
07:55visofdefresource return fn object
07:55visofhow can i deal with it?
07:56clgvvisof: what?
07:59visofclgv: https://www.refheap.com/88764 check this?
08:00clgvvisof: where is defresource from?
08:01visofclgv: [liberator.core :refer [defresource resource request-method-in]])
08:01nathan7wink: no, but why would you need one?
08:01nathan7wink: you could use Google Closure from Clojure just fine
08:01winknathan7: someone mentioned it, but didnt remember the name. and I couldn't quickly google it.
08:03clgvwink: maybe a ring middleware?
08:03Glenjamindieter
08:03Glenjaminperhaps?
08:05clgvvisof: are you sure that you are supposed to call a resource like that?
08:05visofclgv: what do you mean?
08:05clgvvisof: well there is certainly documentation for it
08:11mbacwhat's the idiom for filtering non-nil stuff out of a seq
08:11mbaci'm writing this (filter (fn [x] (not (nil? x))) seq)
08:11mbacer, for filtering nil stuff out of a seq
08:11clgvmbac: do you use "map" before the filtering? then you can simply switch to "keep"
08:12swimbac: (complement nil?)
08:12llasrammbac: (remove nil? s)
08:12llasramOr in 1.6+ (filter some? s)
08:19mbachmm, keep wins i thik
08:26jinks_wink: this one? https://github.com/yogthos/asset-minifier
08:29winkjinks_: I don't know. but thanks, will have a look!
08:32mindbender1Is there a standard way to convert a MapEntry to a map of itself?
08:32mindbender1[:a "foo"] => {:a "foo'} for example.
08:33clgv,(into {} (first {:a :b}))
08:33clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword>
08:33verma,(into {} [[:a :b]])
08:33clojurebot{:a :b}
08:34nathan7,(apply hash-map [:a :b])
08:34clojurebot{:a :b}
08:34vermanice
08:34clgvyeah better use apply+hash-map
08:34verma,(apply hash-map [:a :b :c :d])
08:34clojurebot{:c :d, :a :b}
08:34verma,(apply hash-map [:a :b :c :d :e])
08:34clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No value supplied for key: :e>
08:34nathan7I spent a while thinking about that before realising "wait, so basically the same as pasting it into {}… wait…"
08:35mindbender1Alright. Thanks.
08:54clgv,(mapv (partial apply hash-map) {:a 1 :b 2})
08:54clojurebot[{:b 2} {:a 1}]
09:07mpenet,(conj {:a 1} [:b 2])
09:07clojurebot{:b 2, :a 1}
09:23Venerm, I wonder what's the difference between repeat and constantly
09:23clgvVen: constantly creates a function that constantly returns the given value
09:23swiHello. what difference between rest and next functions ? i dont' get it
09:24clgvVen: "repeat" creates a sequence with the given length that contains only the given element
09:24clgv,((juxt rest next) [a])
09:24clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0:0)>
09:24clgv,((juxt rest next) [1])
09:24clojurebot[() nil]
09:25Venclgv: so `constantly` is like `fn []` ?
09:25Venor is it used like a "let over lambda" kind of thing ?
09:26justin_smithVen: (fn [& _] :foo)
09:26justin_smithtakes zero or more arguments, returns value
09:27Venjustin_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))`
09:27justin_smith,(take 5 (repeatedly (constantly (rand-int))))
09:27clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core/rand-int>
09:27justin_smith,(take 5 (repeatedly (constantly (rand-int 5))))
09:27clojurebot(0 0 0 0 0)
09:28justin_smithVen: 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
09:29swiclgv: 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 ?
09:30clgv,(source constantly)
09:30clojurebot#<SecurityException java.lang.SecurityException: denied>
09:30clgv$source constantly
09:30clgv:/
09:30clgvVen: it creates a function and returns it
09:30clgv,(type (constantly 5))
09:30clojurebotclojure.core$constantly$fn__4085
09:31clgv,(type (repeat 10 5))
09:31clojurebotclojure.lang.LazySeq
09:37clgv,(mapv sequential? [nil []])
09:37clojurebot[false true]
09:38clgvswi: nil is not sequential whereas an empty vector/sequence is
09:39swiclgv: 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?
09:39clgv,(rest [])
09:39clojurebot()
09:40justin_smith,(take 10 (iterate rest []))
09:40clojurebot([] () () () () ...)
09:40swigot it :)
09:40swiclgv: justin_smith thanks :)
09:40clgvswi: yeah, you'll have to ask for empty?
09:40Venclgv: thanks too :)
09:44visofhttps://www.refheap.com/88767 i can't use post
09:44visofcan anybody help me in this?
09:46justin_smithvisof: if you want to accept post, why do you only declare GET ?
09:46visofjustin_smith: https://www.refheap.com/88768
09:46visofi fixed it, i don't get anything though
09:47clgvvisof: "(slurp body)" looks pretty strange
09:47justin_smithare you sure you need to slurp?
09:47justin_smithring should just give you the body
09:47visofjustin_smith: so i need to remove slurp?
09:48justin_smithyeah, just use the body directly
09:48visofjustin_smith: okay i'm trying
09:49justin_smithalso, even if the body was an input stream, slurp would not be the right way to consume it
09:49visofjustin_smith: i got this error https://www.refheap.com/88769
09:49justin_smithyeah, you want to get the string from the HttpInput
09:50visofso how can i do this?
09:50drbobbeatyvisof: justin_smith: ... don't mean to butt in, but you need the 'slurp' to convert the body.
09:50justin_smithusually I use a middleware that does that for me
09:50justin_smithdrbobbeaty: really?
09:51visofjustin_smith: can you give me simple Example for how middleware do this?
09:51justin_smithOK, sorry, I guess I am so dependent on my habitual middleware that I didn't realize
09:51drbobbeatyHere's what I've done - and it works: (POST "/blah" [:as {body :body}] (let [lst (json/parse-string (slurp body))] ...
09:52drbobbeatywhere the 'json' namespace is the cheshire library.
09:52justin_smithvisof: https://github.com/ring-clojure/ring-json wrap-json-params is what I use
09:52sveriHi, 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
09:54boxedsveri: I thought partial use was sort of the point ^_-
09:54blunteI 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
09:55blunteIs there a standard way of populating a record from a hashmap (where the keys are specified, not just a list of values)?
09:55justin_smith,(slurp (-> "hello" .getBytes java.io.ByteArrayInputStream.))
09:55clojurebot"hello"
09:56justin_smithblunte: map->Foo is generated automatically when you define a record Foo
09:57visofdrbobbeaty: that's my code based on what you told https://www.refheap.com/88770 and i got nothing
09:57visofshouldn't i got the json again on the browser?
09:57drbobbeatyvisof: let me have a look-see...
09:57visofokay
09:58bluntejustin_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.
09:59justin_smithblunte: someone called seq on the hash-map
09:59justin_smithyou can either use (into [] s) to make it a hash-map again, or make it not get turned into a seq
09:59justin_smithsorry, (into {} s)
10:00bluntejustin_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:00bluntejustin_smith: (doall (map #(apply create-rec (into {} %)) recs)) ; where create-rec is the function map->Foo
10:00justin_smith,(into {} ([:a 0] [:b 1]))
10:00clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Key must be integer>
10:00drbobbeatyvisof: 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:01justin_smith,(into {} '([:a 0] [:b 1]))
10:01clojurebot{:a 0, :b 1}
10:01drbobbeatyvisof: I'm preparing a Gist for you of exactly what I do...
10:02justin_smithblunte: apply is calling seq on the map
10:02justin_smith,(apply identity {:a 0 :b 1})
10:02clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core/identity>
10:02blunteOhh
10:02justin_smithso you likely don't need into, just don't use apply
10:03bluntejustin_smith: Yeah, what I receive from jdbc looks like ({:key1 val1, :key2 val2} {:key1 ... :key2 ...})
10:03blunteI was just trying to iterate over all elements and stuff them into records
10:04justin_smithso yeah, you don't need apply, just (doall (map map->Foo ...))
10:04bluntejustin_smith: ahh, that makes some sense. Thanks much
10:05clgvplease don't (doall (map ...)) just use (mapv ...) ;)
10:07blunteok
10:08drbobbeatyvisof: Have a look at this: https://gist.github.com/drbobbeaty/e580eba3e13a799b91c1
10:08blunteclgv: why is a vector preferred to a sequence?
10:08bluntefor output
10:08drbobbeatyvisof: It has several useful functions to return JSON and codes, etc.
10:09drbobbeatyvisof: I got a lot of help from gfredericks on this...
10:10clgvblunte: it's not the vector. why do you want to explicitely construct a lazy sequence that you immediately force to evaluate?
10:10clgvblunte: in your case just use the eager "mapv" instead of the lazy "map"
10:11blunteclgv: 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:11justin_smithclgv: 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:11clgvblunte: because you accepted the doall+map suggestion :P
10:12clgvjustin_smith: the (transient) vector construction is much faster than what doall+map offers you ;)
10:13clgvjustin_smith: yeah exactly that is the reason you should process it there, but still "mapv" is preferable then
10:13justin_smithclgv: the vector construction can't be faster than a doall on a map - it calls map eagerly internally
10:13clgvblunte: no not necessarily. I'd only use lazy where it fits
10:13justin_smithand using a vector sequentially is not faster than using a realized lazy-seq
10:15clgvjustin_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:16hyPiRionclgv: It's unchunked vs. chunked essentially.
10:17clgvhyPiRion: I guess database results are not chunked, right?
10:17clojurebotTitim gan éirí ort.
10:18hyPiRionclgv: 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:18clgvhyPiRion: ah ok^^
10:19clgvhyPiRion: you'd agree to prefer "(mapv f coll)" over "(doall (map f coll))" in general?
10:20hyPiRionclgv: If that's the last time you're going to map over the collection, yes
10:21clgvhyPiRion: what is the reason for the restriction?
10:21clgvmapping over anything seqable shouldnt make a difference, right?
10:24bluntewhy convert a lazy sequence into something fully realized, then back to another lazy one
10:24bluntethat's my guess
10:24hyPiRionclgv: If you really need performance and want to do multiple mappings on a seq, better use reducers.
10:24hyPiRionavoid the intermediate seqs.
10:25clgvblunte: because you need to force it anyway - so why not use the fast and syntax-wise lightweight approach?
10:25blunteclgv: 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:25clgvhyPiRion: ah ok right. I was only considering "map" vs "mapv" here ;)
10:26hyPiRionclgv: right, then I'd go mapv all day
10:26clgvblunte: as far as I observed it, "mapv" was introduced as better version of "doall+map" ;)
10:26hyPiRion(if you do a doall over it)
10:26blunteThanks for the advice. Brevity is a nice bonus too
10:37justin_smithblunte: you are right about mapv, mea culpa https://www.refheap.com/88773
10:38justin_smithI clearly underistimated the overhead on a lazy-seq (even a realized one)
10:39schmeeif I have a function (defn listener [socket running]
10:39schmee), how can I apply partial to the second argument, so I get function (defn L [socket])?
10:39joegallopartial doesn't do that
10:39joegallouse #(listener % second-arg-here)
10:39joegalloand you'll get the same net effect
10:39joegallomore or less
10:39schmeegah, of course!
10:40schmeethanks!
10:40joegalloanytime
10:40clgvblunte: that was me ;)
10:40clgvjustin_smith: try replacing the chunked (range 10) with (take 10 (iterate inc 0))
10:41blunteFancy!
10:41blunte:)
10:41clgvoops lol mean justin_smith: ^^
10:41clgv:P
10:41justin_smithclgv: oops
10:41justin_smithheh
10:41clgvcomplete reference confusion :D
10:50hugodIs 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:50gfrederickshugod: I doubt it
10:51hugodthe ns form can't be the output of a macro either :(
10:53gfredericksyeah I believe it's a lot more actually-declarative and less hackable than clojure's
10:54hugodI am trying to do plugin discovery of javascript components via clojure namespace enumeration
11:00hugods/javascript/om clojurescript/
11:10michaelr525hi
11:10michaelr525anyone works with liberator?
11:11michaelr525why post!ing a new item can't return a response? is it because of the HTTP standard?
11:12michaelr525according 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:12michaelr525so this works, but why this way?
11:19michaelr525ok, I think I should use handle-created
11:20michaelr525yeah
11:20michaelr525it works
11:20michaelr525thanks anyway :)
11:22FareI'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:22Farebut the very same thing used to work, and the namespaces look correct to me, so I'm baffled.
11:24Farehow do I inspect the MultiFn object?
11:25clgvFare: you might have forgotten to load a namespace that defines the corresponding method
11:25clgvFare: maybe due to changed :require statements in your ns-form
11:26Fare`(defmethod ...) shows the correct namespaces
11:26FareI grouped the :use and :require statements --- maybe that's the issue? But why does `(defmethod done? ...) show the apparently correct thing?
11:28Fareoh, maybe the class got overwritten after defining the method?
11:29Fareor something like that?
11:33clgvFare: redefinition of the class after the method definition is problematic, if it happened
11:34clgvdid you restart the repl to try whether it works then?
11:35Faresame
11:36clgvok. 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:37clgveach namespace containing defmethods that was removed is a problem
11:58Farecould my build be corrupted somehow?
11:58Farehow do I inspect a multifn ?
12:15clgvFare: maybe with that method https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/MultiFn.java#L577
12:18Bronsaclgv: Fare there's clojure.core/methods
12:18FareI'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:19Bronsathat's does what clgv linked, but as a function
12:19clgvFare: well you could use "git bisect" to find the commit that introduced the problematic changes
12:19Farealso works with a new record class
12:20FareI know which commit it is, but it has plenty of unrelated changes
12:20clgvyour best bet is that the method definition is not loaded.
12:21Bronsaor you have a redefinition of that record somewhere
12:21clgvcouldnt you just reevaluate the desired method definition?
12:21Fareclgv: doesn't look like it's working
12:21FareBronsa, not voluntarily, though there might be some symbol clash with namespaces, though I didn't seen any error or warning
12:22BronsaFare: does (= (class some-instance) the-record) return true?
12:22clgvFare: reevaluting the desired defmethod does not work? then something is seriously wrong since that should fix the class-redefinition issue
12:22BronsaFare: might also be a problem with mixing AOT code w/ JIT
12:22FareBronsa, yes
12:23Bronsano idea then
12:23FareBronsa, wait, no
12:23clojurebotexcusez-moi
12:23Farehow is that possible???
12:23Bronsa,(defrecord x [])
12:23clojurebotsandbox.x
12:23Farethe class has the same name
12:23Bronsa,(def a (x.))
12:23clojurebot#'sandbox/a
12:23Bronsa,(defrecord x [])
12:23clojurebotsandbox.x
12:24Bronsa,(= x (class a))
12:24clojurebotfalse
12:24BronsaFare: ^
12:24FareI don't get it
12:24BronsaFare: the second defrecord overwrites the first one
12:25BronsaFare: but a is an instance of the first record, not the second one
12:25Bronsaeven if the two records have the same class name, they are not the same class
12:26BronsaFare: if you don't have a redefinition of your record, you are probably AOT compiling the record somewhere, that messes things up
12:28FareI have no idea where my defrecord is somehow defined twice, though.
12:28FareBronsa, probably, though I have no idea how
12:32clgvFare: do you have namespaces with hyphens?
12:34clgvif 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:34clgvat least this was the case with Clojure 1.4.0
12:48Ro_Hello, is there a book/paper for functional scalable modular software creation
12:48Ro_?
12:48Ro_or similar
12:53jjwattRo_: 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:53jjwattall are great papers
12:54bbloom_jjwatt: those are all definitely great
12:54jjwattand not too specific
12:54bbloom_Ro_: or are you looking for more info about how to structure larger code bases in a functional language?
12:54jjwatthopefully
12:55Ro_bbloom, yes
12:55bbloom_Ro_: watch this: https://www.destroyallsoftware.com/talks/boundaries
12:55Ro_but I think both
12:55mdrogalisstuartsierra's Clojure in the Large talk was pretty good, Ro_.
12:56jjwattbbloom_: cool, i've never seen that
12:57Ro_Ok, I am going to see those. If you'll think something more, notify me. :)
12:57Ro_btw, thanks :)
12:57jjwattheh. there are a ton more. but hopefully, that's a good start.
12:58Ro_is there a list?
12:58jjwatti think there might be a list of papers on the clojure site somewhere.
12:59bbloom_jjwatt: are you thinking of the clojure bookshelf?
12:59bbloom_~bookshelf ; i hope
12:59clojurebotexcusez-moi
12:59jjwattnot a huge list, though. a lot of papers you just hear people refer to in their talks or books
12:59bbloom_clojurebot: bookshelf is http://www.amazon.com/Clojure-Bookshelf/lm/R3LG3ZBZS4GCTH
12:59clojurebotc'est bon!
13:00jjwattbbloom_: no, I meant papers specifically
13:00bbloom_do share if you find it
13:01jjwattlooks 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:02jjwattwhich reminds me, his bibliographies are a great place to find papers and books!
13:02Ro_I was right coming here and asking! :D
13:03jjwattoh, i found the papers list i was talking about. it's actually on github! https://github.com/papers-we-love/papers-we-love
13:04jjwattthere's a clojure section, funtional section, and a ton more
13:04jjwattwonder if that's in the bot.
13:05justin_smith~papers
13:05clojurebotIt's greek to me.
13:08TimMcmake it so
13:11jjwattclojurebot: papers is https://github.com/papers-we-love/papers-we-love
13:11clojurebotAck. Ack.
13:14timothywclojure.core.cache/through
13:15timothywoops… that was supposed to go in the search bar
13:25hoverbearIs there a library for Clojure to make OAuth HTTP requests?
13:26technomancydepending on what you need, this can be done in ~20 lines with clj-http and cheshire
13:26hoverbeartechnomancy: Perfect. I'll check those out
13:27technomancyhttps://github.com/technomancy/syme/blob/master/src/syme/web.clj#L21
13:34hoverbeartechnomancy: Thanks :)
13:37timothywI’m having some Clojure / Core.Async Dependency Issues (see https://groups.google.com/forum/#!topic/clojure/YYH6XUJ2PzE)
13:37timothywlooks 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:38timothywbut explicitly including org.clojure/core.cache didn’t work for me
13:38timothywanyone else seeing this?
13:40jjwatthaven't seen it; using core.async
13:42timothywthe current page (https://github.com/clojure/core.async/) recommends [org.clojure/clojure "1.6.0"]
13:42timothyw [org.clojure/core.async "0.1.303.0-886421-alpha"]
13:42timothywI’ve tried different permutations to no avail
13:42jjwattjust rebuilt this project on a server yesterday
13:43jjwattyeah, i'm using 1.6
13:43jjwatt[org.clojure/core.async "0.1.303.0-886421-alpha"]
13:43timothywand you’re good?
13:44timothyw… I even tried a clean .m2/repository
13:44jjwattyeah. hmm. I don't :refer :all
13:44jjwattnot sure if that makes a diff
13:44jjwattmaybe you wouldn't pull in some defs
13:45hiredmantimothyw: what version of lein?
13:45jjwatt [clojure.core.async :as a :refer
13:45jjwatt [chan go go-loop close! <!! <! >! >!!]]
13:45jjwatt
13:45timothywtried removing :refer :all - same error
13:45timothywLeiningen 2.3.4 on Java 1.7.0_55 OpenJDK 64-Bit Server VM
13:46hiredmanthere is an issue with certain versions of lein and some line plugins that causes that exception
13:46hiredmanwhat plugins are you using?
13:46hiredmanoh
13:46timothywumm… a bunch (in ~/.lein/profiles.clj)
13:47jjwatti'm only using cider-nrepl
13:47hiredmanlein deps :tree will print a list of depdencies and may print out warnings for things that stomping on the depdencies of other things
13:47hiredmantimothyw: commenting out all the plugins and see what happens
13:47timothywok, lemme try
13:49timothywnope. I tried commenting out all my plugins (below), but no dice.
13:49timothyw: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:50timothywlemme try disabling ~/.lein/profiles.clj
13:50hiredmanso run lein deps :tree and see what conflicting versions of core.cache are being required
13:52timothywok, I got it
13:52timothywdisabling ~/.lein/profiles.clj fixed the problem
13:52timothywso something in there is conflicting with core.cache
13:52xeqijjwatt: are you in the houston area?
13:53jjwattxeqi: no, in the south, though.
14:05jinks_is there a prettier/fancier way to express "(if (> p 10) 10 p)"?
14:06technomancymax
14:06technomancyerr
14:06technomancymin
14:07justin_smithand don't forget minimax http://en.wikipedia.org/wiki/Minimax
14:07amalloyminimax's big brother maxerrmin
14:07amalloythat actually sounds like a cool name. i wouldn't mind being named Max Errmin
14:07technomancyit's just a /nick away
14:08technomancyoh, except your karma is not transferrable
14:08amalloytechnomancy: i have access to the karma database though
14:08jinks_augh... could've thought of that. Looks like there's too much blood in my caffeine circulation :)
14:08technomancyamalloy: you wouldn't...
14:08amalloy$karma MaxErrmin
14:08lazybotMaxErrmin has karma 0.
14:08amalloyapparently i wouldn't
14:13Fareso the only change I made that could have messed AOT was adding a :main foo.core to the project.clj
14:13Farewould that explain why my defmethod didn't work anymore?
14:15amalloyFare: it's certainly suspicious, anyway
14:15amalloyAOT is just a vehicle for sadness
14:16mdrogalisShotgun!
14:20amalloyFare: probably lein clean would have had the same effect
14:20Fareamalloy: quite possible
14:20Fareamalloy: thanks for the tip
14:29amalloy&(class (hash-map))
14:29lazybot⇒ clojure.lang.PersistentArrayMap
14:29xeqi$karma MaxErrmin
14:29lazybotMaxErrmin has karma 1000.
14:29amalloyreeeeeally
14:30xeqiyearly reminder
14:30jinks_amalloy: must be _random_ database corruption...
14:30xeqithose cosmic rays
14:31aperiodicyou can't *disprove* it
14:32bbloom_hash-map is such a strange function name compared to the other data structure factory names
14:32Bronsabbloom_: well map was already taken
14:32amalloysrsly 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:33bbloom_Bronsa: and there's an alternative conflict with the name "assoc" if you wanted to call them "associations"
14:34amalloybbloom_: it seems consistent with the other datastructure factory names. hash-map, hash-set, array-map
14:34Bronsabbloom_: there's still dict though
14:34bbloom_amalloy: i would clarify, but i know you knew what i meant :-P
14:34bbloom_Bronsa: for some reason dict just seems wrong to me...
14:35bbloom_but i guess (map seq), (dict & keyvals), (assoc dict & keyvals) works out
14:36bbloom_barring my discomfort, that's probably a good solution
14:36bbloom_especially since my discomfort doesn't count for anything
14:40amalloy$karma MaxErrmin
14:40lazybotMaxErrmin has karma -1000.0.
14:40amalloyhaha a float. silly me
14:43expez(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:44expezvalidate throws an ExceptionInfo
14:44expezI had this in a (future ...) and I think this explains why it inexplicably dies, without printing any stacktrace
14:45mdrogalisexpez: Correct.
14:49expezmdrogalis: why does this happen?
14:50mdrogalisexpez: 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:51mdrogalisAt least, that was always my understanding. Can anyone confirm/disconfirm?
14:51mdrogalisEven when not using Emacs, stderr will be thrown out in a future if not caught. I dont know why on that one.
14:51mdrogalisI suppose because the thread just gets terminated if the exception bubbles all the way up. End of game.
14:52expezmdrogalis: 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:52justin_smithyou could wrap your future in a try/catch that logs
14:52justin_smithjynx
14:53mdrogalisYou're seeing a freeze? I would have expected that to log just fine.
14:53justin_smithunless you have a problem in your catch block maybe?
14:55expezyes, it appears to just die at the (validate ..)
14:55expezI added some logging just prior and after, and jus the line prior prints
14:55expezI'm using the default configuration for timbre, so this is all logging to console
15:08vdmit11Hi 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:11bbloom_vdmit11: the only thing that matters is the speed of your hash and equality functions
15:12bbloom_vdmit11: if you're storing immutable byte blobs for example, you can either pre-hash or lazy (ie caching) hash them
15:13bbloom_in that case, the size won't matter at all really
15:14justin_smithbbloom_: or give them a hash function that does not require reading the whole element
15:15celwellWould 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:16justin_smithcelwell: . is picked up on the reader level
15:16gtrak,(read-string "(x . y)")
15:16clojurebot(x . y)
15:16gtrakoh, huh
15:16justin_smithwait, maybe I am wrong...
15:16gtraknot what I expected to happen
15:17aperiodicisn't . just a special form and the other interop forms are macros that expand to .?
15:17gtrakin the first position yes
15:17gtrak,.
15:17clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: . in this context, compiling:(NO_SOURCE_PATH:0:0)>
15:17justin_smithahh, it is position dependent
15:17gtrak,do
15:17clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: do in this context, compiling:(NO_SOURCE_PATH:0:0)>
15:17justin_smith,(do (def . :hello) .)
15:17clojurebot:hello
15:18gtrak,`.
15:18clojurebot.
15:18gtrak,'`.
15:18clojurebot(quote .)
15:18xeqi,(second "(read-string "(x . y)")
15:18clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading string>
15:18xeqi,(second "(read-string "(x . y)"))
15:18clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading string>
15:18justin_smith,(do (def . :hello) (. . getName))
15:18clojurebot"hello"
15:18gtrakwhy isn't that namespaced?
15:18gtrak,`do
15:18clojurebotdo
15:18gtrak,`somesym
15:18clojurebotsandbox/somesym
15:19gtrakfunny
15:19justin_smithI still think binding . will have weird effects
15:19Bronsagtrak: special-symbols aren't namespaced
15:19Bronsaand ` doesn't namespace them
15:19justin_smithsince it is special in the first position, see my last clojurebot invocation
15:19Bronsawell except import*
15:20vdmit11bbloom_: tnx
15:20Bronsawich I just realized ` doesn't handle
15:33sveriHi, 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:35Bronsasveri: https://groups.google.com/d/msg/clojure-core-typed/ptVyTMmSHyQ/jN5jquozM2IJ
15:36sveriBronsa: ah, thats funny, just a few hours old this thread, thank you very much
15:47schmeeis it idiomatic to use `juxt` for side-effects (if you don't care about the returned array)?
15:47amalloyseems a little weird
15:48amalloyi'd write (doseq [f [a b]] (f x y z))
15:48gfrederickss/a b/g h/
15:48amalloybut ((juxt a b) x y z) is understandable too
15:49amalloygfredericks: 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:49gfredericksamalloy: I'll fight you.
15:49amalloybahaha
16:50eskatremSorry 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:51rlbeskatrem: one option -- http://leiningen.org/
16:51rlband then "lein new app my-app" followed by "cd my-app; lein run"
16:51justin_smitheskatrem: if you run "lein new", that will create something very close to a hello world clojure app
16:51rlbyou can see the core code in new/my_app/core.clj
16:51justin_smithor what rlb said
16:51rlbs/new/src/
16:52rlbi.e. src/my_app/core.clj
16:52eskatremthe 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:53rlbSo 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:54xeqirlb: how does it break them?
16:54rlbxeqi: it *seems* to be forgetting the session
16:56rlbi.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:57rlb(don't know for sure yet if it lost the session, or somehow cleared the user from the session)
16:57rlbbut the latter's unlikely
16:58rlbxeqi: if it helps, this was via lib-noir's app-handler :middleware setting.
16:58rlbi.e. :middleware [#(wrap-ssl-redirect % {:ssl-port ssl-port})]
16:58rlband there's also a
16:58rlb:access-rules [{:rule authorized-user? :on-fail redirect-to-login}]
16:59rlbsuppose I should strip down to a trivial application and make sure I can still reproduce it there
17:00xeqirlb: are you adding (follow-redirect) in between the requests?
17:00petrusthey 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:00rlbxeqi: not sure that matters -- it's redirecting to /login when I ask for /foo, which I assume means it forgot who you are?
17:01xeqirlb: I'm more thinking (request "/login" ...) is sending back a redirect due to wrap-ssl
17:01rlbbut no, in the current test case, I'm not
17:02rlbwell I can see that the login has succeeded (i.e. I print the response and it's at the normal post-login page)
17:02rlblet me double check that, though
17:13rlbxeqi: 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:15xeqiquack
17:26michaelr525sometimes cider returns just the first line of the stacktrace, it drives me crazy
17:26michaelr525good evening
17:27justin_smithmichaelr525: do you know about clojure.repl/pst ?
17:27danielcomptonmichaelr525: good morning
17:27justin_smith~ugt
17:27clojurebotugt is Universal Greeting Time: http://www.total-knowledge.com/~ilya/mips/ugt.html
17:29ben_vulpesi'd like to get .00001 instead of 1e-5 - what is my brain failing to figure out today?
17:29ben_vulpes,(/ 1 100000000)
17:29clojurebot1/100000000
17:29ben_vulpes,(/ 1 100000000.0)
17:29clojurebot1.0E-8
17:29justin_smith,(format "%f" 0.00001)
17:29clojurebot"0.000010"
17:29ben_vulpesjustin_smith to the rescue again
17:29ben_vulpesthanks boss
17:29justin_smithheh, np
17:31michaelr525justin_smith: what's clojure.repl/pst?
17:32justin_smith,(1)
17:32clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
17:32justin_smith,(clojure.repl/pst)
17:32clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to java.lang.Throwable>
17:32justin_smithoops
17:32justin_smith,(do (1) (clojure.repl/pst))
17:32clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
17:33justin_smithanyway, the repl keeps track of the last exception thrown, pst prints the stack trace for that exception
17:33ben_vulpesjustin_smith: any way to force format to return more decimals?
17:33gws,(format "%.20f" 0.0001)
17:33clojurebot"0.00010000000000000000"
17:33justin_smith,(format "%20.20f" 0.00001)
17:33clojurebot"0.00001000000000000000"
17:33justin_smithyeah, something like that
17:34justin_smithgws: I guess 20 is the magic number
17:34gwshaha guess so
17:34gwsi know it's not a telepathic connection with you otherwise i'd be a lot smarter
17:35justin_smithoh, pshaw
17:35michaelr525justin_smith: ok, sounds usefull.. :)
17:36michaelr525but why cut the stack trace in the first place
17:36michaelr525?
17:36ben_vulpes,(format "20.20%f" (/ 2 100000000.0))
17:36clojurebot"20.200.000000"
17:36amalloymichaelr525: because newcomers complain that stacktraces are scary
17:36ben_vulpesd'oh
17:37michaelr525amalloy: I pitty newcomers who try emacs+cider..
17:38michaelr525Looks like I use emacs all the time now, but I still kind of hate it :)
17:38ben_vulpesmichaelr525: one must learn emacs and lisp at the same time!
17:38justin_smithben_vulpes: the 20.20 means at least 20 wide, 20 points after the decimal point (kind of redundant, I was being sloppy)
17:38ben_vulpesfascinating, justin_smith, i have lots of javadoc reading backlog :(
17:38ben_vulpesthe formatter in particular is a great mystery to me
17:39ben_vulpeslearning java from clojure is a pretty hilarious experience
17:40justin_smithindeed
17:40justin_smith(that's how I learned java too)
17:41ben_vulpesjavadocs in emacs is p neat.
17:41amalloydoes cider hide the stacktrace by default? i thought it was just clojure's built-in repl
17:41ben_vulpesamalloy: 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:41amalloyben_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:42ben_vulpesamalloy: neat! thanks.
17:42ben_vulpesanother excuse to dabble in C.
17:42justin_smithamalloy: put a small ttl on any the cache for any answer to does cider [x]?
17:43amalloyjustin_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:43justin_smithlol
17:43amalloyhe was like "hang on i'll try getting the latest version of cider"
17:43justin_smitheven better
17:43amalloyme: man i would try getting a REALLY OLD version of cider
17:44amalloymy 2010 swank is still running like a dream
17:44ben_vulpessurely you want really really really fancy stack trace handling
17:44justin_smithputting it that way makes me imagine some old hoopty with air fresheners on the rear view
17:44amalloyben_vulpes: swank's is better!
17:44justin_smithduct tape on the glove box "still purrs like a kitten"
17:45andyf_When one runs "java -cp clojure.jar clojure.main", how is it that the function clojure.main/main is then called?
17:46justin_smithandyf_: I think it is related to the fact that fns are runnable / callable
17:46justin_smithand you are telling java to execute that method
17:46amalloyandyf_: the namespace clojure.main is gen-classed, and its main(String[] args) delegates to -main
17:46andyf_I mean, why clojure.main/main and not one of the other functions in that namespace?
17:47amalloyandyf_: actually, that was a lie
17:47amalloysrc/jvm/clojure/main.java
17:48amalloyrequires clojure.main, then calls clojure.main/main
17:49andyf_Thanks. The only .java file in that source directory, which I have probably never noticed before
17:50amalloyyeah, same here
17:50amalloybut it was the only explanation once clojure.main turned out not to be gen-classed like i expected
18:02jjwattcleaner way to say this? (reduce-kv (fn [i k v] (into i {k (if (nil? v) "unknown" v)})) {} {:ip_addr nil :id 1})
18:04justin_smithwhay not assoc instead of into?
18:05justin_smithalso, you could do ({nil "unknown"} v v) but that may be excessively clever
18:07jjwattoh 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:08jjwattis assoc more performant?
18:09justin_smithjjwatt: in that case maybe barely - since it does not need to create the hash map just to break it down again immediately
18:09jjwattthat's what I was thinking
18:09justin_smithbut regardless it avoids pointless nesting
18:10jjwattit could matter over millions of times, and yeah, avoiding the nesting is even more important.
18:11jjwattjustin_smith: looks a surprising amount nicer
18:11justin_smithcool
18:11Bronsauh weird, I'd have expected ((fnil assoc "unknown") {} :foo nil) to work
18:12justin_smithfnil looks at the first arg, right?
18:12BronsaI never realized fnil is positional
18:13justin_smith,((fnil + 0) nil 1)
18:13clojurebot1
18:13justin_smith,((fnil + 0) 1 nil)
18:13clojurebot#<NullPointerException java.lang.NullPointerException>
18:13eskatremwhat's fnil?
18:13justin_smithreplaces the first arg if nil
18:13justin_smithotherwise acts like the function provided
18:13Bronsa,((fnil + 0 0) 1 nil)
18:13clojurebot1
18:14justin_smithahh, fnil is varargs, of course :)
18:14justin_smithI should have expected that
18:14justin_smithso replaces Nth arg if Nth arg is nil
18:14Bronsayeah
18:15eskatremso (fnil+0 0) is equivalent to #(if (nil? %) 0 (+ 1 %)) ?
18:15justin_smith,((fnil assoc nil nil "unknown") {} :foo nil)
18:15clojurebot{:foo "unknown"}
18:15Bronsajustin_smith: uhm it's not vararg, only 1-to-3
18:15justin_smitheskatrem: you missed some spaces in there
18:15justin_smithBronsa: OK, that's weird
18:16eskatremjustin_smith: in my lambda?
18:16justin_smithin your fnil call
18:16eskatremsorry 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:17jjwattyeah, i had never seen it either
18:17eskatremoh yeah right, fnil + 0, not fnil+0, of course
18:17Bronsajustin_smith: it is, I have no idea why it isn't vararg
18:17clojurebotGabh mo leithscéal?
18:17justin_smitheskatrem: 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:17Bronsaseems like it shouldn't be hard to implement as such
18:17justin_smitheskatrem: otherwise it is +
18:18jjwattthat just prompted me to search for every fn with "nil" in the name hehe
18:18jjwattit looks like it's only the two
18:18eskatremjustin_smith: gotcha!!
18:18justin_smitheskatrem: but (fnil+0 0) is an invocation of the nonexistant fnil+0 function
18:18DomKMAnyone familiar with what ^not-native, ^clj, and ^clj-or-nil does in cljs?
18:19eskatremjustin_smith: yeah exactly, asef+0 is a legal variable name in clojure
18:20justin_smith,(let [?1+1=2 5] ?1+1=2)
18:20clojurebot5
18:20hyPiRion,(let [  10] )
18:20clojurebot10
18:20hyPiRionthose variable names.
18:21jjwattjustin_smith: so, can you use fnil to do the reduce-kv I was doing?
18:21bbloom_hyPiRion: what is that? a non-breaking space or something?
18:21jjwattseems like you would need an apply. probably uglier.
18:21vermacan I memoize a function defined inside deftype (and implementing a protocol)?
18:21justin_smith,((fnil assoc nil nil "unknown") {} :foo nil) eskatrem: yeah but it's ugly I think
18:21clojurebot{:foo "unknown"}
18:21hyPiRionbbloom_: yeah, just a nsbp which incidentally is a legal clojure variable name
18:22hyPiRionand, java for that matter.
18:22Bronsajustin_smith: http://sprunge.us/NFjC?clj
18:22bbloom_hyPiRion: 'puters
18:22bbloom_how do they work?
18:23cbpo man fnil has gotta be one of the least used functions
18:23jjwattif you press the buttons the right way for long enough, money comes out
18:23justin_smithBronsa: looks about right at first glance, nice
18:23cbphmm or at least i had forgotten about it
18:23bbloom_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:24Bronsabbloom_: me too, I think think I only used fnil for update-in
18:24justin_smithbbloom_: (fnil inc 0) is a good one too
18:24bbloom_ah, yes, i call that one zinc :-)
18:37rlbxeqi: ok, so smaller example -- with this, the session is clobbered for the second per/request: https://www.refheap.com/f951cfb67b36c8eb477c08af3
18:38rlband 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:39rlbof course it may still be something we're doing wrong, so I'll need to narrow further
18:43Bronsajustin_smith: http://dev.clojure.org/jira/browse/CLJ-1486
18:43justin_smithnice
18:44ahoenigmannadded the paredit package but forward slurp isnt working
18:44ahoenigmannC-<right arrow>
18:44ahoenigmannor C-)
18:45ahoenigmanngot this on emacs startup:
18:45ahoenigmann /.emacs.d/elpa/paredit-22/paredit.el at Thu Jul 31 15:34:11 2014
18:45ahoenigmannIn paredit-kill-region:
18:45ahoenigmannparedit.el:1650:4:Warning: kill-region called with 3 arguments, but accepts
18:45ahoenigmann only 2
18:45ahoenigmannIn paredit-recentre-on-sexp:
18:45ahoenigmannparedit.el:1765:37:Warning: `goto-line' used from Lisp code
18:45ahoenigmannThat command is designed for interactive use only
18:47jjwattBronsa: awesome
18:47justin_smithahoenigmann: just to double check, you are doing c-<right arrow> while inside the parens that should be slurping?
18:47ahoenigmannyes
18:47ahoenigmannim on mac
18:47jjwatttype C-h k
18:47ahoenigmannwith meta mapped to alt key
18:47jjwattand then hit right arrow
18:47ahoenigmannokay
18:47jjwattand see what emacs tells you. er, I mean C-<right arrow>
18:48jjwattC-h k C-<right>
18:48ahoenigmannsays Describe key (or click or menu item):
18:48ahoenigmannin mini buffer
18:48jjwattmine's always messed up in urxvt
18:48jjwattand tmux
18:48jjwattyeah hit c-right there
18:48Jaooddo you guys invert cmd and option for emacs on osx_
18:48Jaood?
18:48ahoenigmanndoesnt do anything just like in the buffer thats in paredit-mode
18:49justin_smithahoenigmann: so emacs is not receiving the C-<right> keystroke
18:49ahoenigmannto install I just put paredit in list of packages, then i did M-x paredit-mode after emacs startup
18:49ahoenigmannok
18:49justin_smithcheck your os / desktop key bindings, you may need to change one that steals that one
18:49technomancyahoenigmann: many keystrokes are impossible to represent with terminal keycodes
18:49ahoenigmannsucks
18:49technomancysince ctrl and meta are represented as bitmasks on normal keycodes
18:50technomancyit does
18:50ahoenigmannso i have to use emacs outside the terminal, seems so wrong
18:50jjwattthere's some blargs or w/e if you google around for paredit and iterm
18:50technomancyahoenigmann: not at all; just pick new bindings
18:50jjwattor term or whatever it's called on macs
18:50justin_smithbut if you use a windowed emacs it can do fancy things like inline svg!
18:50ahoenigmanniterm fixes this?
18:51jjwattahoenigmann: when i'm too lazy or stuborn to change my bindings, I just M-x paredit-slurp-sexp
18:51Jaooditerm lets you control modifiers keys
18:51jjwattevery key in emacs is a command
18:53Jaoodthe nice thing about vim is that key bindings do not interfere with the world ;)
18:53justin_smithJaood: dunno, last time I used it it interfered with my vi muscle memory
19:07xeqirlb: and this works w/o wrap-ssl?
19:08rlbsorry, no -- that was a red herring
19:09rlbit 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:10xeqirlb: 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:11rlbxeqi: ok -- thanks -- I'll keep poking around -- see if I can isolate the problem better.
19:12xeqiis it possible to print the response state out and the next request to see if the cookies make it across correctly?
19:14justin_smithrlb: 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:03ben_vulpesdoes 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:07gwsyou get UTC if you don't specify a tz
21:08ben_vulpesgotcha
21:18gozalacan someone please help me figure out why do I get this error ?
21:18gozalahttps://gist.github.com/Gozala/fc26deeabac7e05e42c6
21:20timsggozala: try making it state#?
21:21DomKMgozala: also diff#
21:21timsggozala: and model#
21:21timsgthough I guess you don’t use it
21:22amalloywell, he probably wants the field to be publicly visible and named state, not state__1234__auto__5678
21:22amalloyoh, but that's just the method param
21:34xeqihas anyone put together a list of design pattenrs for clojure?
21:35justin_smithxeqi: many of us agree with stuart halloway http://thinkrelevance.com/blog/2007/05/17/design-patterns-are-code-smells
21:35xeqijustin_smith: but yet things like "middleware" still exist
21:36xeqifwiw I agree w/ respect to many of the gof patterns
21:36justin_smithit'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:36xeqicat theory based patterns... maybe
21:37brehautif 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:38brehauteven the gof book has patterns that it basically says ‘this is what we do in C++ but in smalltalk its just a block'
21:38justin_smithbrehaut: that's a good point
21:38john2xI like this comment in the article: "Design patterns are programming language smell."
21:39justin_smithbrehaut: 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:39brehauti 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:40brehautexplaining 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:40justin_smithyeah, we can reify patterns into functions or syntax quite trivially, but it is still useful to document
21:41brehautright
21:41xeqiI'm a fan of naming things makes it easier to communicate them
21:41justin_smithso instead of "which pattern to use here?" we can end up with "should I use an agent or a go block for this"
21:43brehautxeqi: totally agreed
21:47brehautjustin_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:47brehauts/behavioural/implementational/?
21:47xeqibrehaut: do you have an example of the later?
21:47brehautxeqi: strategy is a poor mans first class function
21:52xeqiah right, looking up the gof book and it has creational / structural / behavioural
21:52xeqibeen awhile since I've leafed through it
21:53brehautthe nuts and bolts of the book have mostly aged into irrelevance
21:53brehautbut the discussion around it is still quite intereseting i think
22:28LukePaulI 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:28bbloom_empty? is already defined for records...
22:28bbloom_,(defrecord EmptyRecord [])
22:29clojurebotsandbox.EmptyRecord
22:29bbloom_,(empty? (EmptyRecord.))
22:29clojurebottrue
22:29bbloom_,(empty? (assoc (EmptyRecord.) :x 1))
22:29clojurebotfalse
22:29bbloom_but generally, records with fields can't be empty:
22:29bbloom_,(defrecord Foo [x])
22:29clojurebotsandbox.Foo
22:29bbloom_,(Foo. 1)
22:29clojurebot#sandbox.Foo{:x 1}
22:29bbloom_,(dissoc (Foo. 1) :x) ; note: no longer a Foo
22:29clojurebot{}
22:34LukePaulMy 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:35bbloom_that seems unwise
22:36bbloom_(doc empty?)
22:36clojurebot"([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:36bbloom_your use doesn't seem to match that doc string
22:36bbloom_if you want a map-like thing, you (preferably just use a map or) use defrecord
22:36bbloom_alternatively, you can make custom data structures with deftype
22:36bbloom_but in this case, it sounds like you just want to define a function of your own
22:37justin_smithLukePaul: sounds more like .available than empty?
22:48LukePaulThanks, 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:54kelseygii wrote this function so i could use it in a ->> : https://www.refheap.com/88784
22:55kelseygiis there a simpler/more idiomatic way to do that?
22:55justin_smith(identity coll) is coll
22:55justin_smithand defn contains an implicit do
22:56justin_smith(defn log-size [coll] (log/debug (str "filtering " (count coll) " items")) coll)
23:01kelseygioh duh
23:01kelseygithanks!
23:01kelseygithere isn't like a "run" with side effects that returns what's passed in?
23:01justin_smithdoto
23:02justin_smithbut that goes by first arg, not last
23:02justin_smithotherwise I would have suggested it :)
23:02justin_smith,(doto 1 println)
23:02clojurebot1\n1
23:02kelseygiah ok! that'd work with -> then
23:02justin_smithyeah
23:02justin_smitheven works with more args...
23:03justin_smith,(doto 1 (println "is the loneliest number..."))
23:03clojurebot1 is the loneliest number...\n1
23:03justin_smithvery similar to -> actually
23:03justin_smithsomeone should make otod, for ->> forms
23:04justin_smithor maybe dotoo, to follow the -> to ->> transformation
23:11oskarkvHm ""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:14justin_smithI see nothing wrong there (except for that dirty naughty mutation)
23:18oskarkvOh, now I see it, in the next function. :P
23:20oskarkvThanks for taking a look justin_smith
23:21justin_smithnp
23:44ben_vulpesthe funniest part about cider is how " Error compiling:
23:44ben_vulpes /Users/mrfox/repos/van/api/test/van/handler_test.clj:368:17"
23:44ben_vulpesis not linked to the source
23:45justin_smithwow, in emacs that is really low hanging fruit
23:45justin_smithcompilation mode alreayd has all the code to parse that file / line / char info