#clojure logs

2012-05-30

00:14johnmn3how do you conj on to the end of a vec?
00:15johnmn3wait
00:18johnmn3conj'ing on a vector adds it to the end, right?
00:20johnmn3,(conj (map #(inc %) [1 2 3]) 9)
00:20clojurebot(9 2 3 4)
00:21johnmn3so it turns into a lazySeq?
00:22johnmn3okay, that fixed it
00:56arohnerjohnmn3: conj adds an item to the collection wherever it is fastest. so yes, it adds to the end of vectors, and the beginning of lists & lazy seqs
00:56johnmn3k
03:04squidsouphey there, would anyone be willing to share their opinion on web development in clojure? Is Noir generally the most popular framework, or is it considered more idiomatic to assemble libraries like Ring, Hiccup?
03:05Dvyjonessquidsoup: I don't know what's more common, but I just made something with ring, compojure and enlive, and it seems nice. My app is pretty tiny, though.
03:08squidsoupDvyjones: yeah, from the reading I've been doing that seems to be the 'clojure' way, rather than using a full stack framework. I'm used to Rails, so it's a bit of a departure for me.
03:11Dvyjonessquidsoup: I'm coming from Rails too, and it is quite a change. It's actually not too tricky once you get started though. All you really lose is the "magic" of, say, routing. So instead of saying "route / to foo-action on bar-controller" you say "route / to call this function".
03:11Dvyjonessquidsoup: Here's my (probably horrible) little app, if you want an example: https://github.com/cluenet/server-list/blob/master/src/server_list/server.clj
03:11squidsoupoh cool, thanks Dvyjones
03:18wei_johnmn3: yes. pretty sure conj is what you're looking for
03:22amalloynoir is a perfectly-acceptable "magic-included" option. personally i prefer to glue together hiccup, ring, and compojure myself, but i don't really have a good reason
03:38Raynessquidsoup, Dvyjones: Noir is pretty popular these days. It is a bit higher level than compojure and ring (and is in fact built on them). It has a lot of the bells and whistles you want (validation, encryption, session management, etc) but isn't a "framework" as much as it is a library or set of libraries for easily creating large and/or small websites.
03:39ejacksonRaynes: can you tell me the difference between a framework and a library ?
03:39ejacksonis its simply perfective: you put your stuff in a framework, but you but a library into your stuff ?
03:40DvyjonesYou call a library, a framework calls you. That's basically how I separate the two.
03:40ejacksons/perfective/perspective/
03:40Dvyjones(Not completely true, but makes sense to me)
03:40Raynesejackson: Go look at rails and then go look at noir.
03:40ejacksonyeah, that amkes sense to me
03:40ejacksoni've used both
03:41RaynesNoir is a libwork. :P
03:41ejackson:)
03:41ejacksoni was watching bradford cross's vid yesterday
03:42ejacksonhe was also riding this horse about small, composable abstractions
03:42ejacksonand then presented bucket which looked a bit big
03:42ejacksonso i'm trying to figure it all out
03:43ejacksonso i don't go and do stupid things
03:43ejacksoni guess the interface of bucket is 'small' although what it covers is large
03:44kralnamaste
03:44ejacksonnamaste
03:45ejacksonand good luck
04:16tomojcan you access the old state in a validator?
04:19amalloy&(doc set-validator)
04:19lazybotjava.lang.RuntimeException: Unable to resolve var: set-validator in this context
04:19amalloy&(doc set-validator!)
04:19lazybot⇒ "([iref validator-fn]); Sets the validator-fn for a var/ref/agent/atom. validator-fn must be nil or a side-effect-free fn of one argument, which will be passed the intended new state on any state change. If the new state is unacceptable, the validator-fn should ... https://www.refheap.com/paste/2923
04:19amalloylooks like no
04:22tomojwell (swap! a #(when-not % (update %))) will work I guess
04:25clgvdoes the metadata ^{:once true} has an effect on the definition of a deftype?
04:25clgvfor repl use I would love to have defonce semantic for a specific deftype
04:25tomojactually
04:25tomoj(set-validator! a (complement (comp deref (constantly a))))
04:26tomojis that bad?
04:26tomojbesides style.. I couldn't think of a pointy represent I liked..
04:26tomojs//ation/
04:26clgv^{:once true} seems not to work on a deftype.
04:27tomojyou could define deftypeonce as a workaround? :(
04:27clgvtomoj: that validator looks weird
04:27clgvtomoj: what do you want to check?
04:28tomojoh
04:28tomoj(set-validator! a (fn [_] (not @a)))
04:28clgvtomoj: try (set-validator! a not) instead
04:29tomojno
04:29clgvor is that the old state you want to access?
04:29tomoj@a there (in my tests so far) returns the old state
04:29clgvah well...
04:29tomoj(def a (atom nil))
04:30tomoj(this could be (atom)..)
04:30clgvyou want to set the atom only once?
04:30tomojright
04:30tomojwell
04:30clgvthat sounds like a weird use case for an atom
04:30tomojthat actually allows them to reset nil multiple times
04:30tomojor false
04:30tomojbut I don't cre
04:30tomoj(fn [_] (nil? @a))
04:31tomoj(comp nil? defer (constantly a))
04:31tomojso how do you do this without an atom?
04:32tomojhmm
04:32tomojyeah
04:32tomojI want my own deftype anyway
04:33clgv tomoj: there is promise & deliver
04:33tomojyeah
04:33tomojcljs has no promise though
04:33clgvoh. didn't know you were in cljs.
04:34clgvyou code port promise & deliver to cljs ;)
04:34tomojand I am thinking about non-blocking promises
04:34tomojso "promise" from clj doesn't really apply
04:34clgvok
04:34tomojcljque has what I want, they seem to use atoms inside
04:35tomojwith (swap! v (fn [[supplied? & _ :as state]] (if supplied? state (conj state f))))
04:35clgvtomoj: but you can take the clojure source for promise&deliver as inspiration
04:35clgvit's pretty easy to read
04:36tomojoh, it uses an atom too
04:36clgvyep
04:37clgvand in clojure 1.3+ you can query whether it is realized...
04:37tomoj(compare-and-set! a nil x)
05:48DvyjonesHow do I conditionally change all values in a map? I want to change "TRUE" values to true, "FALSE" to false, and leave all others. I have this so far: https://gist.github.com/53a6179953dee821e16b
05:48DvyjonesBasically, I just need to convert ([:foo "bar"] [:bar "foobar"]) back to {:foo "bar" :bar "foobar"}.
05:50DvyjonesAh, (into {} ...).
06:08ordnungswidrigDvyjones: there's also fmap to apply map on map values. and the cond can then be replaced with (get {"TRUE" true "FALSE" false} v v)
06:09Dvyjonesordnungswidrig: fmap? Doesn't show up in the API docs?
06:11clgvDvyjones: it's probably clojure 1.4
06:13clgvDvyjones: it's not fmap I guess - he probably meant reduce-kv in clojure 1.4
06:14clgv&(clojure-version)
06:14lazybot⇒ "1.4.0"
06:14Dvyjones Ah, thanks :)
06:14clgv,(doc reduce-kv)
06:14clojurebotI don't understand.
06:15clgv&(doc reduce-kv)
06:15lazybot⇒ "([f init coll]); Reduces an associative collection. f should be a function of 3 arguments. Returns the result of applying f to init, the first key and the first value in coll, then applying f to that result and the 2nd key and value, etc. If coll contains no en... https://www.refheap.com/paste/2924
06:15tomojhow is IDerefWithTimeout supposed to work in cljs?
06:16clgv,(clojure-version)
06:16clojurebot"1.4.0-master-SNAPSHOT"
06:16clgvpoor bot^^
06:19tomojoh, deref doesn't even call -deref-with-timeout
06:25clgvtomoj: yeah. plain deref blocks
06:25clgv tomoj: err no, in clojure 1.3 it has two arities
06:26tomojcljs, so can't block
06:27clgvhmmm this part of the language seems to diverge heavily
06:42tomojin cljs master, the defcurried macro is defined (private) in src/clj/cljs/core.clj, but it is used in src/cljs/clojure/core/reducers.cljs
06:42tomojis that somehow correct?
06:43clgvtomoj: does reducers.cljs have a proper namespace?
06:45tomojyeah
06:45tomojclojure.core.reducers
06:46tomojwhich is where defcurried is defined in clojure itself..
06:46rkzcljs reducers? how does that work? webworkers?
06:46clgvok. then I guess all reducers in cljs are macros?
06:46tomojrkz: no, fork/join related stuff is commented out
06:47rkzah but we could hack webworkers in it's place
06:47rkzif supported
06:49clgvtomoj: hmm that source folder is confusing anyway...
06:51tomojrkz: seems so
06:57rkzonly annoying thing is that webworkers expect a single js file
06:58rkzcant pass first class function in
06:58tomojhmm
06:59tomojseems like you could work around
07:00tomojactually, I dunno
07:00rkzi don't know gclosure well enough to figure it out. might have a bash later
07:03tomojcouldn't you just send the webworker your compiled js file, with fn.toString() appended to the end?
07:04tomojor you have to give a url?
07:05rkzi think it needs a url
07:05rkzbut hackable to accept a string
07:05rkzhttp://stackoverflow.com/a/10372280/44252
07:05tomojoh, http://www.html5rocks.com/en/tutorials/workers/basics/#toc-inlineworkers
07:07tomojcan you get the source of the script you're in anyway?
08:31dsrguruanyone know if there's a way to render hiccup's html output with indentation and whitespace
08:31rkzI think that's by design
08:32dsrguruI'd like to use the compressed form for production, but it's not very readable while developing
08:32rkzdsrguru: you could try to put the output through jtidy
08:34twhumeHi. I'm trying to get to grips with gen-class, as per the little tutorial at http://kotka.de/blog/2010/02/gen-class_how_it_works_and_how_to_use_it.html … but when I cut and paste the examples from that page into the REPL, I get an error CompilerException java.lang.RuntimeException: java.lang.ClassNotFoundException: some.Example, compiling:(NO_SOURCE_PATH:1) ...
08:35twhumeIs there a good beginner's tutorial for gen-class out there which I should refer to instead? Or does this point to a problem with my environment (Eclipse+counterclockwise, Clojure 1.3)?
08:35dsrgururkz: I might do that if there's no builtin way, thanks
08:38clgvtwhume: do not paste it in the repl but write the source file that is described
08:38twhumeThanks clgv. Why does that make a difference? Does gen-class rely on having a source file it can compile, behind the scenes?
08:39clgvtwhume: I dont think so. but you make sure that the namespace is right.
08:39twhumeok, thanks.
08:40clgvtwhume: what for do you need it? you know the other options?
08:40twhumeI want to access a class method of ClassLoader from my Clojure code. I was thinking of using gen-class to generate a Java class from Clojure which would expose this method… I guess one alternative would be to use proxy?
08:42clgvtwhume: so you want to derive from classloader to expose a private method?
08:43twhumeI'm trying to instantiate a class from an array of bytes; there's a method to do that in ClassLoader. Hmph, why aren't I just instantiating ClassLoader...?
08:43clgvtwhume: you may not even need to instanciate one. you can get the contextclassloader from the current thread for example
08:58twhumeHmm, so now I have the following class. It throws IllegalArgumentException saying there's no matching method found for defineClass. I've checked the types of each parameter and they match the method signature in the javadocs. Any ideas?
08:58twhume(defn load-class "" [name bytes]
08:58twhume (let [cl (ClassLoader/getSystemClassLoader)]
08:58twhume (. cl defineClass name bytes 0 (int (count bytes)))))
09:02devntwhume: please use a pastebin like github gist if you need to post multi-line stuff
09:02twhumedevn: sure, sorry.
09:02devn(or (inline it))
09:10hoeck1twhume: defineClass is protected
09:11hoeck1twhume: only usable from within derived classes
09:11twhumeface palm. OK, so I do need to produce a proxy class or similar to override and expose it…
09:22tomojcould core.logic relations be made asynchronous?
09:29dnolentomoj: what do you mean?
09:31matthavenerlike a multithreaded eval of a 'q'?
09:31tomojnot sure exactly
09:32tomojI'm vaguely imagining relations operating on future seqs
09:32dnolentomoj: no following :)
09:32tomoj(a future seq is an async promise for a cons of an element and another future seq)
09:33dnolenmatthavener: prototype for that exists in the main repo under fork-join branch
09:33matthavenerdnolen: oh, awesome, this core.logic stuff continues to blow my mind
09:33matthavenerlogic programming in general i should say
09:34tomojso (conj fseq 1) is like (deliver fseq [1 (promise)]) where the (promise) is the new tail of the future seq
09:34tomojbut cljs, so you can't block for a promise
09:34dnolentomoj: still trying to understand the "why?" here
09:34tomojI haven't got there yet
09:36tomojon the top of the why stack is running logic programs on streams of facts and getting a stream of results
09:38locojayhi what csv should i use data.csv or clojure-csv?
09:43tomojI only skimmed over TRS
09:43tomojmy thoughts about logic programming are likely incoherent :)
09:43tomojshouldn't clojure.core.reducers also provide a reduce-kv?
09:44tomojit seems strange that clojure.core.reducers uses map? to decide whether to reduce-kv
09:47bobryi wonder why there's still now 'out of the box' way of converting clojurescript structures to js?
09:47tomojI could just implement IMap (which only requires dissoc) to get core.reducers/reduce to reduce-kv something, but I don't think IMap makes sense for everything reduce-kv is useful for
09:48dnolenbobry: there is no sensible conversion
09:49tomojmaybe reduce-kv does only make sense for maps
09:49bobrydnolen: well, at least maps can be coerced to Objects
09:49dnolenbobry: they cannot, complex keys
09:49bobryah, right ...
09:50bobryI guess I can just use js-obj with a list of k-v pairs :)
09:50dnolenbobry: yes, that's what it's there for.
09:51bobrythanks!
09:56mmarczykdnolen: ping
10:05tomojsuppose (rest coll) returns an IDeref and @(rest coll) returns an ISeq
10:05tomojis coll broken?
10:05tomojas an ISeq
10:05tomojwell, yeah, ofc
10:15hcumberdaleis there a ring cache middleware for cache expiration headers in the response?
10:16dnolenmmarczyk: pong
10:17mmarczykdnolen: thanks for setting me straight re: truth_
10:17mmarczykdnolen: replying to your comment
10:17mmarczykdnolen: ...now
10:17hcumberdale^^
10:18mmarczykdnolen: comment posted
10:19dnolenmmarczyk: sounds good!
10:19mmarczykdnolen: great
10:19mmarczykdnolen: at some point in the near future I'd like to finish the patch for putting all protocols on the fast path... that could make things easier I think
10:19dnolenmmarczyk: you were right about satisfies? not generating truth_ sorry I wasn't clear about that.
10:20dnolenmmarczyk: it's just that the last if of a cond will emit a null breaking boolean inference.
10:20mmarczykdnolen: right
10:21mmarczykdnolen: I wonder if cond could special-case truthy literals and just skip the final clause... but that's another issue
10:22ro_stshould my emacs slime clojure exception stacktrace ever show any locals when i expand a stack item?
10:22dnolenmmarczyk: or we perhaps could improve inference - return a set representing the types returned.
10:23dnolenif can remove check if that set is a subset of #{boolean nil}
10:23mmarczykdnolen: that would be great!
10:23mmarczykit's pretty amazing how much of a win type inference is
10:24dnolenmmarczyk: I'm not totally sure that would eliminate the extra fn.
10:24dnolenmmarczyk: remember that satisfies will be almost always embedded in (if ...)
10:25dnolenmmarczyk: so generated code may be complex enough that Closure won't touch it.
10:25dnolenmmarczyk: this was a big problem with old next, two satisifies? calls was enough for Closure to leave the no arg functions alone.
10:25mmarczykdnolen: incidentally, the most annoying issues for this particular patch come up in connection to (surprise, surprise) the string/String etc. duality -- I have a hunch that that'll be a problem for putting all protocols on the fast path :-(
10:25mmarczykdnolen: that is unfortunate
10:26dnolenmmarczyk: it just means we have to write better code :) INext simplified many things and made things faster.
10:26mmarczykdnolen: idiomatic code might be a bit carefree when it comes to Boolean expressions
10:26mmarczykand the like
10:27hcumberdaleamalloy_ ^^
10:27dnolenmmarczyk: yeah the js/String prototype modification for keyword invocation sucks.
10:27mmarczykdnolen: INext is great, yeah :-)
10:27dnolenmmarczyk: been pondering it's removal but I think that would be a bit of work.
10:28dnolenmmarczyk: true about other people being more carefree - doing our own lifting, unwrapping is something we'll get to all in good time I think.
10:29dnolenlynaghk`: ping
10:30lynaghk`dnolen: morning, what's up?
10:30mmarczykdnolen: lots of fun to be head in ClojureScript dev for months to come :-)
10:30dnolenlynaghk`: did you see Brian Taylor's perf graphs?
10:31mmarczykand years, I'm sure.
10:31lynaghk`dnolen: yep, looks pretty boss. It's the direction I wanted to go it but haven't for lack of time
10:32dnolenmmarczyk: hah, probably tho I think by the end of this year we will probably run out of the big optimizations :)
10:32dnolenmmarczyk: lynaghk`: looking forward to seeing Clojure JVM as a baseline on those graphs. Would like to show that off at Strange Loop :)
10:32mmarczykdnolen: :-D
10:33lynaghk`dnolen: there's plenty of time for that to come together. I'd be happy to build more of an interactive web UI on top of that kind of data too
10:33dnolenlynaghk`: that would be sweet!
10:34mmarczykdnolen: we might have some new hosts to worry come end of summer though :-)
10:34lynaghk`dnolen: I actually took some time to use my cljs perf stuff to try and profile/optimize some of the C2 internals. I actually ended up splitting the super DOM intesive stuff out into a CoffeeScript lib.
10:34mmarczyk^worry about
10:34mmarczykI mean, I'm looking forward to being worried in this way :-D
10:34hcumberdaleis there a library for this in clojure: http://www.askapache.com/htaccess/apache-speed-cache-control.html#Add_Cache-Control_Headers
10:35lynaghk`which, evan did some great work to add cljsbuild support for automatically picking up libs & externs
10:36mmarczyklynaghk`: the split was due to cljs perf being less than handwritten Java/CoffeeScript, right?
10:36hcumberdalewrap-file-info does not set cache headers
10:38lynaghk`mmarczyk: yes. I rewrote Hiccup in CoffeeScript because the vector traversal was slow. Also the regular expression fns were much slower than native JS, which I was surprised about.
10:39lynaghk`well, not vector traversal being slow---mostly all of the checks and attribute merging and such.
10:39dnolenlynaghk`: ah merging maps?
10:40brainproxyanyone familiar with the Conway examples in the Cloj Prog book from O'Reilly, have a min for a question?
10:40mmarczyklynaghk`: would you have the time to put together a list of top pain points? would be worthwhile optimization targets
10:40dnolenlynaghk`: regex fns are slower than native JS - in CLJS they return vectors.
10:40dnolenlynaghk`: what mmarczyk said
10:41mmarczyklynaghk`: also, did you switch to arrays for the hiccup-in-coffee? if so, have you tried doing the same thing in cljs?
10:42lynaghk`mmarczyk: the latest few commits of my cljs-profile project has the pain points I ran into. There wasn't a single particular thing that stood out aside from the regex.
10:42lynaghk`mmarczyk
10:42lynaghk`mmarczyk: yeah, singult (hiccup-in-coffee) takes JS arrays. There's a clojurescript API that just does clj->js conversion and then passes to the coffeescript
10:43lynaghk`the reason for the port was just because speed was crucial (working on a mobile app), not that cljs was unusably slow in any way.
10:43mmarczyklynaghk`: I wonder if writing hiccup-on-arrays in cljs would be on a similar level perf-wise
10:43cemerickbrainproxy: Happy to help, but I'll be leaving in a minute. Maybe post the question to the Clojure ML, and one of us can pick it up there?
10:44dnolenmmarczyk: lynaghk`: gotta run for a bit. I recommend forking Brian's benchmarks and adding lynaghk's cases so we can investigate.
10:44lynaghk`dnolen: cya.
10:44mmarczykdnolen: bye
10:45lynaghk`mmarczyk: yeah, it's possible--basically have the first hiccup fn convert its argument to a js array and do all of the manipulation on that?
10:45mmarczyklynaghk`: right
10:45mmarczyklynaghk`: or just expect user code to provide args in the form of arrays, or provide for both usage patterns
10:47lynaghk`mmarczyk: can't do that--the best part about hiccup is that you just feed it literals
10:48lynaghk`mmarczyk: Take a look at the diffs of this file to see what I tried for perf improvements if interested: https://github.com/lynaghk/profile-cljs/blob/master/src/cljs/c2_benchmarks/hiccup.cljs
10:48mmarczyklynaghk`: ah, right, you're doing conversion before passing stuff to coffee
10:49mmarczyklynaghk`: will have a look, thanks! (in fact, browsing the git log now... will need to finish some other stuff before really diving in though)
10:50brainproxycemerick: sure, mailing list is a good idea; in a nutshell, I've dran conclusion that in cell-block func for the index-free stepper, (window (map vector left mid right)) is equivalent to (window (repeat nil) (map...))
10:50brainproxy*drawn
10:50brainproxyand I'm wondering if that is correct
10:50lynaghk`mmarczyk: yeah, do it to satisfy your personal curiosity only. It's not by any means a blocking issue for us, since I just dropped to CoffeeScript.
10:50brainproxycorrect conclusion I mean
10:51mmarczyklynaghk`: sure, no worries
10:52cemerickbrainproxy: Don't know off the top of my head. Been a couple of months since I looked at that code. :-) Definitely post to the list.
10:52brainproxycemerick: cool, will do :)
10:52mmarczyklynaghk`: still, I'd rather you didn't have to do it -- will be interesting to see what can be done about that at this stage
10:52brainproxycemerick: the conway and maze examples are really challening! haven't been challenged by an oreilly book in that way, probably every
10:52brainproxy*ever
10:53cemerickbrainproxy: Those are almost entirely due to Christophe. :-) Glad you're enjoying the book.
10:54lynaghk`mmarczyk: there's always going to be some amount of overhead. At least, until you write some kind of insane whole-program optimization stuff that is smart enough to realize that it can use mutable JS-objects here and JS-arrays there.
10:55borkdudecan you read a version number from defproject inside let's say a core.clj of a leiningen project?
10:55borkdudein an easy way
10:56borkdudehmm
10:56borkdudethat would not work if the project was deployed probably
10:56TimMcRight.
10:57TimMcYou could alter the packaging to add the version to the manifest, though.
10:57mmarczyklynaghk`: in general, sure, but some types of code (explicit use of arrays, fully deducible fn arity stuff etc.) should be very nearly equivalent to JS
10:57borkdudeTimMc so like this? https://github.com/trptcolin/reply/pull/63#issuecomment-6011538
10:58borkdudeTimMc I guess you have to so some ~ expression in defproject?
10:58SurlyFrogare `finally` clauses really just used for side effects?
10:58lynaghk`mmarczyk: I would love to see your attempt at a hiccup compiler; the algorithm I'm using is pretty simple/understandable (I hope) =)
10:59TimMcborkdude: Not sure what the right approach is.
10:59TimMcAnd uberjar'ing "reply" would probably destroy any manifest info...
10:59ystaelMy project.clj has [org.clojure/clojure "1.4.0"] as a dependency, but both lein-swank and "lein repl" start a version 1.3.0 repl. What might I be doing wrong?
11:00borkdudeTimMc right, so having a version.clj is probably the best
11:00SurlyFrogif a function is passed to `send` or `send-off`, and it ends with a finally clause, can I assume that the agent has been updated before the finally clause runs?
11:01TimMcOh! You could use (load "src/.../version.clj") from project.clj and also load it from something in src/.
11:01TimMcYeah, that might work...
11:01mmarczyklynaghk`: I'll give it a shot :-)
11:03borkdudeTimMc you can just put a load before defproject?
11:03TimMcI think so.
11:03TimMcArbitrary code.
11:05borkdudeok cool
11:07dribnetwhat do i use instead of map if i have a collection of functions and one piece of data to pass to each?
11:10TimMcWhy not map? :-)
11:10TimMcOh, juxt.
11:11dribnet(foo [even? odd? big? small?] 3) => [false true false true]
11:11dribnetsolve for foo :)
11:11TimMc&((apply juxt [even? odd? big? small?]) 3)
11:11lazybotjava.lang.RuntimeException: Unable to resolve symbol: big? in this context
11:12TimMc&((apply juxt [even? odd? pos? integer?]) 3)
11:12lazybot⇒ [false true true true]
11:12dribnetThx TimMc - will try.
11:12TimMc~juxt
11:12clojurebotjuxt is usually the right answer
11:19dribnetthank TimMc, that was it, tho it's a shame I can't (reduce and x) the result :-/
11:22dribnetwhy does and have to be a macro? that doesn't seem helpful.
11:22TimMcdribnet: (and (is-valid? foo) (do-stuff foo))
11:22TimMcCan't do that with fns.
11:23TimMcdribnet: Are these fns predicates?
11:23TimMcThere's every-pred.
11:23dribneti just want to reduce a bunch of booleans.
11:23TimMc&((every-pred odd? pos? integer?) 3)
11:23lazybot⇒ true
11:24TimMcdribnet: If need be, you can (reduce #(and % %2) true my-bools)... but every-pred seems more suited to your needs.
11:25dribnetso the answer is: short-circuiting?
11:25dribnetcool - thanks for the every-pred tip.
11:27dribnetyes, every-pred fits the bill. good thing i didn't need or. :)
11:32borkdudeTimMc https://github.com/trptcolin/reply/pull/64/files
11:32mwillhitegiven I have the following: (update-in {:foo 1 :bar 1} ??? inc)
11:32borkdudeo shit, forgot to add version.clj :)
11:32mwillhiteis there anything I can do to update both :foo and :bar?
11:35TimMcdribnet: There's also 'some-fn, which is the 'or equivalent.
11:37borkdudemwillhite assoc takes more than one key-val
11:37borkdude,(assoc {:foo 1 :bar 2} :foo 2 :bar 3)
11:37clojurebot{:foo 2, :bar 3}
11:38mwillhiteideally I could just pass a function in (actually using this to format timestamps), I assume with assoc I'd have to fetch each value as well
11:38mwillhitebut that is helpful, thanks :)
11:39borkdudemwillhite maybe update-in?
11:39borkdude,(doc update-in)
11:39clojurebot"([m [k & ks] f & args]); 'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that will take the old value and any supplied args and return the new value, and returns a new nested structure. If any levels do not exist, hash-maps will be created."
11:40mwillhiteyup, "a value"
11:41tmcivermwillhite: looks like you'd have to call update-in separately for each update: ##(-> {:foo 1 :bar 2} (update-in [:foo] inc) (update-in [:bar] inc))
11:41lazybot⇒ {:foo 2, :bar 3}
11:41mwillhitethx
11:42borkdude,(for [[k v] {:foo 1 :bar 2}] [k (inc v)])
11:42clojurebot([:foo 2] [:bar 3])
11:42borkdude,(apply hash-map (for [[k v] {:foo 1 :bar 2}] [k (inc v)]))
11:42clojurebot{[:foo 2] [:bar 3]}
11:42borkdudenooooooes
11:43borkdudebut sort of that way
11:43borkdudeI gtg
11:45dnolenmmarczyk: excellent vector perf looking good again :)
11:47gowlinsup.
11:52dribnetTimMc: what's the easiest way to explode out the my-bools vector so i can pass it to every-pred?
11:58TimMcdribnet: You don't pass booleans to every-pred; you give it predicate fns.
11:58TimMc&((every-pred odd? pos? integer?) 3)
11:58lazybot⇒ true
11:59TimMc&((apply every-pred [odd? pos? integer?]) 3) ;; alternatively
11:59lazybot⇒ true
11:59dribnetTimMc: sorry, my answer was 'apply'. i didn't ask the question right. :)
12:00dribnetTimMc: Mine ends up looking like ((apply every-pred [odd? pos? integer?]) 3)
12:00dribnetTimMc: still much nicer than (reduce #(and % %2) true foo)
12:00TimMcyep
12:10mmarczykdnolen: great! :-) new patch w/o enumerated protos attached
12:12dnolenmmarczyk: excellent, so we'll leave satisfies? alone for now.
12:12mmarczykdnolen: indeed
12:13dnolenmmarczyk: V8 deoptimization is pretty wild. ~470 ms for vector reduce before patch, ~70ms after on my machine.
12:15mmarczykdnolen: yeah, good to be back on the good side of the fence
12:15mmarczykdnolen: incidentally, would you have the time to look at cljs-259? "confusion avoidance"
12:16dnolenmmarczyk: will take a look
12:16mmarczykdnolen: cool
12:21dnolenmmarczyk: both patches applied, thx much
12:21mmarczykdnolen: great, thanks!
12:26dnolenmmarczyk: you know PersistentVector/fromArray could be a lot a faster if we just set the tail to the array, if the number of elements is less than 32.
12:28dnolenmmarczyk: no sure if that's the real bottleneck around regex perf but worth investigating.
13:03mittchelHello everyone :)
13:06devncheapest quickest way to get a byte-array from a file input stream?
13:07gfredericks(-> is slurp .getBytes)?
13:07technomancynein
13:08technomancyslurp assumes you have a string
13:08gfredericksO_O
13:08gfredericksI must be crazy
13:08gfredericksI swear I've been slurping ring bodies for years
13:09technomancygfredericks: I mean it assumes the contents of its argument will go cleanly into a string
13:09gfrederickssince most of you were in diapers, presumably
13:09technomancyso it's no good for binary data
13:09gfredericksoh some bytes do not go cleanly into strings?
13:09gfredericksI didn't know strings were so opinionated
13:09gfredericksthis must have something to do with "encodings"
13:09technomancythis isn't ruby =)
13:09technomancystrings are actual strings, byte arrays are byte arrays.
13:10technomancydevn: anyway I'd say copy to a ByteArrayOutputStream and do .toByteArray on that
13:11TimMcMake that a fn and call it "blurp".
13:12devnTimMc: heh, like expectorate
13:14p_lgfredericks: there's no guarantee the modified UTF-16 won't damage the data
13:21devntechnomancy: like (let [baos (java.io.ByteArrayOutputStream.)] (io/copy "foo.mp3" baos) (take 5 (.toByteArray baos))) ???
13:21lazybotdevn: Oh, absolutely.
13:21p_lactually I'm pretty sure you can get damage from UTF-16 transform
13:21p_l...saying UTF transform feels like department of redundancy department
13:21tomojwhy does folder wrap twice in xf?
13:22tomojreplacing folder with reducer, which only wraps once with xf, for e.g. map seems to work
13:22tomojwrapping twice seems to work too, which I don't understand
13:39tomojoh, the extra call to xf is in folder is not the only difference
13:39coventry`Can you rely on (rest #{0 1}) and (first #{0 1}) to be consistent, in that the (rest) is the complement of whatever (first) returns?
13:40coventry`I guess under the hood it's converting the set to a seq in both cases, and they do that in the consistent way?
13:41tomojI believe the order depends on the hashcode of the elements?
13:42technomancydevn: sure
13:43McMartincoventry:
13:43McMartinuser=> (.getClass (rest {:a 1 :b 2 :c 3 :d 4}))
13:43McMartinclojure.lang.PersistentArrayMap$Seq
13:44McMartinSeq should be consistent the way HashMap.entrySet().iterator() is.
13:45TimMccoventry`: Yes. THe order is arbitrary, but consistent per identical? object.
13:46McMartinI'd say for clarity it's probably best to make a seq of it on the way in though and then operate on seqs generally.
13:48dwierengais there a way to pass command-line arguments to my code when i do "lein run" ?
13:49borkdudedwierenga: "lein help run"
13:53tomojhuh, it seems the CollReduce/IReduce reifies in reducer/folder are indeed equivalent, just written differently
13:55tomojthese are exactly equivalent, right? https://gist.github.com/78d8bcf9f2753e2f85ed
13:57tomojoh, obviously
14:02dwierengaborkdude: yes i read that. i don't actually get the arguments though: http://pastebin.com/EbsbwXta
14:03devnstuart halloway's datomic talk at euroclojure was interesting. i did not know you could query your code with it in much the same was you'd query a database.
14:03devnhttps://gist.github.com/2645453
14:14eggsbyhmm, so I have a list of keys that I want to turn into a list of values by doing a db lookup
14:14eggsbyhowever (map #(db/get my-database-conn %) (list key1 key2 key3)) isn't working
14:14eggsbyam I missing something?
14:17nDuffeggsby: "isn't working" is pretty vague.
14:18eggsbyI guess my question is 'how do I take a sequence of side effects and turn them into a list)
14:18borkdudedwierenga I think with args you have to also name the ns explicitly?
14:18nDuffeggsby: are you saying you want that sequence to be evaluated immediately, rather than lazily?
14:18eggsbyI can (doseq [key my-keys] (println (db/get my-db key)))
14:19eggsbynDuff: I've tried wrapping it in dorun/doall but no dice...
14:19raekeggsby: does the db/get form need to be wrapped in something? you may be bitten by laziness
14:19nDuffeggsby: the map thing you're doing there should work fine, as long as you don't expect the db/get calls to be made until the values from the sequence are actually used.
14:19eggsbyhm
14:20eggsbyit just hangs the repl
14:20raekif wrapping the map call directly in a doall doesn't solve the problem, then laziness is not the issue here
14:20nDuffHmm. The repl should evaluate it all immediately, at least for a 3-item list.
14:20raekeggsby: have you tried just (db/get my-database-conn key1)
14:20raek?
14:20eggsbyworks fine
14:21eggsbyjust returns the value
14:21raekbut (doall (map #(db/get my-database-conn %) (list key1 key2 key3))) doesn't?
14:21eggsbymhmm
14:22nDuffeggsby: is the context for this small enough that you could provide a reproducer (say, on gist.github.com or another pastebin)?
14:22eggsbysure, it's the redis-clj lib
14:25dwierengaborkdude: i'm not sure how i would do that. you mean with "lein run -m"? that doesn't seem to work unless i'm missing the secret incantation for it..
14:26borkdudedwierenga o wait, without m you should just be able to provided the args
14:26eggsbyhttps://www.refheap.com/paste/2928
14:27nDuff...'ya know, I personally would be pretty wary about overwriting things as critical as get in your namespace.
14:28eggsbyI guess I could have an atom and swap the atoms value in the body of a doseq?
14:28nDuff...but anyhow, installing redis to be able to reproduce.
14:28eggsbynDuff: ya I require in actual code
14:28eggsbyrequire :as redis or w/e
14:29dwierengaborkdude: ok (first args) in main i get a value, but with *command-line-args* i don't: http://pastebin.com/wU436Pz7
14:29borkdudedwierenga the args are passed to the -main function
14:29dwierengaI think i'm maybe more confused about how to structure my program than i am on how to get the arguments..
14:30borkdudeI think
14:30nDuffeggsby: https://gist.github.com/70ff40a28b400fe9bd73
14:30nDuffeggsby: ...works fine here. That's clj-redis 0.0.12 and clojure 1.4.0
14:30borkdudedwierenga I don't know where you got *command-line-args*, I've never seen it before
14:31dwierengaborkdude: yeah i get that. i'm just confused as to how to access them from the rest of my program without going straight imperative style..
14:31dwierengaborkdude: http://clojuredocs.org/clojure_core/clojure.core/*command-line-args*
14:32borkdudeah
14:32raek*command-line-args* is filled in when clojure.main is used as the entry point
14:32eggsbynDuff: no need
14:32mfexeggsby: final ) paren?
14:32eggsbyI think the issue was in those 'WARNINGS'
14:33nDuffHeh.
14:33eggsbywhen I fired up a new repl and used 'require' instead of 'use' it didn't blow up
14:33dwierengaraek: so i shouldn't use lein run then?
14:33eggsbyso map must use get/set/something internally somewhere
14:33nDuffeggsby: actually -- I think mfex has it right
14:33nDuffeggsby: you didn't close your parens before pressing enter, so it didn't execute.
14:34eggsbynah, wasn't that, I tried )))))))) too
14:34nDuffeggsby: ...map is in the clojure.core namespace, so it doesn't care how you redefined get in your local ns
14:34eggsbyhm
14:34raekdwierenga: if you use lein run then your main function is the entry point. use its arguments then
14:34raek(defn -main [& args] ...)
14:35dwierengathat means i'd need lein installed on my production server then right?
14:36mfexeggsby: did you try your code with a closing paren?
14:36raekno, you can ahead of time compile that namespace and make it emit a real java main method
14:36raekwhich will call your main function
14:37raekyou can use the "lein otf" plugin to avoid ahead of time compilation but still get an executable jar
14:37raek(well, executable as in "java -jar"-able)
14:38dwierengabut i *want* ahead of time compilation, no?
14:38McMartinDoes the uberjar really use all the vast number of clojure-core-library classes?
14:39raekas the last step, yes
14:39raekit gets in the way during interactive development though (.class files can shadow your updated source files)
14:42dwierengaraek: i have no idea what that means, sorry. i'm coming from Perl-land where there's no difference between source and executable..
14:47eggsbyclojure has a string split somewhere, right?
14:48McMartinI'd check in clojure/string
14:48mfex,(doc clojure.string/split)
14:48clojurebot"([s re] [s re limit]); Splits string on a regular expression. Optional argument limit is the maximum number of splits. Not lazy. Returns vector of the splits."
14:48eggsbythanks McMartin mfex
14:50eggsbyawesome
14:51McMartinNote that if you want to do the reverse, (clojure.string/join "" v) is roughly equivalent to (apply str v).
15:41timvisherhow do i control the version of clojure lein repl uses outside of a project?
15:42amalloytimvisher: probably in ~/.lein/profiles.clj, but i dunno
15:42timvisheri'm on 1.7.1 at the moment, too
15:42timvisheramalloy: thanks
15:43amalloyoh. then not in that file, which is for lein2
15:43gtrak`what's the state of the art in debugging? ritz? cdt?
15:43yazirianprintln
15:43amalloygtrak`: probably ritz
15:44raektimvisher: I don't think you can in 1.x
15:44timvisheryou know, i don't think you can configure it
15:44timvisherlol
15:55nDuffIf I have two sequences '(1 2 3 ...) '(:a :b :c ...), what's the standard mechanism to get a sequence returning '((1 :a) (2 :b) (3 :c) ...)?
15:55gtrak`zipmap
15:55clojure-newcomerhi guys… can anyone help ? I am falling into a newb lazy seq trap : http://pastebin.com/WgYAd48k
15:55nDuffahh, graci.
15:56mfex,(map list '(1 2 3) '(:a :b :c))
15:56clojurebot((1 :a) (2 :b) (3 :c))
15:57clojure-newcomerI'm getting : 'clojure.data.xml/Emit found for class: clojure.lang.LazySeq' when I try to emit-str
15:57gtrak`ah, same shape as zipmap, with a subtle difference, my mistake :-). zipmap would give you the same thing but possibly in a different order
15:57timvisherwell, is it possible to control the version of clojure from lein2?
15:57clojure-newcomerI figure I need to realise the lazy seq, but am unsure how to do it
15:57nDufftimvisher: yes, in your project.clj
15:58nDufftimvisher: ...just make the dependency be the one you want.
15:58timvisheroutside of a project
15:58duck1123timvisher: why not just lein new up a project?
15:58timvisher:)
15:58timvisheri'm using it for inferior lisp when i don't really want a project
15:58timvisherbasically it's quicker than starting a whole new project and then jacking in
15:58S11001001timvisher: running low on disk space?
15:58mfexnDuff, gtrak`: zipmap builds a (hash)map, not a list and therefore has no ordering
15:58timvisherS11001001: lol
15:58timvishertime
15:59gtrak`mfex: it has an ordering... but probably not the one you want
15:59S11001001so do it once and use that over and over
15:59gtrak`maps are seqs
15:59texnomancytimvisher: it's locked to Leiningen's own version
15:59texnomancyallowing an arbitrary version would make it slower for everyone
15:59timvisherwhich is what i already do
15:59timvishersweet
15:59gtrak`(first (zipmap '(1 2 3) [:a :b :c]))
15:59gtrak`,(first (zipmap '(1 2 3) [:a :b :c]))
15:59clojurebot[3 :c]
15:59gtrak`,(rest (zipmap '(1 2 3) [:a :b :c]))
15:59clojurebot([2 :b] [1 :a])
15:59mfexgtrak`: a set can produce a seq, does it have an ordering?
16:00gtrak`mfex: pretty sure it'll produce the same ordering every time, so yes
16:01mfexthe seq has an ordering, but a set or map does not I would say
16:01gtrak`mfex: maybe not an intentional 'ordering', but definitely an order
16:01S11001001after creating a powerful configuration language for setting up exactly how lein should build a classpath and start clojure &c, does it really seem appropriate, architecturally, to create an alternate half-broken config language for command-line? Maven did this, and the results are spectacularly ugly and still don't work half the time
16:02texnomancyS11001001: the command-line is really just a mechanism for running certain types of clojure functions
16:02texnomancyso you can have higher-order tasks, etc.
16:03texnomancysee lein assoc, lein with-profile, lein trampoline, etc
16:03terommfex, gtrak`: there are also sorted-map and sorted-set which preserve the order
16:03amalloyclojure-newcomer: a realized lazy-seq is still a lazy-seq; it won't become suitable for Emit
16:04clojure-newcomeramolloy: oh… hmmm, am I far from the way to do this right ?
16:04amalloyyou probably just need to switch the first line to (apply element...)
16:05clojure-newcomeramolloy: thanks, I'll give it a go
16:05amalloyelement doesn't take a seq of content as its third arg; it takes a variable number of arguments
16:06clojure-newcomeramalloy: thanks, it works… now going to hit google to see what I just did :-) Appreciate it
16:16amalloycoventry`: you around? ISTR you got ritz working recently, and i'm having some trouble with it. i got it all installed: lein2 ritz fires up a server, and M-x slime-connect recognizes it and attempts to connect. but after it spends some time compiling, i get https://gist.github.com/35025a22a846a742c61d
16:17amalloyritz does seem to be otherwise working - i can inspect local stack frames in the sldb buffer, and there are more restarts than i'm used to seeing
16:17amalloyand in fact, if i just tell it to abort, ritz seems to be able to work perfectly fine after that. so maybe it's not such a big problem
16:37TimMcgtrak`: A map is not a seq; it is seqable.
16:38gtrak`TimMc: i was wondering about that
16:48gfredericks,(seq? [])
16:48clojurebotfalse
16:48gfredericks,(seq? ())
16:48clojurebottrue
16:49nDuffI find myself frequently using (into {} (map #(array-map ...) ...)) -- is this an acceptable idiom, or should I be doing something else?
16:49gfredericks,(map #(identical? % (seq %)) [() '(2 3) [] #{}])
16:49clojurebot(false true false false)
16:50gfrederickshuh; that's curious
16:50hiredmannDuff: no, that is bad
16:50hiredmangfredericks: seq on an empty seq returns nil
16:50gtrak`nDuff: http://tech.puredanger.com/2010/09/24/meet-my-little-friend-mapmap/
16:51nDuffgtrak`: graci
16:52gtrak`nDuff: I was thinking about that earlier but didn't remember what it was for :-), thanks for reminding me
16:52amalloygfredericks: why is that curious?
16:53amalloynDuff: (map #(...) ...) is usually better as (for [...] ...)
16:54hugodamalloy: that exception is with clojure 1.4 I take it
16:54hugodI need to add it to the initially ignored exception list
16:54amalloyhugod: yes
16:54gtrak`amalloy: why is 'for' preferred?
16:55gfredericksamalloy: () is a seq but is not identical to (seq ())
16:55gfrederickseven though that's true for a nonempty seq
16:55gfredericksor list rather
16:55amalloy&(seq ())
16:55lazybot⇒ nil
16:55TimMcIt's a hack to allow (if (seq ...))
16:55gfredericksoh crap of course
16:55gfrederickssilly things
16:56TimMc(as far as I can tell)
16:56amalloyTimMc: that doesn't really sound like a hack, but okay
16:56TimMcIt makes life less pleasant.
16:56TimMcIt's a total kludge.
16:56hugodamalloy: if you IGNORE it, everything should work properly - and then you can save the exception filter list (M-x slime-selector f then 's' for save) and you will not be pestered again
16:56TimMc(*slightly* less pleasant)
16:56gfredericks(if (seq ...)) is real weird. Why not (if (not-empty? ...))
16:56gfredericksunless you've already called seq on something and want to test that
16:57gfredericksbut calling seq just for the test...
16:58S11001001you can't find out whether a seq is empty until you've seqed it
16:58duck1123I've found myself doing (when (seq ...) ...) a lot lately. It takes care of both empty seqs and empty strings
16:58hiredman,(empty? "")
16:58clojurebottrue
16:58gfrederickscertainly it works. It's just oddly named for that purpose.
16:59duck1123hiredman: I need the reverse, so it would be (not (empty? ...))
16:59amalloyhugod: pressing f there gives me an error - i don't see a filter-related option when i press ? to get the list
16:59gfredericksnDuff: I don't doubt it. I'm complaining about that :)
16:59S11001001also
16:59S11001001,(doc empty?)
16:59clojurebot"([coll]); Returns true if coll has no items - same as (not (seq coll)). Please use the idiom (seq x) rather than (not (empty? x))"
17:00hiredmanit is a remnant of a bygone era of nil punning
17:00gfredericksI don't mind disagreeing with a docstring
17:00hiredmanoriginally there was no empty seq
17:00hiredmanyour seq had something in it, or it was nil
17:01hiredmanbut that wasn't lazy enough
17:01gfredericksright
17:01gfredericksis it lazy enough in other lisps?
17:02gfrederickswhere they don't have jvm semantics
17:02hiredmanother lisps don't have lazy seqs
17:02hiredmanI mean they do, as can any language, they just don't have them has the first class iteration protocol
17:03hiredmanmost lisps have linked lists and cons cells
17:03gfredericksah hah. right.
17:03TimMcnon-empty? would call seq on its arg for you
17:03TimMcjust like empty? does
17:03TimMcOr heck, you'd just use (if-not (empty? ..) ... ...)
17:04gfredericksyep
17:05gtrak`how do I pull a jar from clojars?
17:05gtrak`manually?
17:05gtrak`rather, how do I manually pull a jar from clojars?
17:05hiredmananyway, (if (seq x) … …) is the idiom when x is a seq
17:06gtrak`nevermind, I found it, clojars.org/repo
17:09dgrnbrgis there an easy way to have cascalog run a dependency graph?
17:12pbostrom_amalloy: can you elaborate on (map #(...) ...) vs (for [...] ...)? Is it a matter of style/readability? Just curious 'cause you mentioned it yesterday too I believe
17:12coventry`tomoj, McMartin and TimMc: thanks for the info around 1:30 US ET. I got pulled away from my computer.
17:12hiredmanfor is actually more effecient
17:12amalloyhiredman: really? i can't think why
17:13hiredmanno fn object allocation, no intermediate seqs for mapping and filtering
17:13coventry`amalloy: Regarding ritz, I clearly misunderstood when you were talking about it earlier. I thought it was another term for swank-clojure. So it looks like I haven't actually played with ritz.
17:14amalloyhaha that's okay coventry`. i've got hugod helping me out now, and it's going great
17:15glitch99Anybody know how to turn a string into code - (?? "(list 1 2)") --- what should the question marks be?
17:15amalloy$findfn "(list 1 2)" '(list 1 2)
17:15lazybot[clojure.core/read-string]
17:16glitch99Sweet - let me try those
17:18coventry`amalloy: good to know, though. It looks like it would address the problems I've run into since. Thanks.
17:18amalloyhiredman: it still has to allocate the function
17:19amalloyyou can see it in `(fn ~giter ...)
17:21hiredmansure
17:21amalloybut you're right about there being fewer intermediate seqs, of course
17:22amalloypbostrom_: anyway, more importantly it's more readable, more flexible, and more nestable
17:27arohnerare there any maintained zeromq / messaging libraries?
17:28texnomancythere's no JVM zeromq client, just native bindings =(
17:28llasramWriting a library which one expects will be used on occasionally incorrect data, which seems the most idiomatic pattern?: (a) have a correctness-checking function, and raise an exception on error in the actual parsing function; (b) return `nil` on error in the aactual parsing function
17:29arohnertexnomancy: is there anything similar to 0mq?
17:29texnomancyarohner: oh, if you just want messaging there are lots of amqp clients
17:30arohnerI might be out of my depth here. What is the difference between zeromq and messaging?
17:30hiredmanarohner: why do you want 0mq?
17:30llasramzeromq is kind-of-sort-of sort-of fancy UDP sockets
17:30texnomancyzeromq is not a message queue, it's the raw materials to build your own message queue
17:31arohnerhiredman: I don't need it specifically. I'm looking for broadcasting 'event' messages between boxes in a cluster. A persistent queue on top of that would be nice, but not necessary
17:31arohnerI was using hazelcast, but it's made of Fail.
17:31texnomancyarohner: I'd recommend amqp or jms
17:31hiredmanhow about instead of "blah blah blah 0mq is x blah blah blah" we ask arohner what he wants and then we can argue about if 0mq is good for that
17:32hiredmanarohner: hornetq is a nice embedable jvm message queue
17:32llasramhiredman: too productive
17:32hiredman(meaning you can run the hornetq server in your app's jvm in you want)
17:33hiredmanhttps://github.com/hiredman/vespa-crabro
17:33texnomancycame across this the other day for racket: http://planet.racket-lang.org/package-source/gcr/riot.plt/1/0/planet-docs/riot/index.html
17:33antares_arohner: Langohr is a well maintained message library (although depending on your needs, it may make more sense to use zeromq than rabbitmq, but for plenty of cases rabbitmq will work great): https://github.com/michaelklishin/langohr/
17:33texnomancynice approach
17:35arohnerhiredman: thanks. hornetq & vespa looks nice
17:35llasramhiredman: Cool. I've been meaning to check out hornetq. We're using rabbitmq at my company, but I think that was mostly the result of die roll
17:35arohnerbtw, word of warning. stay away from hazelcast. rip it out of any project you have to maintain
17:36hiredmanarohner: I dunno that I would recommend using any of the bits of vespa besides the server embedding code (create-server)
17:36hiredmannot that there is anything bad, just nothing provably good
17:36ivanarohner: what's wrong with it?
17:37arohnerivan: it's not threadsafe. it claims to support distributed transations and locks, but just fails miserably
17:37ivanouch
17:37arohnersometimes your cluster will partition for no good reason, and then *if* the clusters merge, your locks will be in inconsistent states
17:38arohnerthe documentation mentions none of these flaws, but the devs will admit them in the google group
17:38arohner"oh yeah, distributed transactions are best effort. hope you weren't doing anything important with that"
17:38p_larohner: ... that doesn't make sense
17:39arohnerp_l: ?
17:39p_larohner: transactions as best-effort
17:39hiredmanyeah, well, my experience with hazlecast was laptops running hazlecast nodes wired into a gigE switch would not stay clustered
17:39p_lunless it means fail-fast
17:40p_leverything else can go to hell, but distributed transactions are there to help me maintain (eventual) consistency
17:40arohnerp_l: basically, hazelcast transactions aren't transactional
17:40p_l>_>
17:40arohnerthey sometimes fail. sometimes both sides disagree on what happened
17:40p_l... can I have TPF/OpenVMS back?
17:43Chiron_Hi, I'm creating a function that accepts named parameters to execute this command: gluster volume create NEW-VOLNAME [transport tcp | rdma] NEW-BRICK --> gluster volume create test-volume transport tcp server1:/exp1 server2:/exp2 server3:/exp3 server4:/exp4
17:43arohnerp_l: oh, and my favorite. sometimes your queue will report it is N items long, but then you go take the first item off, and get nil
17:43Chiron_new-brick is a vector
17:43arohnerbut the length is still N
17:43Chiron_{:keys [volname transport new-brik]}
17:44Chiron_new-brik could be one value or many
17:44Chiron_what should I tweak in {:keys [volname transport new-brik]}?
17:44p_larohner: ... fun
17:46p_larohner: so I was saying... TPF/OpenVMS? I think both support X/Open XA... ;)
17:50glitch99so update - i still can't seem to get it to work. Let's say I want to execute the line in the string... what would the the one liner? here's my guess: (#(read-string "(list 1 2)")) but that doesn't seem to work
17:50glitch99I'm loooking for the REPL to return (1 2)
17:51arohner,(read-string "(list 1 2)")
17:51clojurebot(list 1 2)
17:51p_l,(eval (read-string "(list 1 2)"))
17:51clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
17:51p_l... SANBOX? ;P
17:51arohnerglitch99: read-string returns the data, if you want to execute, you need to use eval, though that's usually not the best approach
17:52arohnerglitch99: what are you trying to do?
17:52amalloyp_l: it's been that way for so long i think it's now regarded as a feature, not a bug :P
17:53glitch99arohner: there's a research tool on the net that posts the lisp parse of sentence tree for an NLP project - trying to turn the string into the lisp and then just define the keywords so that I just need to eval the line and magic happens haha
17:53p_larohner: I don't know about clojure, but in CL, needing to use EVAL is considered a point to stop and rethink wtf you're doing
17:53glitch99(eval (read-string "(list 1 2)")) seemed to work! Thanks!
17:53arohnerp_l: yeah, that's how we treat eval as well
17:53p_land that there's a reason EVAL is one letter difference from EVIL :>
17:54glitch99p_l: may I ask why it's taboo?
17:55amalloyp_l: the only difference is we don't CAPITALIZE random words like you CRAZIES
17:55p_lglitch99: it's less of a taboo, more of a feature that is more misused than GOTO and Dijsktra's papers.
17:55RaynesI feel like I'm being yelled at and it is making me uncomfortable.
17:55amalloypoor Raynes. let's actually yell at him, to line his perceptions up with reality
17:56p_lamalloy: there's so called modern-mode. It didn't catch on :P
17:56p_l(maybe because it requires manually typing those capitals when needed)
17:56amalloyp_l: oh, where the reader doesn't capitalize symbols?
17:57p_lamalloy: yes
17:57p_lAllegro lisp includes a whole image that has common-lisp package with lowercase symbols for that
17:57glitch99p_l: haha! you should write the anti-eval paper
17:58p_lglitch99: no thanks, someone will try to retitle it as "EVAL considered harmful". And the only "considered harmful" paper I'd like to write would be "Quoting Dijkstra considered harmful"
18:00nDuffHmm.
18:01TimMcnDuff: Guess who doesn't like public fields?
18:01TimMcThat guy.
18:02TimMcnDuff: There's something called a "PublicFieldUberspector" you can tell Velocity to use.
18:03nDuffHmm. Given as the Velocity environment here is handed to me preconfigured by JIRA (writing a plugin), I'm actually not sure if I'm in a position to be able to do that.
18:04TimMcVelocity is quickly beating me into a pulp.
19:02TimMcI apologize to Enlive for anything bad I ever said about it.
19:02RaynesAnother one bites the dust.
19:04TimMcThe Java ecosystem apparently has no notion of library composability.
19:35devnI found a brilliant form while toying around with expressions run in IRC:
19:35devn&(symbol (apply str (mapcat #(cons "\n" (next (map {\0 \ \1 \#} (Long/toBinaryString %)))) [185 13235209671M 25939708511M 1654794401M 12429901063M 131081 65539])))
19:35lazybot⇒ ### ## # # ### # # # ### #### # # # # # # # ###### # # # # # # # # # ### # ### # #### # ### # # ##
19:35devnThat probably looks like garbage. Run that in your repl. Do it now.
19:36TimMcdevn: "RuntimeException Map literal must contain an even number of forms"
19:37TimMc,(symbol (apply str (mapcat #(cons "\n" (next (map {\0 \space \1 \#} (Long/toBinaryString %)))) [185 13235209671M 25939708511M 1654794401M 12429901063M 131081 65539])))
19:37clojurebot ### #
19:37clojurebot# # # ### # # # ### ###
19:37clojurebot# # # # # # # # #####
19:37clojurebot# # # # # # # # # #
19:37clojurebot ### # ### # #### # ###
19:37clojurebot # #
19:37clojurebot ##
19:37gfrederickswitchcraft
19:38TimMcmarquee
19:38devnhaha. now I need to fix this damned project of mine to include who said that so I can send them cupcakes.
19:38tmciverNice
19:39TimMcdevn: http://clojure-log.n01se.net/date/2010-08-26.html#15:05c I think.
19:39McMartinwitchalocks
19:39McMartinAlso, boggle. You can have newlines in symbol names?
19:40gfredericksprobably anything
19:40gfredericks,(symbol "foo/bar/baz/bang")
19:40clojurebotfoo/bar/baz/bang
19:40p_lI'm reminded of that trick which printed some text using position of symbols in CL package
19:42McMartinThis looks like it's old-school monochrome spriting.
19:49JorgeBis cupboard the best lib for using BerkeleyDB? Doesn't seem to be maintained.
19:51eggsbyJorgeB: a lot of clojure libs are just thin wrappers over better maintained java libs, shouldn't be too hard to write one if it doesn't have the features you want :)
19:52JorgeBtrue, but I am looking to make my life easy atm
19:53JorgeBand can't login to clojars.org. maybe a hint I should take a break
21:37sjlwhat's happens when I put two libraries in my project.clj, each requiring a different version of another lib foo, and run lein deps?
21:37sjlwhich version actually gets used?
21:42amalloy1d2
21:42clojurebot2
21:42amalloysjl: probably something a lot like that
21:42sjlsweet
21:42amalloyif you need to be specific, i recommend having your project.clj specify a version - that will "win" over either library
21:43sjlmeh, seems like friend and noir require different versions -- I'll just ignore friend for now I guess
21:43amalloyversions of what? compojure, or ring or something?
21:43sjlring
21:45dreishIt's only at version 1.1.0, isn't it? How could there be any version conflicts?
21:45amalloythere's certainly some version that they both work with (in fact probably lots of such versions), but they have to pick one of them to mention in project.clj (since maven's version ranges are so atrocious). probably whatever version you pick will work
21:45dreish1.1.0 should be backward compatible with 1.0.0, if they're using version numbers correctly.
21:45sjldreish: friend's 1.0.2 doesn't work with the latest version of Noir, which needs 1.1.0
21:45weavejesterdreish: It is
21:45sjlI don't know if the other way around will happen to work
21:46weavejestersjl: Friend should be fine with Ring 1.1
21:47dreishSo the question is just whether you can override friend's dependency on 1.0.2 and force it to use 1.1.0?
21:47weavejesterRing follows semantic versioning, although there is a Hiccup dependency that spoils it a little.
21:47sjldreish: in this case yes, though I'm curious what happens in the more general sense
21:47weavejesterLeiningen should use the higher version when using dependencies.
21:47sjlit would be cool if 'lein deps' would warn you about conflicting version requirements
21:47dreish(It would be nice if Clojure itself followed semantic versioning.)
21:48sjldreish: yeah that would be a nice first step
21:48xeqithat would be really ugly at a clojure transition
21:48sjlxeqi: exactly -- the point is to make transitions that break everyone's code stand out and look ugly
21:49weavejesterAh, gotta go...
21:51xeqiand the fix would be to pester and wait for every library the project uses to update to compatible dependencies.. that could take awhile
21:51TimMcUnfortunately, I'm pretty sure Lein passes all the dep management straight to Maven.
21:52sjlxeqi: the fix is for every library to stop breaking backwards compatibility once they hit 1.0 so you never need to wait.
21:52gfredericksthe proper way to use semantic versioning is to work on the project for years before it's finally ready for the big 0.1.0
21:55xeqisure, until you want a 1.x -> 2.x jump
21:55sjlwhich should happen very rarely, since it breaks all your users' code
21:57dreishIt does seem sort of contrary to the Lisp development model to spend a ton of time designing the perfect interface, and then implement it without changing the spec.
21:57TimMcThe only thing I can't work out is how to version alphas and betas.
21:57TimMcdreish: That's how big parts of Clojure were developed.
21:58dreishTimMc: Clojure's at least partly a Java project. ;-)
21:58TimMc...since maybe you don't know ahead of time if you're going to introduce a breaking change.
22:00sjldreish: You can extend the spec all you want in semver, but if you're going to *break* it, you're going to cause all your users time and frustration, so it *should* be a big deal.
22:00dreishsjl: Right.
22:00sjlbut the best part about semver is that even if you do make a breaking change, it's obvious to your users
22:01sjlwhen they see the major version number change, they know they need to sit down and read the changelog
22:01TimMcThere's a difference between the local dev model and how you manage your spec.
22:01dreishI can think of a few in Clojure itself, some big and some small (and all changes for the better -- don't get me wrong). I don't remember any of them resulting in a major version change.
22:01TimMcReally, you think the RTE-wrapping was for the better? :-/
22:01dreishThe biggest obviously being the move from lazy-cons to lazy-seq.
22:01sjlYeah, Clojure follows a "maybe we broke your code, maybe we didn't" versioning scheme.
22:01sjlIt's fun.
22:13klauernMaybe the simplest step would be to file a bug with Leiningen to make the default `lein new` generate a project.clj with 1.0.0-SNAPSHOT as the version, so as to commit to the big number first...
22:13klauernI know I'm always changing my projects from 0.1.0-SNAPSHOT to 1.0.0 because I do semver
22:13klauernit'd be a nudge in the right direction then at least
22:47vosovichhey. is anyone available to help with a library problem?
22:48coventryI'm getting a NullPointerException when I run 'lein plugin install lein-ritz "0.3.0-SNAPSHOT"' <http://pastebin.com/A0FmhnEH&gt;. Any suggestions?
22:49gfredericks~anyone
22:49clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
22:52vosovichI'm trying to use midje in a project. I've added midje 1.4.0 to my dev-dependencies and dl'ed it with lein deps. Now i try to :use midje.sweet in a test file, but I get a "could not find midje/sweet.... on classpath"
22:53vosovichwhat am I missing?
22:57xeqicoventry: what version of lein?
22:57vosovichlein 1.7.1
23:17coventryxeqi: Thanks for the suggestion. 1.6.1. Will try upgrading.
23:24coventrySimilar failure with 1.7.1, but this time the java exception is "ZIP file must have at least one entry". http://pastebin.com/4TWQDRzD
23:26amalloycoventry: i had the same problem with lein1, and kinda suspect a bad ritz jar in maven somewhere. it works fine in lein2
23:28xeqicoventry: could try removing the jar from your ~/.m2
23:29coventryI was able to install it by making :dependcies in project.clj and doing "lein deps". Weird...
23:33fil512noir question: is there an easy way to serve up a flatfile css?
23:33fil512I know how to include it in the page header, but I need noir to serve the actual css up when it's requested.
23:35gfredericksvosovich: what does `lein classpath` give you?
23:38xeqifil512: I think noir will map the url "/public/*" to the files "resources/*"
23:39vosovichgfredericks: it's quite a bunch of jars. is it appropriate to copy-paste everything here?
23:39vosovichor are you looking for something specific?
23:40gfredericksvosovich: well mostly that the midge jar is there
23:40Raynesxeqi: Nope.
23:40xeqibah, thats what I get for reading source and not actually trying it
23:40vosovichgfredericks: the midje jar is indeed in lib/dev/
23:41Raynesfil512, xeqi: Pretty sure it maps /* to resources/public/*
23:41RaynesBy default.
23:41gfredericksvosovich: and you get the error when running `lein test`?
23:41RaynesYou can change that, if you want.
23:41xeqiRaynes: yeah.. look like you're right
23:42xeqivosovich: pastes can go on refheap.com
23:42vosovichno. I just have mentioned this. lein midje (i installed the plugin) works fine. Only when I compile in slime I get the classpath error
23:42vosovichxeqi: thank you
23:42vosovich*I should have mentioned this*
23:42vosovichfunny typo...
23:44seancorfieldman, how did i not know about C-x rfa / C-x rja until today?
23:47vosovichgfredericks: So in short: lein midje works, but in slime C-c C-k gives the compilation error
23:49xeqivosovich: just to make sure.. have you restarted slime since adding midje?
23:51coventryHmm, I had to put [lein-ritz "0.3.0"] in :plugins in the local project until "lein ritz" would respond with anything but "that's not a task." Putting it in ~/.lein/project.clj did not work. Now "lein ritz" errors out with "Unable to resolve var: leiningen.core.classpath/get-classpath in this context". http://pastebin.com/VPcLhV4d
23:52coventryI'm at a point now where I would probably try to figure this out from the source, if I had a decent debugger. :-
23:52coventryEr, :-)
23:53vosovichxeqi: oops. That's it. I figured i could add libs without restarting slime :S
23:53clojurebotthen its perfect. but of course, there are a lot of other parts too that changes. so after I make assoc :show, is there a problem I make again (def data (assoc data :list ...)
23:53vosovichxeqi: thank you
23:54xeqicoventry: thats an error saying its trying to load a lein2 namespace
23:54xeqiI see it at the bottom of https://github.com/pallet/ritz/blob/develop/lein-ritz/src/leiningen/ritz.clj
23:54xeqiprolly need to file a bug for that one
23:56amalloycoventry: and are you actually running lein2, or is lein still lein1?
23:59coventryamalloy: "lein version" says 1.7.1. I took it from raw/stable/bin/lein in technomancy's github. Should I be using a different version?
23:59coventryWill try lein2
23:59amalloywell, i suggested you upgrade to lein2; you certainly don't have to, but my thought was that ritz doesn't work on lein1