#clojure logs

2012-08-27

00:58SgeoSo, is my unamb too dangerous to use due to possible uncollectable garbage creation?
00:58Sgeo(The creation of unstoppable infinite looping threads)
01:06wmealing_Sgeo: when you say it like that.. it sounds like an evil creation.. just saying
01:07wmealing_all that is missing is maniacal laughter
01:18gzmaskHey folks, I got a question about overtone: why the saw function in the tutorial has three parameters? I checked odoc and it only requires one. Code: https://github.com/overtone/overtone/blob/master/src/overtone/examples/getting_started/basic.clj#L9
01:53emezeskegzmask: That's one one parameter -- it's a vector of length three
01:53emezeskegzmask: From looking at that code, I'd guess that each entry in the vector will produce an additional saw wave
01:53emezeskegzmask: It's pretty common to stack multiple detuned saws to get a "fat" sound
02:09SgeoClojureScript doesn't have promises?
02:10wmealing_empty, empty promises
02:13emezeskeSgeo: Javascript is single threaded, so a lot of Clojure's concurrency primitives don't make much sense. Although I guess they could be implemented in some kind of async way.
02:14SgeoPromises strictly speaking don't need threading, although they might be not as useful without it
02:14SgeoAlthough, doesn't a lot of Javascript library stuff do things that take callbacks?
02:18SgeoHmm, might not be useful without threading even there
02:18emezeskeTons of callbacks, everywhere.
02:19emezeskeBut I don't know how you'd implement a promise in Javascript -- you can't really do coroutines like that, AFAIK
02:19emezeskeMaybe if there was a Thread/yield function or something that let the event loop run
02:21emezeskeBut, JS doesn't have a yield function. If it did, there could be a lot less callback soup
02:21SgeoIt's not a question of implemeting them, it's a question of using them usefully.
02:21SgeoA promise could be as simple as a mutable container that contains either no value or a value.
02:22Sgeodeliver sets the value if there is no value
02:22emezeskeI'm pretty sure that's not what a promise is in clojure.
02:23SgeoAlthough then what would deref do if there is no value... "blocking" would not be ... helpful
02:23emezeskeIt's totally pointless, you can't do that in JS
02:23Sgeoemezeske, hmm?
02:23Sgeo(The "hmm" as to "not what a promise is")
02:24emezeskeI was saying that a promise as just a "mutable container that contains eithe rno value or a value" is not what a promise is in Clojure
02:24emezeskeThe key feature of a promise in Clojure is that it "Calls to deref/@ prior to delivery will
02:24emezeskeblock"
02:24emezeskeWhich you can't do in JS, so it's pointless.
02:25SgeoHmm... I'm sure someone has written continuation stuff for Clojure, that should be portable to ClojureScript right?
02:27emezeskeThe closest thing I know of to continuation passing in Clojure is trampoline
02:28emezeskeWhich should work fine in ClojureScript
02:28amalloy$google clojure delimc
02:28lazybot[swannodette/delimc · GitHub] https://github.com/swannodette/delimc
02:30emezeskeNeato!
02:30amalloydo cljs atoms support watchers? if so you can build promise on top of that
02:30ibdknoxamalloy: yes
02:30emezeskeamalloy: How would that work?
02:31amalloyemezeske: actually, i think the thing i was thinking of uses promises to get blocking, so not really a viable implementation strategy for getting promises
02:31ibdknoxyou can't do it without code-rewriting
02:32emezeskeamalloy: Yeah, the blocking-until-available part is what kills promises for the JS target
02:32emezeskeamalloy: Even if you made deref just poll, you'd be tying up the only thread
02:32ibdknoxyou need a CPS transformer :)
02:32emezeskeibdknox: Yeah, it would have to turn your code into continuations behind the scenes
02:32ibdknoxthat's how the C# async stuff was done
02:32amalloyemezeske: presumably we've made an ajax call that's set to call something when it's completed? i don't do a lot of js, but i thought that's what people did?
02:33emezeskeamalloy: Yeah, but if you made that async ajax call and then, e.g. went into an infinite loop, you'd never get the result
02:33emezeskeamalloy: There's no preempting, nor yield
02:33amalloyfor what it's worth, i was thinking of https://github.com/flatland/useful/blob/develop/src/useful/state.clj#L53, which lets you block until a reference's value satisfies some condition: (wait-until evel? my-atom)
02:34amalloyeven?
02:35emezeskeSo desu
02:36emezeskeHey, it's meta-circular. Just use promises to implement themselves, QED.
02:37emezeskeIf only clojure was a native browser language...
02:37emezeskeOr really anything less stupid than JavaScript
02:38SgeoDart?
02:38tomojI think it shouldn't be too hard to port lamina's async macro to cljs
02:39tomojbut I feel like future seqs (better channels) are more important anyway
02:39emezeskeSgeo: Heh, NaCl running a java vm running clojure? Hell yeah.
02:39emezeskeYo dawg...
02:41Sgeo"Why is it so bad with many threads you might wonder. Well, first of all they are expensive, both in the JVM and on .NET."
02:41Sgeo:/
02:41SgeoHaskell has rather lightweight threading
02:42emezeskeJava threading may not be the lightest weight thing ever, but I think quite a few shops get by with ridiculous numbers of threads
02:43emezeskeAnyway, pooling often makes more sense anyway. Even greenlets have some overhead.
02:49nkkarthikIn lein2 project.clj, how can I include some jars in the lib folder?
02:51amalloy~repeataibility
02:51wmealing_i used lein-localrepo
02:51clojurebotTitim gan ?ir? ort.
02:51amalloy~repeatability
02:51clojurebotrepeatability is crucial for builds, see https://github.com/technomancy/leiningen/wiki/Repeatability
02:51wmealing_but i a agree with amalloy
02:51wmealing_you'll get less suck if you make it work.. ie publish your jars
02:52amalloydon't agree with me, that's technomancy's article. i mean, i basically agree with it, but even if you disagree you should read: iirc it includes workarounds, as well as an explanation of why you shouldn't use them
02:55SgeoWorkarounds?
02:55nkkarthikwmealing_, amalloy... thank you... so there is only the holy approach
02:56SgeoI take it things like Smalltalk and certain Common Lisp implementations are poisonous?
02:56wmealing_Sgeo: localrepo,
02:57Sgeoiirc SBCL was forked from CMU CL in order to have a cleaner build process
02:57wmealing_is it easy to run your own .. clojars ?
02:57nkkarthikwhat's the harm in quickly testing out a jar?
02:58nkkarthikwhy have a repl then... repl is neither used in build or production
03:00nkkarthikI think, tool should allow good practices not mandate them with one holy approach
03:00nkkarthikbut I might be wrong
03:00nkkarthikanyways thank you guys... and sorry if I have said something wrong out of ignorance
03:01nkkarthikI will look at the localrepo
03:09emezeskenkkarthik: I gather that :extra-classpath-dirs was something of a pain from a support perspective /speculation
03:11nkkarthikemezeske: oh... you mean for lein developers or extra-classpath-dirs users?
03:12devn,(require '[clojure.pprint :as pp])
03:12clojurebotnil
03:12emezeskenkkarthik: For developers.
03:12emezeskePure speculation on my part, though.
03:13nkkarthikemezeske: oh ok
03:13devn(with-out-str (pp/with-pprint-dispatch pp/code-dispatch (pp/pprint (read-string "(let [f (^:once fn* [x] x)] [(f 1) (f 2)])")))
03:14devn,(with-out-str (pp/with-pprint-dispatch pp/code-dispatch (pp/pprint (read-string "(let [f (^:once fn* [x] x)] [(f 1) (f 2)])")))
03:14clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
03:14devn,(with-out-str (pp/with-pprint-dispatch pp/code-dispatch (pp/pprint (read-string "(let [f (^:once fn* [x] x)] [(f 1) (f 2)])"))))
03:14SgeoWhy are macros not allowed in the sandbox?
03:14clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol>
03:14nkkarthikemezeske: thank you... I will try out something else then
03:14hyPiRionSgeo: Macros are allowed, but defs aren't
03:14Sgeo&(defmacr sg-macro [])
03:14lazybotjava.lang.RuntimeException: Unable to resolve symbol: defmacr in this context
03:14Sgeo&(defmacro sg-macro [])
03:14lazybotjava.lang.SecurityException: You tripped the alarm! def is bad!
03:14hyPiRionafaik
03:14SgeoOh
03:15devncan anyone help me figure out the above mystery
03:15devnIs it complaining about the (^:once...)
03:15hyPiRion,(with-out-str (pp/with-pprint-dispatch pp/code-dispatch (pp/pprint (read-string "(let [f (fn* [x] x)] [(f 1) (f 2)])"))))
03:15clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol>
03:15Sgeo
03:15hyPiRiondoesn't look like it.
03:16devnthe use of fn* is weird
03:16hyPiRiondevn: oh, blimey
03:17devn,(fn* [x] (+ x 1))
03:17clojurebot#<sandbox$eval135$fn__136 sandbox$eval135$fn__136@695d9f0>
03:17devn,((fn* [x] (+ x 1)) 100)
03:17clojurebot101
03:17hyPiRion,(with-out-str (pp/with-pprint-dispatch pp/code-dispatch (pp/pprint (read-string "(let [f (^:once fn* ([x] x))] [(f 1) (f 2)])"))))
03:17clojurebot"(let [f (fn* ([x] x))] [(f 1) (f 2)])\n"
03:17SgeoWhat's fn*?
03:17devnhyPiRion: except!
03:17devnthe former is valid clojure
03:18hyPiRionyeah, I noticed.
03:18devn,(let [f (^:once fn* [x] x)] [(f 1) (f 2)])
03:18clojurebot[1 2]
03:18hyPiRion,(let [f (^:once fn* [x] x)] (mapv f [1 2]))
03:18clojurebot[1 2]
03:18devn:(
03:18noidi,(doc fn*)
03:18clojurebotExcuse me?
03:19devn,(use 'clojure.repl)
03:19clojurebotnil
03:19devn,(doc fn*)
03:19clojurebotNo entiendo
03:19hyPiRion$source fn*
03:19lazybotSource not found.
03:19devnfn* is internal
03:19devnbut obviously not that internal
03:20hyPiRionIt's in the clojure/java transition area, isn't it?
03:20devntransition area?
03:20devn(yes if you mean what i think you mean)
03:21hyPiRionthe area where clojure fns are written in java
03:21hyPiRionor converted/parsed
03:21amalloy&(macroexpand-1 '(fn [x] x))
03:21lazybot⇒ (fn* ([x] x))
03:21amalloyfn* forms are always generated with the wrapped parens, so pprint probably relies on that. if you're creating fn* forms yourself, you probably shouldn't be
03:22amalloyoh, except that the lazy-seq macro generates the thing you pasted?
03:22devnamalloy: *nod* I think so
03:22amalloyit does. i don't really use pprint much, so i'm not bothered or surprised that it's broken
03:23devnamalloy: im not bothered or surprised either, but i figure it was worth asking
03:23devnwell, let me elaborate
03:23devni was surprised, but after talking it out I'm not bother, nor do I think it is generally surprising
03:24devnbothered*
03:27devnamalloy: thanks for the help
03:27devnamalloy: clojure/conj this year?
03:28amalloynot planning on it
03:28devn:(
03:30magopianman kodowa is recruiting
03:30magopianthat is just so awesome
04:00SgeoHow careful do I have to be to avoid accidentally rebinding functions?
04:00SgeoI know Lisp-2 proponents say things like they like not having to name variables lst, but what if you do in Clojure name a variable list?
04:00SgeoIn a local binding, I mean?
04:01hyPiRionSgeo: it's not a problem
04:01hyPiRion,(let [list '[a-list of elements]] (println list))
04:01clojurebot[a-list of elements]
04:02hyPiRion,(let [f (fn [a] (let [list [1 2 3]] (a list)))] (f list))
04:02clojurebot([1 2 3])
04:02SgeoHmm. Suppose a macro expands into some code that uses list, and you've rebound list like that?
04:02SgeoAnd use the macro from within there?
04:03hyPiRionUse gensyms if that's a problem
04:03amalloySgeo: then the macro is badly written
04:03Sgeo...for using the list function?
04:03amalloy&`(list 1 2 3)
04:03lazybot⇒ (clojure.core/list 1 2 3)
04:03hyPiRionOh, right
04:03hyPiRionthey are namespaced, so it shouldn't be a problem
04:03hyPiRionunless you go full retard with ##`(,'list 1 2 3) it should be okay
04:03lazybot⇒ ((quote clojure.core/list) 1 2 3)
04:04hyPiRion,`(~'list 1 2 3)
04:04clojurebot(list 1 2 3)
04:04hyPiRioni mean.
04:05Chousukeusually hygiene isn't a problem with clojure macros
04:05Sgeo&(let [list '(1 2 3)] (namespace 'list))
04:05lazybot⇒ nil
04:05Sgeo(namespace 'list)
04:05Sgeo&(namespace 'list)
04:05lazybot⇒ nil
04:07Chousukeit's difficult to screw things up so that you get hidden misbehaviour
04:08hyPiRionChousuke: Well, yeah, as long as you know about gensyms, you should be fine
04:08Chousukeyou don't even need gensyms, though they make things easier.
04:08hyPiRionOh, you do.
04:08SgeoUh. I think writing macros without knowing gensyms is probably a recipe for failure.
04:08Chousukeoh, wait, yeah. I was thinking of autogensyms
04:09hyPiRionWell, autogensyms are just syntactic sugar. But it's very clean though.
04:10Chousukeit's a good feature. no point in leaving it out :)
04:11hyPiRionClojure itself seems like the royal bathroom if you compare it to common lisp.
04:12SgeoThere are some things in Common Lisp I like. The ability to rename namespaces, the condition system
04:12ChousukeThe best feature Clojure has is all the features together. :P
04:12Chousukenone of them alone is anything earth-shattering but the way Clojure combines everything just works nicely.
04:13SgeoAnd then protocols get thrown in the mix in a non-interchangeable way with multimethods
04:14Chousukehow could they be interchangeable?
04:14Chousukebesides both creating functions as the interface.
04:14SgeoWell, protocols could be built on top of multimethods in a clear way.
04:15Chousukeno they couldn't.
04:15Chousukethey wouldn't perform well enough
04:15tomoj:D
04:15Chousukethe whole point of having protocols in addition to multimethods is performance :P
05:40nz-what is the home row?
05:42hughfdjacksonasdfjkl;
05:42hughfdjacksonnz-: isn't it those keys on your keyboard? ^
05:43hughfdjacksonasdf on your left hand, jkl; on your right; where your fingers should (in theory) rest
05:43hughfdjackson:3 or am i wildly off the mark here?
05:43magopianhughfdjackson: i would have answered nearly the exact same
05:43magopiannz-: the "home row" is the middle row, the one which has two keys with "bumps" on them
05:44magopianthose keys are where the index of both your hands should 'rest'
05:44nz-goofed with irc history, somebody answered already
06:00SgeoIs Clojure arithmatic really supposed to take 1/10th of a second?
06:00SgeoClojure> (time (* 1 1))
06:00Sgeo"Elapsed time: 103.083431 msecs"
06:01Sgeo(On tryclj.com )
06:01magopian$(time -
06:01magopian$(time (* 1 1))
06:02magopiana(time (* 1 1))
06:02magopian&(time (* 1 1))
06:02lazybot⇒ "Elapsed time: 221.855607 msecs" 1
06:02magopian&(time (* 1 1))
06:02lazybot⇒ "Elapsed time: 225.222137 msecs" 1
06:02magopianmmmm
06:02magopianthat looks long indeed
06:02magopianmaybe the repl is fired up each time?
06:07algernonprobably some sandbox.
06:08algernonit's 0.025 locally (clojure 1.3)
06:22RaynesSgeo: tryclojure and lazybot are completely worthless for benchmarking. The sandbox adds code and such.
06:22Raynesmagopian: ^
06:49magopianRaynes: thanks a lot for the information ;)
07:28SgeoIs it possible for the same jar to have two different versions of a library?
07:28SgeoSay, if my code uses library A which relies on X version 1 and library B which relies on X version 2
07:32ScorchinI'm trying to write a crawler that will check that all links on pages for a given domain (e.g. mysite.com) are valid (return status 200 OK). I have an idea of what I'd like to achieve, but I'm not sure how to make it concurrent. Currently I'm starting with a set of URLs that I call, check their status, and then get a list of URLs for the same domain on the page which I add to the set to be checke
07:32Scorchind. What are the best ways to tackle this in a Clojure-like way?
07:33ScorchinI was originally thinking about using futures, but that could bloat the number of threads
07:36jmlI'm feeling a bit dense. How do I specify jenkins (org.jenkins-ci.jenkins) as a dependency in leiningen?
07:36jmlI've got :repositories [["jenkins" "http://repo.jenkins-ci.org/public/&quot;]] in my project.clj
07:37jmland [org.jenkins-ci/jenkins "1.26"] in the :dependencies vector
07:37jmland http://repo.jenkins-ci.org/public/org/jenkins-ci/jenkins/ seems to be there, merrily existing away
07:38jmlbut I get 'Could not find artifact org.jenkins-ci:jenkins:jar:1.26 in jenkins (http://repo.jenkins-ci.org/public/)' during 'lein run'
07:51xeqijml: http://repo.jenkins-ci.org/public/org/jenkins-ci/jenkins/1.26/ only has a pom, so you might try :extension "pom"
07:52SgeoI'm going to have to learn what a pom is, aren't I?
07:52Sgeo:/
07:52xeqiSgeo: not usually. The jvm loads the first instance of the class it finds on the classpath, so having v1 and v2 leads to bad interaction
07:53Sgeoxeqi, :/
07:53xeqinot usually
07:53SgeoI think the last time I actually liked/wanted/anything'd the JVM or the JDK was as a kid
07:53SgeoI was excited by a book about Java that I bought, since I didn't see any other ways to start programming for free.
07:54SgeoI eventually found Python, which was the first time I actually started writing code outside of Visual Basic and VBA
07:54xeqihow does python handle having two of the same library?
07:55jmlxeqi: it takes the first thing it finds on sys.path
07:55xeqisounds like the same thing to me
07:55SgeoMy Python mention was a tangent
07:58magopianpoor lad, vb and vba
07:58magopian:)
08:06clgvScorchin: you can use java's ExecutorSevices
08:09SgeoI feel like I'm going to end up learning way more than I ever wanted to know about Java.
08:12clgvSgeo: do not complain to soon about vague feelings ;)
08:34llasramSgeo: I felt the same way at first, and everyone knows about the amazingly bad parts of the Java standard library and Java frameworks, but there's some amazingly high-quality parts too
08:35SgeoClojure wouldn't happent to have built-in not-blatent-Java-FFI file access, would it?
08:35Sgeo*happen
08:35llasramIf you look at Clojure's concurrency support, it's pretty interesting how much of it is just bolting the STM to a thin veneer over the Java standard library concurrency libraries
08:35antares_Sgeo: clojure.java.io
09:02jsabeaudryIs there anything besides lein-deps-tree that will print a dependency tree for my project? (lein-deps-tree crashes on a could not locate leiningen/core/classpath__init....)
09:02llasramjsabeaudry: lein2, `lein deps :tree` ? Or is that what you're talking about?
09:02clgvjsabeaudry: lein2 deps :tree - but only for leiningen2
09:03jsabeaudryOh yes, for lein 1.7.1, I'm still waiting for the official release before I move to lein2
09:04RaynesThere isn't a real reason to do that.
09:04llasramI'd suggest going ahead and switching. My understanding is that the only reason technomancy hasn't done an official 2.0 release is because he's waiting on new clojars infrastructure. It's not because the lein2 codebase isn't ready
09:05RaynesPretty much everyone has moved already and lein 2 is generally complete.
09:06RaynesBut if you insist on using old lein, mvn dependency:tree should work with your lein-generated pom.xml file.
09:07pyykkishas anyone installed lein2 with homebrew? I wonder if there's an updated recipe somewhere or should I make pull req
09:10clgvpyykkis: what was different from normal lein installation with homebrew?
09:10RaynesThe commands used. *shrug*
09:11RaynesOh, never mind. Misunderstood the question.
09:12pyykkisoh, and one can actually install 2.x with 'brew install leiningen --HEAD'
09:15pyykkisclgv: it's pretty much the same under the hood, just easier with homebrew one-liner
09:15pyykkishttps://github.com/mxcl/homebrew/blob/master/Library/Formula/leiningen.rb
09:16pyykkisI wasn't awere of --HEAD flag, though. Maybe it's time to actually read homebrew docs..
09:18clgvpyykkis: well, that seems to get you 1.7.1
09:24SgeoDon't have time to fix my copy of labrepl now, but when I get it working, does it provide a REPL in the browser, or will it expect me to do it in the REPL I launch labrepl from?
09:28pyykkisclgv: hm...works on my laptop?
09:28pyykkis$ lein version
09:28pyykkisLeiningen 2.0.0-SNAPSHOT on Java 1.7.0_05 Java HotSpot(TM) 64-Bit Server VM
09:29clgvpyykkis: I just read the link where 1.7.1 was explictely named. maybe there is some magic besides that.
09:29clgvI have not the slightest idea of how homebrew works ;)
09:31pyykkisclgv: there's also 'head' defined in the homebrew recipe, which points to master branch
09:32pyykkis..which is used with 'brew install leiningen --HEAD'
09:32clgvah ok.
09:37SgeoIf I'm on JRE 7 why does (javadoc System) bring me to the thing for 6?
09:38hyPiRion$source javadoc
09:38lazybotSource not found.
09:38xeqipyykkis: that is a weird lein version number
09:41robermannSgeo: http://clojuredocs.org/clojure_core/clojure.java.javadoc/javadoc
09:42xeqipyykkis: I have a suspicion that your getting the 4month old -SNAPHSHT on https://github.com/technomancy/leiningen/downloads
09:42pyykkisxeqi: well..yeah, it isn't any of the previews, it's the HEAD from master branch https://github.com/technomancy/leiningen/blob/master/project.clj#L4
09:43xeqiright, but I don't see the homebrew script bootstrapping lein
09:43xeqijust calling self-install, which pulls from the github download page
09:44naeghow often do you actually use -> and ->> in real code? like (f (g v)) instead of (-> v g f)
09:44pyykkisxeqi: ah..thanks, I haven't even looked so far. Maybe I'll do manual install then, afterall.
09:45xeqi-> is not uncommon, ->> is rarer
09:46pyykkisnaeg: more often than not. I'd be close to say "always"
09:46naegis it rarer because people just don't need ->> that often or because peopl like to write it out instead of using ->>?
09:47xeqiI usually start using -> when I get to a chain of 3
09:47naegdo other lisp's have this too? I can't remember such a macro from CL
09:47antares_naeg: -> is pretty commonly used. In the example you've demonstrated I just do (f (g v)), though
09:47xeqi->> is rarer cause things like assoc are designed for ->
09:47robermannSgeo: maybe you should check/set the *remote-javadocs* var
09:49jweisswould it be frowned upon to use the extensible reader to create a group of common imports (eg, require's, use's)? like (ns blah #=(my-common-stuff-a) #=(my-common-stuff-b))
09:50jsabeaudry,(str (doall (map int [1 2 3 4])))
09:50clojurebot"clojure.lang.LazySeq@e93c3"
09:51S11001001,(str (proxy [Object] [] (toString [] nil))) ; my favorite, jsabeaudry
09:51clojurebotnil
09:52jsabeaudryS11001001, Looks good, unfortunately I cannot really appreciate it as I am not familiar with proxy :(
09:53jsabeaudryAh, I think I get it, str call tostring and you deined an bject that returns nil when you call tostring on it?
09:53hyPiRion,(= (proxy [Object] [] (equals [x] 'foobar)) nil)
09:53clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException: nth not supported on this type: Symbol>
09:54S11001001hyPiRion: sorry, there's only one trick :)
09:54hyPiRionS11001001: Apparently.
09:54chouserjweiss: that's an interesting idea. Certainly not one I've seen.
09:54S11001001,(let [snil (proxy [Object] [] (toString [] nil))] (str snil snil))
09:54clojurebot#<NullPointerException java.lang.NullPointerException>
09:54chouserjweiss: where would my-common-stuff-a be defined?
09:54S11001001neat
09:55S11001001,(let [snil (proxy [Object] [] (toString [] nil))] (-> snil str str))
09:55clojurebot""
09:56S11001001the point of this being that ∃v. (str v) ≠ (str (str v))
09:57jweisschouser, it'd be a function in some other namespace. i suppose i'd have to refer to it by its fully qualified name and ensure that it's already loaded.
10:04augustlanyone know how to get the raw Set-Cookie headers from clj-http? It seems to remove them from :headers and add the parsed result to :cookies
10:04chouserjweiss: yeah, interesting. The 'ns' block was supposed to be declarative so as to support tooling in general, and such use of #=() might break that. ...but I'm not aware of any tools that read the ns block anyway, so *shrug*
10:06jweisschouser, declarative meaning a literal list and no calculated values?
10:07chouserwell, yeah -- that's why you're having to use #=(), because the bodies are essentially quoted for you
10:08augustlcan't find any reference to :cookies anywhere in the code of clj-http, weird
10:08chouserand also declarative in that ns uses :require instead of the symbol require
10:08jeremyheileraugustl: if you don't need the wrap-cookies middleware, you can remove it.
10:08jeremyheilerit's in src/clj_http/cookies.clj
10:08augustlugh, was looking at someones fork on github
10:08augustlor something like that
10:08jeremyheilerah lol
10:09augustldo I need to build my own set of middlewares from scratch?
10:12augustlby reading https://github.com/dakrone/clj-http/blob/0.5.3/src/clj_http/cookies.clj#L129 you'd think setting :cookie-store to false in the request would do the trick, but that doesn't seem to help
10:13jeremyheileryeah, the wrap-cookies function is the culprit.
10:13jeremyheilermore specifcally, decode-cookie-header
10:13augustlugh, when :cookie-store is falsy, it wil use its own internal one
10:16jeremyheilerwould it be possible just to encode the cookie again?
10:19augustlprobably yeah
10:20jeremyheilerthat's probably the less painful solution
10:21robermannin emacs, is there a way to do a "in-ns" to the namespace in the currently open .clj file?
10:23robermannnever mind, found it: C-c M-p
10:23robermann(I was wrongly remembering C-c C-z)
11:12estebannis there any easy way to prevent c3p0 from spewing stuff into the repl? it makes useful output hard to find...
11:16ohpauleezlynaghk: ping
11:20nz-I think that c3p0 prints stuff via log4j so add log4j.xml under test. configure that log4j.xml so that nothing is printed to STDOUT
11:21estebannnz-: cool, thanks
11:23nz-estebann: example of suitable log4j.xml is here
11:23nz-https://github.com/korma/Korma
11:23estebannnz-: nice, thanks again
11:24naegis someone aware of a bigger game written in a functional language? preferably clojure, but doesn't have to be
11:25ejacksondammit - laziness kicks my arse *again* !
11:25psiinaeg: what do you mean by "bigger"?
11:27jmlwhat do I need to add to my projects.clj to be able to depend on Jenkins (in order to be able to make a jenkins plugin)? (a pom.xml here: http://paste.ubuntu.com/1170038/; generated by following instructions at https://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorial#Plugintutorial-SettingUpEnvironmen)
11:29naegpsii: just more than a few hundred lines
11:29psiinaeg: http://joyridelabs.de -- although in haskell
11:29naegpsii: the actual question is whether the functional style could extend to larger (2d) games
11:29psiiwell then, this link is for you :)
11:30naegthanks psii
11:31jmlI think I'm just a vanilla fool
11:39xeqijml: you might be able to figure it out by reading https://github.com/pyr/jenkins-leiningen 's pom
11:40xeqithough I'm not sure there is an equivalent for plugin-repositories ...
11:41jmlxeqi: thanks. I'm looking for an equivalent projects.clj, but I think I've got something that's working well enough for me to move on to the next problem :)
11:41xeqiI think you could use :pom-additions for that, but its prolly not well documented
11:41jmlis there a syntax for importing inner classes?
11:41xeqiOuterClass$InnerClass
11:42jmlthanks
11:44TimMcjml: Inner classes are a Java lie. :-)
11:45TimMcs/lie/concept/
11:46unlink`lein ring server` takes a shocking long time to start (~15 seconds), and code reloading is anything but infallible. How do people work around this?
11:47weavejesterunlink: There's something wrong with the code reloading I need to look into. I suspect the namespace dependencies aren't being calculated correctly.
11:48unlinkOh, OK.
11:48weavejesterunlink: In the meantime, you could always start a server in a REPL and reload manually
11:49unlinkHow would I do that?
11:49weavejesterunlink: (run-jetty your-handler {:join? false :port 3000})
11:49weavejesterunlink: And then (require 'your.namespace :reload-all)
11:50unlinkoh, great. I'll try that.
11:50brainproxyI like to do it the other way around; I use `lein ring server ...` to fire up the dev server, and inside whatev.core I fire up a repl server which I can connect to from emacs
11:50augustlunlink: I've had problems with code reloading as well, for what it's worth :)
11:50augustlso you're not alone
11:51weavejesterIt probably won't be too long until I fix the namespace reloading, as I'm getting bored of it myself.
11:51augustlsome times I get a 500 error in the form of a blank page, and then on the next request everything works, as it was before I changed the code and introduced the error. I very rarely get the stack trace etc.
11:51weavejesterI suspect the problem is in the ns-tracker library
11:51weavejesteraugustl: That indicates a compile error. e.g. the require itself is failing
11:52augustlah, I see
11:52weavejesteraugustl: And because the require throws an exception, it's not loading the new code.
11:52thorbjornDXIs there a well-defined C interface for clojure/java?
11:52augustlin this case I'm one of those "I don't care I just want it to work" peeps :)
11:52weavejesteraugustl: Hm, but… I guess I could say that if there's an exception, it keeps trying to reload so you get the same error and it's not lost when you refresh.
11:53augustlthat would rock :D
11:53augustlwould ofc also be nice if some kind of error could be displayed on the page
11:53weavejesteraugustl: Don't you get a stacktrace?
11:53augustlquite often it's just a blank page
11:54augustland then the "previous version" on subsequent requests, until restart
11:54weavejesterMaybe the stacktrace middleware is below the reload middleware. So if there's an error requiring the file, the stacktrace middleware won't catch it.
11:55weavejesterYeah, it is.
11:55augustlah
11:55weavejesterThat's an easy fix at least.
11:55augustlso apparently code reloading is not black magic, it's just code like everything else?
11:55weavejesteraugustl: Yes :)
11:57weavejesterIn a nutshell it looks for modified files when a new request comes in, then uses ns-tracker to calculate any dependencies. For instance, if namespace A is changed, but namespace B requires A, then both A and B need to be reloaded.
11:57weavejesterThen it reloads the namespaces with (require namespace :reload)
11:58weavejesterThe stacktrace middleware is designed to catch exceptions and display a nice stacktrace, but the stacktrace middleware is currently placed below the reload middleware
11:58weavejesterSo if a require fails because there's a syntax error (for example), then there won't be a stacktrace.
11:59weavejesterI suspect there's also a problem with the namespace tracking in ns-tracker. I'm finding that dependent namespaces aren't being reloaded all the time.
12:00weavejesterBTW, if anyone has problems with Lein-Ring or whatever, raise an issue on Github.
12:05llasramweavejester: Oh, BTW, lein2 now has support for explicit framework-provided dependencies via a :provided profile. I contributed it for Hadoop job JAR building, but my hope is that it'll simplify things like WAR construction
12:10weavejesterllasram: Thanks for the info
12:29hughfdjacksonother than the ability to define records that can have protocols defined for them, doesn't defrecord seem a slightly second-rate way to define datastructures?
12:29hughfdjacksonas far as I can tell, it doesn't seem to support named fields on construction
12:30hughfdjacksonwhich ends up with ordered params instead
12:30hughfdjackson:D i'm thinking that i probably misunderstood this
12:31technomancyyeah, don't use records if you can get away with multimethods
12:31technomancymultimethods and maps, rather
12:31llasramAnd if you do need them, the work-around is that you have a Clojure factor function rather than directly use the JVM class constructor
12:31llasrams,factor,factory,
12:31hughfdjacksonhrm, drat
12:32augustlI'm mostly using records when I need "private" data structures
12:32augustli.e. where initialization only happens one or two places, in the same namespace
12:32hughfdjacksonis it the 'named type rather than duck type' side of it that irks, or is it the problem with instantiating them without key:val pairs that i mentioned?
12:32llasramYeah. I really really wish deftype let you specify custom constructors. I'd let me ditch most of the remaining cases where I need to squiggle some Java into the codebase
12:33SgeoI'm having problems with Eclipse
12:33weavejesterI hate SQL so much
12:34SgeoSurely there are things for Clojure that let you avoid using SQL directly?
12:35weavejesterSgeo: Yes, for querying and such, but less for generating schema. There's lobos, but it can't do everything.
12:36llasramSQL truly is the worst query language, except for all the others
12:36technomancyschema generation isn't even really standardized
12:36weavejesterThe main problem is that SQL syntax is such a horrific ball of mud that even the simplest things are difficult or impossible
12:36nz-what is missing from lobos?
12:36weavejesterllasram: Actually… I can't think of a worse query language than SQL...
12:37weavejesternz-: It might be that lobos can actually do everything I want
12:37weavejesterBut "to keep it simple" I've gone with files of SQL for migrations
12:37technomancynz-: I get the feeling it's just got too much
12:38weavejesterThe problem is that I forgot you can't execute multiple SQL statements of certain types in the same command
12:38weavejesterAnd there doesn't appear to be any library to split them up in Java
12:38weavejesterOr any language.
12:38llasramweavejester: Yeah, fair enough. Really the only contrast I'm familiar with is SQL over full relational data model vs. limited data-access API for much more constrained data model, which doesn't really cover the case of e.g. Datalog
12:39weavejesterllasram: Admittedly most of the better query languages I can think of don't have as much functionality as SQL.
12:39tvladeck1quick question; is there any way to use the "map" function in the new reducers library, if you don't actually need to reduce the result?
12:40Bronsa(into [] (r/map ..))
12:41tvladeck1cool; and does that achieve the same sort of fork/join goodness that exists in the "par" branch?
12:41hughfdjacksonisn't the point of the reducers that all common forms of operations over sets can be 'reduced' (gettit) to a reduce with an appropriate fn?
12:41Bronsainto calls reduce
12:41hughfdjackson(:p this Q is more for me than for you)
12:41weavejestertechnomancy: I'm using the code you wrote for Ragtime ages ago. Did you happen to give any thought to putting more than one SQL statement in a migration file?
12:42dnolenhughfdjackson: not sure what you mean.
12:42hughfdjacksondnolen: i watched the rich hickey talk while i was kinda nodding off i'm afraid :#
12:42technomancyweavejester: not really; best I came up with was splitting on ;; and a big old "don't use ;; inside actual SQL" comment at the top
12:42tvladeck1Bronsa: so into calls "reduce", but isn't it necessary to call "par/reduce" to get the advantage?
12:42augustlhughfdjackson: that's my impression as well. The actual units of work only describe what needs to be done with one item. Then there's a generic tool to parallelize the actual operation.
12:43weavejestertechnomancy: I was afraid of that :)
12:43hughfdjacksonbut i thought the point of it was that reduce an abstract operation that you can define reduce/map/each in terms of
12:43technomancyweavejester: but I also have experimented with doing it from Clojure itself: https://github.com/heroku/buildkits/blob/master/src/buildkits/db/migrate.clj
12:43technomancythe main downside there is you don't get syntax highlighting, which is awful and terrible
12:43Bronsatvladeck1: they both call coll-reduce
12:43tvladeck1ok got it
12:43technomancybut on the other hand data manipulation is a lot nicer
12:44technomancyand ordering too
12:44weavejestertechnomancy: True...
12:44weavejestertechnomancy: I'm currently turning Ragtime into a Lein plugin
12:44technomancymaybe a helper defn to load a single SQL statement from a file, but it lacks immediacy
12:44technomancyreally? why's that?
12:44technomancyI don't see the point of running anything inside leiningen's process
12:45weavejestertechnomancy: Well, ragtime core wouldn't be changed
12:45weavejesterBut I was adding an extra ragtime.lein so you could run "lein migrate"
12:45technomancyyou can do that easily already
12:45technomancy:aliases {"migrate" ["run" "-m" "ragtime.core"]}
12:45weavejesterHm. How?
12:46weavejesterHm… problem with that is that you have to write your own migrate code
12:47technomancythat doesn't mean that you have to run code inside leiningen's process though
12:47technomancyit's all still project-isolated
12:47weavejesterOh, I'm using eval-in-project
12:47weavejesterSo it's a very thin wrapper
12:47technomancysure; but you should use eval-in-project via the run task rather than calling it directly
12:48jweissdoes the extensible reader support spliciing? (eg, #foo/bar 1 -> 1 2 3 ) ?
12:48weavejestertechnomancy: Hm...
12:48Bronsajweiss: dont think so
12:49weavejesterSo if one was making a plugin for Leiningen that primarily execute code in project
12:49SgeoECLIPSE PLEASE STOP BEING STUPID
12:49weavejesterPerhaps instead of using eval-in-project, it would inject alieases instead into the project map
12:49SgeoI'm trying to import labrepl
12:49weavejesterOh wait, that wouldn't work...
12:49SgeoIt complains that it overlaps another project: labrepl
12:49SgeoI think it's downloading the files then noticing that there are files there
12:50technomancyweavejester: if you're going to have to add one line to project.clj for a :plugins entry why not add a line for :aliases instead?
12:50weavejestertechnomancy: Because you'd need lines for rollback as well, and some configuration too.
12:50weavejesterCurrently I have two config vars
12:51SgeoAny help?
12:51technomancyweavejester: suggest loading config from resources
12:51weavejester:ragtime {:migrations ns.for.func.that/generates-migrations, :database "jdbc:h2:mem:test_db"}
12:51technomancyalso: a single -main function can support migration and rollback
12:52technomancylein run -m ragtime.main [REVISION]
12:52weavejestertechnomancy: That's an idea. lein run -m ragtime.main migrate
12:52weavejestertechnomancy: But I don't like the idea of scattering configs around.
12:53technomancyLeiningen has never encouraged using project.clj for runtime config
12:53weavejesterI know
12:53weavejesterBut...
12:54technomancyI suspect any app nontrivial enough to need migrations is already going to have to be reading config from somewhere already
12:54weavejesterThere isn't a better alternative IMO.
12:54bhenrylooks like someone needs to rewrite ants.clj http://news.stanford.edu/news/2012/august/ants-mimic-internet-082312.html
12:54weavejestertechnomancy: In production, that would be the environment, according to 12factor.net :)
12:55weavejesterBut in development...
12:55weavejesterAdding configs to Lein profiles is very nice.
12:56weavejesterSo we either need to build a separate profile/config system
12:56weavejesterOr we could tie into Leiningen's
12:56weavejesterAlthough Lein isn't designed to be used in this fashion, I don't see why it couldn't be.
12:57Frozenlock`find' is to be used with a map, but is there an equivalent function for a collection? I want to check if I have a given item in a vector.
12:58nDuffFrozenlock: some?
12:58xeqi(some #{1} [2 3 4 1])
12:58weavejesterFrozenlock: some?
12:58weavejestertechnomancy: I like the idea of a ragtime.main though
12:58FrozenlockYes! Thanks!
12:59thorbjornDX,(some #{1} [2 3 4 1])
12:59clojurebot1
13:01thorbjornDX,(some #{:a :b} {:a 1 :b 2})
13:01clojurebotnil
13:01thorbjornDXI guess that's where find is used?
13:02FrozenlockI guess I must be too used to elisp's find function.
13:02thorbjornDXFrozenlock: I'm used to python's 'in'
13:02nDuff...the thing about 'in' is that it can behave in ways with wildly different performance characteristics
13:03nDuffwhereas Clojure tends to have functions in its standard library with well-defined performance characteristics
13:03FrozenlockEh python.... one day, one day :)
13:03thorbjornDXnDuff: yeah, it's hard to know what it's doing behind the scenes
13:03nDuff...if you're using some, you _know_ that it's an O(n) operation.
13:04technomancyweavejester: yeah, some people are using project.clj for runtime config
13:04thorbjornDX1 in [1, 2, 3, 4] is O(n), 1 in {1: 1, 2: 2, 3: 3, 4: 4} is O(1), yea?
13:05nDuffthorbjornDX: Exactly.
13:05technomancyit's this weird thing where I can't point to any specific reasons it's a bad idea; it's just that I haven't thought it all the way through yet. there are a lot of design decisions that were made without factoring it in at all
13:05weavejestertechnomancy: If it makes you feel better, I'm only using it in development :)
13:06technomancyI'm just wary because as soon as I start encouraging it I may push myself into a corner where there'd be some great feature I'd like to implement but can't because it doesn't jive with runtime-level config
13:06weavejestertechnomancy: I tend to use environ and profiles to configure dev stuff, and then in production environment vars or system properties.
13:06weavejestertechnomancy: Noted.
13:07technomancyso I guess I should encourage people to experiment with it unofficially for a while and have them report any issues =)
13:07weavejestertechnomancy: But in that case, we'd likely need something to replace Lein. Like… a runtime config/profiles thing.
13:07technomancyweavejester: have you seen configleaf?
13:07weavejestertechnomancy: No...
13:07technomancyI think it does some of the stuff you're describing
13:08weavejestertechnomancy: Hm, that goes a little further than I was thinking...
13:09weavejestertechnomancy: In my case I'm just using it as a way to populate env vars during development.
13:10weavejesterAnd I guess to specify how to run the application.
13:10weavejesterBut Lein does that already with :main, so that seems to be in line with how it works already
13:11weavejesterSpecifying :main or specifying a :handler seem similar.
13:20technomancyyeah, in fact IMO lein run with the right aliases covers most of the use cases of lein ring
13:20technomancylein ring server, I mean
13:20technomancyif you're using embedded jetty
13:21weavejestertechnomancy: Yes, apart from the configuration
13:21weavejestertechnomancy: lein run + aliases + some kind of config with profiles would cover my use cases at the moment
13:21technomancyweavejester: lein-ring says it does stack traces in development; does it just check LEIN_NO_DEV, or what?
13:22weavejestertechnomancy: Yes, by default, but you can be more exact with profiles
13:22weavejestertechnomancy: It seemed like a reasonable default to have.
13:22technomancyyeah, unfortunately LEIN_NO_DEV is specific to 1.x
13:23weavejestertechnomancy: You can still set it for 2.0 - it just wouldn't do anything to Lein itself.
13:23weavejestertechnomancy: That said, for Lein 2 you'd probably want to use profiles.
13:23technomancysure, it's just no longer a documented convention
13:23Sgeo,(some #{:a :b} (keys {:a 1 :b 2})
13:23clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
13:23technomancymight help to be clearer about that in the lein-ring readme
13:23Sgeo,(some #{:a :b} (keys {:a 1 :b 2}))
13:23clojurebot:a
13:23SgeoOh, I was scrolled up
13:23weavejestertechnomancy: True
13:24jbarrios,graph
13:24clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: graph in this context, compiling:(NO_SOURCE_PATH:0)>
13:25jbarrioswhere's the old clojure.contrib.graph package now?
13:27raekjbarrios: nowhere. it is unmaintained.
13:27raekhttp://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
13:27jbarriosso I guess dgraph is the best choice atm?
13:28jbarrioshttps://github.com/gcv/dgraph
13:31jmlis there a recommended pastebin for this channel?
13:31llasramjml: https://www.refheap.com/paste
13:31jmlllasram: thanks.
13:32jmlpretty.
13:32hyPiRiongists are also nice if you wonder whether the code is idiomatic or not
13:32hyPiRion'cause of forking possibilities
13:32sh10151quick leiningen/clojure-jack-in question for emacs people:
13:33sh10151things in my resources/ directory don't appear to be on the classpath in a repl started in clojure-jack-in ... does that sound right? if so, any way to change that?
13:34jsabeaudrywhat kind of "things" ?
13:34sh10151xslt file
13:34sh10151null pointer returned by clojure.java.io/resource on its name
13:35technomancysh10151: did you create the resources/ dir after starting the JVM?
13:35sh10151hmm good question. does clojure-jack-in tear down the whole JVM or not?
13:35sh10151i think i have just been repeatedly calling that
13:35sh10151saying to get rid of the exsting process
13:36technomancyit does restart the JVM, yeah
13:36sh10151ok, so no
13:36sh10151it's been there
13:36sh10151if it's supposed to work, I can look for typos or something
13:36sh10151just wanted to make sure it's supposed to work
13:36sh10151after not seeing any typos
13:36raekyeah, it is supposed to work
13:37technomancyit definitely should work
13:37sh10151ok, I see making the uberjar puts the file in there
13:37jsabeaudryit does work here, just tested it
13:37jsabeaudrywhat path did you give to (resource ) ?
13:37raeksh10151: so if you have a file in resources/foo/bar.txt you use (io/resource "foo/bar.txt") to get it?
13:37sh10151"/filename.xsl"
13:37sh10151it's at top level of resources dir
13:38sh10151maybe no leading "/" ?
13:38jsabeaudrytry without the leading slash?
13:38raekI can't remember what happens if you have a leading slash
13:38jsabeaudryreturns nil if i had a leading slash here
13:38sh10151relative to package of the classloader loading the resource I think
13:38jsabeaudryadd*
13:39sh10151I mean, that's what Java does, not sure about java.io.resource
13:39raekit uses the java stuff under the hood
13:40sh10151that did it, thanks for the help. I should have tried that
13:40deeplloydI have been trying to pick up clojure over the past couple of weekends. i find a decent amout of people's learning experiences w/ clojure plus the normal documentation. What I feel I have not found is a non lisp, non clojure, python/c ish dev's account of coming blind from said technologies to writing a web app in clojure. webnoir is about the best. I have a decent background in programming, and know that it will take time to get
13:40sh10151just porting some clojure 1.0.x era code with maven-clojure-plugin to current stuff
13:40sh10151and I know it used to work back in the day :)
13:41dnolendeeplloyd: have you checked out the O'Reilly book?
13:41FrozenlockPerhaps I was doing it the wrong way, but in clojure I could get the value of a symbole simply by doing (eval my-symbol). How can I do it in cljs?
13:41deeplloyddnolen: clojure programming?
13:42synfinaticyep that one
13:42dnolendeeplloyd: yes
13:42xeqi,(resolve '+)
13:42clojurebot#'clojure.core/+
13:42sh10151deeplloyd: In my experience the Java/JVM adds quite a bit of complexity too, if you're not already familiar with it. my last question is an example of such complexity. :-/
13:43SgeoHmm
13:43cemerickdeeplloyd: http://clojurebook.com if you'd like a precis (or, the closest you'll get to one for a technical book I guess)
13:43Sgeo&(resolve '+)
13:43lazybotjava.lang.SecurityException: You tripped the alarm! resolve is bad!
13:43SgeoSo, there's a difference between clojurebot's sandbox and lazybot's sandbox
13:43deeplloydsynfinatic: dnolen not past the free samples. i dont pirate and would prefer to hold out on spending the bucks until finances are a bette
13:43technomancyyou'd run into the problem of complexity around the ability to load files transparently either off disk or from a compressed archive no matter the runtime
13:43deeplloydcemerick: precis?
13:43Sgeo,(future (+ 1 1))
13:43clojurebot#<SecurityException java.lang.SecurityException: no threads please>
13:44cemerick$google define:precis
13:44lazybot[Précis - Wikipedia, the free encyclopedia] http://en.wikipedia.org/wiki/Pr%C3%A9cis
13:44cemerickoh well
13:44deeplloydah
13:44xeqiSgeo: quite abit, clojurebot resets the sandbox every ~15m or so and uses classloaders to prevent some bad stuff; lazybot uses clojail to achieve the same thing
13:44Sgeoclassloaders?
13:44sh10151technomancy: sure, but in other runtimes that's not really something that's valued enough to bake into the system
13:45SgeoI've heard the term before but don't know much about it
13:45cemerickA brief abstract of some material (paper, book, etc), usually written by a student to verify comprehension, etc.
13:45deeplloydokay. well then that is the way I suppose. hopefully il be able to make what im looking for in the process
13:45sh10151technomancy: here I'm thinking of Python/C per deeplloyd's question :)
13:45xeqiSgeo: think path to search for libraries
13:45SgeoI thought that's classpath
13:45technomancysh10151: so if you don't want the ability to read contents transparently from either an archive or disk why are you using resources?
13:46xeqithey both have to load other libs to run, but want to present a repl w/ a limited subset
13:46xeqiclassloaders are the objects that load classes from the classpath
13:46deeplloydbtw cemerick i enjoyed the state survey
13:46SgeoAh
13:46technomancyyou can always fall back to loading a file from a specific path on disk
13:46SgeoI'm pretty sure that I won't be mentally designing ClojureNomic
13:46sh10151technomancy: oh, I am interested in doing it either way, but only because these things are often deployed as a jar but developed running from files
13:46cemerickdeeplloyd: Glad for that :-)
13:47SgeoI think newLisp is good for a nomic because of save
13:47deeplloydcemerick: what did you write your blog in?
13:47cemerickcemerick.com is on wordpress.com
13:48cemerickSo is mostlylazy.com
13:48deeplloyddo you have a clojure site i can scour?
13:49sh10151technomancy: which is something that a person who's primarily billing themselves as Python/C might not know off the bat.
13:49cemerickdeeplloyd: What, of strictly clojure-related content? http://cemerick.com/category/clojure/ I suppose. :-P
13:50technomancysh10151: sure, so you're trading a bit of up-front complexity for an easier single-file deployment
13:50weavejestertechnomancy: I think I'm going to have a ragtime.main with two arguments. The first to specify a function that returns a list of migrations. The second to specify a database URL.
13:50weavejestertechnomancy: Then I'll add a Lein plugin that will thinly wrap ragtime.main and take the arguments from the project map.
13:50technomancyweavejester: yeah, since aliases support partial application you can put the function in project.clj
13:51weavejestertechnomancy: Yes, though I'll also add a plugin to do the same thing, but in a nicer way
13:51sh10151technomancy: yep, and that complexity's the kind of thing that can trip people up if they're not prepared. just pointing out to deeplloyd that understanding Java is at least as important to production Clojure as is understanding Lisp.
13:51weavejestertechnomancy: I want to see which I like best.
13:52technomancyweavejester: I guess the other thing you get with a plugin is a docstring
13:52technomancyI dunno. I don't think it's worth it, but try it and see for yourself =)
13:52weavejestertechnomancy: Yeah. And if we decide to move away from plugins, it's only going to be a thin wrapper.
13:53deeplloydcemerick: IE9 > FF ?!?
14:02Sgeohttp://www.reddit.com/r/netsec/comments/ywbhq/new_java_0day_exploited_in_the_wild/
14:17cemerickdeeplloyd: ??
14:17lazybotcemerick: Uh, no. Why would you even ask?
14:20SgeoI feel like I'm about to give up on labrepl
14:20SgeoOr maybe just Eclipse
14:20cemerickSgeo: What's tripping you up? I can help with Eclipse/ccw, but I know nothing of labrepl.
14:21Sgeocemerick, when I try to import the thing via git, at the end of the wizard it says there's already a project there
14:22Sgeo(Following the instructions at http://dev.clojure.org/display/doc/Getting+Started+with+Eclipse+and+Counterclockwise )
14:24Sgeo(Specifically, after "Import as general project", it says "C:\Users\Sgeo\DEV\Eclipse\labrepl15 overlaps the location of another project: ;labrepl15'
14:24cemerickSgeo: Worked for me; perhaps you've done this a couple of times, and so the project is already cloned with an eclipse project set up therein?
14:24SgeoErm, 'laprepl15'
14:25Sgeocemerick, would that effect it even if I keep using different numbers for the directory?
14:25cemerickSgeo: Wouldn't think so, but apparently…
14:25darklajidHi. Probably I'm missing something obvious. I'm just getting started, playing with some simple http tools. I'm using ring, and a request seems to be just a map, right? Where would I find the structure/keys of this beast? I'm looking for the remote ip/port of the underlying socket, specifically
14:26cemerickSgeo: Try: Import > General > Existing projects, and see if there's one already in place ready to go
14:26cemerickIs labrepl even maintained anymore? Last change was 10 months ago.
14:26technomancydarklajid: just print the request
14:27SgeoNo projects are found to import
14:27technomancyor return it in the response: (defn app [req] {:headers {"Content-Type" "text/plain"} :status 200 :body (prn req)})
14:27ohpauleezcemerick: I'm not sure, but it is a good learning tool
14:27cemerickSgeo: it looks like labrepl is just another leiningen project, so you can just use a clone of it as such
14:28Sgeo?
14:28xeqidarklajid: https://github.com/ring-clojure/ring/blob/master/SPEC for the structure
14:28cemerickohpauleez: dunno, it's starting people off with clojure 1.3.0, and old compojure, ring, etc.
14:28darklajidtechnomancy: Gives me two problems. a) I don't see the required data there (I get a :remote-addr, but that seems to be a string/ip address. No port) and b) Is that the normal way? I did that already, but I was kind of hoping for a missing link to some docs.. :)
14:29cemerickSgeo: Are you specifically looking to use labrepl for something, or are you just wanting to get started with programming in Clojure in general?
14:29ohpauleezcemerick: Ah wow, I wasn't aware it was that out of date
14:29ohpauleez4clojure would definitely be better
14:29technomancydarklajid: you could read the SPEC file for ring, but you should also get comfortable with exploring the API interactively
14:29Sgeocemerick, getting started with Clojure in general, although I have learned a bit already I think
14:29technomancythat's the whole request object though
14:30darklajidxeqi: technomancy: Cool, the spec looks neat. But .. no port. So ring is not for me, I guess? Back to sockets?
14:30cemerickSgeo: As long as you can get a Clojure+Leiningen project going in ccw with a REPL, you're on your way. :-)
14:30SgeoI seem to have gotten independent leiningen installed finally
14:32Sgeolabrepl working now
14:35xeqidarklajid: yeah, you'll prolly need something else.. why are you interested in the client's port out of curiousity?
14:37darklajid*cough* Quite frankly I suck at Clojure, but have cemerick's book on my kindle for ages. There's a current ctf from stripe and I'm trying to solve the last level -> The only one that needs code -> "Maybe I can learn some clojure with this particular goal"
14:37xeqiah, I solved that one in python
14:37darklajidProblem: I need the addr/port to get even started. So the whole 'explore all these web stuff I've read about in clojure land' dies before I even begin :)
14:37xeqisince it was already on l2
14:37darklajidxeqi: ;-)
14:38darklajidxeqi: Yeah, but .. I'm worse at python than at clojure, even. :) But I don't care about learning python very much, so.. Hmpf.
14:39xeqiheh, I didn't want to deal with installing a jdk
14:39xeqi*jre
14:40lucianxeqi: i didn't even bother getting twisted there
14:40lucianeven that is too much trouble
14:40xeqiyeah, I went singlethreaded python w/ sockets and httplib
14:57Sgeo"Starting in 1.3.0, Clojure no longer auto-boxes this type of operation for you."
14:57SgeoHmm, why?
14:58S11001001Sgeo: what?
14:58SgeoS11001001, arithmatic that might overflow
14:58nDuffSgeo: Performance.
14:58S11001001MORE SPEED
14:58ohpauleezSgeo: Most developers are aware of the numeric scope they're operating in, so the performance trade-off of auto-boxing and converting up the numeric tower wasn't worth it
14:58clojurebotstuartsierra has come to the conclusion that dynamic scope is a bug.
14:59ohpauleezSgeo: you can still get that behavior if you want it
15:08FrozenlockIf any of you have 1 or 2 min to spare, could you look at this code https://www.refheap.com/paste/4660 (view the result here http://173.246.15.182:8888, try to click Bar Foo and Zon) and tell me if I'm doing crazy things?
15:19achengclojure style question: to take a map and return a new one where any nil values have been replaced with empty strings, i wrote an fn that maps an if-statement, flattens, then apply's assoc on {} and the result. is there a better clojure way to do it?
15:19amalloy~flatten
15:19clojurebotflatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.
15:20amalloyi wonder how rude it would be to have lazybot notice any message with "flatten" in it and respond like that
15:21achengi wouldn't mind if it provided an example as well :-P
15:21technomancyacheng: sounds like a classic reduce
15:23Sgeoamalloy, I wonder if its uselessness can be noticed by how in Haskell such a function can't be given a type
15:23xeqi,(into {} (map (fn [k v] (vector k (if (nil? v) "" v))) {:a nil :b "b" :c "c"}))
15:23clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox$eval27$fn>
15:23SgeoWell, in Haskell, you can't even have lists that have different nesting levels
15:24SgeoBut flattenOneLevel :: [[a]] -> [a]
15:24xeqi,(into {} (map (fn [[k v]] (vector k (if (nil? v) "" v))) {:a nil :b "b" :c "c"}))
15:24clojurebot{:a "", :c "c", :b "b"}
15:24SgeoPretty sure there's a real Haskell function
15:24amalloySgeo: it's concat
15:24Sgeoamalloy, indeed. I hoogled it >.>
15:24amalloyxeqi: (map (fn ...)) makes me so sad; just use (for ...)
15:24xeqihaha, habits
15:26xeqi,(into {} (for [[k v] {:a nil :b "b" :c "c"}] (vector k (if (nil? v) "" v))))
15:26clojurebot{:a "", :c "c", :b "b"}
15:26achengthanks folks!
15:26xeqiwill remember for next time
15:27jkkramer,(= (vector :a 1) [:a 1])
15:27clojurebottrue
15:27xeqiI've stopped using data literal syntax with variables, even though I know its safe here
15:27achengoh. so in this case, which is preferable.. reduce or into ... or are these approaches basically equally good?
15:28Chousukeinto is usually better if you're building a data structure.
15:29jkkramerinto is shorter here. vs e.g. (reduce-kv (fn [m k v] (assoc m k (if (nil? v) "" v))) {} m). but either approach is fine
15:29SgeoI really want to be able to browse the source of an item on clojars
15:30llasramIMHO `into` more directly expresses intent (vs just being shorter), and has the side effect of being more efficient due to internally using transients
15:31alcycemerick: ping
15:31cemerickalcy: pong
15:31mkacheng: https://github.com/flatland/useful/blob/develop/src/useful/map.clj#L46 ?
15:31alcycemerick: hi, had a question about the book you authored, is this one of the right mediums to ask ? :)
15:31cemericksure, fire away
15:32achengmk: ooh
15:33alcycemerick: thanks, so i've made till destructuring, which started to pose some semantic confusion (coming from perl), but I have _just_ been able to understand the point minus the technical terms ... is this expected and things gonna get better ?
15:33alcycemerick: for eg., the book doesnt tell me about seqs/vectors etc. formally, but I can kinda make out
15:33alcycemerick: well by book, right now, I mean the first initial few topics
15:34mkacheng: I ended up asking the same question on the 14th, I think that was the best answer (provided by gtrak). You can look at what was said at http://clojure-log.n01se.net/date/2012-08-14.html , by ctrl-f "of map entries"
15:34cemerickalcy: seqs and vectors and all the rest are covered in depth later on; if you're still in chapter 1, the (significant) differences between seqs and vectors can be glossed over.
15:35mkacheng: I think I was worried about efficiency
15:36alcycemerick: ah thanks, I suppose it will be two passes of the book & terminology when I start making real programs ;)
15:36amalloySgeo: petition library authors to include a :url entry in their project.clj
15:36cemerickalcy: Make sure you've got a working REPL going so you can experiment along the way. As for whether it's going to "get better"…well, part I of the book is purposefully intensive. Of course, feel free to jump around in order to get a better feel for details (e.g. certainly read about data structures straight off if that interests you).
15:36alcycemerick: ah yes, definitely, I have been doing that
15:36SgeoWhy can't clojars just open the jar itself?
15:37cemerickalcy: tryclj.com is a good default, if you don't want to mess around with setting up tools, etc.
15:37alcycemerick: oh trust me I have done that tutorial twice, in fact, I have been waiting for someone to complete it ;)
15:37amalloywhy can't you? it's a lot easier to do on a local filesystem than it is for clojars to reinvent githubj
15:37alcycemerick: unless you just meant to get the repl
15:37alcy:)
15:37xeqiand not every jar includes source
15:37cemerickalcy: well, I meant that it's a reasonable REPL in general.
15:38alcycemerick: yep
15:38SgeoUnless you want to mess with futures or agents
15:38alcycemerick: do you think, a preliminary knowledge of some particular concepts help ? prerequisites of sort ?
15:38cemerickalcy: Well, carry on, and feel free to ask questions here; lots of people that know their stuff. :-)
15:39alcycemerick: cool, thanks
15:39cemerickalcy: We refer to various resources along the way in the text, but I'd hope that nothing would be a prerequisite.
15:39mkif I have a map that's a few million entries long, and I want to do map-vals, which I expect to only change 3 values, how might I implement that in a way that doesn't create a brand new and huge map?
15:40alcycemerick: hmm, alright. wonder if its just me who finds the info to be a little dense
15:43SegFaultAX|work2mk: If your only changing 3 values, then it's possible that most of the rest of the data structure will be shared.
15:43SegFaultAX|work2mk: Clojure uses persistent data structures to help ameliorate problems like the one you just outlined.
15:43wkellyalcy: coming from a similar background, I think there's a pretty steep initial learning curve for clojure no matter which book you choose, but there really aren't too many fundamental concepts, so it does not stay too steep for too long
15:44ordnungswidrigis there a path for midje-mode to support nrepl?
15:44ordnungswidrigs/path/patch/
15:44alcywkelly: ah, thanks for the validation :)
15:44mkSegFaultAX|work2: the map-vals implementation I posted above doesn't seem to share that much structure
15:45alcycemerick: thanks for your help too ! kinda like zen & the art of motorcycle maintenance where Pirsig leaves the difficult/dense part for a later chapter ;)
15:45SegFaultAX|work2wkelly: Unless you're new to functional and declarative programming entirely. That might increase the learning complexity.
15:45SegFaultAX|work2mk: Oh? Is it possible you're using the wrong data structure or the wrong algorithm?
15:45SegFaultAX|work2mk: For example. would a zipper be more suitable to your needs?
15:47scriptormk: it doesn't share any structure because theoretically every element could be different
15:47scriptormk: so if you have a a map of entirely different values then of course you won't share any structure, but there's nothing to share
15:47SegFaultAX|work2I see. I don't really know of a good way to side-step that.
15:48SegFaultAX|work2mk: How big is the map in question?
15:50naegI /quit
15:51mkSegFaultAX: I'm imagining a very large map, for example a map of word pair frequencies, or something
15:52amalloymk: map-vals isn't doing any structural sharing, because each key has a new value that it can't predict
15:52scriptormk: you don't really need map-vals if you need to update frequencies or anything like that
15:52amalloypersonally i don't advocate the use of any of the map-* or filter-* functions in useful.map
15:53mkscriptor: what do you suggest?
15:53scriptormk: nothing wrong with assoc
15:54SegFaultAX|work2mk: Why would you only need to update 3 keys in a frequency map?
15:54mkmy general idea is that I might have a large map where I only need to update a few keys. Assoc would do that?
15:54amalloyit's exactly what assoc is for
15:55dnolenwhat is decaf? https://gist.github.com/3491702
15:55TimMcSegFaultAX|work2: Perhaps when new data comes in?
15:55ninjudddnolen: https://github.com/flatland/decaf
15:56mkSegFaultAX|work2: might be adding a 4-word sentence to a large frequency list
15:56SegFaultAX|work2Why does that require map-vals?
15:56mkamalloy: great - is there an impl of map-vals that's better suited for that?
15:57amalloyno, because map-vals is not a tool for doing what you said you need to do
15:57amalloymap-vals iterates the whole map; you have a small number of known keys
15:57dnolenninjudd: ah interesting approach - so it just always a keeps a second JVM ready to go.
15:58tomojninjudd: sounds like a great idea. but how to cleanup the reserve jvms? manually kill?
15:58mkSegFaultAX|work2: not sure, it might not. I don't really remember what case I had in mind earlier. I guess the idea was that you would map-vals over the map, and there's a good chance that only a few would be updated. Like map-vals-when?
15:59tos9a/11
16:01amalloytomoj: i think he already has code to kill them after an hour or whatever length of time if they just sit idle. if he doesn't yet, he will soon
16:02ninjuddtomoj amalloy: haven't written that code yet but i did make an issue https://github.com/flatland/decaf/issues/2
16:02tomojoh, cool
16:11pbostrom_does anyone know of a good "intro to Clojure" slide deck? I found a couple that look pretty good: http://stuartsierra.com/download/2011-09-18-strangeloop-clojure-intro.pdf and http://www.slideshare.net/theceo/introduction-to-clojure-9639369
16:20alcypbostrom_: don't know about slide decks, probably just search on speakerdeck but http://blip.tv/clojure is also full of resources
16:20alcypbostrom_: and infoq as well
16:24FrozenlockIf any of you have 1 or 2 min to spare, could you look at this code https://www.refheap.com/paste/4660 (view the result here http://173.246.15.182:8888, try to click Bar Foo and Zon) and tell me if I'm doing crazy things? I wouldn't want to start my cljs adventure on a bad foot :-)
16:26naegFrozenlock: did you ask on stack overflow for code review already?
16:27nDuffIsn't there a separate StackExchange site for review?
16:27nDuffStackOverflow is more for specific questions
16:27naegnDuff: dunno, but there is: http://stackoverflow.com/questions/tagged/code-review
16:27nDuff..."please review this code" questions tend to get closed quickly
16:27FrozenlockNo, I've never used it and it didn't think it was a question worth of it...
16:27amalloyhttp://codereview.stackexchange.com
16:27nDuff^^ that.
16:28naegoh, but still in beta. You either use that or stack overflow's code-review tag
16:28naegwhy not try it Frozenlock? can't hurt I guess
16:29naeg(sry, new to Clojure too, can't help that much)
16:30Frozenlocknaeg: Sure I'll give it a try
16:30naegFrozenlock: but use that codereview stackexchange
16:31naegthis questions suggest so: http://stackoverflow.com/questions/12098078/how-readable-is-this-line-of-code
16:33FrozenlockOh wow... "To create code blocks or other preformatted text, indent by four spaces:" I wasn't on Emacs, I would cry.
16:34RaynesFrozenlock: copy them all and then ctrl+k
16:34nDuffFrozenlock: There's a javascript button to do that for you.
16:34nDuffFrozenlock: ...so you can select your code in the browser's editor, click the {} symbol, and it does the indent.
16:36FrozenlockRaynes: That's for inline, no?
16:36RaynesI don't think so, no.
16:36FrozenlocknDuff: Indeed... I don't know why I stopped looking once I found the `code' button.
16:36RaynesThere is a command that does it regardless, but what nDuff just said would work too.
16:37emezeskeFrozenlock: I am not sure about this, but I kind of seem to think that things like (js/jQuery.plot) only work by accident, and that you should use (.plot js/jQuery) instead
16:37emezeskeFrozenlock: I could be wrong though.
16:37amalloyhah, i never even noticed SO had wysiwyg-style editor buttons. i just have a keybinding in emacs for "copy all this, and indent it by four spaces"
16:39Frozenlockemezeske: I have found js/jQuery to be working sporadically. I still don't know why :(
16:39casiontechnomancy: rectangle commands are out there for cokeror
16:39emezeskeFrozenlock: What do you mean by sporadic?
16:39casionthere was someone on the IRC channel who implemented them
16:39casionconkeror*
16:40technomancycasion: as a third-party lib?
16:40casiontechnomancy: yes
16:41technomancyhuh; cool
16:41Frozenlockemezeske: Sometimes it works, other it doesn't.
16:41technomancyI wonder if it'd be good enough to merge into mainline
16:42emezeskeFrozenlock: Can you be more specific? Like, what happens when it doesn't work? An exception? A compile warning? Does it ever fail without recompiling, and just refreshing the browser?
16:45bosietechnomancy: are you responsible for clojure at heroku?
16:46technomancybosie: yeah, what's up?
16:46bosietechnomancy: no, nothing. was just wondering if you do ruby or clojure there
16:46technomancyI do a bit of ruby here and there
16:47bosiewhy the heck are you fluent in indonesian/malaysian?
16:48technomancyI grew up in Indonesia
16:48technomancyalso, it's literally the easiest non-artificial language in the world
16:48bosiecool
16:48Frozenlockemezeske: Sure, sorry about that. So if it works for a function, it will always work, but not all function are ok with this. For example, If I want to use the .datepicker from jQuery, I need to call it directly: (.datepicker ($ :#datepicker)). Calling it as I did with the .plot, (js/jQuery.datepicker ($ :#datepicker)) will result in this: #<TypeError: Property 'datepicker' of object function (a,b){return new p.fn.init(a,b,c)} is
16:48Frozenlockfunction>
16:48bosieeasy to say if you grew up there ;)
16:49emezeskeFrozenlock: I think sporadic is not the right word for that. Inconsistent, maybe?
16:49emezeskeFrozenlock: Anyway, I'm pretty sure js/Something.anything is wrong
16:49emezeskeFrozenlock: If you want to call something on the jQuery object iself, (.member js/jQuery)
16:49emezeskeFrozenlock: If you want to call something on a jquery container: (.member ($ thing))
16:50Sgeohttp://nathanaeljones.com/45/clojure-cross-platform-fast-concurrent-concise/
16:50FrozenlockDefinition of SPORADIC
16:50Frozenlock: occurring occasionally, singly, or in irregular or random instances (from merriam-webster)
16:50SgeoWhat's this about edit-and-continue?
16:50FrozenlockI like my words :)
16:50emezeskeFrozenlock: "irregular"
16:50emezeskeFrozenlock: I promise that it works regularly, just not how you expect
16:50emezeskeFrozenlock: Sporadic would be if js/jQuery worked when you ran the code once, but not the next time you ran the same code
16:52emezeskeFrozenlock: Anyway, you want to avoid js/Stuff as much as possible. Wrap js/jQuery in a function, and use that, and never use js/Whatever anywhere else in your code, and you'll be fine
16:53FrozenlockOk, for a particular instance, it's consistent (js/jQuery.plot), but for the usage of js/jQuery it's irregular.
16:53FrozenlockBut what's wrong with it?
16:54FrozenlockShouldn't js/jQuery be able to call ev-e-ry thing?
16:55emezeskeWell, the fact that it does unexpected things seems like a great reason not to use it
16:55emezeskeAnd again, I really don't think js/Thing.member is supposed to work, I think that's an accident
16:55emezeskeAnyway, feel free to not listen to me, I'm just throwing out some suggestions
16:56SegFaultAX|work2emezeske: Why should you wrap js/* in a function?
16:56SegFaultAX|work2emezeske: (I have never used cljs)
16:57FrozenlockHey, I really appreciate, I just didn't want to rely on rule of thumbs.
16:57FrozenlockPlease, feel free to suggest anytime :)
16:58emezeskeSegFaultAX|work2: I just suggest it to keep the code as clojure-y as possible
16:58emezeskeSegFaultAX|work2: js/ is a bit of an escape hatch to JS, and you can do silly things with it -- it's nice to just hide it away and do everything clojure-y
17:00Sgeo,(.toUpper "hm")
17:00clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: toUpper for class java.lang.String>
17:00hyPiRion,(.toUpperCase "hm")
17:00clojurebot"HM"
17:00Sgeo,(map .toUpperCase '("hm" "argh"))
17:00clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: .toUpperCase in this context, compiling:(NO_SOURCE_PATH:0)>
17:00Sgeo,(map #(.toUpperCase %) '("hm" "argh"))
17:00clojurebot("HM" "ARGH")
17:01hyPiRion,(map (memfn toUpperCase) ["hm" "argh"])
17:01clojurebot("HM" "ARGH")
17:01hyPiRion,(doc memfn)
17:01clojurebot"([name & args]); Expands into code that creates a fn that expects to be passed an object and any args and calls the named instance method on the object passing the args. Use when you want to treat a Java method as a first-class fn."
17:01brehaut,(map (memfn toUpperCase) ["hm" "argh"])
17:01clojurebot("HM" "ARGH")
17:02Sgeois there an equivalent for static methods?
17:16tanzoniteblackSgeo: generally I just use the #() for statics
17:16tanzoniteblack,(map #(String/valueOf %) [2 3])
17:16clojurebot("2" "3")
17:17SgeoI'm going to end up learning the Java standard library, aren't I? :/
17:17tanzoniteblackwhat static method do you need?
17:17SegFaultAX|work2Is there a function to get every nth element of a seq given some step. Like the first, third, fifth, seventh, etc.
17:18SegFaultAX|work2Ah, take nth.
17:18magopianguys, i'm pondering at problem 113 on 4clojure at the moment (http://www.4clojure.com/problem/113), but can't find how to tackle it
17:19Sgeotanzoniteblack, I mean, just in general for using Clojure
17:19magopianmay i have a hint on what to use? I'm just a noob in clojure, so i'm believing i'm missing some kind of language construct/feature that would allow some data to be represented differently if it's "str" or "seq"
17:20magopianfor example, using python, i would play with __str__ and __iter__
17:20brehautmagnars: i havent solved that one, but it looks like reify might be a good play to start
17:20tanzoniteblack,(let [my-list '("one" "two" "three" "four")]
17:20tanzoniteblack (map #(nth my-list %) (range 0 4 2)))
17:20clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
17:20tanzoniteblackwhoops, messed that up
17:20tanzoniteblackbut nth will get the nth item from a set
17:20tanzoniteblackand you can use that as a function
17:20SegFaultAX|work2tanzoniteblack: If that's for me, take-nth is a thing.
17:20magopianbrehaut: i think that was for me and not magnars ;) thanks for the tip, i'm going to find some documentation on reify
17:21brehautmagopian: yes. sorry
17:21magopianbrehaut: no problem, thanks for the tip ;)
17:21tanzoniteblackSgeo: the nth thing was for you
17:21tanzoniteblack,(let [my-list '("one" "two" "three" "four")] (map #(nth my-list %) (range 0 4 2)))
17:21clojurebot("one" "three")
17:21Sgeotanzoniteblack, wait, what? why am I being told about nth?
17:21brehautmagopian: you now about the doc command?
17:22brehauts/command/function/
17:22tanzoniteblackno wait...I'm confusing myself now, that was for SegFaultAX|work2
17:22SegFaultAX|work2tanzoniteblack: And see my reply.
17:22magopianbrehaut: i think so (doc reify)
17:22magopianhowever, it doesn't seem to work in the LightTable playground ;)
17:23magopian&(doc reify)
17:23lazybot⇒ "Macro ([& opts+specs]); reify is a macro with the following structure: (reify options* specs*) Currently there are no options. Each spec consists of the protocol or interface name followed by zero or more method bodies: protocol-or-interface-or-Object (methodNa... https://www.refheap.com/paste/4663
17:23tanzoniteblackSegFaultAX|work2: cools, I hadn't seen take-nth before, thanks
17:24mpenetSgeo: not necessarly, there are lua, c, js, gambit scheme, clr, python and probalbly more implementations out there
17:27mpenetAt this point it depends on what you intend to do. Playing with the language, or getting things done, if that is the later the JVM or clojurescript is your best bet for now.
17:27magopianbrehaut: wow, the doc of reify speaks chinese to me ;)
17:27brehauthaha
17:27brehautsorry
17:28ordnungswidrigyou'll understand the doc when you understand reify
17:28magopianbrehaut: however, the doc seems to more or less answer the exact problem stated in 4clojure ;)
17:29magopian(with str and seq ;)
17:29magopiani should be able to work something out
17:29magopianordnungswidrig: that's scary :)
17:29magopianordnungswidrig: and will i understand reify when i understand the doc? ^^
17:29hyPiRionWow, the reify-doc is horrible.
17:30magopianhyPiRion: dunno, i can hardly understand half of it
17:30magopianbut i keep re-reading it, i'll make some sense out of it ;)
17:30hyPiRionmagopian: Look at examples, they give you a better understanding.
17:31ordnungswidrigthe best part: (reify options* specs*) … Currently there are no options.
17:31magopianhyPiRion: yup, thanks for the tip
17:31ordnungswidrigthis is what I call a real optional parameter
17:31ordnungswidrigSgeo: no
17:36magopianmmm i'm going to get some sleep now, i'm sure it'll make more sense tomorrow ;)
17:36SegFaultAX|work2For http://www.4clojure.com/problem/50, is this cheating? (comp vals (partial group-by type))
17:36magopianSegFaultAX|work2: why would it be cheating?
17:36amalloyany solution that works isn't cheating. you heard it here first, folks
17:37magopianamalloy: thanks for 4clojure ;)
17:37magopianit's what drives me to learn more clojure, day after day ;)
17:37magopian(and keeps my brain awake)
17:37SegFaultAX|work2amalloy: It just seems slightly abusive. :)
17:37magopianwell, it's going to sleep now, but you get my point ;)
17:37magopiangood night folkds
17:38Raynesamalloy: I saw something implement the nth problem with '.get'
17:38RaynesI lol'd
17:38amalloynice
17:49hiredmanob
17:58SegFaultAX|work2To do #53 on 4clojure, I've written the following: https://www.refheap.com/paste/4665 Does this seem generally useful? Is there a better way?
18:00FrozenlockAm I a bad person for never using defn- ?
18:01dnolenFrozenlock: no
18:01ordnungswidrigFrozenlock: No, unless you're using (defn ^:private) :-)
18:01RaynesImplying that (defn ^:private ..) is bad?
18:02SegFaultAX|work2Is it functionally different from (defn- ...)?
18:02RaynesNo.
18:02xeqiI don't like to make functions private, but when I do I use (defn ^:private ..)
18:02RaynesAnd it is much more consistent with the rest of Clojure.
18:02SegFaultAX|work2Ah.
18:02Raynesdefn- is more of an artifact of the past than anything.
18:02hyPiRionSegFaultAX|work2: If you generalize it, it would proably be a bit more... general
18:02RaynesWhich is why there isn't any def-, for example.
18:03ordnungswidrigdnolen: is core.logic capable of generating solutions that are lists in a "minimal" way? it's finite domain.
18:03SegFaultAX|work2Is there something wrong with private functions? It seems like keeping your namespace API uncluttered with internal functions is a good thing.
18:03dnolenordnungswidrig: what do you mean?
18:03ordnungswidrigdnolen: so, give a list of chess queen positions such that every field on the board is attacked.
18:04ordnungswidrigdnolen: there are a lot of solutions, some are smaller than others
18:04nDuffSegFaultAX: The place where they annoy me are cases where I want to replace some parts of functionality in 3rd-party code while retaining those which overlap, but where the overlap is all in functions marked private.
18:05ordnungswidrigdnolen: i'm not interested in the theoretical minimum, though. building the constrainst, such that the "first" solution is a small one would do.
18:05nDuffSegFaultAX: ...and with respect to namespace cleanliness, there's an argument to be made that global refers are Doing It Wrong anyhow.
18:05SegFaultAX|work2nDuff: Well if it's private that probably means "internal implementation detail," right? Do wouldn't monkey patching that be pretty bad anyway?
18:05SegFaultAX|work2So wouldn't*
18:06dnolenordnungswidrig: are you specifically interested in an nqueens solution? Martin Trojer did one.
18:07FrozenlockThanks guys, I wasn't expecting so much details :)
18:07SegFaultAX|work2dnolen: That's a pretty compact solution, too.
18:08dnolenordnungswidrig: but perhaps I understand what you are asking ... and I believe the answer is yes. the new core.logic alphas support constraint logic programming over finite domains.
18:08ordnungswidrigdnolen: no, it was only an example. I have a list of devices which have each some properties which values are in a finite domain. I want to generate a set of devices such that 1) every possible value of a single property is covered. 2) every pairwise combination of two properties values are coverred.
18:09ordnungswidrigdnolen: like device1: big, yellow, expensive device2: big, green, cheap, device3: big, yellow, cheep.
18:09ordnungswidrigdnolen: (d1,d2) would cover every property value.
18:10ordnungswidrigdnolen: but for pairwise it would miss a device that is "yellow+cheap"
18:14hyPiRionordnungswidrig: So put differently, given a set of vectors on the form [x_1 x_2 ... x_n], find the minimal solution where every pair [x_a x_b], 1 <= a, b <= n, is contained within the solution.
18:15dnolenordnungswidrig: you could encode those values as integers - I've been thinking about some sugar to make it less tedious.
18:15ordnungswidrighyPiRion: yes, I think this is the formalized variant
18:15ordnungswidrigdnolen: integers would be ok
18:15ordnungswidrigI can map them back later
18:15dnolenordnungswidrig: will have to wait for some refactoring of the constraint solver.
18:15dnolenordnungswidrig: then yes that works just fine.
18:16dnolenordnungswidrig: that's precisely what I did here, http://github.com/clojure/core.logic/blob/master/src/main/clojure/clojure/core/logic/bench.clj#L398
18:17ordnungswidrigdnolen: how would I ensure that a "minimal" solution will be found?
18:19dnolenordnungswidrig: hmm ... I believe there are some ad-hoc tricks for that in CLP(FD) literature. More explicit support may be possible a la Mozart/OZ, but I've got nothing planned in the near future.
18:19ordnungswidrigok
18:19ordnungswidrigI'll dig the literature then
18:20hyPiRionordnungswidrig: It's an interesting problem though, thanks for sharing.
18:20dnolenordnungswidrig: google for "Finite Domain Constraint Programming in Oz. A Tutorial.". Most of my understanding of CLP(FD) and far beyond is from their. Haven't time to dig into - there are some things that need fixing first to tackle even the simplest CLP(FD) problems they talk about.
18:21ordnungswidrigdnolen: ok, thanks!
18:21ordnungswidrigI'll go to bed now. Hammock time, or like that.
18:22dnolenordnungswidrig: I would like a lot of that text to applicable to Clojure. Though the search strategy may be challenging since that's not really covered in the original cKanren design.
18:22ordnungswidrigdnolen: I'd love it!
18:22ordnungswidrigbye!
18:23XPheriorwith-redefs.. It redefines something within the scope of it's calling that macro. But it doesn't seem to redefine it in other namespaces?
18:24XPheriorIE, I redefine the function b to be something else. Within the with-redefs, function a calls b. b appears to be the original b, not the one I substituted in.
18:27XPheriorI guess what I'm asking for is a "global function redefinition"
18:30technomancyXPherior: with-redefs works in terms of vars. if someone has a copy of the original version in a local or some such, there's no way to change it.
18:31technomancyother than to pass around vars instead
18:31XPheriortechnomancy: It's merely calling the other function via namespace. No functions with side effects.
18:31SegFaultAX|work2hyPiRion: Was that about my code post?
18:31XPheriorHow would one "hold onto" a function in Clojure?
18:31XPheriorWell, I guess with def. But I don't see a case where I used that.
18:38technomancythe classic example is with (run-jetty app {:port 8080})
18:38SgeoIt occurs to me that if I keep getting bothered when I see individuals who are crucial to an ecosystem in an IRC channel, I will always be bothered
18:39technomancywith-redefs and recompilation won't be visible to jetty since you're passing the value of app; you have to pass in #'app
18:39XPheriortechnomancy: Go on
18:39hyPiRionSegFaultAX|work2: oh, second.
18:39XPheriorHm..
18:39SegFaultAX|work2hyPiRion: I'm interested in your thoughts on how I could make it better.
18:39XPheriorOkay, I think that puts me on the right track, technomancy
18:40XPheriorI'll be back. Gonna switch out to Linux so I can hack on the problem more.
18:40XPheriorThanks again!
18:40hyPiRionSegFaultAX|work2: So instead of taking 2 elements, namely prev and current, you could take more than 2
18:41hyPiRionLike n-2 n-1 and n.
18:41SegFaultAX|work2hyPiRion: I don't know how to make that very general. The usage I was looking at was something like (take-seq #(= (inc %1) %2) [1 2 3 4])
18:42SegFaultAX|work2hyPiRion: It would return [1 2 3 4]. But if that seq was, say, [1 2 3 5 6 7] it would only return [1 2 3]
18:42hyPiRionSegFaultAX|work2: What would that one return?
18:42hyPiRionoh, okay.
18:43hyPiRionhmm, second
18:43SegFaultAX|work2hyPiRion: So where take-while returns values as long as the predicate is true, take-seq does the same thing but it allows you to work with the current and last value to recognize a sequence.
18:55hyPiRionSegFaultAX|work2: https://www.refheap.com/paste/4667
19:01SegFaultAX|work2hyPiRion: Awesome!
19:03hyPiRionSegFaultAX|work2: It's not perfect though - it cannot take in an infinite seq and return a new infinite seq
19:04hyPiRionThough if it helps you in any way, then I'm glad to be of help :)
19:04SegFaultAX|work2hyPiRion: I wanted mine to work on infinite seqs which is why it's so verbose. But your solution is a lot cleaner and more general than mine.
19:05SegFaultAX|work2partition* are awesome.
19:06wmealing_1SegFaultAX|work2: did you find an built-in function to split a list on a condition (dichotomize-by ?
19:06hyPiRionyeah, partition and partition-all are more powerful than I thought they would be
19:06SegFaultAX|work2wmealing_1: Not a built-in, no.
19:07SegFaultAX|work2wmealing_1: (juxt remove filter) was good enough for my purposes.
19:07hyPiRionsplit-with?
19:07SegFaultAX|work2hyPiRion: Nope.
19:08wmealing_1had me scratching my head for a bit.
19:08hyPiRionHum, okay
19:08hyPiRionOh, yeah, I see.
19:08wmealing_1i ended up writing my own, but i wasn't happy.
19:08SegFaultAX|work2wmealing_1: The only downside is running through the list twice instead of separating it in one pass.
19:09hyPiRion,(vals (group-by odd? (range 10)))
19:09clojurebot([0 2 4 6 8] [1 3 5 7 9])
19:09hyPiRionThe order is scary though
19:09hyPiRion,(vals (group-by even? (range 10)))
19:09clojurebot([0 2 4 6 8] [1 3 5 7 9])
19:09hyPiRionSo scratch that.
19:10SegFaultAX|work2hyPiRion: Yea. This was for a quicksort so I wanted to have all the numbers >= pivot separated from the rest.
19:11SegFaultAX|work2hyPiRion: My initial solution started with a group-by. The juxt one was better, minus the aforementioned speed penalty.
19:11SegFaultAX|work2(Better in terms of code size.)
19:12amalloySegFaultAX|work2: shouldn't take-seq just use partition?
19:13hyPiRion,(separate odd? (range 10))
19:13clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: separate in this context, compiling:(NO_SOURCE_PATH:0)>
19:13SegFaultAX|work2amalloy: How do you mean? I wanted it to be able to recognize arbitrary sequences, not just increasing or decreasing.
19:13XPheriorHey technomancy. The function I'm trying to redefine in used by a route in Compojure's defroutes macro. It must be hanging onto the value of the function that I told it to call when it hits the respective route, huh?
19:14amalloy&((fn take-seq [pred coll] (map second (filter (partial apply pred) (partition 2 1 coll)))) #(= %2 (inc %1)) [1 2 3 5 6 9])
19:14lazybot⇒ (2 3 6)
19:15SegFaultAX|work2amalloy: That's not correct.
19:15technomancyXPherior: yeah, just using a var instead should do the trick
19:15amalloyit matches your docstring
19:15XPheriortechnomancy: Hm? Instead what?
19:16technomancyinstead of the value of the var
19:16amalloyif you want to include the 1 at the front, then you can do the three-arg vs two-arg thing, but i was just demonstrating using partition instead of lazy-seq
19:16SegFaultAX|work2amalloy: Then my docstring sucks. For context I was working on 4clojure #53
19:16SegFaultAX|work2amalloy: Longest subseq of increasing integers.
19:16SegFaultAX|work2amalloy: Yours does not return the correct answer.
19:17XPheriortechnomancy: Yeah, that seeems correct. I don't see how to be able to override it for testing though. Is it just not possible? Sorry, my understanding is a little fuzzy here.
19:18SegFaultAX|work2amalloy: Did you catch hyPiRion's solution? https://www.refheap.com/paste/4667
19:18SegFaultAX|work2amalloy: I'm still looking for a good way to implement the general take-seq/take-while-partition "take the longest contiguous sequence given some predicate" function.
19:19XPheriorOh technomancy, sorry I read that wrong. Makes more sense now.
19:26amalloySegFaultAX|work2: useful.seq/glue has a pretty thorough implementation of that sort of "split a sequence up into N chunks" idea, although it's so flexible it's a bit unwieldy to use in most real-life cases. https://gist.github.com/3493313 has an example usage, and docstring is at https://github.com/flatland/useful/blob/develop/src/useful/seq.clj#L193
19:33hyPiRionAh, SegFaultAX|work2, https://www.refheap.com/paste/4669 works on infinite lists too.
19:35XPheriorWhy would something like with-redefs [#'ns/func substitute-fun] throw lojure.lang.PersistentList cannot be cast to clojure.lang.Symbol
19:35XPheriorWerd
19:36amalloy&(doc with-redefs)
19:36lazybotjava.lang.SecurityException: You tripped the alarm! with-redefs is bad!
19:36amalloy,(doc with-redefs)
19:36hyPiRionhaha
19:36clojurebot"([bindings & body]); binding => var-symbol temp-value-expr Temporarily redefines Vars while executing the body. The temp-value-exprs will be evaluated and each resulting value will replace in parallel the root value of its Var. After the body is executed, the root values of all the Vars will be set back to their old values. These temporary changes will be visible in all threads. Useful for mockin...
19:36amalloyXPherior: read the docstring
19:37XPherioramalloy: I have many times. =/
19:37XPherior#' returns a var, as far as I understand. Passing that in as the first element in the vector should be fine
19:37amalloywhat do you suppose var-symbol means? i would bet money that it means "this should be a symbol"
19:38XPheriorI suppose that makes a bit more sense. But, when I do that, I just get that 'cons cannot be cast to symbol'
19:38XPheriorI mean, when it says it rebinds vars, it seems like it wants a var to target.
19:39Apage43it does (var) aka #' internally.
19:40Apage43https://github.com/clojure/clojure/blob/d0c380d9809fd242bec688c7134e900f0bbedcac/src/clj/clojure/core.clj#L6589
19:40XPheriorI can't just pass in the function value, because as technomancy were talking about earlier.. Another function already has the value of that function. I'd need to redefine the function at the var level
19:41Apage43with-redefs is a macro, so you're passing it symbols, not values
19:46FrozenlockI've stumbled uppon this nice little function in a C2 demo code: (defn evt->key [e] (get {13 :enter} (.-keyCode e))) Is it the idiomatic way to get a keypress?
19:47Frozenlock
19:47dnolenFrozenlock: yes
19:48Frozenlockdnolen: thank you
20:01SegFaultAX|work2amalloy: Awesome, thanks for the tip. I hadn't heard of useful until now.
21:18cjfriszEverybody must be hard at work here
21:20stankleycjfrisz: Very much so...
21:22cjfriszSeeing as though I broke my parser last night and it's still mad at me, I should probably be harder at work
21:27FrozenlockAh crap, I think I opened a can of worms.
21:28Frozenlock-=keyCodes=-
21:28uvtcHey, where did all these worms come from? ... Frozenlock!
21:31cjfriszMan...sometimes I think Clojure has too few parentheses
21:31shaungilchristahaha
21:32cjfriszTake "cond" for instance
21:32Frozenlockcjfrisz: Yeah, I don't feel the rush of adrenaline caused by closing 20 parentheses! ))))))))))))))))0
21:33cjfriszScheme has an extra set of brackets around each clause
21:33cjfriszThis makes indent functions in text editors much happier if you need to make a line break after the test
21:33shaungilchristI like to accelerate as I type them so it's literally a rush
21:49FrozenlockBefore I waste a night trying to make some hotkeys functions for cljs, does anybody know if there's already a library for this? (in cljs)
21:59RaynesFrozenlock: Why does it have to be in cljs?
22:03FrozenlockIt could also be in google closure (I haven't found one). If I understand correctly, google closure or cljs are what is required to be able to use the compiler efficiently.
22:31Spaceghostc2cPlease sir, may I have some clojure?
22:34cjfriszSpaceghostc2c: ...yes?
22:34Spaceghostc2ccjfrisz: I think my british accent was off.
22:34cjfriszOh!
22:34cjfriszSpaceghostc2c: More?
22:34cjfriszSpaceghostc2c: You want *MORE*??
22:34lazybotcjfrisz: What are you, crazy? Of course not!
22:36Spaceghostc2cWell done gents! We'll be here all week.
23:06emezeskeFrozenlock: You can use any javascript library you want from cljs, as long as you provide an :externs file
23:07emezeskeFrozenlock: (The :exterms file lets you compile with :advanced optimizations)
23:10Frozenlockemezeske: But the extern files won't be included in the generated js?
23:10Frozenlock(that might not be a big deal)
23:11emezeskeFrozenlock: This probably will answer your question: http://lukevanderhart.com/2011/09/30/using-javascript-and-clojurescript.html
23:11FrozenlockThanks!
23:45TimMcFrozenlock: Man, who even types closing parens?
23:45TimMcThat's so... without paredit. :-P
23:46cjfriszSo...I used to use paredit
23:46tomojthat's surprising
23:46cjfriszAnd I had a couple of very prolific Schemers convince me that it can be detrimental to hacking out scraps of code
23:47cjfriszThere are things I miss about it, but I think I am overall happier
23:47cjfriszYou inherently get corralled into writing your code in a particular way when you use tools like paredit that force structure on your coding while you're in the process of writing it
23:48uvtcTimMc: I have not yet drank of the paredit coolaid. I kinda' like watching those matching parens light up when I type the closing ones. :)
23:48cjfriszThere's nothing necessarily wrong with it, but it is something I hadn't thought about when I started using it
23:48cjfriszuvtc: I totally drank the paredit coolaid at first ;-)
23:48arohner_cjfrisz: it convinces you to *type* your code in a different way, but I'm reasonably sure I'm net productive on it
23:48FrozenlockTimMc: Yeah, paredit is among the numerous tools I've yet to try.
23:49arohner_never having misbalanced parens has definitely improved my flow
23:49cjfriszarohner_: Mileage may vary
23:49cjfriszarohner_: I don't doubt that you are very productive, and you may even be moreso than me
23:49tomojyou get corralled into writing your code in valid forms
23:49tomojhow could that be a bad thing?
23:49eggsbydid anyone itc finish stripes CTF and mind lending a hint ?
23:49emezeskecjfrisz: You get corralled into writing code that has balanced and structurally correct paranthesis, but that's about it
23:50emezeskeEvery time you balance parens manually, God kills a kitten and replaces it with a slightly less productive kitten
23:52FrozenlockEh, the time I waste writing parens in clojure is negligible.
23:52FrozenlockI waste way more time by being stupid.
23:52Frozenlock\o/
23:52tomojit's not just auto-balancing
23:53uvtcMight save my right pinky some fatigue though ... not having to reach for that closing paren. :)
23:53tomoj(and you must also count the time spent dealing with balance errors)
23:53emezeskeTell me this: do you literally count the number of parens at the end of a function sometimes? And that doesn't drive you bats?
23:53Frozenlock(show-paren-mode)
23:54emezeskeStill, you're basically counting. Keep moving the cursor until the paren you want is highlighted, right?
23:54uvtcI never count ... just let Emacs show me the matching one. It smartly highlights it when the cursor is just after the closing one.
23:55FrozenlockYes.
23:55FrozenlockI can has bad methodz?
23:55emezeskeTo each his own.
23:55TimMcYou don't have to use it, but you do have to try it.
23:56cjfriszemezeske: That's really the crux of it
23:56cjfriszI used to have a workflow that jived with paredit
23:56FrozenlockYes it's on my todo list. This and elnode are on the top.
23:56uvtcWill try it, at some point ... just need to get this program working ...
23:56cjfriszAnd then I worked with some people who showed me a workflow where paredit kinda got in the way
23:56emezeskecjfrisz: Like what?
23:56cjfriszAnd for now I use the latter
23:56TimMcIt's more than paren balancing -- it is structural editing. Kill a whole form at a time, or transpose it with another, or convolute them...
23:56emezeskeI cannot possibly see how it could get in the way.
23:57tomojcjfrisz: any possibility you can give an example?
23:57FrozenlockTimMc: To select forms I like expand-region.el
23:57TimMcIt's hard to give examples, since code evolves in weird ways.
23:57emezeskeYou can always shut paredit off temporarily while you do some crazy pasting, and then turn it back on
23:58Frozenlockhttp://emacsrocks.com/e09.html
23:58cjfriszMaybe it's less that it gets in the way and more that it's just not helpful
23:58cjfriszI've started writing more of an unfinished scrap here, moving on, and then coming back to the unfinished bits
23:59emezeskeI refuse to believe that it's more productive to write in units of not-even-structurally-correct code.
23:59cjfriszI found it more helpful when there were no scraps; only plunking out complete thoughts at a time
23:59cjfriszemezeske: That's fine; you don't have to