#clojure logs

2011-10-04

01:06michaelr525hello
03:01fliebelHow is IDE support at the moment? I need to wade through some Java code, so I thought I'd check the clojure plugin for whatever IDE I'm going to use.
03:03khaliGfliebel, they say Counterclockwise for eclipse is pretty good, i'm just trying to use it at the moment
03:13pyri have a bit of chicken and egg program
03:14pyrproblem, rather
03:14pyrsay you have a protocol defined in a project
03:14pyrand you want to allow external lib to implement it
03:14pyrto be able to let users of the software provide an implementation
03:14pyr(say, for a transport or serializer)
03:15pyrhow do you manage the cross dependency ?
03:17carkhum i don't see a problem ... the library user requires the namespace where you defined the protocol, and that's it
03:17carkyour library only refers to the namespace where the protocol was defined
03:17carkthere's no cross-dependency
03:17pyrhmm let me be more clear
03:18pyri have a daemon, not a library that relies on transport
03:18pyrand i want to be able to switch transports from the configuration
03:18pyrthe daemon defines the transport protocol
03:19pyroh, I guess i see a way of having this work
03:19pyrok
03:19carkok well : file1 = define your protocol
03:19carkfile2 : define your demon
03:20carkfile3 : define your transport
03:20carkfiles 2 and 3 are using file 1
03:20pyrwith files i'm alright
03:20pyrit's libraries that get me confused
03:21pyrbut yeah
03:21carkthat's the same thing =P
03:21pyrit works that way
03:24rimmjobis there a style guide for clojure?
03:25rimmjobive never really writen lisp that other humans had to read..
03:26rimmjobmostly just for my own use
03:27pepuchoZquit
03:28pyrrimmjob: sp indent, let emacs or vim show the way
03:30rimmjobi mean like, after when to newline after a parens
03:30pyrif you look at existing code a bit
03:30rimmjobill just look at
03:30rimmjobok
03:30pyryou'll see there's no definite style
03:31rimmjoboh
03:31pyrnot at all like C / Java / Ruby
03:31pyrbecause the lack of syntax in clojure makes it almost pointless
03:32pyrI tend to newline after "block" calls (doseq, do, when, dosync, ...)
03:33pyrusing the (defn foo \n "" \n [args]) syntax forces you to put some text in that docstring
03:34rimmjobok, i guess that makes sense. thanks
03:42dbushenkohi
03:42dbushenkowhat's the difference between fn* and fn?
03:42Blktgood morning everyone
03:53raekdbushenko: fn* is the "real" more primitive special form. I think it's like fn, but doesn't do destructuring or something.
03:53raekdbushenko: it's not meant to be used directly
03:55dbushenkoraek, yep, but I just want to dig in the sources of clojure and don't get what for is fn*
03:56dbushenkoso, thanks for your explanaition
04:24pyris there a way to pass a class around and let another function instantiate it ?
04:25pyri.e: (deftype Foo [x y]) (let [class user.Foo] (instantiate-with class :some :args)))
04:43michaelr525pyr: you can use java stuff: (Class/forName "java.lang.String")
04:44pyrmichaelr525: yep, but then there's no instantiation possible
04:46pyr(eval `(new ~(symbol class-as-string) arg1 arg2))
04:46pyrthat works
04:46michaelr525it feels like cheating ;)
04:47terompyr: classes can be instantiated with reflection, also (but it's certainly more complicated than eval)
04:48raekpyr: you can use (import 'clojure.lang.Reflector) (Reflector/invokeConstructor class (object-array parameters))
04:48raekthe Reflector class makes this much simpler compared to java's reflection api
04:49raekeval is uncessary here. it will just generate code that calls the invokeConstructor method in this case.
04:50raekoh, and 'class' here is an instance of java.lang.Class (the thing you get from "class literals" in clojure)
04:50pyr(Reflector/invokeConstructor (Class/forName "user.Foo") (to-array [:a :b]))
04:50pyrworks
04:51pyrnice
04:53pyrraek: i looked for clojure reflect api earlier
04:54pyrraek: no clear doc
05:03srdjanwhy doesn't the following thing work in clojure 1.3: (-> 4 #(* 10 %)), but (* 10 4) works?
05:04srdjanI get the following error: #<CompilerException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.ISeq, compiling:(NO_SOURCE_PATH:1)>
05:05srdjanand the following thing forks: (#(* 10 %) 4)
05:05srdjanand does clojure support macros inside of macros, or macros in clojure are not composable?
05:06Blafasel,(-> 4 (* 10))
05:06clojurebot40
05:07BlafaselIn other words: Your #() is unnecessary and potentially (I'm clueless) wrong.
05:07srdjanBlafasel: please, can you explain me why it has to be written in that way?
05:07Blafasel-> already does the magic for you, inserting the current value into the forms
05:07Blafasel,(4 (println "foo" "bar"))
05:07clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
05:08Blafasel,(-> 4 (println "foo" "bar"))
05:08clojurebot4 foo bar
05:08Blafasel,(->> 4 (println "foo" "bar"))
05:08clojurebotfoo bar 4
05:08BlafaselSpot what happens.
05:09Blafasel-> inserts the current value into all forms as first argument. ->> as a last argument.
05:10raeksrdjan: #(* 10 %) is a shorthand for (fn [%] (* 10 %)) and this translation is done at readtime (before macroexpansion time)
05:10Chousuke,'(-> 4 #(* 10 %)); srdjan, spot the problem
05:10clojurebot(-> 4 (fn* [p1__131#] (* 10 p1__131#)))
05:11Chousukeyou're basically asking for (fn 4 [x] (* 10 x))
05:11raeksrdjan: (-> 4 #(* 10 %)) ---> (-> 4 (fn [%] (* 10 %))) --> (fn 4 [%] (* 10 %))
05:12Chousukemacros inside macros work just fine, too
05:12raeksrdjan: another approach for this case is (->> 4 (* 10))
05:12srdjanthanks for the explanation
05:13raekto thread functions of one argument you can use comp. (it takes the function in the reverse order compared to -> though)
05:14srdjanraek: how is you exaple different wiht mine? (using ->> instead of using -> )
05:14BlafaselSee my println examples. The argument order is different.
05:14srdjanBlafasel: thanks
05:14Blafasel->> inserts as last element. -> as first argument
05:14srdjani see now
05:14BlafaselDoesn't matter of course for *
05:15raek,((comp #(- % 1) #(- 10 %)) 5)
05:15clojurebot4
05:16raeksame as (- (- 10 5) 1)
05:22srdjanI was writing SKI evlauator in clojure, as an excercise. I am alowed to discuss the pieces of the code in the chat? (the pieces of the code are about 5 lines each)
05:23srdjanAm I alowed*
05:26Fossiit's better to use a pastebin
05:26raeksrdjan: it's perhaps simpler paste the complete code at gist.github.com and the refer to the lines
05:31srdjanI have my small SKI evaluator on the http://pastebin.com/Pp33AuNh
05:31srdjanI have 3 questions related with my code.
05:32srdjanin line 50. I have function 'ff' that evaluates S, K, and I rules.
05:33srdjancan anybody suggest me how can this code be improved?
05:33srdjanin line 58. I have function 'ap' that tries to apply rule 'ff' recursively.
05:33srdjanis it better to combine functions 'ff' and 'ap' in one function?
05:34srdjanI have noticed that if I have 'recur' in the pattern matching, the compiler complains.
05:35srdjanin the line 66 i have function 'st' that walks the SKI tree and appies the SKI rules to each subtree
05:35srdjanthis give in the end the minimal SKI tree
05:35srdjanis function 'st' idiomatic clojure, or I can simplify it?
05:36raekff and ap looks fine to me
05:36raekbut (reduce conj ...) = (into ...)
05:36srdjanfunction 'f' was my first try to implement the SKI evaluator, is is to verbose comapred to 'ff'
05:37srdjanraek: I see that the '(reduce conj ...)' stinks a little, but I don't know how to improve it.
05:38raekI have barely used zippers at all, so I can't give you any feedback on the st function except for that it look small, which is a good thing, I think
05:39raeksrdjan: also (dorun (for ...)) = (doseq ...)
05:39srdjanraek: i have never used zippers in my life, until now, and I don't find the difficult to use (actually, it is the only way that I know to transform the trees in functional language)
05:39raek(dorun (for [x tests] (do ...))) = (doseq [x tests] ...)
05:41raekyou could perhaps make a recusively defined transformation function
05:42srdjanraek: you mean to combine 'ff' and 'ap'?
05:43srdjan'st' kind of stinks too. I would say that this look like a common pattern in tree transformation.
05:43raekno I was thinking about the zippers
05:44raekwhat does st do?
05:44srdjanI mean. The common thing is to apply the rule on the subtrees until we come to the end of the zipper, and then return the zip/root. I would expect that there is some function in clojure.zip that does exaclty this, but I could find it. :(
05:45srdjanraek: 'st' stans for 'ski-transform-tree'
05:45srdjanit walkd the tree in and applies the SKI rules on the subtrees. This gives you the minimal SKI tree.
05:46srdjanExample: (st '[S [I I]]) returns [S I], buy applying recuding [I I] to I
05:48raekare you looking for something like (st '[S [I I]]) --> (ap ['S (ap [(ap 'I) (ap 'I)])]) ?
05:48srdjanraek: 'st' takes the location in zipper, takes the node, applies the rules, replaces the node on the current location, and goes to the next node
05:49srdjanraek: 'st' works for me, but the question is if other people can understand the code. (I know that I didn't put the commetns, and that the function names are cryptic)
05:49srdjanraek: 'st' goes to S node, applies 'ap'
05:49srdjangoes to [I I] node, applies 'ap'
05:50srdjanand in the end goes to [S I] and applies 'ap' (the I in this expression is actually the recudtion of [I I] from the previous step)
05:51raeksrdjan: srdjan can you describe how the resulting tree should be constructed for the '[S [I I]] case using symbols, vector literals and calls to ap?
05:51srdjanwhat is the common way in clojure to represent product types like in ocaml?
05:52raeksrdjan: a map or a vector, depending on whether you want to name the slots or not
05:52srdjanthe expression '[S [I I]] is a tree
05:53srdjanyou can think of '[S [I I]] as a '(S (I I))
05:53raekyeah, that is clear
05:54srdjanraek: http://people.cs.uchicago.edu/~odonnell/Teacher/Lectures/Formal_Organization_of_Knowledge/Examples/combinator_calculus/
05:54srdjanon this link you can see how the tree is represented
05:54srdjanI just use clojure vectors to represent the trees
05:54srdjanprobably I could use clojure list, and do the pattern patchin on them
05:54srdjanthe end resut doesn't change
05:55raekmaybe it's simpler to transform the expression in to full parenthesis form first
05:55raekand then apply the rules
05:55srdjanraek: please, can you elaborate on that?
05:56raeknow you have examples like '[S x y z w], which really means '[[[[S x] y] z] w]
05:58srdjanraek: yes
05:59srdjanraek: the representation that I use is easier to use in pattern matching
05:59srdjanthe end result is the same
06:51ZabaQcommas are whitespace!
06:52ZabaQcan't decide if thats genius or madness.
07:01thorwildepends on how you feel about using ~ to unquote, instead of the comma
07:02thorwilcan it be that apply doesn't like macros?
07:24ordnungswidrigthorwil: you can't apply macros.
07:24thorwilok, wiser about that now after going through http://osdir.com/ml/clojure/2010-01/msg01242.html
07:24ordnungswidrig*g*
07:44pyninjaHas anyone else had problems with clj-http? Any time I try to do a POST request that works perfectly with curl, it never works. (dakrone are you here?)
07:50nappingI haven't tried it yet, but I was planning to use it soon
07:51pyninjaok cool, looks like they fixed whatever was wrong. i updated it to 0.2.1 and it works now!
07:53kij
08:33nappingwhy is there a not-any? but not an any?
08:34clgvnapping: english language? there is a 'some though
08:34cark,(some even? [1 2 3])
08:34clojurebottrue
08:35clgv&(some identity [nil 2 3])
08:35lazybot⇒ 2
08:36cark,(some #{1 2 3 4} [1 6])
08:36clojurebot1
08:36cark=)
08:39nappingI see it's the only one of the four which makes sense without a ?, but the name still seems a bit funny
08:57srdjan,(clojure-version)
08:57clojurebot"1.3.0-master-SNAPSHOT"
09:23mattmitchellI'm using Ring... and I'm curious to know if there is an elegant way to benchmark individual middleware layers?
09:31nappingto set up a benchmark for them, or to instrument your server?
09:53mattmitchellnapping: To benchmark all of them
10:31darqHello. What's the best way to combine 2 vectors? Actually I want [elem] + elem + [elem] . Is there a nice way to add them together to a vector?
10:32clgvdarq: how about ##(apply conj [1 2 3] 4 [5 6 7 8])
10:32lazybot⇒ [1 2 3 4 5 6 7 8]
10:34darqThx clgv :)
10:42TimMcclgv: Whoa!
10:42TimMc,(doc conj)
10:42clojurebot"([coll x] [coll x & xs]); conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type."
10:43clgv,(doc apply)
10:43clojurebot"([f args] [f x args] [f x y args] [f x y z args] [f a b c d ...]); Applies fn f to the argument list formed by prepending intervening arguments to args."
10:43TimMcNo unary conj. That precludes (apply conj base more) when more might be 0-length.
10:44ilyak,(conj [1 2 3])
10:44clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core$conj>
10:45winkWhat's the easiest way to persist some data? jdbc+h2db? or is there anything simpler? Basically just a cache for some maps identified by a primary key
10:46TimMcTHere are a lot of core functions missing degenerate cases.
10:46clgvwink: I used java serialization in some cases
10:46TimMc,(doc pr)
10:46clojurebot"([] [x] [x & more]); Prints the object(s) to the output stream that is the current value of *out*. Prints the object(s), separated by spaces if there is more than one. By default, pr and prn print in a way that objects can be read by the reader"
10:46duck1123wink: redis is pretty easy
10:46ilyakTimMc: Why not (concat base more)?
10:46ilyakI agree with you, tho
10:47winkduck1123: I'm not inclined to even try to get redis running on windows, sorry :P
10:47TimMcilyak: concat behaves differently than conj -- it uses cons
10:47clgvilyak: concat does return a lazy seq and no vector
10:47ilyakClojure could have less fns but more orthogonal ones
10:47TimMc,(concat [] '(1 2 3 4 5))
10:47clojurebot(1 2 3 4 5)
10:47TimMc,(concat () '(1 2 3 4 5))
10:47clojurebot(1 2 3 4 5)
10:48TimMc,(apply conj [] '(1 2 3 4 5))
10:48clojurebot[1 2 3 4 5]
10:48TimMc,(apply conj () '(1 2 3 4 5))
10:48clojurebot(5 4 3 2 1)
10:48TimMcIf you know that base is a vector, it's fine.
10:50ilyakTimMc: (conj base (apply vector more))
10:50ilyakOops, no
10:51ilyakI don't really understand the performance profile of those operations, so I can't figure out the best way
10:52ilyakI guess I rarely need vectors
10:53clgvilyak: (conj base (apply vector more)) should have 2*N runtime if more has N elements
10:54clgvilyak: btw, there is vec which can be used as (vec more)
10:54ilyakclgv: It won't work because conj doesn't expect vector as second param
10:55clgvilyak: hm what do you mean?
10:55ilyakI'm yet to find a vector concatenation
10:55jbwivcan someone tell me how to change the working directory of the repl from within the repl?
10:55ilyaksomething like haskell's ++
10:55ilyakclgv: conj is (conj vec x & xs)
10:56raekilyak: into
10:56raek,(into [1 2 3] [4 5 6])
10:56clojurebot[1 2 3 4 5 ...]
10:56ilyakPerhaps
10:56ilyakTimMc:
10:57raekbut this does not (and can not) use the fact that the second argument is a vector
10:58raekit simply treats it as a sequence and constructs a new vector with those elements added
10:58raekthe new vector will share structure with the first element, but not the second
10:59raekif you want something that can share structure with both arguments, you need another data structure (finger trees can do this)
11:00khaliGraek, what's the story with finger trees, are they part of core?
11:00raekthey are in the "new contrib" I think
11:01ilyakraek: Neither does (apply conj)
11:01khaliGi'm interested in why they /cannot/ share structure with both arguments
11:01raekdarq: this is how I would do it (into (conj left center) right)
11:03raekkhaliG: have you read about how persistent vectors organize their data internally?
11:03khaliGraek, nope not yet
11:03TimMcraek: Why is that better than (conj left center right)?
11:03raek(conj left center right) does not do the same thing
11:04raek,(conj [1 2 3] 4 [5 6 7])
11:04clojurebot[1 2 3 4 [5 6 7]]
11:04TimMcerr, throw an apply in there
11:06jbwivis there a clojure debugger with which you can set breakpoints and inspect variable values?
11:06raekTimMc: hm, the fact that you cannot call conj with only one argument is not a problem there. I guess they are equivalent then.
11:06zerokarmaleftkhaliG: http://blog.higher-order.net/2009/02/01/understanding-clojures-persistentvector-implementation/
11:08TimMcraek: Fancy. I guess this means that subvec doesn't need the whole tree, just some relevant subtrees. Allows more GC.
11:13zerokarmaleftjbwiv: https://github.com/GeorgeJahad/debug-repl
11:14clgvzerokarmaleft: that thing is pretty awesome. I use it about 50times a week
11:16zerokarmalefti just discovered it a few days ago...and just read hugod' post about integrating into swank...now i need to look into why i can't examine locals in stack traces
11:16jbwivzerokarmaleft, cool...thanks
11:17duck1123I've never managed to get it working very well
11:28mattmitchellI'm attempting to use the "time" function in my app. I'm finding it difficult to know which "time" call I'm seeing in stdout. Is there a way to wrap time so that it displays a label along with the time taken?
11:31TimMcYou could print to *out* or whatever just before time is called.
11:32TimMcOr do somethign tricky so that time prints to a capturing writer.
11:33Raynes_&(println "Labeled:" (with-out-str (time (range 3))))
11:33lazybot⇒ Labeled: "Elapsed time: 0.513915 msecs" nil
11:33Raynes_Hardly tricky.
11:34TimMcRaynes_: It would have to be done to all calls to time.
11:34TimMcAlso, any other output would be captured.
11:34mattmitchellRaynes_: The only problem with that the code that's being timed doesn't return the value to the caller
11:34dnolengiven the existence of JSCocoa, programming iOS devices with ClojureScript is trivial.
11:34mattmitchellerr sorry, in other words.. I need still need the return value
11:34TimMcmattmitchell: Use a let.
11:35TimMcOh, wait... I see.
11:35RaynesYeah, he can't really get the result while wrapping it in with-out-str.
11:36mattmitchellexactly
11:36RaynesHe could rebind *out* to a writer himself though.
11:36llasram &(source time)
11:36TimMcRight.
11:36llasram&(source time)
11:36lazybotjava.lang.Exception: Unable to resolve symbol: source in this context
11:36llasramHaha
11:36llasramAnyway, it's about 4 lines of code
11:36llasramCould just re-write it
11:36TimMchttp://clojuredocs.org/clojure_core/clojure.core/time has source
11:36duck1123you could assign it to an atom or some such, but that would affect timings
11:37TimMcYou also have to account for recursive calls.
11:37TimMcIf A calls B and both use time, you only want to capture the time output from each level separately.
11:38mattmitchellright
11:38duck1123right, this atom would be local to the time2 macro
11:38TimMcmattmitchell: (let [ret (time ...)] (println "Foo done.") ret)
11:38TimMcMacroize that.
11:39duck1123,(time (+ 1 1))
11:39clojurebot"Elapsed time: 0.086 msecs"
11:39clojurebot2
11:40TimMcPrinting a label to *out* before calling time is trouble, since an inferior call may also print to time.
11:40TimMcPrinting afterwards is fine.
11:40mattmitchellTimMc: yes that's right. I'll try your let code out.
11:41TimMcmattmitchell: Or, as llasram pointed out... just rewrite time. :-)
11:42duck1123just not any of the fixed points
11:42TimMcfixed points?
11:43TimMcIs this some Haskelly nonsense?
11:43duck1123Doctor Who reference
11:43TimMcah
11:44TimMcgot it
11:44llasramHa, the phrase "rewrite time" made me think the same sort of thing, but not a Dr. Who fan, so missed the ref
11:44duck1123sorry, you're talking about re-writing time, I couldn't resist
11:45TimMcmattmitchell: Write with-time, taking a function that accepts the time string and does something with it.
11:45TimMc(with-time ... #(println "Foo: " %))
11:46TimMcor (with-time ... #(str "Foo: " %)) with the expectation that the fn's return is printed.
11:51duck1123it would be cool if with-time accepted a callback fn that receives info about the run in a future
11:51clgvincanter question: somehow $join with three keys does not work like expected. e.g. [[:a :b :c] [:a :b :c]] - it just ignores :c somehow
11:53mattmitchellTimMc: You mean the string would act as a template, and with-time would fill it in with "format" or something?
11:58TimMcyeah
11:58TimMcerr
11:58TimMcNot really. Depends how you write it.
11:58TimMcYou could pass a format string, a prefix, a string-building function, or a function that can even print all by itself
11:59TimMcWrite the simplest thing for now (accept a label) and expand it later as needed.
11:59robermannjust resolved Gus' Quinundrum problem (http://www.4clojure.com/problem/125) after 4 days of tries - now, after seeing amalloy's solution, I consider myself totally dumb! :)
12:00robermannamcnamara's solution uses a fn*
12:00robermannwhat is it?
12:00TimMcCompiler primitive. It is what fn uses.
12:00TimMc,(macroexpand-all `(fn [x y] (+ x y))
12:00clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
12:01TimMcugh
12:01TimMc&(macroexpand-all `(fn [x y] (+ x y)))
12:01lazybotjava.lang.Exception: Unable to resolve symbol: macroexpand-all in this context
12:01TimMc&(macroexpand-1 `(fn [x y] (+ x y)))
12:01lazybot⇒ (fn* ([clojure.core/x clojure.core/y] (clojure.core/+ clojure.core/x clojure.core/y)))
12:03robermannthank you
12:18duck1123Here's a version of with-time that I came up with https://github.com/duck1123/ciste/blob/master/src/ciste/debug.clj#L13
12:18duck1123it takes a function to receive the timing data
12:19mattmitchellduck1123: awesome, I will need to study that for a bit :)
12:20TimMcmattmitchell: most of it is the same as time
12:20mattmitchellok
12:20TimMcduck1123: Why a separate thread?
12:21duck1123to not interfere with the rest of the flow. I guess that might not be needed
12:21TimMcCould be confusing if the timing statements print out of order.
12:22duck1123yeah, I think you might be right
12:22duck1123the user can always start a new thread if they want it
12:25glob157any good "full" application examples, other than ants.clj out there for learning how to build "real" clojure apps ?
12:26glob157im still getting lost in a maze of maps with hidden key names etc... i think my code organization is missing something
12:27mattmitchellduck1123: This is what I came up with, basically TimMc 's idea of using let https://gist.github.com/1262089
12:28mattmitchellnot real elegant, but working for now. I'll try your implementation out next.
12:29TimMcI'm not sure why time uses prn instead of println.
12:30duck1123mattmitchell: won't that print twice?
12:30mattmitchellduck1123: no, it's only printing once
12:31mattmitchellduck1123: oh, well yes sorry.
12:32TimMcglob157: Here's an application I wrote: https://github.com/timmc/CS4300-HW6 -- can't speak for "good", but it is a decent application
12:33TimMcglob157: Sample output: https://github.com/timmc/CS4300-hw6/blob/master/dev/sierpinski%20trace%20pastels%20ambient.png
12:33duck1123this is my largest app. https://github.com/duck1123/jiksnu I have a few other libraries on my page
12:33dnolenglob157: also Ring source is pretty clean well organized.
12:34TimMcdnolen: It can be hard to understand library sources, because you also have to understand the hypothetical clients that use them.
12:34duck1123that (should be) what tests are for
12:34TimMcmmm, true
12:34glob157the ray trace is great , but a little off topic compared with most apps. im thinking of a typical client side app with some application logic, maybe some MVC, etc...
12:35dnolenglob157: you might want to check out clooj, people actually use that, it's a lightweight Clojure IDE
12:36glob157oh ok
12:36TimMcglob157: Like something with widgets in a UI, or a web app?
12:37TimMcWidgets and state: https://github.com/timmc/CS4300-HW3/blob/master/doc/screencap-main.png -- another project of mine, involves dragging and stuff.
12:37glob157not worried about the particulars - but I wanted to see an app that had good separation of concerns.... hopefully one that explained the design philosophy as well. most of the examples I find are project euler.
12:37TimMcAh, like a proper sample app.
12:38TimMcAlmost like a tutorial.
12:38glob157Yeah, like JPetStore. Anyone interested in collaborating on one ? I have a github project called RudolF that was built to exemplify functional programming for new people like me.
12:39glob157ive built a lot of example apps using heroku, wrapping molecular vialization tools, etc, but i never really got a good feel for how complex data and state is handled in clj
12:41TimMcI think I did a pretty good job in the HW3 project. State is managed in refs, and the user data state is fully undoable/redoable.
12:41duck1123https://github.com/search?language=Clojure&amp;q=tutorial
12:43TimMcI should actually split out cascade.clj to a separate utility.
12:44glob157which is hw3
12:44TimMchttps://github.com/timmc/CS4300-HW3/tree/master/src/timmcHW3
12:45TimMccore.clj declares some refs at the top (I use *earmuffs* to mark them, even though that is usually used for rebindable vars) and the data structures are defined in state.clj
12:46TimMccascade.clj is a make-like utility for managing state recomputations
12:46glob157oh ok. tim thanks. tim if interested in collab on some open source clojure bioinformatics stuff let me know !
12:46TimMcThat might be cool.
12:46TimMcDo you have a github project (or similar) for it yet?
12:47glob157check out https://github.com/jayunit100/RudolF/bioclojure/
12:47glob157its all prototype code, but works. we want to bring it into a non prototype stage
12:48TimMcbad URL?
12:49TimMc-RudolF
12:51duck1123,(= 1/2 0.5)
12:51clojurebotfalse
12:51duck1123that's more unfortunate than the 2 vs 2.0 IMO
12:51glob157https://github.com/jayunit100/RudolF/tree/master/bioclojure
12:57semperosI need to call a static method on a Java class; I'm given the name of that static method as a string/keyword; what's the best way to dynamically call that method? any Clojure-specific way?
12:57jkkramer,(== 1/2 0.5)
12:57clojurebottrue
12:59mattmitchellWhat's the preferred json output library for clojure?
12:59technomancy~cheshire
12:59clojurebotHuh?
12:59technomancy...
12:59dakrone~json
12:59clojurebothttp://dakrone.github.com/cheshire/
12:59joegallomattmitchell: https://github.com/dakrone/cheshire
12:59mattmitchellcool thanks!
13:00joegallosemperos: you'll probably just want to use reflection for that
13:00technomancyhow do you do redirects/aliases with clojurebot?
13:00dakroneclojurebot: cheshire is <reply>https://github.com/dakrone/cheshire
13:00clojurebotIk begrijp
13:00dakrone~cheshire
13:00clojurebothttps://github.com/dakrone/cheshire
13:00dakronelike that?
13:01dakronenot sure what you meant
13:01joegallodakrone: now define ~alias to output the example :)
13:01technomancydakrone: I was thinking so it would refer to the same entry in memory, but I guess that's not as important in clojurebot since terms only show one entry at a time
13:02dakroneahh
13:02semperosjoegallo: yeah, I just got .invoke working, wasn't sure if there was a preferred/better abstraction at the Clojure level
13:02TimMcsemperos: Maybe RT could help.
13:03joegallohttp://clojure.github.com/clojure-contrib/#reflect
13:03joegallothere's that
13:03zerokarmaleftdakrone: fyi, the stream encoding example in the readme has args out of order
13:04semperosTimMc, joegallo thanks
13:04semperosjoegallo: that looks about like what I'm doing, so good to know I was on the right track
13:04dakronezerokarmaleft: you are right! lemme update that
13:04semperosusing 1.3, so not going to depend on a 1.2 contrib fn, but good to see the implementation
13:04dakronezerokarmaleft: thanks!
13:11devthhi. trying to upgrade to 1.3 but i'm getting "Warning: *classpath* not declared dynamic .." and "ClassNotFoundException clojure.lang.ILookupHost java.net.URLClassLoader" when i try to start my repl. what would be a good way to debug? i tried removing deps in my project.clj but makes no difference.
13:12technomancydevth: try lein upgrade
13:13devthtechnomancy: upgrading...
13:15devthtechnomancy: upgraded to 1.6.1 but seeing the same issue. deps: https://gist.github.com/1262209
13:15technomancydevth: clojure-json is deprecated. but it's more likely lein-nailgun.
13:18devthtechnomancy: hm, still see it after removing both of those
13:18technomancydevth: can't repro here; are you sure you're using 1.6?
13:18devthtechnomancy: i'll reinstall. originally installed with homebrew
13:22tremoloin Leiningen, what's the preferred way to set up a dependency to another local lein project? is this possible?
13:22tremoloi couldn't find any documentation on this
13:23technomancytremolo: add it to :dependencies and then set up the checkouts/ directory. look for "checkout dependencies" in "lein help readme"
13:23tremolotechnomancy: awesome, thank you
13:24technomancyno problem
13:26devthtechnomancy: classpath error is gone -- now just seeing "ClassNotFoundException clojure.lang.ILookupHost java.net.URLClassLoader$1.run (URLClassLoader.java:202)"
13:26technomancyhuh; never seen that before
13:26devthhrm. strange. i will keep messing with it. thanks!
13:48faust451hi guys
13:48devnHow does Haskell's iteratee relate to clojure's chunked sequences?
13:48devnIs there any relationship there?
13:48faust451i try using Lucene with Clojure, but fail. please help me
13:50joegallofaust451: that's a pretty open-ended question. maybe a little more detail?
13:50faust451this code http://friendpaste.com/56X61Tkfi6u1iwDEOvVD7A fail with java.lang.ClassNotFoundException: RAMDirectory.
13:50dakronefaust451: recommend this: https://github.com/weavejester/clucy
13:51faust451dakrone: thanks
13:51joegallofaust451: are you using leiningen? is lucene on your classpath? it seems like you are missing the jars you need
13:51faust451joegallo: yes leiningen
13:52joegalloand if you `ls lib`, do you see the lucene jars there?
13:52joegallobecause it seems like you might be missing some of them
13:52TimMclein classpath
13:55faust451joegallo: ls lib/ lucene-core-3.0.3.jar, lucene-queries-3.0.3.jar
13:56faust451joegallo: http://friendpaste.com/2pKJXrnwhWmVGcDieu2ogP
13:57TimMcfaust451: That's all that's in lib? Try running lein deps
13:59faust451TimMc: it's for ls -l lib/ | grep lucene
13:59TimMck
13:59technomancyfaust451: I recommend using clucy
13:59faust451TimMc: in project file i require only lucene-core and lucene-queries
14:02joegallodef index (RAMDirectory.))
14:03joegalloyou are missing parens around the RAMDirectory. constructor call
14:03faust451technomancy: but what i am doing wrong?
14:03joegalloyou are doing your syntax wrong
14:03joegalloyour dependencies are fine, but because of the way you have your code typed in, clojure is looking for the non-existent class "RAMDirectory." rather than "RAMDirectory", which you have.
14:05faust451joegallo: thanks, let me try to fix
14:33zodiakis it jst me that is sitting watching the whole node.js community become rabid dogs and thinking, I don't actually want to convert any of them to clojure :)
14:33RaynesIt's just you.
14:33zodiakawesome :D
14:34Raynes;)
14:34zodiakall the peeps at work here are trying to jump onto the node.js bandwagon, I keep trying to push clojure+ring
14:35zodiakI don't know how to 'soft sell' clojure+ring more though.
14:36zodiakthere is definitely a visceral reaction when it comes up that clojure is a child (somewhat ;) of lisp
14:38cemerickzodiak: just bring up that node.js is a child of javascript; on the merits, that should carry the day.
14:38amalloyhahahaha
14:39amalloycemerick: js is a disowned mutant child of scheme though, right?
14:39technomancyI've never understood that argument
14:39technomancy
14:39technomancyis it just shorthand for "it has closures"?
14:39cemericktechnomancy: which one?
14:39technomancycemerick: "JS is secretly just scheme with bad syntax"
14:40technomancyfeels like a non-sequitur
14:40amalloytechnomancy: allegedly the guy who wrote js was hired with the promise that he could write "scheme for the browser"
14:40amalloyand then was told "oh btw it has to look like java, marketing guys love that shit"
14:40cemerickI think it came from Eich having referred to scheme while working on the implementation.
14:40zodiakcemerick, sadly, I think that because it's a "language we know" that node.js is "the way to go" .. which is laughable when I bring up js has prototypal inheritance (which is not good imo) and everyone else goes 'huh' in the room
14:41TimMc>_<
14:45PPPauldoes anyone know a good way to flatten a tree into a 1d vector (preserving the paths) :eg [[root child child][root child child]]
14:46cemerickzodiak: doesn't sound like people know the language all that much.
14:47PPPauljs is a child of lisp too
14:47PPPaulmy js looks a lot like my clojure code
14:47RaynesProbably more parentheses in the JS code.
14:47PPPaulmaybe
14:52ibdknox,(flatten [[:hey :how [:are :you]] [:doing :today]])
14:52clojurebot(:hey :how :are :you :doing ...)
14:52ibdknoxPPPaul: ^
14:53PPPaulbut, no
14:53amalloyPPPaul: your question is pretty vague, it seems to me
14:53PPPaul[hey how are... [hey how you...
14:53PPPauli want to be able to re make the tree
14:54TimMcPPPaul: Provide sample input and output.
14:54bsod1is there a function in clojure like (some), but returns value of first true item instead of true or nil?
14:54PPPaul[:a [:b :c]] [[:a :b][:a :c]]
14:54TimMcbsod1: That's what some does.
14:55bsod1TimMc: no, some returns true or nil, I want the value of item instead of true
14:55ibdknox,(some (partial > 3) [1 2 1 1 5 4 3 2])
14:55clojurebottrue
14:55TimMc,(some identity [nil false 5 'bsod1])
14:55clojurebot5
14:55ibdknoxit depends on the function TimMc
14:55bsod1,(some #(= % 12) [1 3 12])
14:55clojurebottrue
14:56bsod1oh, wait
14:56TimMcAh, you want to run a predicate too.
14:56bsod1TimMc: yes
14:56symboleAnybody here at JavaOne?
14:56bsod1,(some #(when (= % 12) %) [1 3 12])
14:56clojurebot12
14:57bsod1any better ways to do this?
14:57jkkramer,(some #{12} [1 3 12])
14:57clojurebot12
14:57TimMcbsod1: That won't work for a predicate that accepts nil or false.
14:58bsod1TimMc: I know, I can't find any better solutions
14:58bsod1jkkramer: great
14:58bsod1thanks
14:59TimMc,(some #{nil} [1 nil 5]) :-P
14:59clojurebotnil
14:59amalloybsod1: (comp first filter)
15:00TimMcnice
15:01amalloypersonally i wish that's how some behaved, but it's not a huge deal
15:12apgwozhas anyone ever use Gson/fromJson with clojure?
15:14mister_robotoIs clojure-clr at clojure 1.2 now? 1.3? Can't seem to find any specifics on the github page
15:14Bronsa1.3
15:14mister_robotoCool thx
15:19TimMcOh hey, is that still in development?
15:33hugodI wonder if it makes sense for clojure.match to allow matching on arbitrary function literals [#(some-predicate? %)]
15:36amalloyhugod: isn't that the "predicate dispatch" dnolen has been saying he plans to add eventually?
15:37amalloydisclaimer: i know little about either match or predicate-dispatch
15:41hugodamalloy: I don't think so - I think that is a dispatch mechanism for multimethods, etc
15:43hiredmandakrone: have you ever seen errors about a missing class SyncBasicHttpParams when trying to use clj-http?
15:45hiredmanah, ring and clj-http depend on different versions of httpcomponents
15:47dnolen_hugod: it also supports that via guards
15:47dnolen_s/also/already
15:47lazybot<dnolen_> hugod: it already supports that via guards
15:49sridwhat is the primitive for returning a count of true's in a list of true's and false's?
15:49sridor should I just use (count (filter ...?
15:49amalloywhy would there be a primitive for that?
15:50sridjust wondering if there was (to score in code golf :P )
15:50amalloy*chuckle*
15:50amalloysrid: problem 83?
15:50sridnope, 83
15:50sridnope, 120
15:52TimMc$findfn [true false true true false] 3
15:52lazybot[]
15:52TimMc:-)
15:52amalloyTimMc: o/
15:54sridis there a function to map f1 f2 .. fn on a coll? got it, (map (comp f1 f2) coll)!
15:56gtrakmap comp looks to be the same as (map f1 (map f2 coll))
15:56amalloyit is the same
15:58duck1123isn't it closer to (map #(f1 (f2 %)) coll) ? (same effect though)
15:58gtrakbut the comp is 1 more character
15:58gtrakyea, that's smaller
15:58hugoddnolen_: ah, thanks. should have realised that…
15:59gtrakactually, mine is fewer chars :-)
16:03duck1123wasn't there a contrib library that aliased comp and partial for point-free nuts?
16:04amalloyclojure.contrib.haskell?
16:04clojurebotclojure-stub is http://github.com/nakkaya/clojure-stub/tree/master
16:04amalloy~rimshot
16:04clojurebotBadum, *ching*
16:04TimMcching, really?
16:04TimMcmore of a tsh
16:04srid(filter #(true? %) ... <- can I obviate the true? here?
16:05TimMcidentity, sort of
16:05sridright
16:05TimMc,(doc true?)
16:05amalloyTimMc: take it up with fsbot; i copied his rimshot to clojurebot
16:05clojurebot"([x]); Returns true if x is the value true, false otherwise."
16:05srid#(* % %) <- can't this be shortened
16:05TimMcsrid: identity is going to be sloppier
16:05srid?
16:05sridit would only accept boolean, so identity is fine.
16:06gtrak,#t
16:06clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: t>
16:07kzarAny ideas how I can re-write this blog-snippet enlive snippet? https://github.com/kzar/daveinadub/blob/master/src/daveinadub/views/blog.clj#L10 It looks awful ATM
16:42technomancyif you haven't been using M-x clojure-jack-in on account of how much elisp it spews out upon every connect, there's a new swank-clojure that fixes that: lein plugin install swank-clojure 1.3.3
16:46hugodis there a predicate to test if a number is boxed or not?
16:47amalloyhugod: i don't think that's possible
16:49duck1123isn't that a Heisenberg situation? Always true
16:49hugodnot even in java?
16:49brehautamalloy: really? surely a protocol would make it fairly trivial?
16:49amalloysince functions can only take objects, which are necessarily boxed. in 1.3 you can have a function that takes unboxed primitives, but afaik it can't say "i take a single arg which is either Object or long or double"
16:50amalloybrehaut: no way
16:50nappingmaybe something like *warn-on-reflection* could exist
16:50brehautamalloy: but you can make a protocol know about arrays of bytes
16:50hiredmanugh
16:50brehauti guess theres a backing class though isn't there
16:51hiredmananyone know if clj-http's :form-params actually work?
16:51amalloyhugod: you can't do it in java either, i think, but i'm less certain
16:52amalloyit's a weirder question in java, because java has static type information: "Did I declare this variable as an int or an Integer?" is not a useful question to ask
16:52dakronehiredman: have you tried the latest clj-http version? someone sent a pull recently that was merged
16:52hugodamalloy: I thought it might be possible with overloading
16:53amalloyhugod: maybe. that's certainly the only approach that might work
16:53brehauthugod: in java i think it would; but only because the type system already knows what that the local vars are primitives already
16:53amalloybut i don't know the details of how clojure passes numbers to java methods; it might notice that the thing takes a primitive long and unbox it
16:54brehauthugod: i recall method overload selection being a compile time rather than runtime decision
16:54hiredmandakrone: I'm on the latest release
16:55dakronecool, how's it not working for you?
16:55amalloybrehaut: correct. but since he's calling it from clojure, he'll be using reflection with runtime data
16:56brehautamalloy: at which point, you are using the reflection data anyway, so why go to java?
16:56hiredmandakrone: from what I can tell (running it against ring, ring just printing out request map) it looks like it is ignoring :form-params
16:56amalloygood point
16:56dakronehiredman: GET or POST?
16:56hiredmanclient/post
16:57dakronecan you send me a snippet?
16:58terom,(.isPrimitive (class 3))
16:58clojurebotfalse
16:58terom,(.isPrimitive (Integer/TYPE))
16:58clojurebottrue
17:04kzaribdknox: You there?
17:06ibdknoxkzar: hey
17:07kzaribdknox: Is there a way have multiple routes in a defpage? I wanted /blog to set :page to 0 and /blog/archive/:page to set :page to what's given
17:08ibdknoxtake a look at (render)
17:08ibdknoxwith a named route for blog-page, it would look like this:
17:09ibdknox(defpage "/blog" (render blog-page {:page 0}))
17:09kzaribdknox: Ah cool I see, cheers
17:10kzaribdknox: Oh wait, how do name blog-page? defpage doesn't take a name
17:11ibdknoxit does
17:11ibdknoxas of 1.2
17:11kzaraha gotya
17:11ibdknox(defpage blog-page "/blog/archive/:page" {:keys [page]} ...)
17:11ibdknoxor rather
17:11ibdknoxit can :)
17:14ibdknoxkzar: you can do the same thing without naming it
17:14ibdknox(render "/blog/archive/:page" {:page 0})
17:17kzaribdknox: cool OK, yea I got both ways working fine :) cheers
17:19carllercheI have a leiningen project that has a ragel -> java step, what would be the easiest way to have leiningen run a couple of ragel commands before javac?
17:34semperosI'm not strong on my Java jarring skills, getting following error while trying to uberjar
17:34semperosjava.lang.SecurityException: no manifiest section for signature file entry org/bouncycastle/asn1/ocsp/ResponderID.class
17:34semperosI see that I can add a :uberjar-exclusions ["signature file here"] in my project.clj as one possible solution
17:35semperosbut I don't entirely understand
17:38semperosnm, just needed to learn more about jar structure...
17:44mwillhitehey all - I'm confused. working with the jets3t lib and I can get a list of all the objects in my bucket, however when I try to apply a prefix (filter) I get an IllegalArgumentException
17:44mwillhiteit may be a clojure syntax issue, just not sure
17:44mwillhitehttps://gist.github.com/1262913
17:44mwillhiteany help will be greatly appreciated!
17:46hiredmanmwillhite: check the javadocs, the method you are trying to call doesn't exist
17:47mwillhiteI'm looking at the method in the docs…
17:47mwillhiteand why would it work without the prefix arg?
17:47winklistObjects only takes one argument
17:47winkwhat is stammer? your bucket?
17:47mwillhitecheck the next method definition
17:47mwillhiteyeah its the bucket
17:47amalloymwillhite: listObjects doesn't seem to have a two-arg version
17:47amalloyone, or three
17:47mwillhiteoh (I know nothing about java)
17:48mwillhiteso I need to fill in the other arguments?
17:48semperosyep
17:48mwillhitethanks :)
17:48semperosthat API offers several different method signatures
17:48semperosyou have to support at least one, giving all arg's for that one
17:48mwillhiteokay cool
17:48mwillhitegood to know
17:49winkso (.listObjects s3-foo bucket prefix delimiter) basiclaly
17:49mwillhitewhat is that last thing "long maxListingLength"
17:49mwillhitewhat does that mean? its not an arg?
17:49winkthat's the 4 arg version
17:49mwillhiteokay
17:50winkoh how I love people who use @deprecated without stating what is the best way now
17:50mwillhitehehe thanks all, its working now!!
17:53winkhm, when "lein deps" fails to find a dependency and tells me to mvn install:install-file - what do I do if I seem to have no maven because I'm on windows and lein magically works anyway?
17:54hiredmanwink: install maven
17:57duck1123or download the project in question and build it, but install maven anyway
17:58technomancycould be your :dependencies has a typo or something
17:58winkit worked when just copying the jar inside lib/ - but another lein deps kills it
17:58winkit's h2 - not in any repo I've seen
17:59technomancyprobably need to file a bug with h2 then
18:00technomancyin the mean time that's something you still do need maven for
18:00winkoh? it sounded like total intended behavior, so I wasn't really bothered
18:00winkyeah, on it
18:00hiredmanh2? the embedded sql? it is in repos
18:00joegallohttp://mirrors.ibiblio.org/pub/mirrors/maven2/com/h2database/h2/
18:00technomancywell if their intention is to not publish an artifact then their intention is wrong
18:01joegallofor future reference:
18:01joegallohttp://mvnrepository.com/search.html?query=h2
18:01hiredman~google maven h2
18:01clojurebotFirst, out of 22400 results is:
18:01clojurebotMaven Repository: com.h2database » h2
18:01clojurebothttp://mvnrepository.com/artifact/com.h2database/h2
18:01technomancyjoegallo: nah: http://search.maven.org/#search%7Cga%7C1%7Ch2
18:01technomancycrappier URL, but nicer otherwise
18:02winkoh well, if they suggest org.h2 instead of com.h2database - that could be it
18:03winkagain, you're all really helpful and I'm the idiot. thanks a lot
18:03joegallotechnomancy: nice, and thanks! (keyword added for search!)
18:04winkworks :)
18:11TimMcOK, I just got a new laptop, and I am picking a hostname. I'm thinking about "thunk". My question: If I go to the Conj, is everyone else going to have the same damn hostname?
18:12sjlAnyone know if there's a reason I shouldn't be able to start the Noir server from inside of swank?
18:12technomancyTimMc: there's a who occasionally visits this channel who goes by thunk
18:13winkTimMc: Did you really thunk hard about that hostname? Was it even a ThunkPadded?
18:13TimMcwink: It's a ThinkPad, yes.
18:13TimMcWhich is also built pretty sturdily, so it was a shoo-in name.
18:13winka colleague of mine named it lolnovo
18:13TimMchaha
18:14technomancyniiiice
18:21technomancycemerick: looking forward to trying out pomegranate
18:21technomancyI've had the idea for something like that for a while
18:21cemericktechnomancy: I demo'd it live at J1 about an hour ago, so it *seems* to work :-)
18:22technomancygutsy for a brand-new project =)
18:22cemerickI'm trying to go big these days.
18:22cemerickor, bigger :-P
18:22technomancymy plan was to have the users edit project.clj and have the running instance recalculate it, but of course that only works for additive deltas.
18:23cemerickwell, pomegranate isn't any smarter
18:23cemerickIt's a very long length of rope
18:23technomancyyeah, it's just more specific
18:23technomancybut then the responsibility lies with the user to keep the instance in sync with the deps declaration
18:24cemericksure
18:25cemerickI think we're talking about the same thing in any case; the 'recalculate' part is in aether, insofar as existing dependencies are in .m2/repo
18:26cemericki.e. I don't think it matters if the same jar URL is registered with a classloader twice
18:26technomancyright
18:27cemerickAs I was writing it, I was thinking "jeez, leiningen already has some of these utilities" :-P
18:27technomancyI meant "recalculate from project.clj" rather than taking the additional deps as function args"
18:28cemerickHave you started with aether in lein yet, or is that still just dangling over your head?
18:28technomancyI have a stash for it, but it's mostly cribbed from a gist I got from hugod
18:28ibdknoxcemerick: technomancy: it'd be nice to have a lib that just generally lets you interact with the classpath
18:28ibdknoxfor example, there are somethings in tools.namespace that I really wished worked in more contexts
18:29ibdknoxsome things*
18:29cemerickibdknox: It's tricky. Once you're talking about the classpath as a mutable thing, you have to ask, "which classpath?"
18:30hiredmanyeah, there is no classpath
18:30hiredmanthere are classloaders
18:31ibdknoxsure, is there no way for us to create an abstraction that would make that an implementation detail?
18:31cemerickeither no classpath, or 1 + N classpaths, yes.
18:31ibdknoxthese are the things that are currently available to us
18:31cemerickibdknox: pomegranate is 99% of the way there, as long as you only care about clojure
18:32cemerickmodule systems and app servers suck for these sorts of things
18:33ibdknoxcemerick: in theory does pomegranate work in a war?
18:33cemericksure
18:33cemerickactually, it will currently attempt to find the "eldest" classloader, which may be above the war's classloader
18:34cemerickThat may be a problem. :-P
18:34ibdknoxhaha :)
18:34cemerickMaybe I'll look at that in week 2.
18:34ibdknoxwhy the caveat "only about Clojure", are things significantly different for loading random java stuff? (I know very little about classloaders and such)
18:36cemerickRandom Java stuff has static names in it. You need something like JRebel for that.
18:36cemerickor osgi :-P
18:36ibdknoxah
18:37cemerickvars are the real hero of clojure's dynamicism.
19:15sjlibdknox: Hey, you're the author of Noir, right?
19:15ibdknoxsjl: yep
19:16sjlibdknox: any idea why I'd be getting this when trying to use 'lein run' in a noir project? http://dpaste.com/627489/
19:16ibdknoxthose are netty errors
19:16ibdknoxare you using aleph?
19:18ibdknoxsjl: that's from something external to noir. It doesn't use contrib or netty :)
19:19ibdknoxsjl: is your project on github? I can take a quick look to see if I can spot anything
19:19shep-homeSo, one of my functions goes off into an infinite loop when I test it. How do I jump in to that running thread with a debugger?
19:19sjlibdknox: nevermind, I think I figured it out... for some reason Puppet doesn't want to install and start Redis until I provision it a second time
19:19shep-homeI'm running it inside of emacs with clojure-test-mode
19:20technomancyshep-home: M-x slime-list-threads maybe
19:25shep-hometechnomancy: that seems to go off into it's own little hole
19:27shep-homeM-x slime-interrupt doesn't
19:28shep-home(work that is)
19:30technomancysorry don't know
19:31shep-homeANy idea how to get the JVM running so that I can attach with a java debugger?
19:32shep-homeI'm currently using clojure-jack-in
19:33technomancymaybe the cdt documentation would say
19:35shep-homeI'll dig into that, thnks
19:38shep-homeIs there a way I can change what `lein jack-in` does?
19:39TheBusbyonly if you purchase a lein gold account
19:39ibdknoxlol
19:42technomancyshep-home: you can add additional elisp files to be piggy-packed, though it's not well-documented
19:42technomancyis that what you mean?
19:51shep-hometechnomancy: move like trying to figure if I can add -X... options when it starts Java
19:51technomancysure; that's orthogonal to jack-in
19:51technomancy:jvm-opts in project.clj
19:52shep-homethx
19:54whiddenHello all, is the function 'some efficient?
19:56arohnerwhidden: it's O(n)
19:59whiddenarohner: hmm that's what I thought but when i profile my use of some it doesn't look like O(n), more like O(e^n)
20:00arohnerwhidden: what's in your predicate? I'm confident some by itself is O(n)
20:01whiddenarohner: yeah all things point to my predicate, which is a partial that at its core does a range check.
20:01amalloyarohner: prime? :)
20:02arohneramalloy: factor-rsa :-)
20:02whiddenAre there issues with using the clojure.contrib.profile collection of tools?
20:53paul_anyone here use clutch?
20:54brehautpaul_: just go ahead and ask your question; if someone can help they will answer
20:55paul_ok
20:55paul_i want to change the port for clutch
20:55paul_i think i need to use "with-bindings"
20:55paul_i don't know how, though
20:57brehautpaul_: its the slightly more awkward version of binding; (with-bindings {#'*foo* :bar} …) rather than (binding [*foo* :bar] …)
20:57ibdknoxwoah what is that nonsense?
20:58brehautibdknox: i didn't think i was that far off track
20:58ibdknoxno no
20:58ibdknoxwhy doesn't that use a vector?
21:00brehautibdknox: so that you can build up a map of bindings programattically
21:00ibdknoxhm
21:02ibdknoxbrehaut: is this the clutch we're talking about? https://github.com/ashafa/clutch
21:03brehauti think so
21:03ibdknoxI looked through the source
21:03ibdknoxwith-bindings isn't there?
21:03ibdknoxlol
21:03brehauti think with-db probably uses bindings rather than with-bindings?
21:04brehautwould you look at that it does
21:04brehauthttps://github.com/ashafa/clutch/blob/master/src/com/ashafa/clutch.clj#L129-135
21:04ibdknoxhah
21:05ibdknoxI thought with-bindings was something specific to clutch. I didn't realize it was a core thing
21:05brehautoh right haha
21:05ibdknoxI don't think he needs with-bindings.
21:06brehauti dont either
21:06brehauti think with-db will do it
21:06ibdknoxpaul_: ^
21:06brehautpaul_: the db map is i think {:host "hostname" :port int? :name "dbname"}
21:07brehautpaul_: see also set-clutch-defaults! https://github.com/ashafa/clutch/blob/master/src/com/ashafa/clutch.clj#L54-62
21:08brehautpaul_: way back when i last used clutch i found the source to be pretty readable in general. theres very little complicated stuff
21:12cgrayis there a more idiomatic way of doing (comp not =) ?
21:12brehaut(complement =)
21:12cgrayand is comp idiomatic in general?
21:13ibdknox,(doc not=)
21:13clojurebot"([x] [x y] [x y & more]); Same as (not (= obj1 obj2))"
21:13ibdknoxcgray: yeah, comp is idiomatic
21:13cgrayibdknox: thanks
21:14khaliGwonder why they didn't just go with the java !=
21:15ibdknox! means side-effects in clojure
21:15ibdknoxas a matter of convention
21:15khaliGas a prefix though?
21:15brehautand not= is the lisp convention isn't it?
21:16zippy314Hi, what's the correct way to use regular expressions in clojurescript. i.e. what's the equivalent of (re-find #"^a" some-str)?
21:16ibdknox(/=) is lisp I think
21:16ibdknoxerr CL that is
21:16khaliGibdknox, yeah /= in CL
21:17TimMc,(doc re-find)
21:17clojurebot"([m] [re s]); Returns the next regex match, if any, of string to pattern, using java.util.regex.Matcher.find(). Uses re-groups to return the groups."
21:17TimMczippy314: I'm not a cljs user -- does it have regex literals yet?
21:17ibdknoxzippy314: it's the same?
21:17ibdknoxzippy314: https://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/core.cljs#L2576
21:18zippy314no, it's not
21:18ibdknoxah
21:18TimMczippy314: So what happens if you do ##(re-find #"^a" "abc") in cljs?
21:18lazybot⇒ "a"
21:18ibdknox(re-pattern)
21:20zippy314It's weird: https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure says you have to use Javascript regexs (see Other Functions)
21:20ibdknoxzippy314: I just did it in the repljs
21:21zippy314ibdknox: what exactly?
21:21ibdknox(re-find #"a" "hhha")
21:21zippy314hmmm..
21:22ibdknoxalso fine: (let [x "some string"] (re-find #"a" x))
21:22zippy314Is there version thing going on here?
21:23zippy314In my code that totally fails.
21:23ibdknoxI have the latest
21:23zippy314I have (if (re-find #"/^multipart/" "multipart") (js/alert "test")) and I don't get the alert...
21:24ibdknoxget rid of the /
21:24zippy314duh!
21:24zippy314It worked. Thanks!
21:34paul_for clutch i tried (db/set-clutch-port! "5985" (db/all-databases)) but it doesn't work
21:34paul_going to look at the src
21:36devtham i correct to assume it's not possible to (:require [com.foo.bar.*]) to require all namespaces starting with `com.foo.bar`?
21:37paul_seems to work with set-clutch-defaults!
21:39paul_ok, got it working... i'm now trying to query a view, but i'm having trouble doing so too... going to look at the source :D
21:46gfredericksdevth: darn tootin you're correct!
21:50amalloyask lazybot, he knows everything. lazybot, is it possible to (:require [com.foo.bar.*])??
21:50lazybotamalloy: Uh, no. Why would you even ask?
21:51gfrederickslazybot, is it possible to (:require [clojure.set])??
21:51lazybotgfredericks: What are you, crazy? Of course not!
21:51amalloygfredericks: you just have to not ask him any dumb questions. it's all your fault for phrasing it wrong
21:52gfrederickslazybot: is it possible for me to ask you a dumb question??
21:52lazybotgfredericks: Uh, no. Why would you even ask?
21:54gfredericksamalloy: given that he just contradicted you, I have to conclude that you're right.
21:59ibdknoxlazybot: is gfredericks trying to game the system???
21:59lazybotibdknox: Oh, absolutely.
22:00ibdknoxlazybot: is that acceptable??
22:00lazybotibdknox: Definitely not.
22:00brehautlazybot: is this a question?????
22:00ibdknoxlol
22:00amalloybrehaut: he probably knows better than to respond to people with five question marks. answering such people only leads to sadness
22:00ibdknox> 4 ?'s and he should tell you to go to hell ;)
22:00hsbot <hint>:1:6: lexical error in string/character literal at character ' '
22:00ibdknoxoh no's
22:00ibdknoxlol
22:00brehautwe have a haskell bot?!
22:01amalloybrehaut: we have two
22:01brehautfantastic :)
22:01amalloyi'm not sure who owns hsbot, but lazybot does haskell too
22:01brehaut> print "hello, world!"
22:01hsbot No instance for (GHC.Show.Show (GHC.Types.IO ())) arising from a use of `M5580730128600360166.show_M5580730128600360166' Possible fix: add an instance declaration for (GHC.Show.Show (GHC.Types.IO ()))
22:01amalloy$heval [1,3...15]
22:01brehautbaha fail
22:01lazybot⟹ Not in scope: `...'
22:01amalloy$heval [1,3..15]
22:01lazybot⟹ [1,3,5,7,9,11,13,15]
22:02ibdknox$heval print "hey"
22:02lazybot⟹ No instance for (GHC.Show.Show (GHC.Types.IO ())) arising from a use of `M1183673886.show_M1183673886' at <interactive>:(2,0)-(4,30)Possible fix: add an instance declaration for (GHC.Show.Show (GHC.Types.IO ()))
22:02brehautclearly they are sanely not operating in the IO monad
22:02brehautits a pretty good sandbox
22:02amalloyhah
22:02brehaut> show 1
22:02hsbot "1"
22:02amalloy> [1, 2..]
22:02hsbot [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,...
22:03brehaut> 1 + read "1"
22:03hsbot 2
22:04brehaut> fib where fib = 1:1: zipWith (+) fib $ tail fib
22:04hsbot <hint>:1:5: parse error on input `where'
22:04brehaut> let fib = 1 : 1 : zipWith (+) fib $ tail fib in fib
22:04hsbot Couldn't match expected type `[a0]' with actual type `[b0] -> [c0]'
22:04brehautand this is why i use clojure, not haskell, for my day to day programming
22:04ibdknoxwhat I'm learning here is that haskell sucks
22:05brehautibdknox: i think if i threw some braces at the first one it would be ok
22:05ibdknoxhaha I was just trying to see who would yell at me ;)
22:05brehautor at least present the same type con flit as the second
22:05ibdknoxI know basically nothing about haskell
22:06gfredericksI look away for two seconds and suddenly everybody knows haskell.
22:06ibdknoxgfredericks: welcome to #haskell, hope you brought your helmet.
22:06amalloyi love that it thinks :1:5: parse error on input `where' is a good hint
22:07ibdknoxlol
22:09brehautibdknox: i only know enough haskell to get the really cryptic compiler warnings
22:09mjonsson> let fib = 1:1:zipWith (+) fib (tail fib) in fib
22:09hsbot [1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,14930352,24157817,39088169,63245986,102334155,1...
22:09ibdknoxbrehaut: about enough I'd say
22:10brehautmjonsson: was it the $ that tripped it up?
22:10mjonssonbrehaut: yep
22:17gfredericksit's so weird to look at recursive code and not worry about what the poor jvm is going to think
22:18gfredericks> let fib = 1:4:zipWith (+) fib (tail fib) in fib
22:18hsbot [1,4,5,9,14,23,37,60,97,157,254,411,665,1076,1741,2817,4558,7375,11933,19308,31241,50549,81790,132339,214129,346468,560597,907065,1467662,2374727,3842389,6217116,10059505,16276621,26336126,42612747,68948873,111561620,180...
22:20sleepynatelambdabot in #clojure, this just seems so backward
22:22brehautsleepynate: i think you're thinking of algolbot
22:24sleepynatehar har
22:51srid&(or (and (zero? 1) 'zero) 'nonzero)
22:51lazybot⇒ nonzero
22:51srid&(or (and (zero? 0) 'zero) 'nonzero)
22:51lazybot⇒ zero
22:53brehautsrid: that looks like a complicated way to write if :P
22:54amalloybrehaut: i've written if that way before, in a language that had and/or expressions, and if statements
22:54brehautamalloy: likewise; python frinstance
22:54sridits the habbit of doing "expr and 'foo' or 'bar'" in languages like python
22:55sridin lisp, an `if` is nothing special.
22:56brehautsrid: I'm also curious why you used quoted symbols rather than keywords (not that its really important here)
22:57sridoh right. forgot keywords. scheme-habit
22:57sridthough i use them pretty often in my html code using hiccup
23:19miwillhitegood eve; I know they are the same thing but which is more standard? (:name bucket) or (bucket :name)
23:19miwillhiteassuming bucket is a map of course…
23:20dnolenmiwillhite: (:foo x) preferred.
23:20dnolen,(nil :foo)
23:20clojurebot#<CompilerException java.lang.IllegalArgumentException: Can't call nil, compiling:(NO_SOURCE_PATH:0)>
23:20dnolen,(:foo nil)
23:20clojurebotnil
23:21miwillhitecool thanks
23:27amalloymiwillhite: http://stackoverflow.com/questions/7034803/idiomatic-clojure-map-lookup-by-keyword/7035984#7035984 gives a little detail on why that is, if you're interested
23:37khaliGso i've got a bunch of data files in the form of clojure readable sexps - and i'd like to batch modify the lot. is there an existing tool suitable for this purpose or shall i go ahead and roll my own?