#clojure logs

2015-10-09

01:28elgI'm getting "my.namespace.MyRecord cannot be cast to java.util.concurrent.Future" but only in tests. It seems, maybe, to be because my record methods are using the @ reader macro for the atom state?
01:34justin_smithelg: yes, "cannot be cast to future" is almost always because the wrong thing has @ in front of it
01:34justin_smith,@\?
01:34clojurebot#error {\n :cause "java.lang.Character cannot be cast to java.util.concurrent.Future"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Character cannot be cast to java.util.concurrent.Future"\n :at [clojure.core$deref_future invokeStatic "core.clj" 2187]}]\n :trace\n [[clojure.core$deref_future invokeStatic "core.clj" 2187]\n [clojure.core$deref invokeStatic "core.clj" 2209...
01:35elghm. well the @ is in the right place - this works as it should when I use the code, it only breaks in this test
01:35justin_smiththen your test should be providing something that can be dereffed?
01:36justin_smithelg: a favorite trick of mine is providing a delay where the code expects a future or atom, because it can be dereffed, but can't do much
01:36justin_smith(which reduces confusion)
01:36justin_smiththis is all in testing contexts, of course
01:39elgah-hah. It's my mock that doesn't have an atom but should
01:39justin_smithor a delay!
02:19skoudeNoob question, clj-http.client get function return ring map.. The problem is that how can I get just for example print what's inside the :body ? I tried like (println (json :body)) and (println (get json :body)) but none of these works..
02:36justin_smithskoude: what is "json"
02:37justin_smithtry (type json)
02:37justin_smithif it's a hash-map like you think, check the values of (keys json)
02:40skoudejustin_smith: it's: clojure.lang.PersistentArrayMap
02:40justin_smithOK, so what are the keys?
02:41skoudejustin_smith: their: (:orig-content-encoding :trace-redirects :request-time :status :headers :body)
02:41justin_smithOK, then (:body json), or (json :body) (I prefer the former) will show you exactly what is there
02:42justin_smithmaybe the body is empty / nil ?
02:42skoudejustin_smith: no the body is not empty.. I I write the whole Map to file, I see that there is some json data,..
02:43skoudemaybe I ave some sort ot typo.. I will double checkk
02:43skoudebtw.. Have been programming java like 15 years.. and started to lear this yesterday.. Seems like very powerfull language.. It just takes time to learn the syntax :)
02:44justin_smiththe syntax may be unfamiliar, but it is very simple actually - far less complex than most languages
02:45skoudeyeap, I noticed that.. just need to get used to it..
02:49skoudeanother stupid question.. If I do like: (filecore/write-to-file "jsonoutput.js" json) the whole map is written to file..
02:49skoudebut if I do like: (filecore/write-to-file "jsonoutput.js" (:body json)) the object name is just wirtten to file.. D
02:50justin_smithI don't get that at all.
02:50justin_smithperhaps you shadow the object?
02:50skoudeIn the first one the whole data in the map is written to file with all the json and all the keys
02:51skoudebut in the second one I get: clojure.lang.LazySeq@b823df75
02:51skoudethat is written to file
02:52justin_smithOK, that's because lazy-seqs print oddly, use pr-str
02:52justin_smithpr-str is different from the normal toString in that it tries to print the form that can be read again
02:53justin_smith,(str (map inc range))
02:53clojurebot#error {\n :cause "Don't know how to create ISeq from: clojure.core$range"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: clojure.core$range"\n :at [clojure.lang.RT seqFrom "RT.java" 535]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 535]\n [clojure.lang.RT seq "RT.java" 516]\n [clojure.core$seq__4116 invokeStatic "core.clj" 137]\n [cl...
02:53justin_smith,(str (map inc (range)))
02:53clojurebot#error {\n :cause "Java heap space"\n :via\n [{:type java.lang.OutOfMemoryError\n :message "Java heap space"\n :at [clojure.lang.Iterate next "Iterate.java" 54]}]\n :trace\n [[clojure.lang.Iterate next "Iterate.java" 54]\n [clojure.lang.ASeq more "ASeq.java" 131]\n [clojure.lang.RT more "RT.java" 690]\n [clojure.core$rest__4102 invokeStatic "core.clj" 73]\n [clojure.core$map$fn__4541 invok...
02:53justin_smithergh, never mind, I forget how to make that happen now
02:53justin_smith,(str (map inc (range 10)))
02:53clojurebot"clojure.lang.LazySeq@c5d38b66"
02:53justin_smith,(pr-str (map inc (range 10)))
02:53clojurebot"(1 2 3 4 5 ...)"
02:54justin_smiththere we go, see the difference
02:54skoudejustin_smith: Thanks, I will try that one out :)
02:54justin_smithpr-str has other advantages too:
02:54justin_smith,((juxt str pr-str) {:a "hello" :b 'hello})
02:54clojurebot["{:a \"hello\", :b hello}" "{:a \"hello\", :b hello}"]
02:55justin_smithoops
02:55justin_smith,(map print ((juxt str pr-str) {:a "hello" :b 'hello}))
02:55clojurebot({:a "hello", :b hello}{:a "hello", :b hello}nil nil)
02:55justin_smithI swear there's a case where you see a difference
02:55justin_smithaha!
02:55justin_smith,(map print ((juxt identity pr-str) {:a "hello" :b 'hello}))
02:55clojurebot({:a hello, :b hello}{:a "hello", :b hello}nil nil)
02:56justin_smiththere's the difference
02:57skoudejustin_smith: brilliant, it worked like a charm :) No I will parse the json..
02:58skoudebtw. I noticed that println is taking away the " from json, is there a way to preserve those when printing to console?
02:58justin_smithskoude: that's what I was trying to show above
02:58justin_smithyou can use pr-str to surround the value, or you can use prn instead of println
02:58skoudejustin_smith: aah, okay I see :)
03:07skoudeIs there a javadoc equivalent for clojure?
03:07skoudeor any same kind of mechanism that would automatically generate the documentation from code?
03:16TEttingerskoude: there's a literate programming doc generator that's somewhat popular
03:16TEttingerunder Documentation Tools at http://www.clojure-toolbox.com/
03:17TEttingerseveral are listed
03:18skoudeTEttinger: thanks, I will check that out
03:18TEttingerthe literate programming one I was thinking of was https://github.com/gdeer81/marginalia
03:18TEttingerI think Codox is more commonly used
04:00skoudehmm.. I really don't get this,. (def jsonbody (str(:body json)))
04:00skoudeit says that: java.lang.String cannot be cast to clojure.lang.IFn
04:01skoudeI try to assing the :body part of the json -map to jsonbody..
04:01SeyleriusThere isn't a clojure equivalent of pelican/octopress, is there?
04:02mavbozoSeylerius, cryogen? http://cryogenweb.org/
04:03Seyleriusmavbozo: That looks suspiciously like just what I asked for. Thank you.
04:04ianhedoesitskoude: is that the exact code that gives that exact error?
04:10kungimagnars: In your Parens of the Dead videos you narrow the file to only show functions which call the function you are refactoring. How did you do that in emacs?
04:12magnarskungi: it's my symbol-focus mode, found here: sed -i "s/return res/module.exit_json(**res)/g" /usr/local/lib/python2.7/dist-packages/ansible/modules/core/packaging/os/yum.py
04:12magnarsack
04:12magnarshere: https://github.com/magnars/.emacs.d/blob/master/site-lisp/symbol-focus.el
04:16kungimagnars: When are you going to release the next video? :-) I want to know more about games and zombies :-)
04:16kungimagnars: And thank you!
04:16magnars:) I got lazy at some point, but planning to get it done this weekend.
04:20kungimagnars: Lazy tsts :-)
04:29SeyleriusNext question: is there an org parser for clojure?
04:30SeyleriusHmm... This seems promising.
04:30Seyleriushttps://github.com/gmorpheme/organum
05:34skoudeianhedoesit: thanks, I got it working..
05:34schmirI've got a byte[] containing an excel sheet that I like to send back via a ring response to the users browser
05:35schmirI get a "java.lang.RuntimeException: class [B is not understandable" from httpkit
05:35schmiranyone know how to send back the data?
05:38skoudeif I decode json string withj parse-string: (def json3 ( parse-string jsonbody));
05:38skoudethe json3 type is string.. Should that be map?
05:38lumaschmir, create a ByteArrayInputStream from the byte[] and use that as the response body
05:39luma(java.io.ByteArrayInputStream. bytes)
05:40schmirluma: that works. Many thanks.
09:20mkrI want to do a native app project and am considering Reagent. My friend is pushing for pure react-native as we don't have much experience with Reagent.
09:21mkrI want to know whether Reagent can be used for both android and ios development
09:21mkrI have seen examples on ios
09:21mkrbut can't find much help on Android
09:21mkrsomeone tried android development?
09:25mkrI guess everyone's busy with their own lives.. thanks :)
09:47snowellmkr: You might have more luck over in #clojurescript
09:47justin_smithalso, not leaving after four minutes
09:47snowellYeah, I have part messages off. That also would have helped
10:57gfredericksanybody know the explanation for this off the top of their head?
10:57gfredericks,(-> [-128] byte-array String. .getBytes seq)
10:57clojurebot(-17 -65 -67)
10:57gfredericksI'm not saying it should do anything different, just don't know what's at play exactly
10:57gfredericksin terms of encodings
11:08dstockton,(-> [-128] byte-array (String. "ISO-8859-1") .getBytes seq)
11:08clojurebot(-62 -128)
11:08dstockton,(-> [-128] byte-array (String. "ISO-8859-1") (.getBytes "ISO-8859-1") seq)
11:08clojurebot(-128)
11:08dstocktongfredericks: does that help?
11:10gfredericksdstockton: well I'm not trying to achieve a different output
11:11gfredericksjust trying to explain the one I have
11:11gfrederickshave been reading some docs and I think it might be undefined behavior, as I think [-128] is not a valid UTF-8 bytesequence?
11:12dstocktonnope and that's probably the default charset of your system
11:13gfredericksright, it is according to (System/getProperty "file.encoding")
11:13gfredericksso I think that's a good enough explanation: not all byte sequences are valid UTF-8, and GIGO
12:06{blake}Given a list of items, this sums the number of truthy values: (reduce (fn[acc i] (if i (inc acc) acc)) 0 a-list)
12:06{blake}I feel like there might be a more elegant way to do that.
12:06justin_smith{blake}: (count (remove nil? a-list))
12:08justin_smith(apply + (map #(get {nil 0} % 1) a-list))
12:08justin_smiththat last one is silly
12:09{blake}Heh...I like that first one! Is there a "remove falsey?" or would I need a function?
12:10justin_smith(keep identity ...)
12:10justin_smithI thought you were just taking out nil
12:10{blake}summing truthys
12:10justin_smith,(keep identity [true nil false :a "" ()])
12:10clojurebot(true false :a "" ())
12:10justin_smithoh, not keep!
12:10justin_smith,(filter identity [true nil false :a "" ()])
12:10clojurebot(true :a "" ())
12:11justin_smithkeep is also nil-specific
12:11{blake}Int'resting.
12:12{blake}There is false? though.
12:12{blake}It's a good example of why you should pick one or the other in a given structure.
13:16nzstHi, is http://www.luminusweb.net/ the only game in town for web frameworks?
13:16justin_smith~framework
13:16clojurebotframework is a library obsessed with its own abstractions
13:16justin_smithnzst: I was hoping for a more helpful factoid from clojurebot, but anyway, in clojure for better or worse, frameworks are not very popular
13:17justin_smiththat said, pretty much everyone doing web dev with clojure is building on ring (including luminus)
13:17justin_smithsee also liberator, pedastel, immutant
13:18nzstthank you :)
13:50hoppfullHello. I hear calling clojure from java or .net, the preffered way is to use the method where pass a string with the name of the clojure script rather than compiling clojure with (:gen-class). This was a little hard for me to swallow at first but I figure I my instincts might be wrong.
13:50justin_smiththe string is the argument used to look up a defined var, right?
13:51hoppfullIsn't it a little unsafe to call clojure functions with strings? And perhaps not very efficient. Or is my assumption that we need to call clojure from java or c# wrong?
13:51hoppfulljustin_smith: I think so.
13:51justin_smithhoppfull: specifically which method are you supplying a string to?
13:51hoppfulljustin_smith: give me a sec and I'll get it
13:54hoppfullLet's see: in the clr we do IFn myfunc = clojure.clr.api.Clojure.var("myclojurefile", "myfunc")
13:54justin_smithright, that's a var lookup
13:54hoppfullAnd then I think we call that function with myfunc.invoke("5"); for example
13:54justin_smithhoppfull: that's weird
13:55justin_smithunless the function expects a string?
13:55hoppfulljustin_smith: I originally recoiled at this when I heard this was common practice.
13:55justin_smithbecause clojure functions don't take strings and eval them
13:55justin_smithit's not just a bad idea, it isn't even how clojure works
13:55justin_smithclojure uses the native data types of its host
13:56justin_smithwe can explicitly parse strings, but most of our functions are not doing that
13:56justin_smithhoppfull: the string arg to var isn't dangerous, it's a lookup in a hash-map, if the wrong string is compiled
13:56hoppfulljustin_smith: maybe I've got something wrong. Because I insisted on compiling clojure with (:gen-class) and in the REPL (compile 'myclojurefile)
13:56justin_smithyou don't need to call compile
13:56justin_smithhmm...
13:56hoppfullBut it was so messy that I was sure I was doing it the wrong way.
13:57justin_smithso, the Clojure.var call looks up a var in a namespace - it will fail if the namespace is not already loaded
13:57hoppfullI've played a lot with clojure for the jvm a while back. And I really liked Clojure. Now I am studying .Net in school and I want to play with Clojure again. Except I am going to stick to .Net.
13:58justin_smithusually the first thing you would do is use var to look up require and symbol, and use those to construct and invoke the require call that compiles and loads your code
13:58justin_smithvar gets string args and looks them up, but otherwise you should be able to use the functions that var returns with the actual data type that function uses
13:58hoppfulljustin_smith: But this is safe?
13:58justin_smithin fact you should be required to do so
13:59justin_smithhoppfull: no safer or less safe than using another compiler
13:59justin_smithrequire / compile will both invoke the compiler
14:00justin_smithclojure on the jvm or clr does not have a runtime without a built in compiler
14:00hoppfulljustin_smith: Thanks for the help. I am going to play around a little with this and see if I can get over my anxiety. ; )
14:01hoppfullWait, what do you mean by "built in compiler"?
14:01justin_smithhoppfull: clojure supports aot compilation, but the compiler will still be loaded at runtime
14:01justin_smithhoppfull: clojure is a compiler
14:01hoppfullRight, I've heard this. Doesn't that make it a little slow?
14:01justin_smithit's not an interpreter running a script, it's a compiler generating byte-code that can be run by clojure itself or host code
14:02hoppfulljustin_smith: And doesn't that provide us with the same issues as python? If we don't compile it, how can we protect our source code?
14:02justin_smithit's slow in the sense that if you compile at runtime, you have to wait for the compilation - but that shouldn't be your bottleneck
14:02justin_smithhoppfull: python compiles?
14:03hoppfulljustin_smith: No. Not unless you use cython. Which is a problem if you want to distribute your application.
14:03justin_smithhoppfull: most clojure folks don't protect their source code, but then again most of us are not shipping client desktop apps
14:03hoppfulljustin_smith: How could you ever distribute an application in clojure?
14:03justin_smithhoppfull: but you can aot compile, and you can ship bytecode without source, it's just not done very often
14:03justin_smithhoppfull: I wouldn't
14:03justin_smithor at least, I have not yet
14:03justin_smithI deploy to servers I control
14:04justin_smithand clients connect to that server
14:04hoppfullInteresting.
14:04justin_smithhoppfull: clojure isn't used much for app dev, but most code being shipped out there is not app code
14:04justin_smithmost code as in most code in all languages, not just clojure
14:06hoppfullI am a little speechless. I didn't know that one wouldn't care about this.
14:06justin_smithhoppfull: it hasn't come up because in all my experience coding I have never shipped an "app", only server side or browser based code
14:07justin_smithif I were shipping an app that had to be closed source, I would aot-compile and not ship the source
14:08hoppfulljustin_smith: Alright. Still, aot is a little messy. And it seems unnecessarily slow to me.
14:09justin_smithhoppfull: that slowness happens regardless - either at packaging time, or else the same work is done when the app starts up
14:09justin_smiththere's no free lunch, the stuff is compiled eventually no matter what
14:09hoppfulljustin_smith: But it's only at startup? I haven't made any large programs with clojure yet.
14:09justin_smithAot is only messy if you have side effects in the top level of your code. You shouldn't be doing that anyway.
14:10justin_smithhoppfull: sure, the time is either at build time or start up, but most apps start up multiple times for one build, so build time is the better time to do that job
14:11hoppfulljustin_smith: This has been interesting. Thanks for your insights!
14:12justin_smithnp
14:12justin_smithin my experience all the changes I need to make for aot to work are fixes of what I would consider bugs in the code (the code was taking some action at compile time that it should not be)
14:13justin_smitheg. (def conn (connect db-spec)) - that connects to the db at compile time, which is obviously a bad thing to be doing...
14:34sobeljustin_smith: heh, i had a similar exp fixinga lot of bugs just to make a nest of spring dependencies work (i was adding spring to a prj that was otherwise pure adhoc spaghetti-OO
14:34sobeli didn't realize they were all bugs due to order of creation issues
14:35sobelit was my 'object' lesson on not getting fancy with creation patterns
15:07justin_smithhehe, you said "object"
15:09taylanjustin_smith: compiling code actually executes the top-level?
15:10justin_smithtaylan: yes, which is why you should not have top level side effects
15:10taylanweird, would have expected the top-level to be executed at load time
15:10justin_smithtaylan: clojure's compiler only has one "mode", there is no separate "no side effects" mode available
15:11justin_smithin order to compile (def x (foo)), clojure executes foo
15:11taylanwell, a compiler should not be running any of the compiled code at all (not counting partial-evaluation optimizations), should it?..
15:11justin_smithtaylan: that's not true of clojure's compiler at all
15:11taylananyway, guess I'll need to get used to that. it's different from how I'm used to things from e.g. Elisp and Scheme
15:11justin_smithclojure's compiler doesn't do any optimization either
15:12justin_smithtaylan: it's a little weird, but it's actually very simple and consistent - only one set of rules to remember :)
15:12taylanin a way it also seems simpler though; in the past I found myself confusing library-compile-time from library-load-time in Scheme
15:12taylanheh, exactly
15:12justin_smithit's just that we are used to other compilers having two behaviors (the compile and load behaviors) and clojure only has the one
15:13taylanI didn't know of compilers having a load behavior at all to be honest
15:13Bronsataylan: clojure evaluation strategy during compilation is the same as it would be if you were runnig each form at the repl
15:13justin_smithtaylan: this is the root of why eg. stuartsierra/component is so popular
15:13taylanBronsa: and then it serializes the resulting process state?
15:13Bronsataylan: I think CL works this way too
15:13justin_smithtaylan: it offers the sort of deferred behaviors you might want, with very sane defaults and a lot of control
15:14Bronsataylan: no, a top-level is executed both at compile time and at load-time
15:14taylanoh...
15:14Bronsataylan: note that doing actual AOT compilation in clojure is not that common
15:15taylanI see
16:01sveriHi, how can I define a prismatic schema for "def"?
16:16sdegutisHow do you prefer to write CSS when you're doing a Reagent project? Do you use Garden?
16:18justin_smithsdegutis: best practice is to make someone else do all the CSS by pretending you don't understand it at all
16:19sdegutisIn my case it isn't pretending, my CSS skills are not the best. ;P
16:19sdegutisBut I'm the only guy, so I have to do it. I was hoping the scene had improved ever since those older days where everything was new?
16:20sdegutisI see Mesh now too..
16:25sdegutishttps://github.com/facjure/mesh
16:26justin_smithsdegutis: mesh looks interesting
16:26sdegutisI'm not sure I'd use it though because I've heard you should always roll your own responsive stuff.
16:29justin_smithsdegutis: is that the "build your own light saber" of the frontend world?
16:29sdegutisOh nice. Sick reference bro. Everyone knows your references are out of control.
16:30justin_smithsdegutis: I have some rare pepes too
16:35sdegutisAlso Gardener https://github.com/facjure/gardener
16:36noncom|2so, what's mesh
16:36sdegutisresponsive grid for clojure
16:36noncom|2responsive to what?
16:36sdegutisweb scale
16:36justin_smithnoncom|2: if you don't know what "responsive" is, just be happy, and you don't want any more information
16:36sobel(view scale)
16:37sobel(inc justin_smith)
16:37justin_smithnoncom|2: any more info will just torture your soul
16:37sdegutis(inc sobel)
16:37sobel,(inc justin_smith)
16:37clojurebot#error {\n :cause "Unable to resolve symbol: justin_smith in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: justin_smith in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol:...
16:37sobeloh well
16:37justin_smithsobel: the bot that does karma is on vacation
16:37noncom|2heh, when sdegutis said "web scale" i thought of something running multiple nodes, like distributed responsive system
16:38sdegutisyes, I was intentionally *ever so slightly* ambiguous
16:38sdegutisjust in case.
16:38justin_smithnoncom|2: if only, that would actually be interesting
16:38sobelport your front end to mongodb
16:38sdegutiswebsql
16:38sdegutisyou mean websql
16:39sobelthe original web scale joke i knew was around mongodb
16:39sdegutisoh yes very good
16:39justin_smithhelp, my web-server is mutating, and is now covered in web-scales, and its attacking innocent ops people in its web-tentacles and devouring them whole
16:39sdegutismy memes are out of date, my apologies
16:39sobelhehe
16:40sdegutisi only recently learned of kid at computer nodding head and giving thumbs up
16:40emdashcommaif you get behind enough on memes you will become up to date again
16:40emdashcommaeventually
16:40justin_smithsdegutis: new hotness: http://i.imgur.com/55feAT3.gif
16:40noncom|2overflow?
16:41sdegutisbtw i mean this guy http://www.reactiongifs.us/wp-content/uploads/2014/03/brent_rambo_still_approves.gif
16:42sdegutisbut younger
16:42sdegutisjustin_smith: oh wow keeper
16:43justin_smithsdegutis: proper usage "i m code monkey af rn <gif>"
16:43sdegutislol
17:09sdegutisjustin_smith: Do you usually call (d/create-database) at the beginning of every process, even though it usually returns false?
17:09justin_smithsdegutis: I haven't done much with datomic - I experimented but the project did not go far
17:09sdegutisok
17:13sobeli don't get what datomic offers over relational storage
17:14sdegutissobel: it is relational storage
17:15sdegutissobel: it's a middle-ground between sql and nosql in terms of flexibility
17:15sobelis it more than relational storage?
17:15sdegutissobel: it's a layer on top of relational storage
17:15sdegutissobel: an extremely handy convenience layer
17:15sobelpgsql alreadp gives some middle ground in that way but i understand i could run datomic on top of pg, among others
17:16sdegutiswriting datomic queries is really pleasant and easy compared to writing sql queries in my experience
17:16sobeli'm already really solid with sql
17:16sdegutissobel: and in datomic, queries run in your app, rather than in the database, and there's no blocking
17:17sobelwhat's the concurrency model?
17:35nefigcasHi!!
17:36nefigcasThere is anybody here??
17:36mungojellynefigcas: kinda
17:36nefigcas:D
17:36justin_smithsobel: it keeps a cached db, and until you need a new "state", it simply uses the immutable cached db state
17:38nefigcasI'm trying come code but it have an weird behavior, Its using Overtone OSC
17:39nefigcasI'm mapping(Using map) some code for handlers (kinda listeners)
17:39justin_smithnefigcas: you can go ahead and describe your problem, and if you stay logged in eventually someone is likely to help - if you need to share code or errors, put them on a site like refheap.com and share the link here
17:39xcvHave any of you guys been using Pulsar?
17:39nefigcasBut I'm almost shure the thing is not clojure but my understanding of it
17:40xcvLooks like an interesting library.
17:40nefigcasOK
17:40mungojellynefigcas: map is lazy so if you need the side effects you might want "run!" justin_smith taught me that recently :)
17:41nefigcasThat sounds like my problem, checking...
17:41nefigcas;)
17:43nefigcasdorun
17:43nefigcas??
17:43clojurebotCLABANGO!
17:43nefigcas:D
17:43justin_smithnefigcas: dorun can wrap map, but run! replaces map directly
17:43justin_smith,(doc run!)
17:44clojurebot"([proc coll]); Runs the supplied procedure (via reduce), for purposes of side effects, on successive items in the collection. Returns nil"
17:44justin_smith,(run! println (range 10))
17:44clojurebot0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n
17:46nefigcasCompilerException java.lang.RuntimeException: Unable to resolve symbol: run!
17:46nefigcas:(
17:47justin_smithnefigcas: need clojure 1.7 for that
17:47nefigcasOk, ok
17:47justin_smithforgot to mention. But clojure is really good about backward compat, you really don't have much reason not to upgrade.
17:47justin_smithor at least try
17:48nefigcasThanks!!
17:49nefigcasI was breaking my head with that ;), the code works in the REPL, the REPL is anti-lazy?
17:50justin_smithnefigcas: printing forces laziness - rePl
17:51rhg135mapv, but the overhead
17:51justin_smith,(do (map println ["hello" "world"]) nil) ; no print, no side effect, thanks to do/nil
17:51clojurebotnil
17:51justin_smithrhg135: which is why run! is great
17:52rhg135yeah, I mean on archaic versions
17:55rhg135usere refusing to upgrade has led to far too many sleepless nights
17:55rhg135users*
17:59rhg135or, (reduce #(do (f %2) %1) nil teh-coll)
17:59justin_smith,(source run!)
17:59clojurebotSource not found\n
17:59justin_smithrhg135: anyway, that's pretty much what run! is
18:00rhg135yup
18:00justin_smith(reduce #(proc %2) nil coll)
18:02rhg135run! always returns nil though
18:02justin_smith,(run! inc (range 10))
18:02clojurebotnil
18:03justin_smithrhg135: oh weird, in my older clojure 1.7, (where the source is as I pasted above), it returns the last item
18:04rhg135ah
18:17gfredericksisn't there a build tool (lein plugin?) for copying dependencies into your project & renaming its namespaces?
18:17gfredericksnot very easy to google
18:18justin_smithgfredericks: sounds like something you could hack together with slamhound...
18:18rhg135Sounds buggy
18:18gfredericksI've seen bizarre namespaces from such a tool in my deps before
18:18gfredericksso it *must* exist
18:19gfredericksI guess it's not a whole lot harder to fork and manually rename the namespaces myself, since it's a one-off
18:22justin_smithgfredericks: anyway, slamhound would probably make it easier to engulf, appropriate, and extend a victim project
18:23numbertenis there a core function that applies a function to each top level value in a map?
18:24rhg135is this not the packet managers job? but lein does package the project.clj
18:24rhg135map
18:24justin_smithnumberten: map
18:24numbertenmap turns each key-value to a pair right?
18:24numbertenand applies the function to the pair?
18:24rhg135yeah
18:24justin_smithnumberten: entries in maps are pairs
18:25justin_smithit doesn't "turn them into" anything
18:25numbertenI want something like: (my-map inc {:a 1 :b 2}) => {:a 2 :b 3}
18:25justin_smithspecifically they are two element vectors
18:25rhg135plumbing has map-val
18:26rhg135uses reduce
18:26numbertenyeah just seemed like it would be commonly used, so was curious if there was a core impl
18:26justin_smithyeah, there's also reduce-kv - laziness and hash-maps are like toothpaste and orange juice
18:26numbertenw/o me writing it with a reduce
18:28rhg135why does reduce-kv even excist?
18:28numberten(defn my-map [f m] (reduce-kv #(assoc %1 %2 (f %3)) {} m))
18:29numbertenthat's actually not bad at all
18:29rhg135destructuring
18:29justin_smithdestructuring?
18:29clojurebotdestructuring is http://clojure.org/special_forms#binding-forms
18:30justin_smithdestructuring???
18:30rhg135performance perhaps?
18:30amalloyreduce-kv exists because you can avoid allocating a bunch of [k v] pairs, compared to (reduce (fn [acc [k v]] ...) ...)
18:30rhg135thought so
18:33rhg135That sounds like a good optimiztion for t.a
18:39rhg135gfredericks: you could open the jar of a dep that does so and check if it is using a plugin
19:21sdegutisjustin_smith: huh, seems like I don't need component after all, considering all my components except one (web server) dont have start/stop because they're idempotent
19:22justin_smithwell, that's super nifty
19:22justin_smithnot even db connection?
19:22sdegutisright, datomic is idempotent
19:22justin_smithand no bugs from it trying to connect while building your uberjar?
19:22sdegutisit doesnt try to connect until you first access the database
19:22sdegutisat which point it opens up a long running connection
19:23justin_smithsweet
19:23sdegutisyeah this rocks
19:23sdegutistotally psyched
19:26sdegutisbbl
19:45justin_smith,(clojure.string/split "Wat" #"[ -_]")
19:45clojurebot["" "at"]
19:45justin_smith^^^
19:47justin_smith,(clojure.string/split "Wat" #"[ \-_]")
19:47clojurebot["Wat"]
19:48emdashcomma(let [u m8] (what? u))
20:04putaIn Hiccup how can I add a title option to a generated list of options? This doesn't work: (defn menu [title start end] (do [:option {:value ""} title] (for [i (range start end)] [:option i])))
20:05putaMore specifically, in function context. It's simple declaratively.
20:12nogdenIf I implement a protocol in (defrecord) should I be able to call other methods of the same protocol from within my implementation?
20:13rhg135yesish
20:14nogdenI keep getting an unresolved symbol error for the protocol function that I want to call.
20:15rhg135weird, since it's defined by (defprotocol ...)
20:15nogdenYeah, I figured I could just call it and pass on 'this' and I'd be golden.
20:17nogdenAh, bingo. You still have to require the individual methods rather than just the protocol.
20:18nogdenThanks, talking things through always helps ;-)
20:18rhg135oh, I assumed same ns
20:19nogdenFair assumption, I wasn't clear.
20:44WickedShellI'm experiencing a problem with lein that I can't seem to track down. lein repl and lein run both work but lein uberjar stalls and never seems to finish
20:45WickedShellAnyone ever experienced this before?
21:05mmitchellThinking about building a JS client lib for an API using cljs. Then I thought, maybe I could use the same code to build a js, cljs, clj, js AND java client with the same core. Would this be possible?
21:06mmitchellI'd imagine clj and java would use the same "http adapter", while the cljs and JS would use a JS version?
21:16amalloyWickedShell: you probably have some side effects at the top level of your namespace, like starting up a server, which never completes
21:17WickedShellamalloy, is there a technique for chasing those down? There's some go's etc that get spawned off, but that's always been happening, so I'm having trouble finding the change
21:17amalloythose shouldn't happen either
21:17amalloynothing should happen that isn't triggered by -main
21:19WickedShellHm... Well that raises the question of how I've been completing uberjar's in the past, but nicely puts to rest my suspicion that I should move where I spin up some of these go's etc
21:21amalloywell it's often harmless, but it's never good
21:26WickedShellwell that's why I had ignored it, but somehow breaking the jar building is awful :)
21:32rritochDoes clojurescript have it's own channel?
21:36sobelat least one
21:36WickedShellIs the ^:const metadata supported/worthwhile (for constants used in math functions)? I have a fairly tight inner loop that is extremely perfromance bound on my lower end target device
21:37sobelrritoch: but it's often a good start to try questions here
21:40rritochsobel: Ok, well I'm looking at cljs-bootstrap, but basically I'd like to bootstrap clojure scripts via AJAX. In a tomcat environment updating scripts/resources typically requires restarting the instance (souch as touching web.xml) which is a less than ideal development environment. Using AJAX I could create a web service which delivers the most up to date code.
21:41rritochsouch=such
21:41amalloyWickedShell: (def ^:const x (+ 1 1)) will evaluate (+ 1 1), getting 2, and then replace x with 2 every time x is used, as if you had typed 2 to begin with
21:42WickedShell(def ^:const x 256) (+ x foo) where foo is something passed in at runtime wont see any benefit then? (just to confirm)
21:42rritochI noted that cljs-bootstrap hasn't been updated in 2 months, and doesn't support macros. Is there some other project which is more capable?
21:50rritochIf not, is clojurescript modular, such as being able to deliver namespaces as seperate javascripts (main.cljs.js , draganddrop.cljs.js, etc). If that's possible than it seems I could compile server-side in real time to achieve a comparable effect.
21:51amalloyno
22:05heowany starving students need a place to crash at the philly conj, ping me
22:12rritochWould it be fair to say clojurescript is best suited for single page applications, since it isn't modular?
23:03WickedShellHas anyone here experimented with the skummet compilier at all? I tried swapping my project to it, but seem to be encountering compilation problems that I don't know how to solve at all. (they are occuring outside my code, and in a library somewhere) http://pastebin.com/etqa9u93 (this is with lein-skummet targeting the JVM with Java 8)
23:05amalloyyou don't have a namespace named pushback-stream?
23:05amalloyno, i guess not
23:07WickedShellNo I don't, its somewher in a library or core
23:08WickedShellThe exact same code was launching with lein repl before swapping to skummet
23:08SeyleriusWeird. I can't seem to get clj-barcode to load properly in the Gorilla REPL.
23:09Seyleriushttps://github.com/nmquirk/clj-barcode
23:10Seyleriushttps://clojars.org/clj-barcode
23:12amalloyskummet certainly doesn't promise to work with all valid clojure code. there is certainly some it can't handle. i don't know if that's the case you're running into
23:13WickedShellamalloy, I suspect that's the case, but thought I'd enquire if anyone had encountered it before. I just have one target device that performance is a real problem on. (Not really clojure's fault, its just weak hardware)
23:17Seyleriusamalloy: D'you have a minute to take a look at https://clojars.org/clj-barcode and see if you can get it to load into a REPL? I can't manage to make it go.
23:18SeyleriusI don't know why.
23:18SeyleriusAh, nevermind.
23:19SeyleriusFound it.
23:19SeyleriusNeeded clj-barcode.core, rather than clj-barcode.